Skip to content

Commit 5efd7b9

Browse files
committed
FFstrbuf: add ffStrbufContainC
1 parent f2bae20 commit 5efd7b9

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/util/FFstrbuf.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,11 @@ static inline FF_C_NODISCARD bool ffStrbufIgnCaseEqual(const FFstrbuf* strbuf, c
189189
return ffStrbufIgnCaseComp(strbuf, comp) == 0;
190190
}
191191

192+
static inline FF_C_NODISCARD bool ffStrbufContainC(const FFstrbuf* strbuf, char c)
193+
{
194+
return memchr(strbuf->chars, c, strbuf->length) != NULL;
195+
}
196+
192197
static inline FF_C_NODISCARD bool ffStrbufContainS(const FFstrbuf* strbuf, const char* str)
193198
{
194199
return strstr(strbuf->chars, str) != NULL;

tests/strbuf.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ int main(void)
204204
VERIFY(strbuf.allocated == 32);
205205
VERIFY(ffStrbufEqualS(&strbuf, "1234567890123456789012345678901"));
206206

207+
//containC
208+
VERIFY(ffStrbufContainC(&strbuf, '1'));
209+
VERIFY(!ffStrbufContainC(&strbuf, '-'));
210+
207211
ffStrbufDestroy(&strbuf);
208212

209213
//Success

0 commit comments

Comments
 (0)