nasmlib.h: add a nasm_zero() macro to the pointer helpers

We do have a number of places where we had problems doing things like:

memset(foo, 0, sizeof foo) instead of sizeof *foo.  Add a helper macro
nasm_zero() to the list of (sadly not yet well used) pointer-safe
helper macros.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin 2017-01-24 12:28:40 -08:00
parent 94e4052a8a
commit 5d7fdc1962

View file

@ -156,6 +156,7 @@ char * safe_alloc nasm_strndup(const char *, size_t);
#define nasm_new(p) ((p) = nasm_zalloc(sizeof(*(p))))
#define nasm_newn(p,n) ((p) = nasm_calloc(sizeof(*(p)),(n)))
#define nasm_delete(p) do { nasm_free(p); (p) = NULL; } while (0)
#define nasm_zero(p) (memset((p), 0, sizeof(*(p))))
/*
* Wrapper around fwrite() which fatal-errors on output failure.