Skip to content

Commit b30bcb8

Browse files
committed
Fixes after latest review
1 parent 7427d25 commit b30bcb8

File tree

9 files changed

+19
-49
lines changed

9 files changed

+19
-49
lines changed

include/umf/memory_pool_ops.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,11 @@ typedef struct umf_memory_pool_ops_t {
144144
void *arg, size_t size, umf_ctl_query_type_t queryType);
145145

146146
///
147-
/// @brief Get the name of the memory pool.
148-
/// @param pool pointer to the memory pool
149-
/// @return name of the memory pool
147+
/// @brief Retrieves the name of the disjoint memory pool [optional]
148+
/// @param pool pointer to the memory pool or NULL value
149+
/// @return A constant character string representing the pool's name.
150+
/// Returns "disjoint" if `pool` is NULL, otherwise returns the
151+
/// configured name of the specific pool instance.
150152
///
151153
const char *(*get_name)(void *pool);
152154
} umf_memory_pool_ops_t;

src/ctl/ctl.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -544,24 +544,6 @@ int ctl_load_config_from_file(struct ctl *ctl, void *ctx,
544544
}
545545
#endif
546546

547-
/*
548-
* ctl_new -- allocates and initializes ctl data structures
549-
*/
550-
struct ctl *ctl_new(void) {
551-
struct ctl *c = Zalloc(sizeof(struct ctl));
552-
if (c == NULL) {
553-
return NULL;
554-
}
555-
556-
c->first_free = 0;
557-
return c;
558-
}
559-
560-
/*
561-
* ctl_delete -- deletes ctl
562-
*/
563-
void ctl_delete(struct ctl *c) { umf_ba_global_free(c); }
564-
565547
/*
566548
* ctl_parse_ll -- (internal) parses and returns a long long signed integer
567549
*/

src/ctl/ctl.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,6 @@ struct ctl {
113113
int first_free;
114114
};
115115

116-
struct ctl *ctl_new(void);
117-
void ctl_delete(struct ctl *c);
118-
119116
void initialize_global_ctl(void);
120117

121118
int ctl_load_config_from_string(struct ctl *ctl, void *ctx,

src/memory_pool.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static int CTL_SUBTREE_HANDLER(default)(void *ctx,
6969
}
7070
if (UMF_DEFAULT_SIZE == i) {
7171
LOG_ERR("Default entries array is full");
72-
return -1;
72+
return UMF_RESULT_ERROR_OUT_OF_RESOURCES;
7373
}
7474
} else if (queryType == CTL_QUERY_READ) {
7575
int i = 0;

src/pool/pool_scalable.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ static const char *tbb_symbol[TBB_POOL_SYMBOLS_MAX] = {
116116
#endif
117117
};
118118

119-
struct ctl *pool_scallable_ctl_root;
119+
struct ctl pool_scallable_ctl_root;
120120

121121
static UTIL_ONCE_FLAG ctl_initialized = UTIL_ONCE_FLAG_INIT;
122122

@@ -411,15 +411,13 @@ static umf_result_t tbb_get_last_allocation_error(void *pool) {
411411
return TLS_last_allocation_error;
412412
}
413413

414-
static void initialize_pool_ctl(void) { pool_scallable_ctl_root = ctl_new(); }
415-
416414
static umf_result_t pool_ctl(void *hPool, int operationType, const char *name,
417415
void *arg, size_t size,
418416
umf_ctl_query_type_t query_type) {
419417
(void)operationType; // unused
420418
umf_memory_pool_handle_t pool_provider = (umf_memory_pool_handle_t)hPool;
421-
utils_init_once(&ctl_initialized, initialize_pool_ctl);
422-
return ctl_query(pool_scallable_ctl_root, pool_provider->pool_priv,
419+
utils_init_once(&ctl_initialized, NULL);
420+
return ctl_query(&pool_scallable_ctl_root, pool_provider->pool_priv,
423421
CTL_QUERY_PROGRAMMATIC, name, query_type, arg, size);
424422
}
425423

src/provider/provider_fixed_memory.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,11 @@ static __TLS fixed_last_native_error_t TLS_last_native_error;
5757
#define CTL_PROVIDER_TYPE fixed_memory_provider_t
5858
#include "provider_ctl_stats_impl.h"
5959

60-
struct ctl *fixed_memory_ctl_root;
60+
struct ctl fixed_memory_ctl_root;
6161
static UTIL_ONCE_FLAG ctl_initialized = UTIL_ONCE_FLAG_INIT;
6262

6363
static void initialize_fixed_ctl(void) {
64-
fixed_memory_ctl_root = ctl_new();
65-
CTL_REGISTER_MODULE(fixed_memory_ctl_root, stats);
64+
CTL_REGISTER_MODULE(&fixed_memory_ctl_root, stats);
6665
}
6766

6867
static const char *Native_error_str[] = {
@@ -283,7 +282,7 @@ static umf_result_t fixed_ctl(void *provider, int operationType,
283282
const char *name, void *arg, size_t size,
284283
umf_ctl_query_type_t query_type) {
285284
utils_init_once(&ctl_initialized, initialize_fixed_ctl);
286-
return ctl_query(fixed_memory_ctl_root, provider, operationType, name,
285+
return ctl_query(&fixed_memory_ctl_root, provider, operationType, name,
287286
query_type, arg, size);
288287
}
289288

src/provider/provider_os_memory.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ static const char *Native_error_str[] = {
173173
"HWLOC topology discovery failed",
174174
};
175175

176-
struct ctl *os_memory_ctl_root;
176+
struct ctl os_memory_ctl_root;
177177

178178
static UTIL_ONCE_FLAG ctl_initialized = UTIL_ONCE_FLAG_INIT;
179179

@@ -197,9 +197,8 @@ static const umf_ctl_node_t CTL_NODE(params)[] = {CTL_LEAF_RO(ipc_enabled),
197197
CTL_NODE_END};
198198

199199
static void initialize_os_ctl(void) {
200-
os_memory_ctl_root = ctl_new();
201-
CTL_REGISTER_MODULE(os_memory_ctl_root, params);
202-
CTL_REGISTER_MODULE(os_memory_ctl_root, stats);
200+
CTL_REGISTER_MODULE(&os_memory_ctl_root, params);
201+
CTL_REGISTER_MODULE(&os_memory_ctl_root, stats);
203202
}
204203

205204
static void os_store_last_native_error(int32_t native_error, int errno_value) {
@@ -1446,7 +1445,7 @@ static umf_result_t os_ctl(void *hProvider, int operationType, const char *name,
14461445
void *arg, size_t size,
14471446
umf_ctl_query_type_t query_type) {
14481447
utils_init_once(&ctl_initialized, initialize_os_ctl);
1449-
return ctl_query(os_memory_ctl_root, hProvider, operationType, name,
1448+
return ctl_query(&os_memory_ctl_root, hProvider, operationType, name,
14501449
query_type, arg, size);
14511450
}
14521451

test/ctl/ctl_debug.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313

1414
#include "ctl_debug.h"
1515

16-
static struct ctl *ctl_debug;
16+
static struct ctl ctl_debug;
1717

1818
static int alloc_pattern = 0;
1919
static int enable_logging = 0;
2020
static int log_level = 0;
2121

22-
struct ctl *get_debug_ctl(void) { return ctl_debug; }
22+
struct ctl *get_debug_ctl(void) { return &ctl_debug; }
2323

2424
/*
2525
* CTL_WRITE_HANDLER(alloc_pattern) -- sets the alloc_pattern field in heap
@@ -137,9 +137,4 @@ static const umf_ctl_node_t CTL_NODE(debug)[] = {CTL_CHILD(heap),
137137
*/
138138
void debug_ctl_register(struct ctl *ctl) { CTL_REGISTER_MODULE(ctl, debug); }
139139

140-
void initialize_debug_ctl(void) {
141-
ctl_debug = ctl_new();
142-
debug_ctl_register(ctl_debug);
143-
}
144-
145-
void deinitialize_debug_ctl(void) { ctl_delete(ctl_debug); }
140+
void initialize_debug_ctl(void) { debug_ctl_register(&ctl_debug); }

test/ctl/ctl_unittest.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ TEST_F(test, ctl_debug_read_from_string) {
5050
0);
5151

5252
debug_ctl_register(ctl_handler);
53-
deinitialize_debug_ctl();
5453
}
5554

5655
int ctl_config_write_to_file(const char *filename, const char *data) {
@@ -89,6 +88,5 @@ TEST_F(test, ctl_debug_read_from_file) {
8988
ASSERT_EQ(value, 1);
9089

9190
debug_ctl_register(ctl_handler);
92-
deinitialize_debug_ctl();
9391
#endif
9492
}

0 commit comments

Comments
 (0)