@@ -219,6 +219,11 @@ static umf_result_t umfDefaultTrimMemory(void *provider,
219219 return UMF_RESULT_ERROR_NOT_SUPPORTED ;
220220}
221221
222+ static umf_result_t umfDefaultExtPostInitialize (void * pool ) {
223+ (void )pool ;
224+ return UMF_RESULT_SUCCESS ;
225+ }
226+
222227// logical sum (OR) of all umf_pool_create_flags_t flags
223228static const umf_pool_create_flags_t UMF_POOL_CREATE_FLAG_ALL =
224229 UMF_POOL_CREATE_FLAG_OWN_PROVIDER | UMF_POOL_CREATE_FLAG_DISABLE_TRACKING ;
@@ -251,7 +256,6 @@ static umf_result_t umfPoolCreateInternal(const umf_memory_pool_ops_t *ops,
251256 }
252257
253258 umf_result_t ret = UMF_RESULT_SUCCESS ;
254-
255259 umf_memory_pool_ops_t compatible_ops ;
256260 if (ops -> version != UMF_POOL_OPS_VERSION_CURRENT ) {
257261 LOG_WARN ("Memory Pool ops version \"%d\" is different than the current "
@@ -260,8 +264,8 @@ static umf_result_t umfPoolCreateInternal(const umf_memory_pool_ops_t *ops,
260264
261265 // Create a new ops compatible structure with the current version
262266 memset (& compatible_ops , 0 , sizeof (compatible_ops ));
263- if (UMF_MINOR_VERSION ( ops -> version ) == 0 ) {
264- LOG_INFO ("Detected 1.0 version of Memory Pool ops, "
267+ if (UMF_VERSION_BELOW ( 1 , 1 ) ) {
268+ LOG_INFO ("Detected 1.0 version or below of Memory Pool ops, "
265269 "upgrading to current version" );
266270 memcpy (& compatible_ops , ops ,
267271 offsetof(umf_memory_pool_ops_t , ext_trim_memory ));
@@ -303,13 +307,17 @@ static umf_result_t umfPoolCreateInternal(const umf_memory_pool_ops_t *ops,
303307 pool -> ops .ext_trim_memory = umfDefaultTrimMemory ;
304308 }
305309
310+ if (NULL == pool -> ops .ext_post_initialize ) {
311+ pool -> ops .ext_post_initialize = umfDefaultExtPostInitialize ;
312+ }
313+
306314 if (NULL == utils_mutex_init (& pool -> lock )) {
307315 LOG_ERR ("Failed to initialize mutex for pool" );
308316 ret = UMF_RESULT_ERROR_UNKNOWN ;
309317 goto err_lock_init ;
310318 }
311319
312- ret = ops -> initialize (pool -> provider , params , & pool -> pool_priv );
320+ ret = pool -> ops . initialize (pool -> provider , params , & pool -> pool_priv );
313321 if (ret != UMF_RESULT_SUCCESS ) {
314322 goto err_pool_init ;
315323 }
@@ -335,7 +343,14 @@ static umf_result_t umfPoolCreateInternal(const umf_memory_pool_ops_t *ops,
335343 }
336344 }
337345
346+ ret = pool -> ops .ext_post_initialize (pool -> pool_priv );
347+ if (ret != UMF_RESULT_SUCCESS ) {
348+ LOG_ERR ("Failed to post-initialize pool" );
349+ goto err_pool_init ;
350+ }
351+
338352 * hPool = pool ;
353+
339354 LOG_INFO ("Memory pool created: %p" , (void * )pool );
340355 return UMF_RESULT_SUCCESS ;
341356
0 commit comments