2424
2525umf_memory_pool_ops_t * umfJemallocPoolOps (void ) { return NULL ; }
2626
27- umf_result_t
28- umfJemallocPoolParamsCreate (umf_jemalloc_pool_params_handle_t * hParams ) {
29- (void )hParams ; // unused
30- return UMF_RESULT_ERROR_NOT_SUPPORTED ;
31- }
32-
33- umf_result_t
34- umfJemallocPoolParamsDestroy (umf_jemalloc_pool_params_handle_t hParams ) {
35- (void )hParams ; // unused
36- return UMF_RESULT_ERROR_NOT_SUPPORTED ;
37- }
38-
39- umf_result_t
40- umfJemallocPoolParamsSetKeepAllMemory (umf_jemalloc_pool_params_handle_t hParams ,
41- bool keepAllMemory ) {
42- (void )hParams ; // unused
43- (void )keepAllMemory ; // unused
44- return UMF_RESULT_ERROR_NOT_SUPPORTED ;
45- }
46-
4727#else
4828
4929#include <jemalloc/jemalloc.h>
@@ -53,16 +33,8 @@ umfJemallocPoolParamsSetKeepAllMemory(umf_jemalloc_pool_params_handle_t hParams,
5333typedef struct jemalloc_memory_pool_t {
5434 umf_memory_provider_handle_t provider ;
5535 unsigned int arena_index ; // index of jemalloc arena
56- // set to true if umfMemoryProviderFree() should never be called
57- bool disable_provider_free ;
5836} jemalloc_memory_pool_t ;
5937
60- // Configuration of Jemalloc Pool
61- typedef struct umf_jemalloc_pool_params_t {
62- /// Set to true if umfMemoryProviderFree() should never be called.
63- bool disable_provider_free ;
64- } umf_jemalloc_pool_params_t ;
65-
6638static __TLS umf_result_t TLS_last_allocation_error ;
6739
6840static jemalloc_memory_pool_t * pool_by_arena_index [MALLCTL_ARENAS_ALL ];
@@ -75,52 +47,6 @@ static jemalloc_memory_pool_t *get_pool_by_arena_index(unsigned arena_ind) {
7547 return pool_by_arena_index [arena_ind ];
7648}
7749
78- umf_result_t
79- umfJemallocPoolParamsCreate (umf_jemalloc_pool_params_handle_t * hParams ) {
80- if (!hParams ) {
81- LOG_ERR ("jemalloc pool params handle is NULL" );
82- return UMF_RESULT_ERROR_INVALID_ARGUMENT ;
83- }
84-
85- umf_jemalloc_pool_params_t * params_data =
86- umf_ba_global_alloc (sizeof (* params_data ));
87- if (!params_data ) {
88- LOG_ERR ("cannot allocate memory for jemalloc poolparams" );
89- return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY ;
90- }
91-
92- params_data -> disable_provider_free = false;
93-
94- * hParams = (umf_jemalloc_pool_params_handle_t )params_data ;
95-
96- return UMF_RESULT_SUCCESS ;
97- }
98-
99- umf_result_t
100- umfJemallocPoolParamsDestroy (umf_jemalloc_pool_params_handle_t hParams ) {
101- if (!hParams ) {
102- LOG_ERR ("jemalloc pool params handle is NULL" );
103- return UMF_RESULT_ERROR_INVALID_ARGUMENT ;
104- }
105-
106- umf_ba_global_free (hParams );
107-
108- return UMF_RESULT_SUCCESS ;
109- }
110-
111- umf_result_t
112- umfJemallocPoolParamsSetKeepAllMemory (umf_jemalloc_pool_params_handle_t hParams ,
113- bool keepAllMemory ) {
114- if (!hParams ) {
115- LOG_ERR ("jemalloc pool params handle is NULL" );
116- return UMF_RESULT_ERROR_INVALID_ARGUMENT ;
117- }
118-
119- hParams -> disable_provider_free = keepAllMemory ;
120-
121- return UMF_RESULT_SUCCESS ;
122- }
123-
12450// arena_extent_alloc - an extent allocation function conforms to the extent_alloc_t type and upon
12551// success returns a pointer to size bytes of mapped memory on behalf of arena arena_ind such that
12652// the extent's base address is a multiple of alignment, as well as setting *zero to indicate
@@ -150,9 +76,7 @@ static void *arena_extent_alloc(extent_hooks_t *extent_hooks, void *new_addr,
15076 }
15177
15278 if (new_addr != NULL && ptr != new_addr ) {
153- if (!pool -> disable_provider_free ) {
154- umfMemoryProviderFree (pool -> provider , ptr , size );
155- }
79+ umfMemoryProviderFree (pool -> provider , ptr , size );
15680 return NULL ;
15781 }
15882
@@ -186,10 +110,6 @@ static void arena_extent_destroy(extent_hooks_t *extent_hooks, void *addr,
186110
187111 jemalloc_memory_pool_t * pool = get_pool_by_arena_index (arena_ind );
188112
189- if (pool -> disable_provider_free ) {
190- return ;
191- }
192-
193113 umf_result_t ret ;
194114 ret = umfMemoryProviderFree (pool -> provider , addr , size );
195115 if (ret != UMF_RESULT_SUCCESS ) {
@@ -212,10 +132,6 @@ static bool arena_extent_dalloc(extent_hooks_t *extent_hooks, void *addr,
212132
213133 jemalloc_memory_pool_t * pool = get_pool_by_arena_index (arena_ind );
214134
215- if (pool -> disable_provider_free ) {
216- return true; // opt-out from deallocation
217- }
218-
219135 umf_result_t ret ;
220136 ret = umfMemoryProviderFree (pool -> provider , addr , size );
221137 if (ret != UMF_RESULT_SUCCESS ) {
@@ -466,12 +382,10 @@ static void *op_aligned_alloc(void *pool, size_t size, size_t alignment) {
466382
467383static umf_result_t op_initialize (umf_memory_provider_handle_t provider ,
468384 void * params , void * * out_pool ) {
385+ (void )params ; // unused
469386 assert (provider );
470387 assert (out_pool );
471388
472- umf_jemalloc_pool_params_handle_t je_params =
473- (umf_jemalloc_pool_params_handle_t )params ;
474-
475389 extent_hooks_t * pHooks = & arena_extent_hooks ;
476390 size_t unsigned_size = sizeof (unsigned );
477391 int err ;
@@ -484,12 +398,6 @@ static umf_result_t op_initialize(umf_memory_provider_handle_t provider,
484398
485399 pool -> provider = provider ;
486400
487- if (je_params ) {
488- pool -> disable_provider_free = je_params -> disable_provider_free ;
489- } else {
490- pool -> disable_provider_free = false;
491- }
492-
493401 unsigned arena_index ;
494402 err = je_mallctl ("arenas.create" , (void * )& arena_index , & unsigned_size ,
495403 NULL , 0 );
0 commit comments