Skip to content

Commit a3b084b

Browse files
committed
Add function to get pool name
1 parent 5075645 commit a3b084b

File tree

6 files changed

+26
-0
lines changed

6 files changed

+26
-0
lines changed

include/umf/memory_pool.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,13 @@ umf_memory_pool_handle_t umfPoolByPtr(const void *ptr);
165165
umf_result_t umfPoolGetMemoryProvider(umf_memory_pool_handle_t hPool,
166166
umf_memory_provider_handle_t *hProvider);
167167

168+
///
169+
/// @brief Retrieve name of a given memory \p hPool.
170+
/// @param hPool handle to the memory pool
171+
/// @return pointer to a string containing the name of the \p hPool
172+
///
173+
const char *umfPoolGetName(umf_memory_pool_handle_t hPool);
174+
168175
///
169176
/// @brief Set a custom tag on the memory pool that can be later retrieved using umfPoolGetTag.
170177
/// @param hPool specified memory pool

include/umf/memory_pool_ops.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,13 @@ typedef struct umf_memory_pool_ops_t {
141141
///
142142
umf_result_t (*ctl)(void *hPool, int operationType, const char *name,
143143
void *arg, umf_ctl_query_type_t queryType);
144+
145+
///
146+
/// @brief Get the name of the memory pool.
147+
/// @param pool pointer to the memory pool
148+
/// @return name of the memory pool
149+
///
150+
const char *(*get_name)(void *pool);
144151
} umf_memory_pool_ops_t;
145152

146153
#ifdef __cplusplus

src/libumf.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,4 @@ EXPORTS
140140
umfCtlExec
141141
umfCtlGet
142142
umfCtlSet
143+
umfPoolGetName

src/libumf.map

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,5 @@ UMF_0.12 {
140140
umfCtlExec;
141141
umfCtlGet;
142142
umfCtlSet;
143+
umfPoolGetName;
143144
} UMF_0.11;

src/memory_pool.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ umf_result_t umfPoolGetMemoryProvider(umf_memory_pool_handle_t hPool,
168168
return UMF_RESULT_SUCCESS;
169169
}
170170

171+
const char *umfPoolGetName(umf_memory_pool_handle_t hPool) {
172+
return hPool->ops.get_name(hPool->pool_priv);
173+
}
174+
171175
umf_result_t umfPoolCreate(const umf_memory_pool_ops_t *ops,
172176
umf_memory_provider_handle_t provider, void *params,
173177
umf_pool_create_flags_t flags,

src/pool/pool_disjoint.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,11 @@ void disjoint_pool_finalize(void *pool) {
929929
umf_ba_global_free(hPool);
930930
}
931931

932+
const char *disjoint_pool_get_name(void *pool) {
933+
disjoint_pool_t *hPool = (disjoint_pool_t *)pool;
934+
return hPool->params.name;
935+
}
936+
932937
static umf_memory_pool_ops_t UMF_DISJOINT_POOL_OPS = {
933938
.version = UMF_VERSION_CURRENT,
934939
.initialize = disjoint_pool_initialize,
@@ -940,6 +945,7 @@ static umf_memory_pool_ops_t UMF_DISJOINT_POOL_OPS = {
940945
.malloc_usable_size = disjoint_pool_malloc_usable_size,
941946
.free = disjoint_pool_free,
942947
.get_last_allocation_error = disjoint_pool_get_last_allocation_error,
948+
.get_name = disjoint_pool_get_name,
943949
};
944950

945951
umf_memory_pool_ops_t *umfDisjointPoolOps(void) {

0 commit comments

Comments
 (0)