ubase

suckless linux base utils
git clone git://git.2f30.org/ubase
Log | Files | Refs | README | LICENSE

commit 1920516abfc72c1befa41d093cef9d87aa0e64d0
parent 8f4c0f2a8ef86942c4c147f82c5eeb2bd4107f9a
Author: sin <sin@2f30.org>
Date:   Wed, 30 Apr 2014 12:25:29 +0100

Add explicit_bzero() in util/

Diffstat:
MMakefile | 19++++++++++---------
Mutil.h | 2++
Autil/explicit_bzero.c | 10++++++++++
3 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/Makefile b/Makefile @@ -5,15 +5,16 @@ include config.mk HDR = arg.h config.def.h proc.h reboot.h util.h LIB = \ - util/agetcwd.o \ - util/apathmax.o \ - util/eprintf.o \ - util/estrtol.o \ - util/proc.o \ - util/putword.o \ - util/recurse.o \ - util/strlcat.o \ - util/strlcpy.o \ + util/agetcwd.o \ + util/apathmax.o \ + util/eprintf.o \ + util/estrtol.o \ + util/explicit_bzero.o \ + util/proc.o \ + util/putword.o \ + util/recurse.o \ + util/strlcat.o \ + util/strlcpy.o \ util/tty.o SRC = \ diff --git a/util.h b/util.h @@ -12,6 +12,8 @@ void devtotty(int, int *, int *); void enprintf(int, const char *, ...); void eprintf(const char *, ...); long estrtol(const char *, int); +#undef explicit_bzero +void explicit_bzero(void *, size_t); void putword(const char *); void recurse(const char *, void (*)(const char *)); #undef strlcat diff --git a/util/explicit_bzero.c b/util/explicit_bzero.c @@ -0,0 +1,10 @@ +#include <string.h> +#include "../util.h" + +static void *(*volatile explicit_memset)(void *, int, size_t) = memset; + +void +explicit_bzero(void *b, size_t len) +{ + (*explicit_memset)(b, 0, len); +}