diff --git a/libwget/bar.c b/libwget/bar.c index c426638b..91499c80 100644 --- a/libwget/bar.c +++ b/libwget/bar.c @@ -128,29 +128,29 @@ wget_bar_t *wget_bar_init(wget_bar_t *bar, int nslots, int max_width) max_width -= _BAR_DECOR_COST; if (!bar) { - if (!(bar = calloc(1, sizeof(*bar)))) + if (!(bar = xcalloc(1, sizeof(*bar)))) return NULL; allocated = 1; } else memset(bar, 0, sizeof(*bar)); if (bar->nslots < nslots) { - free(bar->slots); + xfree(bar->slots); bar->nslots = nslots; - if (!(bar->slots = calloc(nslots, sizeof(_bar_slot_t) * nslots))) + if (!(bar->slots = xcalloc(nslots, sizeof(_bar_slot_t) * nslots))) goto cleanup; } else { memset(bar->slots, 0, sizeof(_bar_slot_t) * nslots); } if (bar->max_width < max_width) { - free(bar->filled); - if (!(bar->filled = malloc(max_width))) + xfree(bar->filled); + if (!(bar->filled = xmalloc(max_width))) goto cleanup; memset(bar->filled, '=', max_width); - free(bar->spaces); - if (!(bar->spaces = malloc(max_width))) + xfree(bar->spaces); + if (!(bar->spaces = xmalloc(max_width))) goto cleanup; memset(bar->spaces, ' ', max_width); @@ -275,9 +275,9 @@ void wget_bar_update(const wget_bar_t *bar, int slotpos) { void wget_bar_deinit(wget_bar_t *bar) { if (bar) { - free(bar->spaces); - free(bar->filled); - free(bar->slots); + xfree(bar->spaces); + xfree(bar->filled); + xfree(bar->slots); } } @@ -287,7 +287,7 @@ void wget_bar_deinit(wget_bar_t *bar) void wget_bar_free(wget_bar_t **bar) { if (bar) { - free(*bar); + xfree(*bar); } } diff --git a/libwget/hashmap.c b/libwget/hashmap.c index 3725b8cd..1b96444b 100644 --- a/libwget/hashmap.c +++ b/libwget/hashmap.c @@ -146,7 +146,7 @@ static _GL_INLINE void G_GNUC_WGET_NONNULL((1,3)) hashmap_new_entry(wget_hashmap ENTRY *entry; int pos = hash % h->max; - entry = malloc(sizeof(ENTRY)); + entry = xmalloc(sizeof(ENTRY)); entry->key = (void *)key; entry->value = (void *)value; entry->hash = hash;