blankart/src/strbuf.h
NepDisk f004b36dbb Revert 'Merge pull request 'File loading refactor' (#68) from wadstrbuf into blankart-dev'
This reverts commit f72475b557, reversing
changes made to 0c89c85aae.

Sorry Generic this branch is really cool but it needs more work. I shouldn't have merged it too early...
2025-06-30 01:45:01 -04: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