Changeset aab4664d in rtems for cpukit/libcsupport/src/malloc.c
- Timestamp:
- 10/22/03 16:53:55 (19 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- a51735c
- Parents:
- 08c09e24
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpukit/libcsupport/src/malloc.c
r08c09e24 raab4664d 34 34 #include <unistd.h> /* sbrk(2) */ 35 35 36 #include <chain.h> 37 38 Chain_Control RTEMS_Malloc_GC_list; 39 36 40 rtems_id RTEMS_Malloc_Heap; 37 41 size_t RTEMS_Malloc_Sbrk_amount; … … 72 76 73 77 /* 78 * Initialize the garbage collection list to start with nothing on it. 79 */ 80 Chain_Initialize_empty(&RTEMS_Malloc_GC_list); 81 82 /* 74 83 * If the starting address is 0 then we are to attempt to 75 84 * get length worth of memory using sbrk. Make sure we … … 151 160 rtems_unsigned32 sbrk_amount; 152 161 rtems_status_code status; 162 Chain_Node *to_be_freed; 153 163 154 164 MSBUMP(malloc_calls, 1); … … 156 166 if ( !size ) 157 167 return (void *) 0; 168 169 /* 170 * Do not attempt to allocate memory if in a critical section or ISR. 171 */ 172 173 if (_Thread_Dispatch_disable_level > 0) 174 return (void *) 0; 175 176 if (_ISR_Nest_level > 0) 177 return (void *) 0; 178 179 /* 180 * If some free's have been deferred, then do them now. 181 */ 182 while ((to_be_freed = Chain_Get(&RTEMS_Malloc_GC_list)) != NULL) 183 free(to_be_freed); 158 184 159 185 /* … … 268 294 MSBUMP(realloc_calls, 1); 269 295 296 /* 297 * Do not attempt to allocate memory if in a critical section or ISR. 298 */ 299 300 if (_Thread_Dispatch_disable_level > 0) 301 return (void *) 0; 302 303 if (_ISR_Nest_level > 0) 304 return (void *) 0; 305 306 /* 307 * Continue with calloc(). 308 */ 270 309 if ( !ptr ) 271 310 return malloc( size ); … … 314 353 return; 315 354 355 /* 356 * Do not attempt to free memory if in a critical section or ISR. 357 */ 358 359 if ((_Thread_Dispatch_disable_level > 0) || (_ISR_Nest_level > 0)) { 360 Chain_Append(&RTEMS_Malloc_GC_list, (Chain_Node *)ptr); 361 return; 362 } 363 316 364 #ifdef MALLOC_STATS 317 365 {
Note: See TracChangeset
for help on using the changeset viewer.