hash.c: use xalloc
This commit is contained in:
parent
891e438a7a
commit
e78f8bea4d
2 changed files with 5 additions and 4 deletions
7
hash.c
7
hash.c
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Reference in a new issue