Ignore:
Timestamp:
Sep 2, 2020, 1:13:28 PM (15 months ago)
Author:
m3zulfiq <m3zulfiq@…>
Branches:
arm-eh, jacob/cs343-translation, master, new-ast-unique-expr
Children:
3a4834b3, 73f1b1c
Parents:
f6fe597
Message:

alloc2.txt: added expected output file for test alloc2.cfa. heap.cfa: removed alignment bugs from realloc and resize with alignment. stdlib.hfa: removed debug prints from alloc interface. alloc2.cfa, malloc.cfa: uncommented tests that were previously commented because of a bug in realloc and resize.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/heap.cfa

    rf6fe597 rf76ff0b  
    12391239        size_t odsize = dataStorage( bsize, oaddr, header ); // data storage available in bucket
    12401240
    1241         if ( oalign <= nalign && (uintptr_t)oaddr % nalign == 0 ) { // <= alignment and new alignment happens to match
    1242                 if ( oalign > libAlign() ) {                                    // fake header ?
    1243                         headerAddr( oaddr )->kind.fake.alignment = nalign | 1; // update alignment (could be the same)
    1244                 } // if
     1241        if ( oalign == nalign && size <= odsize && odsize <= size * 2 ) { // <= alignment and new alignment are same, allow 50% wasted storage for smaller size
     1242                header->kind.real.blockSize &= -2;                      // turn off 0 fill
     1243                header->kind.real.size = size;                          // reset allocation size
     1244                return oaddr;
     1245        } // if
     1246        if ( oalign < nalign && (uintptr_t)oaddr % nalign == 0 && oalign > libAlign() ) { // <= alignment and new alignment happens to match, and oaddr has a fake header
     1247                headerAddr( oaddr )->kind.fake.alignment = nalign | 1; // update alignment (could be the same)
    12451248                if ( size <= odsize && odsize <= size * 2 ) {   // allow 50% wasted storage for smaller size
    12461249                        header->kind.real.blockSize &= -2;                      // turn off 0 fill
     
    12821285        headers( "realloc", oaddr, header, freeElem, bsize, oalign );
    12831286
    1284         if ( oalign <= nalign && (uintptr_t)oaddr % nalign == 0 ) { // <= alignment and new alignment happens to match
    1285                 if ( oalign > libAlign() ) {                                    // fake header ?
    1286                         headerAddr( oaddr )->kind.fake.alignment = nalign | 1; // update alignment (could be the same)
    1287                 } // if
     1287        if ( oalign == nalign ) { // <= alignment and new alignment are same
     1288                return realloc( oaddr, size );
     1289        } // if
     1290        if ( oalign < nalign && (uintptr_t)oaddr % nalign == 0 && oalign > libAlign() ) { // <= alignment and new alignment happens to match, and oaddr has a fake header
     1291                headerAddr( oaddr )->kind.fake.alignment = nalign | 1; // update alignment (could be the same)
    12881292                return realloc( oaddr, size );
    12891293        } // if
Note: See TracChangeset for help on using the changeset viewer.