-
Notifications
You must be signed in to change notification settings - Fork 37
Split initialize function and add post-initialize phase #1467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
54df467
to
40c6dfc
Compare
Split between initialize and post-initialize function is necessary for properly handling CTL defaults.
40c6dfc
to
1f76309
Compare
/// @param provider memory provider that will be used for coarse-grain allocations. | ||
/// Should contain at least one memory provider. | ||
/// @param numProvider number of elements in the providers array | ||
/// @param params pool-specific params, or NULL for defaults | ||
/// @param pool [out] returns pointer to the pool | ||
/// @return UMF_RESULT_SUCCESS on success or appropriate error code on failure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Write better documentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -250,6 +276,16 @@ umf_result_t umfMemoryProviderCreate(const umf_memory_provider_ops_t *ops, | |||
|
|||
provider->provider_priv = provider_priv; | |||
|
|||
if (provider->ops.ext_post_initialize != NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this if is not needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
src/pool/pool_disjoint.c
Outdated
static umf_result_t CTL_READ_HANDLER(name)(void *ctx, | ||
umf_ctl_query_source_t source, | ||
void *arg, size_t size, | ||
umf_ctl_index_utlist_t *indexes) { | ||
static umf_result_t CTL_READ_HANDLER(name)(void* ctx, | ||
umf_ctl_query_source_t source, | ||
void* arg, size_t size, | ||
umf_ctl_index_utlist_t* indexes) { | ||
(void)source, (void)indexes; | ||
|
||
disjoint_pool_t *pool = (disjoint_pool_t *)ctx; | ||
disjoint_pool_t* pool = (disjoint_pool_t*)ctx; | ||
|
||
if (arg == NULL) { | ||
return UMF_RESULT_ERROR_INVALID_ARGUMENT; | ||
} | ||
|
||
if (size > 0) { | ||
strncpy((char *)arg, pool->params.name, size - 1); | ||
((char *)arg)[size - 1] = '\0'; | ||
strncpy((char*)arg, pool->params.name, size - 1); | ||
((char*)arg)[size - 1] = '\0'; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wtf?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected. Funny fact is that this is ignored by code check, I suppose that #if 0
is here a perpetrator.
src/pool/pool_disjoint.c
Outdated
(void)source, (void)indexes, (void)size; | ||
disjoint_pool_t *pool = (disjoint_pool_t *)ctx; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dito
@@ -261,7 +276,16 @@ static umf_result_t umfPoolCreateInternal(const umf_memory_pool_ops_t *ops, | |||
} | |||
} | |||
|
|||
if (ops->ext_post_initialize != NULL) { | |||
ret = ops->ext_post_initialize(pool->provider, params, pool->pool_priv); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
document what happens if post initialize fails. Who is responsible for clearing things initialized in initialize bunction
|
||
err_free_disjoint_pool: | ||
umf_ba_global_free(disjoint_pool); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it memleak? Who is respoinsible for this free?
@@ -161,7 +161,7 @@ TEST_F(test, jemallocPoolParams) { | |||
EXPECT_EQ(ret, UMF_RESULT_SUCCESS); | |||
} | |||
|
|||
TEST_F(test, jemallocPoolParamsInvalid) { | |||
TEST_F(test, jemallocPoolParamsInvalid) { // TODO FIX THIS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
????
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Description
Checklist