diff options
Diffstat (limited to 'include/gc')
-rw-r--r-- | include/gc/gc_typed.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/include/gc/gc_typed.h b/include/gc/gc_typed.h index 1de355fe..a9a82931 100644 --- a/include/gc/gc_typed.h +++ b/include/gc/gc_typed.h @@ -104,6 +104,37 @@ GC_API GC_ATTR_MALLOC GC_ATTR_CALLOC_SIZE(1, 2) void * GC_CALL /* bitmap of d multiplied by sizeof GC_word. */ /* Returned object is cleared. */ +#define GC_CALLOC_TYPED_DESCR_WORDS 8 + +#ifdef GC_BUILD + struct GC_calloc_typed_descr_s; +#else + struct GC_calloc_typed_descr_s { + GC_word opaque[GC_CALLOC_TYPED_DESCR_WORDS]; + }; +#endif + +GC_API int GC_CALL GC_calloc_prepare_explicitly_typed( + struct GC_calloc_typed_descr_s * /* pctd */, + size_t /* sizeof_ctd */, size_t /* nelements */, + size_t /* element_size_in_bytes */, GC_descr); + /* This is same as GC_calloc_explicitly_typed but more optimal */ + /* in terms of the performance and memory usage if the client */ + /* needs to allocate multiple typed object arrays with the */ + /* same layout and number of elements. The client should call */ + /* it to be prepared for the subsequent allocations by */ + /* GC_calloc_do_explicitly_typed, one or many. The result of */ + /* the preparation is stored to *pctd, even in case of */ + /* a failure. The prepared structure could be just dropped */ + /* when no longer needed. Returns 0 on failure, 1 on success; */ + /* the result could be ignored (as it is also stored to *pctd */ + /* and checked later by GC_calloc_do_explicitly_typed). */ + +GC_API GC_ATTR_MALLOC void * GC_CALL GC_calloc_do_explicitly_typed( + const struct GC_calloc_typed_descr_s * /* pctd */, + size_t /* sizeof_ctd */); + /* The actual object allocation for the prepared description. */ + #ifdef GC_DEBUG # define GC_MALLOC_EXPLICITLY_TYPED(bytes, d) ((void)(d), GC_MALLOC(bytes)) # define GC_MALLOC_EXPLICITLY_TYPED_IGNORE_OFF_PAGE(bytes, d) \ |