Skip to content

Commit 38415da

Browse files
committed
use actual pool name instead of default name
1 parent d1ce946 commit 38415da

File tree

5 files changed

+26
-30
lines changed

5 files changed

+26
-30
lines changed

docs/config/ctl.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ to providers or pools created after the defaults are set. For example::
8484

8585
Every subsequently created disjoint pool will use ``custom`` as its name unless
8686
overridden by explicit parameters. Defaults may be supplied programmatically or
87-
via configuration and are saved internally and applied during initalization of
87+
via configuration and are saved internally and applied during initialization of
8888
a matching provider or pool.
8989

9090
Environment variables
@@ -346,7 +346,7 @@ Disjoint pool (``disjoint``)
346346
provider.
347347
:type bytes: ``size_t``
348348

349-
**Access:** read-write. (write is only avaiable through defaults)
349+
**Access:** read-write. (write is only available through defaults)
350350
**Defaults / Env:** supported.
351351

352352
Governs how much memory the pool grabs in each slab. Lower values reduce
@@ -359,7 +359,7 @@ Disjoint pool (``disjoint``)
359359
cached by the pool.
360360
:type bytes: ``size_t``
361361

362-
**Access:** read-write. (write is only avaiable through defaults)
362+
**Access:** read-write. (write is only available through defaults)
363363
**Defaults / Env:** supported.
364364

365365
Sets the cut-off for pooling allocations. Requests larger than this value are
@@ -372,7 +372,7 @@ Disjoint pool (``disjoint``)
372372
may retain.
373373
:type count: ``size_t``
374374

375-
**Access:** read-write. (write is only avaiable through defaults)
375+
**Access:** read-write. (write is only available through defaults)
376376
**Defaults / Env:** supported.
377377

378378
Caps the pool's cached slabs per bucket to limit memory retention. Shrinking
@@ -385,7 +385,7 @@ Disjoint pool (``disjoint``)
385385
serve.
386386
:type bytes: ``size_t``
387387

388-
**Access:** read-write. (write is only avaiable through defaults)
388+
**Access:** read-write. (write is only available through defaults)
389389
**Defaults / Env:** supported.
390390

391391
Controls the smallest chunk size kept in the pool, which in turn affects the
@@ -397,7 +397,7 @@ Disjoint pool (``disjoint``)
397397
:param level: Receives or supplies the tracing level for the pool.
398398
:type level: ``int`` (``0`` disables tracing)
399399

400-
**Access:** read-write. (write is only avaiable through defaults)
400+
**Access:** read-write. (write is only available through defaults)
401401
**Defaults / Env:** supported.
402402

403403
Controls the disjoint pool's tracing features. ``0`` disables tracing.

examples/ctl/ctl_example.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ static umf_result_t ctl_ctl(void *provider, umf_ctl_query_source_t source,
204204
return UMF_RESULT_SUCCESS;
205205
}
206206
if (queryType == CTL_QUERY_RUNNABLE &&
207-
strcmp(formatted, "substraction") == 0) {
207+
strcmp(formatted, "subtraction") == 0) {
208208
if (p->m) {
209209
p->c = (p->a - p->b) % p->m;
210210
} else {
@@ -300,9 +300,9 @@ int main(void) {
300300

301301
// Execute subtraction and fetch the result
302302
res =
303-
umfCtlExec("umf.provider.by_handle.{}.substraction", NULL, 0, provider);
303+
umfCtlExec("umf.provider.by_handle.{}.subtraction", NULL, 0, provider);
304304
if (res != UMF_RESULT_SUCCESS) {
305-
fprintf(stderr, "Failed to execute substraction!\n");
305+
fprintf(stderr, "Failed to execute subtraction!\n");
306306
goto out;
307307
}
308308
res = umfCtlGet("umf.provider.by_handle.{}.c", &result, sizeof(result),
@@ -311,7 +311,7 @@ int main(void) {
311311
fprintf(stderr, "Failed to get c!\n");
312312
goto out;
313313
}
314-
printf("substraction result: %d\n", result);
314+
printf("subtraction result: %d\n", result);
315315

316316
out:
317317
umfMemoryProviderDestroy(provider);

examples/ctl/ctl_statistics_example.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ int main(void) {
201201
goto cleanup;
202202
}
203203

204-
/* set name of the pool so we can easly ref it by using name */
204+
/* set name of the pool so we can easily ref it by using name */
205205
res = umfDisjointPoolParamsSetName(disjoint_params, pool_name);
206206
if (res != UMF_RESULT_SUCCESS) {
207207
fprintf(stderr, "Failed to name disjoint pool (error %d)\n", (int)res);

src/memory_pool.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -469,15 +469,14 @@ static umf_result_t umfPoolCreateInternal(const umf_memory_pool_ops_t *ops,
469469
goto err_pool_init;
470470
}
471471

472-
// Set default property "name" to pool if exists
473472
const char *pname = NULL;
474-
ret = ops->get_name(NULL, &pname);
473+
ret = ops->get_name(pool->pool_priv, &pname);
475474
if (ret != UMF_RESULT_SUCCESS) {
476475
LOG_ERR("Failed to get pool name");
477476
goto err_pool_init;
478477
}
479478
assert(pname != NULL);
480-
479+
utils_warn_invalid_name("Memory pool", pname);
481480
ctl_default_apply(pool_default_list, pname, ops->ext_ctl, pool->pool_priv);
482481

483482
ret = umfPoolPostInitialize(&pool->ops, pool->pool_priv);
@@ -489,12 +488,6 @@ static umf_result_t umfPoolCreateInternal(const umf_memory_pool_ops_t *ops,
489488
*hPool = pool;
490489
pools_by_name_add(pool);
491490

492-
const char *pool_name = NULL;
493-
if (ops->get_name(pool->pool_priv, &pool_name) == UMF_RESULT_SUCCESS &&
494-
pool_name) {
495-
utils_warn_invalid_name("Memory pool", pool_name);
496-
}
497-
498491
LOG_INFO("Memory pool created: %p", (void *)pool);
499492
return UMF_RESULT_SUCCESS;
500493

src/memory_provider.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -345,10 +345,20 @@ umf_result_t umfMemoryProviderCreate(const umf_memory_provider_ops_t *ops,
345345

346346
utils_init_once(&mem_provider_ctl_initialized, provider_ctl_init);
347347
const char *pname = NULL;
348-
if (provider->ops.get_name(NULL, &pname) == UMF_RESULT_SUCCESS && pname) {
349-
ctl_default_apply(provider_default_list, pname, provider->ops.ext_ctl,
350-
provider->provider_priv);
348+
349+
ret = provider->ops.get_name(provider->provider_priv, &pname);
350+
if (ret != UMF_RESULT_SUCCESS) {
351+
LOG_ERR("Failed to get pool name");
352+
umf_ba_global_free(provider);
353+
return ret;
351354
}
355+
356+
assert(pname != NULL);
357+
utils_warn_invalid_name("Memory provider", pname);
358+
359+
ctl_default_apply(provider_default_list, pname, provider->ops.ext_ctl,
360+
provider->provider_priv);
361+
352362
ret = umfProviderPostInitialize(&provider->ops, provider_priv);
353363
if (ret != UMF_RESULT_SUCCESS && ret != UMF_RESULT_ERROR_INVALID_CTL_PATH) {
354364
LOG_ERR("Failed to post-initialize provider");
@@ -358,13 +368,6 @@ umf_result_t umfMemoryProviderCreate(const umf_memory_provider_ops_t *ops,
358368

359369
*hProvider = provider;
360370

361-
const char *provider_name = NULL;
362-
if (provider->ops.get_name(provider->provider_priv, &provider_name) ==
363-
UMF_RESULT_SUCCESS &&
364-
provider_name) {
365-
utils_warn_invalid_name("Memory provider", provider_name);
366-
}
367-
368371
return UMF_RESULT_SUCCESS;
369372
}
370373

0 commit comments

Comments
 (0)