Archived
1
0
Fork 0

hash.c: use xalloc

This commit is contained in:
Henrik Hautakoski 2012-10-14 14:53:42 +02:00
parent 891e438a7a
commit e78f8bea4d
2 changed files with 5 additions and 4 deletions

View file

@ -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

7
hash.c
View file

@ -19,6 +19,7 @@
*/
#include "hash.h"
#include "xalloc.h"
#include <stdlib.h>
#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);
}
}