10
10
#include <assert.h>
11
11
#include <stdint.h>
12
12
#include <string.h>
13
+ #include <stdarg.h>
13
14
14
15
#include <umf/base.h>
15
16
#include <umf/memory_pool.h>
@@ -372,6 +373,20 @@ static umf_result_t umfDefaultTrimMemory(void *provider,
372
373
return UMF_RESULT_ERROR_NOT_SUPPORTED ;
373
374
}
374
375
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
+
375
390
// logical sum (OR) of all umf_pool_create_flags_t flags
376
391
static const umf_pool_create_flags_t UMF_POOL_CREATE_FLAG_ALL =
377
392
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,
393
408
}
394
409
395
410
umf_result_t ret = UMF_RESULT_SUCCESS ;
396
-
397
411
umf_memory_pool_ops_t compatible_ops ;
398
412
if (ops -> version != UMF_POOL_OPS_VERSION_CURRENT ) {
399
413
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,
402
416
403
417
// Create a new ops compatible structure with the current version
404
418
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, "
407
421
"upgrading to current version" );
408
422
memcpy (& compatible_ops , ops ,
409
423
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,
451
465
goto err_lock_init ;
452
466
}
453
467
454
- ret = ops -> initialize (pool -> provider , params , & pool -> pool_priv );
468
+ ret = pool -> ops . initialize (pool -> provider , params , & pool -> pool_priv );
455
469
if (ret != UMF_RESULT_SUCCESS ) {
456
470
goto err_pool_init ;
457
471
}
@@ -467,6 +481,12 @@ static umf_result_t umfPoolCreateInternal(const umf_memory_pool_ops_t *ops,
467
481
468
482
ctl_default_apply (pool_default_list , pname , ops -> ext_ctl , pool -> pool_priv );
469
483
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
+
470
490
* hPool = pool ;
471
491
pools_by_name_add (pool );
472
492
0 commit comments