Skip to content

Commit a2e5542

Browse files
committed
use xxmalloc
1 parent 6fc9b1a commit a2e5542

1 file changed

Lines changed: 2 additions & 17 deletions

File tree

dttools/src/itable.c

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ See the file COPYING for details.
77

88
#include "itable.h"
99
#include "debug.h"
10+
#include "xxmalloc.h"
1011

1112
#include <stdlib.h>
1213
#include <string.h>
@@ -192,22 +193,7 @@ int itable_insert(struct itable *h, UINT64_T key, const void *value)
192193
if (((float)h->size / h->bucket_count) > DEFAULT_MAX_LOAD)
193194
itable_double_buckets(h);
194195

195-
struct entry *new_entry = (struct entry *)malloc(sizeof(struct entry));
196-
if (!new_entry)
197-
return 0;
198-
199-
new_entry->key = key;
200-
new_entry->value = (void *)value;
201-
202-
int inserted = insert_to_buckets_aux(h->buckets, h->bucket_count, new_entry);
203-
if (inserted) {
204-
h->size++;
205-
itable_double_buckets(h);
206-
207-
struct entry *new_entry = (struct entry *)malloc(sizeof(struct entry));
208-
if (!new_entry)
209-
return 0;
210-
196+
struct entry *new_entry = (struct entry *)xxmalloc(sizeof(struct entry));
211197
new_entry->key = key;
212198
new_entry->value = (void *)value;
213199

@@ -351,5 +337,4 @@ int itable_nextkey(struct itable *h, UINT64_T *key, void **value)
351337
return 0;
352338
}
353339
}
354-
355340
/* vim: set noexpandtab tabstop=8: */

0 commit comments

Comments
 (0)