From: Ivan Maidanski Date: Wed, 1 Feb 2012 19:21:00 +0000 (+0400) Subject: Tag auxiliary malloc-like API functions with 'malloc' attribute X-Git-Tag: gc7_3alpha2~143 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1883e72a86a13fbfa533fede69072aa85cbaed94;p=gc Tag auxiliary malloc-like API functions with 'malloc' attribute * include/gc.h (GC_malloc_many): Add GC_ATTR_MALLOC attribute. * include/gc_mark.h (GC_generic_malloc): Likewise. * include/gc_typed.h (GC_calloc_explicitly_typed): Likewise. * include/gc_disclaim.h (GC_finalized_malloc): Add GC_ATTR_MALLOC and GC_ATTR_ALLOC_SIZE attributes. * include/gc_typed.h (GC_malloc_explicitly_typed, GC_malloc_explicitly_typed_ignore_off_page): Likewise. --- diff --git a/include/gc.h b/include/gc.h index 56024c85..18491571 100644 --- a/include/gc.h +++ b/include/gc.h @@ -1291,7 +1291,7 @@ GC_API void (GC_CALLBACK * GC_is_visible_print_proc)(void *); /* This returns a list of objects, linked through their first word. */ /* Its use can greatly reduce lock contention problems, since the */ /* allocation lock can be acquired and released many fewer times. */ -GC_API void * GC_CALL GC_malloc_many(size_t /* lb */); +GC_API GC_ATTR_MALLOC void * GC_CALL GC_malloc_many(size_t /* lb */); #define GC_NEXT(p) (*(void * *)(p)) /* Retrieve the next element */ /* in returned list. */ diff --git a/include/gc_disclaim.h b/include/gc_disclaim.h index beb1bc12..3631e6e8 100644 --- a/include/gc_disclaim.h +++ b/include/gc_disclaim.h @@ -48,7 +48,8 @@ struct GC_finalizer_closure { /* dedicated object kind with a disclaim procedure, and is more */ /* efficient than GC_register_finalizer and friends. */ /* GC_init_finalized_malloc must be called before using this. */ -GC_API void *GC_CALL GC_finalized_malloc(size_t /*size*/, - const struct GC_finalizer_closure * /*fc*/); +GC_API GC_ATTR_MALLOC GC_ATTR_ALLOC_SIZE(1) void * GC_CALL + GC_finalized_malloc(size_t /*size*/, + const struct GC_finalizer_closure * /*fc*/); #endif diff --git a/include/gc_mark.h b/include/gc_mark.h index e8d7ece4..71bf2859 100644 --- a/include/gc_mark.h +++ b/include/gc_mark.h @@ -184,7 +184,8 @@ GC_API unsigned GC_CALL GC_new_proc_inner(GC_mark_proc); /* the descriptor is not correct. Even in the single-threaded case, */ /* we need to be sure that cleared objects on a free list don't */ /* cause a GC crash if they are accidentally traced. */ -GC_API void * GC_CALL GC_generic_malloc(size_t /* lb */, int /* k */); +GC_API GC_ATTR_MALLOC void * GC_CALL + GC_generic_malloc(size_t /* lb */, int /* k */); typedef void (GC_CALLBACK * GC_describe_type_fn)(void * /* p */, char * /* out_buf */); diff --git a/include/gc_typed.h b/include/gc_typed.h index 0eeb2538..8261cd7b 100644 --- a/include/gc_typed.h +++ b/include/gc_typed.h @@ -12,6 +12,7 @@ * provided the above notices are retained, and a notice that the code was * modified is included with the above copyright notice. */ + /* * Some simple primitives for allocation with explicit type information. * Facilities for dynamic type inference may be added later. @@ -76,19 +77,21 @@ GC_API GC_descr GC_CALL GC_make_descriptor(const GC_word * /* GC_bitmap bm */, /* ... */ /* T_descr = GC_make_descriptor(T_bitmap, GC_WORD_LEN(T)); */ -GC_API void * GC_CALL GC_malloc_explicitly_typed(size_t /* size_in_bytes */, - GC_descr /* d */); +GC_API GC_ATTR_MALLOC GC_ATTR_ALLOC_SIZE(1) void * GC_CALL + GC_malloc_explicitly_typed(size_t /* size_in_bytes */, + GC_descr /* d */); /* Allocate an object whose layout is described by d. */ /* The resulting object MAY NOT BE PASSED TO REALLOC. */ /* The returned object is cleared. */ -GC_API void * GC_CALL GC_malloc_explicitly_typed_ignore_off_page( - size_t /* size_in_bytes */, - GC_descr /* d */); +GC_API GC_ATTR_MALLOC GC_ATTR_ALLOC_SIZE(1) void * GC_CALL + GC_malloc_explicitly_typed_ignore_off_page(size_t /* size_in_bytes */, + GC_descr /* d */); -GC_API void * GC_CALL GC_calloc_explicitly_typed(size_t /* nelements */, - size_t /* element_size_in_bytes */, - GC_descr /* d */); +GC_API GC_ATTR_MALLOC void * GC_CALL + GC_calloc_explicitly_typed(size_t /* nelements */, + size_t /* element_size_in_bytes */, + GC_descr /* d */); /* Allocate an array of nelements elements, each of the */ /* given size, and with the given descriptor. */ /* The element size must be a multiple of the byte */