diff options
| author | Mattias Andrée <m@maandree.se> | 2026-01-27 20:40:48 +0100 |
|---|---|---|
| committer | Mattias Andrée <m@maandree.se> | 2026-01-27 20:40:48 +0100 |
| commit | 7e70c15821b6bdcc38c5e129d6332cc57edb9e0c (patch) | |
| tree | e3ba75e908a495cafa873025f7fff43eca68266e /memcasemem.c | |
| parent | memmem, memcasemem: use kmp algorithm (diff) | |
| download | libsimple-7e70c15821b6bdcc38c5e129d6332cc57edb9e0c.tar.gz libsimple-7e70c15821b6bdcc38c5e129d6332cc57edb9e0c.tar.bz2 libsimple-7e70c15821b6bdcc38c5e129d6332cc57edb9e0c.tar.xz | |
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to '')
| -rw-r--r-- | memcasemem.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/memcasemem.c b/memcasemem.c index d883b62..625861a 100644 --- a/memcasemem.c +++ b/memcasemem.c @@ -10,6 +10,7 @@ libsimple_memcasemem(const void *hay_, size_t hayn, const void *sub_, size_t sub const char *sub = sub_; size_t *next, i, j; + if (!subn) return REMOVE_CONST(hay, char *); if (hayn < subn) @@ -17,6 +18,7 @@ libsimple_memcasemem(const void *hay_, size_t hayn, const void *sub_, size_t sub if (subn == 1) return libsimple_memcasechr(hay, *sub, hayn); + /* TODO segment search if pattern is too large */ next = alloca((subn + 1U) * sizeof(*next)); i = 0, j = SIZE_MAX; goto beginning; |
