Change nasm_zero() to pass an object, not a pointer

Passing an object to nasm_zero() allows us to use it on arrays.
Otherwise the array will decay to a pointer and silently clear only
the first member of the array!

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
This commit is contained in:
H. Peter Anvin 2017-03-31 14:56:17 -07:00
parent 1980abfb7a
commit e886c0e968
3 changed files with 3 additions and 3 deletions

View file

@ -546,7 +546,7 @@ int64_t assemble(int32_t segment, int64_t start, int bits, insn *instruction)
int32_t itimes;
int64_t wsize; /* size for DB etc. */
nasm_zero(&data);
nasm_zero(data);
data.offset = start;
data.segment = segment;
data.itemp = NULL;

View file

@ -169,7 +169,7 @@ void process_pragma(char *str)
struct pragma pragma;
char *p;
nasm_zero(&pragma);
nasm_zero(pragma);
pragma.facility_name = nasm_get_word(str, &p);
if (!pragma.facility_name) {

View file

@ -97,7 +97,7 @@ char * safe_alloc nasm_strndup(const char *, size_t);
nasm_free(*_pp); \
*_pp = NULL; \
} while (0)
#define nasm_zero(p) (memset((p), 0, sizeof(*(p))))
#define nasm_zero(x) (memset(&(x), 0, sizeof(x)))
#define nasm_zeron(p,n) (memset((p), 0, (n)*sizeof(*(p))))
/*