1010#include <assert.h>
1111#include <stdint.h>
1212#include <string.h>
13+ #include <stdarg.h>
1314
1415#include <umf/base.h>
1516#include <umf/memory_pool.h>
@@ -372,6 +373,20 @@ static umf_result_t umfDefaultTrimMemory(void *provider,
372373 return UMF_RESULT_ERROR_NOT_SUPPORTED ;
373374}
374375
376+ static umf_result_t umfPoolPostInitialize (const umf_memory_pool_ops_t * ops ,
377+ void * pool_priv , ...) {
378+ va_list args ;
379+ va_start (args , pool_priv );
380+ umf_result_t ret = ops -> ext_ctl (pool_priv , CTL_QUERY_PROGRAMMATIC ,
381+ "post_initialize" , NULL , 0 ,
382+ CTL_QUERY_RUNNABLE , args );
383+ va_end (args );
384+ if (ret == UMF_RESULT_ERROR_INVALID_ARGUMENT ) {
385+ ret = UMF_RESULT_ERROR_NOT_SUPPORTED ;
386+ }
387+ return ret ;
388+ }
389+
375390// logical sum (OR) of all umf_pool_create_flags_t flags
376391static const umf_pool_create_flags_t UMF_POOL_CREATE_FLAG_ALL =
377392 UMF_POOL_CREATE_FLAG_OWN_PROVIDER | UMF_POOL_CREATE_FLAG_DISABLE_TRACKING ;
@@ -393,7 +408,6 @@ static umf_result_t umfPoolCreateInternal(const umf_memory_pool_ops_t *ops,
393408 }
394409
395410 umf_result_t ret = UMF_RESULT_SUCCESS ;
396-
397411 umf_memory_pool_ops_t compatible_ops ;
398412 if (ops -> version != UMF_POOL_OPS_VERSION_CURRENT ) {
399413 LOG_WARN ("Memory Pool ops version \"%d\" is different than the current "
@@ -402,8 +416,8 @@ static umf_result_t umfPoolCreateInternal(const umf_memory_pool_ops_t *ops,
402416
403417 // Create a new ops compatible structure with the current version
404418 memset (& compatible_ops , 0 , sizeof (compatible_ops ));
405- if (UMF_MINOR_VERSION ( ops -> version ) == 0 ) {
406- LOG_INFO ("Detected 1.0 version of Memory Pool ops, "
419+ if (ops -> version < UMF_MAKE_VERSION ( 1 , 1 ) ) {
420+ LOG_INFO ("Detected 1.0 version or below of Memory Pool ops, "
407421 "upgrading to current version" );
408422 memcpy (& compatible_ops , ops ,
409423 offsetof(umf_memory_pool_ops_t , ext_trim_memory ));
@@ -451,7 +465,7 @@ static umf_result_t umfPoolCreateInternal(const umf_memory_pool_ops_t *ops,
451465 goto err_lock_init ;
452466 }
453467
454- ret = ops -> initialize (pool -> provider , params , & pool -> pool_priv );
468+ ret = pool -> ops . initialize (pool -> provider , params , & pool -> pool_priv );
455469 if (ret != UMF_RESULT_SUCCESS ) {
456470 goto err_pool_init ;
457471 }
@@ -467,6 +481,12 @@ static umf_result_t umfPoolCreateInternal(const umf_memory_pool_ops_t *ops,
467481
468482 ctl_default_apply (pool_default_list , pname , ops -> ext_ctl , pool -> pool_priv );
469483
484+ ret = umfPoolPostInitialize (ops , pool -> pool_priv );
485+ if (ret != UMF_RESULT_SUCCESS && ret != UMF_RESULT_ERROR_NOT_SUPPORTED ) {
486+ LOG_ERR ("Failed to post-initialize pool" );
487+ goto err_pool_init ;
488+ }
489+
470490 * hPool = pool ;
471491 pools_by_name_add (pool );
472492
0 commit comments