Changeset 7b149bc for libcfa/src


Ignore:
Timestamp:
May 19, 2019, 6:24:07 PM (6 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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
Message:

formatting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/heap.cfa

    rf6964ef r7b149bc  
    1010// Created On       : Tue Dec 19 21:58:35 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 22 13:43:10 2019
    13 // Update Count     : 514
     12// Last Modified On : Thu May  9 16:29:12 2019
     13// Update Count     : 516
    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
    236237static inline size_t getKey( const HeapManager.FreeHeader & freeheader ) { return freeheader.blockSize; }
     238
    237239// 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;
     535        HeapManager.Storage * block;                                            // pointer to new block of storage
    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                 char helpText[64];
     658                enum { BufferSize = 64 };
     659                char helpText[BufferSize];
    659660                int len = snprintf( helpText, sizeof(helpText), "Free( %p ) size:%zu\n", addr, size );
    660661                __cfaabi_dbg_bits_write( helpText, len );
     
    853854                        // Mapped storage is zero filled, but in debug mode mapped memory is scrubbed in doMalloc, so it has to be reset to zero.
    854855                        if ( ! mapped )
    855                                 #endif // __CFA_DEBUG__
     856                        #endif // __CFA_DEBUG__
    856857                                memset( (char *)area + usize, '\0', asize - ( (char *)area - (char *)header ) - usize ); // zero-fill back part
    857858                        header->kind.real.blockSize |= 2;                       // mark new request as zero fill
Note: See TracChangeset for help on using the changeset viewer.