blankart/src/strbuf.h
GenericHeroGuy 0009807746 Unify info lookup functions for SOC/Lua/ACS
Use MAX* constants instead of -1 for invalid values, because enum signedness
is implementation-defined
2025-05-18 17:37:47 +02:00

38 lines
996 B
C

// BLANKART
//-----------------------------------------------------------------------------
// Copyright (C) 2025 by Team BlanKart.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file strbuf.h
/// \brief string buffer library, for making chunks of many small strings
#ifdef __cplusplus
extern "C" {
#endif
// for simplicity's sake, the header is included in the size (keeps the allocation aligned!)
struct strbuf_t
{
UINT32 size;
char buf[];
};
strbuf_t *strbuf_alloc(void);
UINT32 strbuf_append(strbuf_t **strbuf, const char *str);
// returns the string at the given offset
FUNCINLINE static ATTRINLINE char *strbuf_get(strbuf_t *strbuf, UINT32 ofs)
{
#ifdef __cplusplus
return reinterpret_cast<char *>(strbuf) + ofs;
#else
return (char *)strbuf + ofs;
#endif
}
#ifdef __cplusplus
}
#endif