/[pspp]/pspp/src/hash.c
ViewVC logotype

Diff of /pspp/src/hash.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.16 by blp, Tue Oct 25 04:28:17 2005 UTC revision 1.17 by blp, Wed Oct 26 05:06:14 2005 UTC
# Line 178  hsh_create (int size, hsh_compare_func * Line 178  hsh_create (int size, hsh_compare_func *
178    if (size < 4)    if (size < 4)
179      size = 4;      size = 4;
180    h->size = next_power_of_2 (size);    h->size = next_power_of_2 (size);
181    h->entries = xmalloc (sizeof *h->entries * h->size);    h->entries = xnmalloc (h->size, sizeof *h->entries);
182    for (i = 0; i < h->size; i++)    for (i = 0; i < h->size; i++)
183      h->entries[i] = NULL;      h->entries[i] = NULL;
184    h->aux = aux;    h->aux = aux;
# Line 268  rehash (struct hsh_table *h, size_t new_ Line 268  rehash (struct hsh_table *h, size_t new_
268    end = begin + h->size;    end = begin + h->size;
269    
270    h->size = new_size;    h->size = new_size;
271    h->entries = xmalloc (sizeof *h->entries * h->size);    h->entries = xnmalloc (h->size, sizeof *h->entries);
272    for (i = 0; i < h->size; i++)    for (i = 0; i < h->size; i++)
273      h->entries[i] = NULL;      h->entries[i] = NULL;
274    for (table_p = begin; table_p < end; table_p++)    for (table_p = begin; table_p < end; table_p++)
# Line 385  hsh_data_copy (struct hsh_table *h) Line 385  hsh_data_copy (struct hsh_table *h)
385    void **copy;    void **copy;
386    
387    assert (h != NULL);    assert (h != NULL);
388    copy = xmalloc ((h->used + 1) * sizeof *copy);    copy = xnmalloc ((h->used + 1), sizeof *copy);
389    copy_if (h->entries, h->size, sizeof *h->entries, copy, not_null, NULL);    copy_if (h->entries, h->size, sizeof *h->entries, copy, not_null, NULL);
390    copy[h->used] = NULL;    copy[h->used] = NULL;
391    return copy;    return copy;

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26