Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2016-02-23 01:45:15 +0300
committerJunio C Hamano <gitster@pobox.com>2016-02-23 01:51:09 +0300
commit08c95df8faa25ab4c9ad3da45bc12abb9274d343 (patch)
tree6f238edb11041a0383ce970b19963c90feaf4db7 /ewah/ewah_bitmap.c
parentfb7dbf3e7a668ab60c158d3d1efc77578ef9db1b (diff)
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>
Diffstat (limited to 'ewah/ewah_bitmap.c')
-rw-r--r--ewah/ewah_bitmap.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/ewah/ewah_bitmap.c b/ewah/ewah_bitmap.c
index fcd465e9c2..2dc9c82ecf 100644
--- a/ewah/ewah_bitmap.c
+++ b/ewah/ewah_bitmap.c
@@ -39,8 +39,7 @@ static inline void buffer_grow(struct ewah_bitmap *self, size_t new_size)
return;
self->alloc_size = new_size;
- self->buffer = xrealloc(self->buffer,
- self->alloc_size * sizeof(eword_t));
+ REALLOC_ARRAY(self->buffer, self->alloc_size);
self->rlw = self->buffer + (rlw_offset / sizeof(eword_t));
}
@@ -283,8 +282,8 @@ struct ewah_bitmap *ewah_new(void)
struct ewah_bitmap *self;
self = xmalloc(sizeof(struct ewah_bitmap));
- self->buffer = xmalloc(32 * sizeof(eword_t));
self->alloc_size = 32;
+ ALLOC_ARRAY(self->buffer, self->alloc_size);
ewah_clear(self);
return self;