summaryrefslogtreecommitdiffstats
path: root/libopkg/hash_table.c
diff options
context:
space:
mode:
authorgraham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2009-11-04 23:20:09 (EST)
committer graham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2009-11-04 23:20:09 (EST)
commit480538737a8a9be074a1848f2e52cf2d1ff4709f (patch)
treee24d32dc46e0b83600aaa02a33ecaa6779765d9b /libopkg/hash_table.c
parentacd905996191df6ab59050bd179a5ed11e6f72a4 (diff)
s/malloc/xmalloc/ s/calloc/xcalloc/ s/realloc/realloc/
And redundant error checking removed from the places where allocation failures were actually checked. git-svn-id: http://opkg.googlecode.com/svn/trunk@259 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358
Diffstat (limited to 'libopkg/hash_table.c')
-rw-r--r--libopkg/hash_table.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/libopkg/hash_table.c b/libopkg/hash_table.c
index 6de9085..df6ff4f 100644
--- a/libopkg/hash_table.c
+++ b/libopkg/hash_table.c
@@ -69,11 +69,8 @@ int hash_table_init(const char *name, hash_table_t *hash, int len)
--picker;
hash->n_entries = *picker;
- hash->entries = (hash_entry_t *)calloc(hash->n_entries, sizeof(hash_entry_t));
- if (hash->entries == NULL) {
- fprintf(stderr, "%s: Out of memory.\n", __FUNCTION__);
- return ENOMEM;
- }
+ hash->entries = xcalloc(hash->n_entries, sizeof(hash_entry_t));
+
return 0;
}
@@ -147,10 +144,7 @@ int hash_table_insert(hash_table_t *hash, const char *key, void *value)
return 0;
}
}
- hash_entry->next = (hash_entry_t *)calloc(1, sizeof(hash_entry_t));
- if (!hash_entry->next) {
- return -ENOMEM;
- }
+ hash_entry->next = xcalloc(1, sizeof(hash_entry_t));
hash_entry = hash_entry->next;
hash_entry->next = NULL;
}