string-util: introduce explicit_zero_safe()

The only real difference is that this wrapper can deal with NULL
pointer arguments, but only if the length is also zero.

CID 1396277
This commit is contained in:
Lennart Poettering
2018-10-24 21:00:15 +02:00
parent 7388cea30d
commit 87f5446311
5 changed files with 25 additions and 15 deletions
+9 -2
View File
@@ -198,8 +198,15 @@ static inline void *memmem_safe(const void *haystack, size_t haystacklen, const
return memmem(haystack, haystacklen, needle, needlelen);
}
#if !HAVE_EXPLICIT_BZERO
void explicit_bzero(void *p, size_t l);
#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);