summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
2c20abc)
Signed-off-by: Cody P Schafer <dev@codyps.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
suffix, suffix_len) == 0);
}
suffix, suffix_len) == 0);
}
+/**
+ * memends_str - Does this byte array end with a string suffix?
+ * @a: byte array
+ * @al: length in bytes
+ * @s: string suffix
+ *
+ * Example:
+ * if (memends_str(somebytes, bytes_len, "It")) {
+ * printf("somebytes ends with with 'It'\n");
+ * }
+ */
+PURE_FUNCTION
+static inline bool memends_str(const void *a, size_t al, const char *s)
+{
+ return memends(a, al, s, strlen(s));
+}
+
char scan2[] = "\0\0\0b";
/* This is how many tests you plan to run */
char scan2[] = "\0\0\0b";
/* This is how many tests you plan to run */
ok1(memmem(haystack1, sizeof(haystack1), needle1, 2) == haystack1);
ok1(memmem(haystack1, sizeof(haystack1), needle1, 3) == NULL);
ok1(memmem(haystack1, sizeof(haystack1), needle1, 2) == haystack1);
ok1(memmem(haystack1, sizeof(haystack1), needle1, 3) == NULL);
ok1(!memends(S("a\0bcdef"), S("a\0b")));
ok1(memends(S("a\0bcdef"), S("ef")));
ok1(!memends(S("a\0bcdef"), S("a\0b")));
ok1(memends(S("a\0bcdef"), S("ef")));
+ ok1(memends_str(S("abcdef"), "abcdef"));
+ ok1(!memends_str(S("abcde\0f"), "d\0f"));
+ ok1(!memends_str(S("a\0bcdef"), "a"));
+ ok1(memends_str(S("a\0bcdef"), "ef"));
/* This exits depending on whether all tests passed */
return exit_status();
/* This exits depending on whether all tests passed */
return exit_status();