diff --git a/src/common/FFstrbuf.h b/src/common/FFstrbuf.h index e3722ad82..d84ed3506 100644 --- a/src/common/FFstrbuf.h +++ b/src/common/FFstrbuf.h @@ -8,6 +8,7 @@ #include #include #include "common/memrchr.h" +#include "common/arrutil.h" #ifdef FF_USE_SYSTEM_YYJSON #include @@ -628,3 +629,4 @@ static inline void ffStrbufPutTo(const FFstrbuf* strbuf, FILE* file) { bool ffStrbufDecodeHexEscapeSequences(FFstrbuf* strbuf); #define FF_STRBUF_AUTO_DESTROY [[gnu::cleanup(ffStrbufDestroy)]] FFstrbuf +#define FF_STRBUF_STATIC(str) { .allocated = 0, .length = (uint32_t) ARRAY_SIZE(str) - 1, .chars = str } diff --git a/tests/strbuf.c b/tests/strbuf.c index a8e698caf..d1ca64265 100644 --- a/tests/strbuf.c +++ b/tests/strbuf.c @@ -23,6 +23,8 @@ int shouldNotBeCalled(int c) { exit(1); } +const FFstrbuf testCreateStatic = FF_STRBUF_STATIC("TEST"); + int main(void) { FFstrbuf strbuf;