Преглед изворни кода

malloc attribute changes

tags/v0.9.3
Holger Lubitz пре 17 година
родитељ
комит
373022108b
3 измењених фајлова са 10 додато и 2 уклоњено
  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 Прегледај датотеку

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

+ 4
- 0
src/core/malloc.c Прегледај датотеку

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

+ 4
- 2
src/crypto/cryptoLayer.h Прегледај датотеку

@@ -31,12 +31,14 @@ typedef void psPool_t;
31 31
 
32 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 36
 psMalloc ( psPool_t *pool __unused, size_t len ) {
36 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 42
 psRealloc ( void *ptr, size_t len ) {
41 43
 	return realloc ( ptr, len );
42 44
 }

Loading…
Откажи
Сачувај