@@ -41,6 +41,12 @@ typedef struct jemalloc_memory_pool_t {
41
41
bool disable_provider_free ;
42
42
} jemalloc_memory_pool_t ;
43
43
44
+ // Configuration of Jemalloc Pool
45
+ typedef struct umf_jemalloc_pool_params_t {
46
+ /// Set to true if umfMemoryProviderFree() should never be called.
47
+ bool disable_provider_free ;
48
+ } umf_jemalloc_pool_params_t ;
49
+
44
50
static __TLS umf_result_t TLS_last_allocation_error ;
45
51
46
52
static jemalloc_memory_pool_t * pool_by_arena_index [MALLCTL_ARENAS_ALL ];
@@ -53,6 +59,52 @@ static jemalloc_memory_pool_t *get_pool_by_arena_index(unsigned arena_ind) {
53
59
return pool_by_arena_index [arena_ind ];
54
60
}
55
61
62
+ umf_result_t
63
+ umfJemallocPoolParamsCreate (umf_jemalloc_pool_params_handle_t * hParams ) {
64
+ if (!hParams ) {
65
+ LOG_ERR ("jemalloc pool params handle is NULL" );
66
+ return UMF_RESULT_ERROR_INVALID_ARGUMENT ;
67
+ }
68
+
69
+ umf_jemalloc_pool_params_t * params_data =
70
+ umf_ba_global_alloc (sizeof (* params_data ));
71
+ if (!params_data ) {
72
+ LOG_ERR ("cannot allocate memory for jemalloc poolparams" );
73
+ return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY ;
74
+ }
75
+
76
+ params_data -> disable_provider_free = false;
77
+
78
+ * hParams = (umf_jemalloc_pool_params_handle_t )params_data ;
79
+
80
+ return UMF_RESULT_SUCCESS ;
81
+ }
82
+
83
+ umf_result_t
84
+ umfJemallocPoolParamsDestroy (umf_jemalloc_pool_params_handle_t hParams ) {
85
+ if (!hParams ) {
86
+ LOG_ERR ("jemalloc pool params handle is NULL" );
87
+ return UMF_RESULT_ERROR_INVALID_ARGUMENT ;
88
+ }
89
+
90
+ umf_ba_global_free (hParams );
91
+
92
+ return UMF_RESULT_SUCCESS ;
93
+ }
94
+
95
+ umf_result_t
96
+ umfJemallocPoolParamsSetKeepAllMemory (umf_jemalloc_pool_params_handle_t hParams ,
97
+ bool keepAllMemory ) {
98
+ if (!hParams ) {
99
+ LOG_ERR ("jemalloc pool params handle is NULL" );
100
+ return UMF_RESULT_ERROR_INVALID_ARGUMENT ;
101
+ }
102
+
103
+ hParams -> disable_provider_free = keepAllMemory ;
104
+
105
+ return UMF_RESULT_SUCCESS ;
106
+ }
107
+
56
108
// arena_extent_alloc - an extent allocation function conforms to the extent_alloc_t type and upon
57
109
// success returns a pointer to size bytes of mapped memory on behalf of arena arena_ind such that
58
110
// the extent's base address is a multiple of alignment, as well as setting *zero to indicate
@@ -401,8 +453,8 @@ static umf_result_t op_initialize(umf_memory_provider_handle_t provider,
401
453
assert (provider );
402
454
assert (out_pool );
403
455
404
- umf_jemalloc_pool_params_t * je_params =
405
- (umf_jemalloc_pool_params_t * )params ;
456
+ umf_jemalloc_pool_params_handle_t je_params =
457
+ (umf_jemalloc_pool_params_handle_t )params ;
406
458
407
459
extent_hooks_t * pHooks = & arena_extent_hooks ;
408
460
size_t unsigned_size = sizeof (unsigned );
0 commit comments