Changeset 13fece5


Ignore:
Timestamp:
Dec 16, 2020, 1:42:55 PM (9 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
arm-eh, jacob/cs343-translation, master, new-ast-unique-expr
Children:
3e5dd913
Parents:
54eb1bb3
Message:

modify location of mmapped storage to either side of the heap, and fix pattern for memory scrubbing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/heap.cfa

    r54eb1bb3 r13fece5  
    1010// Created On       : Tue Dec 19 21:58:35 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec 15 21:37:54 2020
    13 // Update Count     : 1013
     12// Last Modified On : Wed Dec 16 12:28:25 2020
     13// Update Count     : 1023
    1414//
    1515
     
    438438        header = headerAddr( addr );
    439439
    440   if ( unlikely( heapEnd < addr ) ) {                                   // mmapped ?
     440  if ( unlikely( addr < heapBegin || heapEnd < addr ) ) { // mmapped ?
    441441                fakeHeader( header, alignment );
    442442                size = header->kind.real.blockSize & -3;                // mmap size
     
    445445
    446446        #ifdef __CFA_DEBUG__
    447         checkHeader( addr < heapBegin, name, addr );            // bad low address ?
     447        checkHeader( header < (HeapManager.Storage.Header *)heapBegin, name, addr ); // bad low address ?
    448448        #endif // __CFA_DEBUG__
    449449
     
    484484#endif // __CFA_DEBUG__
    485485
     486
    486487#define NO_MEMORY_MSG "insufficient heap memory available for allocating %zd new bytes."
    487488
    488 #include <unistd.h>
    489489static inline void * extend( size_t size ) with( heapManager ) {
    490490        lock( extlock __cfaabi_dbg_ctx2 );
     
    511511                #ifdef __CFA_DEBUG__
    512512                // Set new memory to garbage so subsequent uninitialized usages might fail.
    513                 memset( (char *)heapEnd + heapRemaining, '\hde', increase );
     513                memset( (char *)heapEnd + heapRemaining, '\xde', increase );
    514514                //Memset( (char *)heapEnd + heapRemaining, increase );
    515515                #endif // __CFA_DEBUG__
     
    586586                #ifdef __CFA_DEBUG__
    587587                // Set new memory to garbage so subsequent uninitialized usages might fail.
    588                 memset( block, '\hde', tsize );
     588                memset( block, '\xde', tsize );
    589589                //Memset( block, tsize );
    590590                #endif // __CFA_DEBUG__
     
    634634                #ifdef __CFA_DEBUG__
    635635                // Set free memory to garbage so subsequent usages might fail.
    636                 memset( ((HeapManager.Storage *)header)->data, '\hde', freeElem->blockSize - sizeof( HeapManager.Storage ) );
     636                memset( ((HeapManager.Storage *)header)->data, '\xde', freeElem->blockSize - sizeof( HeapManager.Storage ) );
    637637                //Memset( ((HeapManager.Storage *)header)->data, freeElem->blockSize - sizeof( HeapManager.Storage ) );
    638638                #endif // __CFA_DEBUG__
     
    10291029        } // cmemalign
    10301030
     1031
    10311032        // Same as memalign(), but ISO/IEC 2011 C11 Section 7.22.2 states: the value of size shall be an integral multiple
    10321033    // of alignment. This requirement is universally ignored.
     
    10451046                return 0;
    10461047        } // posix_memalign
     1048
    10471049
    10481050        // Allocates size bytes and returns a pointer to the allocated memory. The memory address shall be a multiple of the
Note: See TracChangeset for help on using the changeset viewer.