Browse Source

malloc attribute changes

tags/v0.9.3
Holger Lubitz 17 years ago
parent
commit
373022108b
3 changed files with 10 additions and 2 deletions
  1. 2
    0
      src/arch/i386/core/umalloc.c
  2. 4
    0
      src/core/malloc.c
  3. 4
    2
      src/crypto/cryptoLayer.h

+ 2
- 0
src/arch/i386/core/umalloc.c View File

135
  * Calling realloc() with a new size of zero is a valid way to free a
135
  * Calling realloc() with a new size of zero is a valid way to free a
136
  * memory block.
136
  * memory block.
137
  */
137
  */
138
+__attribute__ ((malloc))
138
 userptr_t urealloc ( userptr_t ptr, size_t new_size ) {
139
 userptr_t urealloc ( userptr_t ptr, size_t new_size ) {
139
 	struct external_memory extmem;
140
 	struct external_memory extmem;
140
 	userptr_t new = ptr;
141
 	userptr_t new = ptr;
208
  *
209
  *
209
  * Memory is guaranteed to be aligned to a page boundary.
210
  * Memory is guaranteed to be aligned to a page boundary.
210
  */
211
  */
212
+__attribute__ ((malloc))
211
 userptr_t umalloc ( size_t size ) {
213
 userptr_t umalloc ( size_t size ) {
212
 	return urealloc ( UNULL, size );
214
 	return urealloc ( UNULL, size );
213
 }
215
 }

+ 4
- 0
src/core/malloc.c View File

95
  *
95
  *
96
  * @c align must be a power of two.  @c size may not be zero.
96
  * @c align must be a power of two.  @c size may not be zero.
97
  */
97
  */
98
+__attribute__ ((malloc))
98
 void * alloc_memblock ( size_t size, size_t align ) {
99
 void * alloc_memblock ( size_t size, size_t align ) {
99
 	struct memory_block *block;
100
 	struct memory_block *block;
100
 	size_t align_mask;
101
 	size_t align_mask;
248
  * Calling realloc() with a new size of zero is a valid way to free a
249
  * Calling realloc() with a new size of zero is a valid way to free a
249
  * memory block.
250
  * memory block.
250
  */
251
  */
252
+__attribute__ ((malloc))
251
 void * realloc ( void *old_ptr, size_t new_size ) {
253
 void * realloc ( void *old_ptr, size_t new_size ) {
252
 	struct autosized_block *old_block;
254
 	struct autosized_block *old_block;
253
 	struct autosized_block *new_block;
255
 	struct autosized_block *new_block;
297
  * Allocates memory with no particular alignment requirement.  @c ptr
299
  * Allocates memory with no particular alignment requirement.  @c ptr
298
  * will be aligned to at least a multiple of sizeof(void*).
300
  * will be aligned to at least a multiple of sizeof(void*).
299
  */
301
  */
302
+__attribute__ ((malloc))
300
 void * malloc ( size_t size ) {
303
 void * malloc ( size_t size ) {
301
 	return realloc ( NULL, size );
304
 	return realloc ( NULL, size );
302
 }
305
 }
326
  * This function name is non-standard, but pretty intuitive.
329
  * This function name is non-standard, but pretty intuitive.
327
  * zalloc(size) is always equivalent to calloc(1,size)
330
  * zalloc(size) is always equivalent to calloc(1,size)
328
  */
331
  */
332
+__attribute__ ((malloc))
329
 void * zalloc ( size_t size ) {
333
 void * zalloc ( size_t size ) {
330
 	void *data;
334
 	void *data;
331
 
335
 

+ 4
- 2
src/crypto/cryptoLayer.h View File

31
 
31
 
32
 #define sslAssert( ... ) assert ( __VA_ARGS__ )
32
 #define sslAssert( ... ) assert ( __VA_ARGS__ )
33
 
33
 
34
-static inline __attribute__ (( always_inline )) void *
34
+static inline __attribute__ (( always_inline )) __attribute__ ((malloc))
35
+void *
35
 psMalloc ( psPool_t *pool __unused, size_t len ) {
36
 psMalloc ( psPool_t *pool __unused, size_t len ) {
36
 	return malloc ( len );
37
 	return malloc ( len );
37
 }
38
 }
38
 
39
 
39
-static inline __attribute__ (( always_inline )) void *
40
+static inline __attribute__ (( always_inline )) __attribute__ ((malloc))
41
+void *
40
 psRealloc ( void *ptr, size_t len ) {
42
 psRealloc ( void *ptr, size_t len ) {
41
 	return realloc ( ptr, len );
43
 	return realloc ( ptr, len );
42
 }
44
 }

Loading…
Cancel
Save