aboutsummaryrefslogtreecommitdiff
path: root/ewah/bitmap.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2016-02-22 17:45:12 -0500
committerJunio C Hamano <gitster@pobox.com>2016-02-22 14:51:09 -0800
commitfb7dbf3e7a668ab60c158d3d1efc77578ef9db1b (patch)
tree08bdbe53231d4f70972e66eef39d5b7c64c99c98 /ewah/bitmap.c
parentb1ddfb9151ca817c30825d1250d565b32c5fc0f5 (diff)
downloadgit-fb7dbf3e7a668ab60c158d3d1efc77578ef9db1b.tar.gz
git-fb7dbf3e7a668ab60c158d3d1efc77578ef9db1b.tar.xz
convert ewah/bitmap code to use xmalloc
This code was originally written with the idea that it could be spun off into its own ewah library, and uses the overrideable ewah_malloc to do allocations. We plug in xmalloc as our ewah_malloc, of course. But over the years the ewah code itself has become more entangled with git, and the return value of many ewah_malloc sites is not checked. Let's just drop the level of indirection and use xmalloc and friends directly. This saves a few lines, and will let us adapt these sites to our more advanced malloc helpers. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'ewah/bitmap.c')
-rw-r--r--ewah/bitmap.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/ewah/bitmap.c b/ewah/bitmap.c
index 47ad6747c..c88daa0aa 100644
--- a/ewah/bitmap.c
+++ b/ewah/bitmap.c
@@ -25,8 +25,8 @@
struct bitmap *bitmap_new(void)
{
- struct bitmap *bitmap = ewah_malloc(sizeof(struct bitmap));
- bitmap->words = ewah_calloc(32, sizeof(eword_t));
+ struct bitmap *bitmap = xmalloc(sizeof(struct bitmap));
+ bitmap->words = xcalloc(32, sizeof(eword_t));
bitmap->word_alloc = 32;
return bitmap;
}
@@ -38,8 +38,8 @@ void bitmap_set(struct bitmap *self, size_t pos)
if (block >= self->word_alloc) {
size_t old_size = self->word_alloc;
self->word_alloc = block * 2;
- self->words = ewah_realloc(self->words,
- self->word_alloc * sizeof(eword_t));
+ self->words = xrealloc(self->words,
+ self->word_alloc * sizeof(eword_t));
memset(self->words + old_size, 0x0,
(self->word_alloc - old_size) * sizeof(eword_t));
@@ -102,7 +102,7 @@ struct bitmap *ewah_to_bitmap(struct ewah_bitmap *ewah)
while (ewah_iterator_next(&blowup, &it)) {
if (i >= bitmap->word_alloc) {
bitmap->word_alloc *= 1.5;
- bitmap->words = ewah_realloc(
+ bitmap->words = xrealloc(
bitmap->words, bitmap->word_alloc * sizeof(eword_t));
}
@@ -134,7 +134,7 @@ void bitmap_or_ewah(struct bitmap *self, struct ewah_bitmap *other)
if (self->word_alloc < other_final) {
self->word_alloc = other_final;
- self->words = ewah_realloc(self->words,
+ self->words = xrealloc(self->words,
self->word_alloc * sizeof(eword_t));
memset(self->words + original_size, 0x0,
(self->word_alloc - original_size) * sizeof(eword_t));