Changes in / [4af5396:f82f07e]
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/heap.cfa
r4af5396 rf82f07e 10 10 // Created On : Tue Dec 19 21:58:35 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Oct 13 21:41:32202213 // Update Count : 15 5312 // Last Modified On : Wed Oct 12 18:06:01 2022 13 // Update Count : 1528 14 14 // 15 15 … … 515 515 } // with 516 516 } // if 517 518 517 return heap; 519 518 } // getHeap … … 586 585 // allocUnfreed is set to 0 when a heap is created and it accumulates any unfreed storage during its multiple thread 587 586 // usages. At the end, add up each heap allocUnfreed value across all heaps to get the total unfreed storage. 588 int64_t allocUnfreed = 0;587 long long int allocUnfreed = 0; 589 588 for ( Heap * heap = heapMaster.heapManagersList; heap; heap = heap->nextHeapManager ) { 590 589 allocUnfreed += heap->allocUnfreed; … … 1043 1042 if ( errno == ENOMEM ) abort( NO_MEMORY_MSG, tsize ); // no memory 1044 1043 // Do not call strerror( errno ) as it may call malloc. 1045 abort( " **** Error ****attempt to allocate large object (> %zu) of size %zu bytes and mmap failed with errno %d.", size, heapMaster.mmapStart, errno );1044 abort( "attempt to allocate large object (> %zu) of size %zu bytes and mmap failed with errno %d.", size, heapMaster.mmapStart, errno ); 1046 1045 } // if 1047 1046 block->header.kind.real.blockSize = MarkMmappedBit( tsize ); // storage size for munmap … … 1107 1106 if ( unlikely( munmap( header, size ) == -1 ) ) { 1108 1107 // Do not call strerror( errno ) as it may call malloc. 1109 abort( " **** Error ****attempt to deallocate large object %p and munmap failed with errno %d.\n"1108 abort( "attempt to deallocate large object %p and munmap failed with errno %d.\n" 1110 1109 "Possible cause is invalid delete pointer: either not allocated or with corrupt header.", 1111 1110 addr, errno ); … … 1217 1216 1218 1217 #ifdef __STATISTICS__ 1219 static void incCalls( intptr_t statName ) libcfa_nopreempt {1218 static void incCalls( long int statName ) libcfa_nopreempt { 1220 1219 heapManager->stats.counters[statName].calls += 1; 1221 1220 } // incCalls 1222 1221 1223 static void incZeroCalls( intptr_t statName ) libcfa_nopreempt {1222 static void incZeroCalls( long int statName ) libcfa_nopreempt { 1224 1223 heapManager->stats.counters[statName].calls_0 += 1; 1225 1224 } // incZeroCalls … … 1227 1226 1228 1227 #ifdef __CFA_DEBUG__ 1229 static void incUnfreed( intptr_t offset ) libcfa_nopreempt {1228 static void incUnfreed( size_t offset ) libcfa_nopreempt { 1230 1229 heapManager->allocUnfreed += offset; 1231 1230 } // incUnfreed … … 1568 1567 if ( write( STDERR_FILENO, MALLOC_STATS_MSG, sizeof( MALLOC_STATS_MSG ) - 1 /* size includes '\0' */ ) == -1 ) { 1569 1568 #endif // __STATISTICS__ 1570 abort( " **** Error ****write failed in malloc_stats" );1569 abort( "write failed in malloc_stats" ); 1571 1570 } // if 1572 1571 } // malloc_stats -
tests/alloc.cfa
r4af5396 rf82f07e 10 10 // Created On : Wed Feb 3 07:56:22 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Oct 13 21:39:34202213 // Update Count : 4 4912 // Last Modified On : Fri Jul 29 10:57:02 2022 13 // Update Count : 436 14 14 // 15 15 … … 180 180 }; 181 181 182 182 ip = alloc(); 183 183 *ip = 5; 184 184 double * dp = alloc( ip`resize ); 185 185 *dp = 5.5; 186 186 S * sp = alloc( dp`resize ); 187 187 *sp = (S){ {0, 1, 2, 3, 4} }; 188 188 ip = alloc( sp`resize ); 189 189 *ip = 3; 190 190 free( ip ); 191 191 192 192 193 193 // resize, array types 194 194 195 195 ip = alloc( 5 ); 196 196 for ( i; 5 ) { ip[i] = 5; } 197 197 dp = alloc( 5, ip`resize ); 198 198 for ( i; 5 ) { dp[i] = 5.5; } 199 199 sp = alloc( 5, dp`resize ); 200 200 for ( i; 5 ) { sp[i] = (S){ {0, 1, 2, 3, 4} }; } 201 201 ip = alloc( 3, sp`resize ); 202 202 for ( i; 3 ) { ip[i] = 3; } 203 203 ip = alloc( 7, ip`realloc ); 204 204 for ( i; 7 ) { ip[i] = 7; } 205 205 ip = alloc( 7, ip`resize ); 206 206 for ( i; 7 ) { ip[i] = 7; } 207 207 free( ip ); 208 208 209 209 … … 217 217 const_count++; 218 218 } 219 void ^?{}( Struct & a ) { dest_count++; } // destruct219 void ^?{}( Struct & a ) { dest_count++; } // destruct 220 220 Struct st, st1, sta[dim], sta1[dim], * stp, * stp1; 221 221
Note: See TracChangeset
for help on using the changeset viewer.