diff options
author | Mattias Andrée <maandree@kth.se> | 2018-10-28 16:40:44 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2018-10-28 16:40:44 +0100 |
commit | f66c02620d394819a29267b6fe4b682589201cbf (patch) | |
tree | 71f8942398e77ff3a20ec2a463d6a2c9ac88edc2 /memelem.c | |
parent | Add doc to aligned_memdup.h, memdup.h, strdup.h, and strndup.h (diff) | |
download | libsimple-f66c02620d394819a29267b6fe4b682589201cbf.tar.gz libsimple-f66c02620d394819a29267b6fe4b682589201cbf.tar.bz2 libsimple-f66c02620d394819a29267b6fe4b682589201cbf.tar.xz |
m
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r-- | memelem.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -43,9 +43,14 @@ libsimple_memelem(const void *hay_, size_t hayn, const void *sub_, size_t subn) { char *hay = (void *)hay_; const char *sub = sub_; - for (; hayn--; hay += subn) - if (!memcmp(hay, sub, subn)) - return hay; + size_t i; + for (; hayn--; hay += subn) { + for (i = 0; i < subn; i++) + if (hay[i] != sub[i]) + goto next; + return hay; + next:; + } break; } |