Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/heap.cfa

    r7b149bc r7117ac3  
    1010// Created On       : Tue Dec 19 21:58:35 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu May  9 16:29:12 2019
    13 // Update Count     : 516
     12// Last Modified On : Thu Sep  6 09:01:30 2018
     13// Update Count     : 513
    1414//
    1515
     
    220220                StackLF<Storage> freeList;
    221221                #else
    222                         #error undefined lock type for bucket lock
     222                #error undefined lock type for bucket lock
    223223                #endif // SPINLOCK
    224224                size_t blockSize;                                                               // size of allocations on this list
     
    234234}; // HeapManager
    235235
    236 
    237236static inline size_t getKey( const HeapManager.FreeHeader & freeheader ) { return freeheader.blockSize; }
    238 
    239237// statically allocated variables => zero filled.
     238
     239
    240240static size_t pageSize;                                                                 // architecture pagesize
    241241static size_t heapExpand;                                                               // sbrk advance
     
    306306        sbrk( (char *)libCeiling( (long unsigned int)End, libAlign() ) - End ); // move start of heap to multiple of alignment
    307307        heapBegin = heapEnd = sbrk( 0 );                                        // get new start point
    308 } // HeapManager
     308                           } // HeapManager
    309309
    310310
     
    316316        // } // if
    317317        #endif // __STATISTICS__
    318 } // ~HeapManager
     318                                } // ~HeapManager
    319319
    320320
     
    533533
    534534static inline void * doMalloc( size_t size ) with ( heapManager ) {
    535         HeapManager.Storage * block;                                            // pointer to new block of storage
     535        HeapManager.Storage * block;
    536536
    537537        // Look up size in the size list.  Make sure the user request includes space for the header that must be allocated
     
    656656        __atomic_add_fetch( &allocFree, -size, __ATOMIC_SEQ_CST );
    657657        if ( traceHeap() ) {
    658                 enum { BufferSize = 64 };
    659                 char helpText[BufferSize];
     658                char helpText[64];
    660659                int len = snprintf( helpText, sizeof(helpText), "Free( %p ) size:%zu\n", addr, size );
    661660                __cfaabi_dbg_bits_write( helpText, len );
     
    854853                        // Mapped storage is zero filled, but in debug mode mapped memory is scrubbed in doMalloc, so it has to be reset to zero.
    855854                        if ( ! mapped )
    856                         #endif // __CFA_DEBUG__
     855                                #endif // __CFA_DEBUG__
    857856                                memset( (char *)area + usize, '\0', asize - ( (char *)area - (char *)header ) - usize ); // zero-fill back part
    858857                        header->kind.real.blockSize |= 2;                       // mark new request as zero fill
     
    10351034// Local Variables: //
    10361035// tab-width: 4 //
    1037 // compile-command: "cfa -nodebug -O2 heap.cfa" //
     1036// compile-command: "cfa -nodebug -O2 heap.c" //
    10381037// End: //
Note: See TracChangeset for help on using the changeset viewer.