mirror of
https://github.com/Dasharo/systemd.git
synced 2026-03-06 15:02:31 -08:00
util: move some raw memory functions from string-util.h → memory-util.h
This commit is contained in:
@@ -184,32 +184,6 @@ int split_pair(const char *s, const char *sep, char **l, char **r);
|
||||
int free_and_strdup(char **p, const char *s);
|
||||
int free_and_strndup(char **p, const char *s, size_t l);
|
||||
|
||||
/* Normal memmem() requires haystack to be nonnull, which is annoying for zero-length buffers */
|
||||
static inline void *memmem_safe(const void *haystack, size_t haystacklen, const void *needle, size_t needlelen) {
|
||||
|
||||
if (needlelen <= 0)
|
||||
return (void*) haystack;
|
||||
|
||||
if (haystacklen < needlelen)
|
||||
return NULL;
|
||||
|
||||
assert(haystack);
|
||||
assert(needle);
|
||||
|
||||
return memmem(haystack, haystacklen, needle, needlelen);
|
||||
}
|
||||
|
||||
#if HAVE_EXPLICIT_BZERO
|
||||
static inline void* explicit_bzero_safe(void *p, size_t l) {
|
||||
if (l > 0)
|
||||
explicit_bzero(p, l);
|
||||
|
||||
return p;
|
||||
}
|
||||
#else
|
||||
void *explicit_bzero_safe(void *p, size_t l);
|
||||
#endif
|
||||
|
||||
char *string_erase(char *x);
|
||||
|
||||
char *string_free_erase(char *s);
|
||||
|
||||
Reference in New Issue
Block a user