mirror of
				https://github.com/GrapheneOS/hardened_malloc.git
				synced 2025-10-26 14:16:33 +01:00 
			
		
		
		
	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-align
This commit is contained in:
		
							parent
							
								
									36dfed3354
								
							
						
					
					
						commit
						78cbb964d4
					
				
					 1 changed files with 7 additions and 3 deletions
				
			
		|  | @ -48,9 +48,11 @@ extern "C" { | |||
| #endif | ||||
| 
 | ||||
| // C standard
 | ||||
| void *h_malloc(size_t size); | ||||
| void *h_calloc(size_t nmemb, size_t size); | ||||
| void *h_realloc(void *ptr, size_t size); | ||||
| __attribute__((alloc_size(1))) void *h_malloc(size_t size); | ||||
| __attribute__((alloc_size(1, 2))) void *h_calloc(size_t nmemb, 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_free(void *ptr); | ||||
| 
 | ||||
|  | @ -76,6 +78,8 @@ int h_malloc_info(int options, FILE *fp); | |||
| #endif | ||||
| 
 | ||||
| // obsolete glibc extensions
 | ||||
| __attribute__((alloc_align(1))) | ||||
| __attribute__((alloc_size(2))) | ||||
| void *h_memalign(size_t alignment, size_t size); | ||||
| #ifndef __ANDROID__ | ||||
| void *h_valloc(size_t size); | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue