HASH *hash_create (int nelem)
{
- HASH *table = safe_malloc (sizeof (HASH));
+ HASH *table = mem_malloc (sizeof (HASH));
if (nelem == 0)
nelem = 2;
table->nelem = nelem;
table->curnelem = 0;
- table->table = safe_calloc (nelem, sizeof (struct hash_elem *));
+ table->table = mem_calloc (nelem, sizeof (struct hash_elem *));
return table;
}
tmp = elem;
elem = elem->next;
hash_insert (table, tmp->key, tmp->data, 1);
- FREE (&tmp);
+ mem_free (&tmp);
}
}
- FREE (&ptr->table);
- FREE (&ptr);
+ mem_free (&ptr->table);
+ mem_free (&ptr);
return table;
}
struct hash_elem *ptr;
int h;
- ptr = (struct hash_elem *) safe_malloc (sizeof (struct hash_elem));
+ ptr = (struct hash_elem *) mem_malloc (sizeof (struct hash_elem));
h = hash_string ((unsigned char *) key, table->nelem);
ptr->key = key;
ptr->data = data;
for (tmp = table->table[h], last = NULL; tmp; last = tmp, tmp = tmp->next) {
r = str_cmp (tmp->key, key);
if (r == 0) {
- FREE (&ptr);
+ mem_free (&ptr);
return (-1);
}
if (r > 0)
*last = ptr->next;
if (destroy)
destroy (ptr->data);
- FREE (&ptr);
+ mem_free (&ptr);
ptr = *last;
} else {
elem = elem->next;
if (destroy)
destroy (tmp->data);
- FREE (&tmp);
+ mem_free (&tmp);
}
}
- FREE (&pptr->table);
- FREE (ptr);
+ mem_free (&pptr->table);
+ mem_free (ptr);
}