Add alloc_size and alloc_align attributes
This should help a bit the compiler to emit better diagnostics and to improve the correctness of `__builtin_object_size`. See https://clang.llvm.org/docs/AttributeReference.html#alloc-size and https://clang.llvm.org/docs/AttributeReference.html#alloc-alignpull/181/head
parent
36dfed3354
commit
78cbb964d4
|
@ -48,9 +48,11 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// C standard
|
// C standard
|
||||||
void *h_malloc(size_t size);
|
__attribute__((alloc_size(1))) void *h_malloc(size_t size);
|
||||||
void *h_calloc(size_t nmemb, size_t size);
|
__attribute__((alloc_size(1, 2))) void *h_calloc(size_t nmemb, size_t size);
|
||||||
void *h_realloc(void *ptr, size_t size);
|
__attribute__((alloc_size(2))) void *h_realloc(void *ptr, size_t size);
|
||||||
|
__attribute__((alloc_align(1)))
|
||||||
|
__attribute__((alloc_size(2)))
|
||||||
void *h_aligned_alloc(size_t alignment, size_t size);
|
void *h_aligned_alloc(size_t alignment, size_t size);
|
||||||
void h_free(void *ptr);
|
void h_free(void *ptr);
|
||||||
|
|
||||||
|
@ -76,6 +78,8 @@ int h_malloc_info(int options, FILE *fp);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// obsolete glibc extensions
|
// obsolete glibc extensions
|
||||||
|
__attribute__((alloc_align(1)))
|
||||||
|
__attribute__((alloc_size(2)))
|
||||||
void *h_memalign(size_t alignment, size_t size);
|
void *h_memalign(size_t alignment, size_t size);
|
||||||
#ifndef __ANDROID__
|
#ifndef __ANDROID__
|
||||||
void *h_valloc(size_t size);
|
void *h_valloc(size_t size);
|
||||||
|
|
Loading…
Reference in New Issue