Changeset 2b23d78


Ignore:
Timestamp:
Jul 21, 2020, 11:16:09 AM (4 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
d8d8f20
Parents:
b0a0ee4
Message:

check for allocation size change and reset if necessary in resize and realloc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/heap.cfa

    rb0a0ee4 r2b23d78  
    1010// Created On       : Tue Dec 19 21:58:35 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Jul 19 17:37:21 2020
    13 // Update Count     : 806
     12// Last Modified On : Mon Jul 20 23:00:32 2020
     13// Update Count     : 808
    1414//
    1515
     
    901901          if ( oalign == 0 && size <= odsize && odsize <= size * 2 ) { // allow 50% wasted storage for smaller size
    902902                        header->kind.real.blockSize &= -2;                      // no alignment and turn off 0 fill
     903                        if ( size != odsize ) header->kind.real.size = size; // reset allocation size
    903904                        return oaddr;
    904905                } // if
     
    929930
    930931                size_t odsize = dataStorage( bsize, oaddr, header ); // data storage available in bucket
    931           if ( size <= odsize && odsize <= size * 2 ) { // allow up to 50% wasted storage in smaller size
    932                         // Do not know size of original allocation => cannot do 0 fill for any additional space because do not know
    933                         // where to start filling, i.e., do not overwrite existing values in space.
     932          if ( size <= odsize && odsize <= size * 2 ) {         // allow up to 50% wasted storage in smaller size
     933                        if ( size != odsize ) header->kind.real.size = size; // reset allocation size
    934934                        return oaddr;
    935935                } // if
     
    12271227                if ( size <= odsize && odsize <= size * 2 ) {   // allow 50% wasted storage for smaller size
    12281228                        header->kind.real.blockSize &= -2;                      // turn off 0 fill
     1229                        if ( size != odsize ) header->kind.real.size = size; // reset allocation size
    12291230                        return oaddr;
    12301231                } // if
Note: See TracChangeset for help on using the changeset viewer.