@@ -233,8 +233,11 @@ typedef struct pmix_tma {
233
233
void * (* tma_memmove )(struct pmix_tma * tma , const void * src , size_t n );
234
234
/** Pointer to the TMA's free() function. */
235
235
void (* tma_free )(struct pmix_tma * , void * );
236
- /** Pointer inside the memory allocation arena. */
237
- void * arena ;
236
+ /**
237
+ * Points to generic data used by a TMA. An example includes a pointer to a
238
+ * value that maintains the next available address.
239
+ */
240
+ void * * data_ptr ;
238
241
} pmix_tma_t ;
239
242
240
243
static inline void * pmix_tma_malloc (pmix_tma_t * tma , size_t size )
@@ -322,7 +325,7 @@ PMIX_EXPORT extern int pmix_class_init_epoch;
322
325
.obj_tma.tma_strdup = NULL, \
323
326
.obj_tma.tma_memmove = NULL, \
324
327
.obj_tma.tma_free = NULL, \
325
- .obj_tma.arena = NULL, \
328
+ .obj_tma.data_ptr = NULL, \
326
329
.cls_init_file_name = __FILE__, \
327
330
.cls_init_lineno = __LINE__ \
328
331
}
@@ -338,7 +341,7 @@ PMIX_EXPORT extern int pmix_class_init_epoch;
338
341
.obj_tma.tma_strdup = NULL, \
339
342
.obj_tma.tma_memmove = NULL, \
340
343
.obj_tma.tma_free = NULL, \
341
- .obj_tma.arena = NULL \
344
+ .obj_tma.data_ptr = NULL \
342
345
}
343
346
#endif
344
347
@@ -542,7 +545,7 @@ static inline void pmix_obj_construct_tma(pmix_object_t *obj, pmix_tma_t *tma)
542
545
obj -> obj_tma .tma_strdup = NULL ;
543
546
obj -> obj_tma .tma_memmove = NULL ;
544
547
obj -> obj_tma .tma_free = NULL ;
545
- obj -> obj_tma .arena = NULL ;
548
+ obj -> obj_tma .data_ptr = NULL ;
546
549
} else {
547
550
obj -> obj_tma = * tma ;
548
551
}
@@ -552,7 +555,7 @@ static inline void pmix_obj_construct_tma(pmix_object_t *obj, pmix_tma_t *tma)
552
555
do { \
553
556
PMIX_SET_MAGIC_ID((object), PMIX_OBJ_MAGIC_ID); \
554
557
if (pmix_class_init_epoch != (type)->cls_initialized) { \
555
- pmix_class_initialize((type), (t)); \
558
+ pmix_class_initialize((type)); \
556
559
} \
557
560
((pmix_object_t *) (object))->obj_class = (type); \
558
561
((pmix_object_t *) (object))->obj_reference_count = 1; \
@@ -609,7 +612,7 @@ PMIX_CLASS_DECLARATION(pmix_object_t);
609
612
*
610
613
* @param class Pointer to class descriptor
611
614
*/
612
- PMIX_EXPORT void pmix_class_initialize (pmix_class_t * cls , pmix_tma_t * tma );
615
+ PMIX_EXPORT void pmix_class_initialize (pmix_class_t * cls );
613
616
614
617
/**
615
618
* Shut down the class system and release all memory
@@ -686,7 +689,7 @@ static inline pmix_object_t *pmix_obj_new_tma(pmix_class_t *cls, pmix_tma_t *tma
686
689
object = (pmix_object_t * ) pmix_tma_malloc (tma , cls -> cls_sizeof );
687
690
688
691
if (pmix_class_init_epoch != cls -> cls_initialized ) {
689
- pmix_class_initialize (cls , tma );
692
+ pmix_class_initialize (cls );
690
693
}
691
694
if (NULL != object ) {
692
695
#if PMIX_ENABLE_DEBUG
@@ -717,7 +720,7 @@ static inline pmix_object_t *pmix_obj_new_tma(pmix_class_t *cls, pmix_tma_t *tma
717
720
object -> obj_tma .tma_realloc = NULL ;
718
721
object -> obj_tma .tma_strdup = NULL ;
719
722
object -> obj_tma .tma_free = NULL ;
720
- object -> obj_tma .arena = NULL ;
723
+ object -> obj_tma .data_ptr = NULL ;
721
724
} else {
722
725
object -> obj_tma = * tma ;
723
726
}
@@ -750,6 +753,22 @@ static inline int pmix_obj_update(pmix_object_t *object, int inc)
750
753
return ret ;
751
754
}
752
755
756
+ /**
757
+ * Get a pointer to a given object's memory allocator. Returns a pointer to the
758
+ * TMA, if available. Returns NULL Otherwise.
759
+ */
760
+ static inline pmix_tma_t *
761
+ pmix_obj_get_tma (
762
+ pmix_object_t * obj
763
+ ) {
764
+ // Look for a given function pointer. If it isn't NULL, then assume that
765
+ // this object has a custom memory allocator.
766
+ if (obj -> obj_tma .tma_malloc ) {
767
+ return & obj -> obj_tma ;
768
+ }
769
+ return NULL ;
770
+ }
771
+
753
772
END_C_DECLS
754
773
755
774
#endif
0 commit comments