summaryrefslogtreecommitdiff
path: root/dict.c
diff options
context:
space:
mode:
authorMichael Grunder <michael.grunder@gmail.com>2020-01-28 12:13:05 -0800
committerGitHub <noreply@github.com>2020-01-28 12:13:05 -0800
commit669ac9d0c843f9ccf07d4969ff6bff75fafee01f (patch)
tree6075cb357e13342f6844dc9891d6c3c38c8e6f86 /dict.c
parent0501c623c91344e54cb2775a91509650960789b1 (diff)
Safe allocation wrappers (#754)
Create allocation wrappers with a configurable OOM handler (defaults to abort()). See #752, #747
Diffstat (limited to 'dict.c')
-rw-r--r--dict.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/dict.c b/dict.c
index 5b349f0..eaf4e4d 100644
--- a/dict.c
+++ b/dict.c
@@ -34,6 +34,7 @@
*/
#include "fmacros.h"
+#include "alloc.h"
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
@@ -71,7 +72,7 @@ static void _dictReset(dict *ht) {
/* Create a new hash table */
static dict *dictCreate(dictType *type, void *privDataPtr) {
- dict *ht = malloc(sizeof(*ht));
+ dict *ht = hi_malloc(sizeof(*ht));
_dictInit(ht,type,privDataPtr);
return ht;
}
@@ -142,7 +143,7 @@ static int dictAdd(dict *ht, void *key, void *val) {
return DICT_ERR;
/* Allocates the memory and stores key */
- entry = malloc(sizeof(*entry));
+ entry = hi_malloc(sizeof(*entry));
entry->next = ht->table[index];
ht->table[index] = entry;
@@ -256,7 +257,7 @@ static dictEntry *dictFind(dict *ht, const void *key) {
}
static dictIterator *dictGetIterator(dict *ht) {
- dictIterator *iter = malloc(sizeof(*iter));
+ dictIterator *iter = hi_malloc(sizeof(*iter));
iter->ht = ht;
iter->index = -1;