From e78f8bea4dcdf1b14678b5e81f29518c6e367868 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Sun, 14 Oct 2012 14:53:42 +0200 Subject: [PATCH] hash.c: use xalloc --- Makefile | 2 +- hash.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index d93cdfe..6241d7e 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ install : $(PROGRAMS) cp $^ $(HOME)/bin/ dlight : dlight.o buffer.o env.o http.o rss.o lockfile.o filter.o cconf.o \ - proc-cache.o dlhist.o hash.o error.o + proc-cache.o dlhist.o hash.o xalloc.o error.o dlight-compile : compile.o buffer.o env.o lockfile.o filter.o cconf.o \ error.o dlight-read-config : read-config.o buffer.o env.o cconf.o error.o diff --git a/hash.c b/hash.c index b1c08f4..4a55fd6 100644 --- a/hash.c +++ b/hash.c @@ -19,6 +19,7 @@ */ #include "hash.h" +#include "xalloc.h" #include #define TABLE_MIN_SIZE 128 @@ -42,7 +43,7 @@ void hash_init(struct hash_table *table) { void hash_free(struct hash_table *table) { if (table->ptr) - free(table->ptr); + xfree(table->ptr); hash_init(table); } @@ -103,7 +104,7 @@ static void resize(struct hash_table *t) { t->size = TABLE_MIN_SIZE; t->count = 0; - t->ptr = calloc(sizeof(t->ptr), t->size); + t->ptr = xmallocz(sizeof(t->ptr) * t->size); if (old) { for(i=0; i < old_size; i++) { @@ -111,7 +112,7 @@ static void resize(struct hash_table *t) { if (entry) insert(t, *entry, entry); } - free(old); + xfree(old); } }