Changes in libcfa/src/heap.cfa [7b149bc:7117ac3]
- File:
-
- 1 edited
-
libcfa/src/heap.cfa (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/heap.cfa
r7b149bc r7117ac3 10 10 // Created On : Tue Dec 19 21:58:35 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu May 9 16:29:12 201913 // Update Count : 51 612 // Last Modified On : Thu Sep 6 09:01:30 2018 13 // Update Count : 513 14 14 // 15 15 … … 220 220 StackLF<Storage> freeList; 221 221 #else 222 #error undefined lock type for bucket lock222 #error undefined lock type for bucket lock 223 223 #endif // SPINLOCK 224 224 size_t blockSize; // size of allocations on this list … … 234 234 }; // HeapManager 235 235 236 237 236 static inline size_t getKey( const HeapManager.FreeHeader & freeheader ) { return freeheader.blockSize; } 238 239 237 // statically allocated variables => zero filled. 238 239 240 240 static size_t pageSize; // architecture pagesize 241 241 static size_t heapExpand; // sbrk advance … … 306 306 sbrk( (char *)libCeiling( (long unsigned int)End, libAlign() ) - End ); // move start of heap to multiple of alignment 307 307 heapBegin = heapEnd = sbrk( 0 ); // get new start point 308 } // HeapManager308 } // HeapManager 309 309 310 310 … … 316 316 // } // if 317 317 #endif // __STATISTICS__ 318 } // ~HeapManager318 } // ~HeapManager 319 319 320 320 … … 533 533 534 534 static inline void * doMalloc( size_t size ) with ( heapManager ) { 535 HeapManager.Storage * block; // pointer to new block of storage535 HeapManager.Storage * block; 536 536 537 537 // Look up size in the size list. Make sure the user request includes space for the header that must be allocated … … 656 656 __atomic_add_fetch( &allocFree, -size, __ATOMIC_SEQ_CST ); 657 657 if ( traceHeap() ) { 658 enum { BufferSize = 64 }; 659 char helpText[BufferSize]; 658 char helpText[64]; 660 659 int len = snprintf( helpText, sizeof(helpText), "Free( %p ) size:%zu\n", addr, size ); 661 660 __cfaabi_dbg_bits_write( helpText, len ); … … 854 853 // Mapped storage is zero filled, but in debug mode mapped memory is scrubbed in doMalloc, so it has to be reset to zero. 855 854 if ( ! mapped ) 856 #endif // __CFA_DEBUG__855 #endif // __CFA_DEBUG__ 857 856 memset( (char *)area + usize, '\0', asize - ( (char *)area - (char *)header ) - usize ); // zero-fill back part 858 857 header->kind.real.blockSize |= 2; // mark new request as zero fill … … 1035 1034 // Local Variables: // 1036 1035 // tab-width: 4 // 1037 // compile-command: "cfa -nodebug -O2 heap.c fa" //1036 // compile-command: "cfa -nodebug -O2 heap.c" // 1038 1037 // End: //
Note:
See TracChangeset
for help on using the changeset viewer.