From 858d3749f49febf4c3602ff0181411a3d2bdfdc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 14 Aug 2026 18:27:53 +0800 Subject: [PATCH] FFstrbuf: adds `FF_STRBUF_STATIC` --- src/common/FFstrbuf.h | 2 ++ tests/strbuf.c | 2 ++ 2 files changed, 4 insertions(+) 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;