ewah: convert to REALLOC_ARRAY, etc
Now that we're built around xmalloc and friends, we can use helpers like REALLOC_ARRAY, ALLOC_GROW, and so on to make the code shorter and protect against integer overflow. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
fb7dbf3e7a
commit
08c95df8fa
@ -134,8 +134,7 @@ int ewah_read_mmap(struct ewah_bitmap *self, const void *map, size_t len)
|
||||
self->buffer_size = self->alloc_size = get_be32(ptr);
|
||||
ptr += sizeof(uint32_t);
|
||||
|
||||
self->buffer = xrealloc(self->buffer,
|
||||
self->alloc_size * sizeof(eword_t));
|
||||
REALLOC_ARRAY(self->buffer, self->alloc_size);
|
||||
|
||||
/*
|
||||
* Copy the raw data for the bitmap as a whole chunk;
|
||||
@ -177,8 +176,7 @@ int ewah_deserialize(struct ewah_bitmap *self, int fd)
|
||||
return -1;
|
||||
|
||||
self->buffer_size = self->alloc_size = (size_t)ntohl(word_count);
|
||||
self->buffer = xrealloc(self->buffer,
|
||||
self->alloc_size * sizeof(eword_t));
|
||||
REALLOC_ARRAY(self->buffer, self->alloc_size);
|
||||
|
||||
/** 64 bit x N -- compressed words */
|
||||
buffer = self->buffer;
|
||||
|
Reference in New Issue
Block a user