mirror of
				https://github.com/GrapheneOS/hardened_malloc.git
				synced 2025-11-03 01:06: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
							
								
									3696f071a4
								
							
						
					
					
						commit
						b7f1bb99c9
					
				
					 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