Changeset 1aa6ecb
- Timestamp:
- Oct 20, 2019, 11:14:28 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- cafb687
- Parents:
- fdf4efb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/heap.cfa
rfdf4efb r1aa6ecb 10 10 // Created On : Tue Dec 19 21:58:35 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jul 24 13:12:45201913 // Update Count : 55 012 // Last Modified On : Fri Oct 18 07:42:09 2019 13 // Update Count : 556 14 14 // 15 15 … … 541 541 // along with the block and is a multiple of the alignment size. 542 542 543 if ( unlikely( size > ~0ul - sizeof(HeapManager.Storage) ) ) return 0; 543 544 size_t tsize = size + sizeof(HeapManager.Storage); 544 545 if ( likely( tsize < mmapStart ) ) { // small size => sbrk … … 592 593 block->header.kind.real.home = freeElem; // pointer back to free list of apropriate size 593 594 } else { // large size => mmap 595 if ( unlikely( size > ~0ul - pageSize ) ) return 0; 594 596 tsize = libCeiling( tsize, pageSize ); // must be multiple of page size 595 597 #ifdef __STATISTICS__ … … 888 890 } // realloc 889 891 890 891 892 // The obsolete function memalign() allocates size bytes and returns a pointer to the allocated memory. The memory 892 893 // address will be a multiple of alignment, which must be a power of two. … … 992 993 size_t malloc_alignment( void * addr ) { 993 994 if ( unlikely( addr == 0 ) ) return libAlign(); // minimum alignment 994 HeapManager.Storage.Header * header = (HeapManager.Storage.Header *)( (char *)addr - sizeof(HeapManager.Storage));995 HeapManager.Storage.Header * header = headerAddr( addr ); 995 996 if ( (header->kind.fake.alignment & 1) == 1 ) { // fake header ? 996 997 return header->kind.fake.alignment & -2; // remove flag from value … … 1004 1005 bool malloc_zero_fill( void * addr ) { 1005 1006 if ( unlikely( addr == 0 ) ) return false; // null allocation is not zero fill 1006 1007 HeapManager.Storage.Header * header = (HeapManager.Storage.Header *)( (char *)addr - sizeof(HeapManager.Storage) ); 1007 HeapManager.Storage.Header * header = headerAddr( addr ); 1008 1008 if ( (header->kind.fake.alignment & 1) == 1 ) { // fake header ? 1009 1009 header = (HeapManager.Storage.Header *)((char *)header - header->kind.fake.offset);
Note: See TracChangeset
for help on using the changeset viewer.