Changeset 7b149bc for libcfa/src
- Timestamp:
- May 19, 2019, 6:24:07 PM (6 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- b2ac656
- Parents:
- f6964ef
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/heap.cfa
rf6964ef r7b149bc 10 10 // Created On : Tue Dec 19 21:58:35 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 22 13:43:10201913 // Update Count : 51 412 // Last Modified On : Thu May 9 16:29:12 2019 13 // Update Count : 516 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 236 237 static inline size_t getKey( const HeapManager.FreeHeader & freeheader ) { return freeheader.blockSize; } 238 237 239 // 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 308 } // HeapManager 309 309 310 310 … … 316 316 // } // if 317 317 #endif // __STATISTICS__ 318 318 } // ~HeapManager 319 319 320 320 … … 533 533 534 534 static inline void * doMalloc( size_t size ) with ( heapManager ) { 535 HeapManager.Storage * block; 535 HeapManager.Storage * block; // pointer to new block of storage 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 char helpText[64]; 658 enum { BufferSize = 64 }; 659 char helpText[BufferSize]; 659 660 int len = snprintf( helpText, sizeof(helpText), "Free( %p ) size:%zu\n", addr, size ); 660 661 __cfaabi_dbg_bits_write( helpText, len ); … … 853 854 // Mapped storage is zero filled, but in debug mode mapped memory is scrubbed in doMalloc, so it has to be reset to zero. 854 855 if ( ! mapped ) 855 856 #endif // __CFA_DEBUG__ 856 857 memset( (char *)area + usize, '\0', asize - ( (char *)area - (char *)header ) - usize ); // zero-fill back part 857 858 header->kind.real.blockSize |= 2; // mark new request as zero fill
Note: See TracChangeset
for help on using the changeset viewer.