Skip to content

Commit 4b5b0df

Browse files
committed
Use the UMF base allocator in UThash
1 parent c3c6053 commit 4b5b0df

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/uthash/uthash.h

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
/*
2+
Copyright (C) 2024 Intel Corporation
3+
All rights reserved.
4+
5+
This code includes modifications to UTHash.
6+
27
Copyright (c) 2003-2022, Troy D. Hanson https://troydhanson.github.io/uthash/
38
All rights reserved.
49
@@ -21,6 +26,12 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2126
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2227
*/
2328

29+
/*
30+
Modifications by Intel:
31+
- define uthash_malloc unconditional as a umf_ba_global_alloc
32+
- define uthash_free unconditional as a umf_ba_global_free
33+
*/
34+
2435
#ifndef UTHASH_H
2536
#define UTHASH_H
2637

@@ -30,6 +41,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3041
#include <stdlib.h> /* exit */
3142
#include <string.h> /* memcmp, memset, strlen */
3243

44+
#include "base_alloc_global.h"
45+
3346
#if defined(HASH_DEFINE_OWN_STDINT) && HASH_DEFINE_OWN_STDINT
3447
/* This codepath is provided for backward compatibility, but I plan to remove it. */
3548
#warning \
@@ -76,12 +89,9 @@ typedef unsigned char uint8_t;
7689
} while (0)
7790
#endif
7891

79-
#ifndef uthash_malloc
80-
#define uthash_malloc(sz) malloc(sz) /* malloc fcn */
81-
#endif
82-
#ifndef uthash_free
83-
#define uthash_free(ptr, sz) free(ptr) /* free fcn */
84-
#endif
92+
#define uthash_malloc(sz) umf_ba_global_alloc(sz) /* malloc fcn */
93+
#define uthash_free(ptr, sz) umf_ba_global_free(ptr) /* free fcn */
94+
8595
#ifndef uthash_bzero
8696
#define uthash_bzero(a, n) memset(a, '\0', n)
8797
#endif

0 commit comments

Comments
 (0)