Changes in tests/heap.cfa [6a25b8f:3e91703d]
- File:
-
- 1 edited
-
tests/heap.cfa (modified) (20 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tests/heap.cfa
r6a25b8f r3e91703d 10 10 // Created On : Tue Nov 6 17:54:56 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Nov 20 16:10:24 201913 // Update Count : 2512 // Last Modified On : Fri Jul 19 08:22:34 2019 13 // Update Count : 19 14 14 // 15 15 … … 74 74 size_t s = (i + 1) * 20; 75 75 char * area = (char *)malloc( s ); 76 if ( area == 0 p) abort( "malloc/free out of memory" );76 if ( area == 0 ) abort( "malloc/free out of memory" ); 77 77 area[0] = '\345'; area[s - 1] = '\345'; // fill first/last 78 78 area[malloc_usable_size( area ) - 1] = '\345'; // fill ultimate byte … … 83 83 size_t s = i + 1; // +1 to make initialization simpler 84 84 locns[i] = (char *)malloc( s ); 85 if ( locns[i] == 0 p) abort( "malloc/free out of memory" );85 if ( locns[i] == 0 ) abort( "malloc/free out of memory" ); 86 86 locns[i][0] = '\345'; locns[i][s - 1] = '\345'; // fill first/last 87 87 locns[i][malloc_usable_size( locns[i] ) - 1] = '\345'; // fill ultimate byte … … 99 99 size_t s = i + default_mmap_start(); // cross over point 100 100 char * area = (char *)malloc( s ); 101 if ( area == 0 p) abort( "malloc/free out of memory" );101 if ( area == 0 ) abort( "malloc/free out of memory" ); 102 102 area[0] = '\345'; area[s - 1] = '\345'; // fill first/last 103 103 area[malloc_usable_size( area ) - 1] = '\345'; // fill ultimate byte … … 108 108 size_t s = i + default_mmap_start(); // cross over point 109 109 locns[i] = (char *)malloc( s ); 110 if ( locns[i] == 0 p) abort( "malloc/free out of memory" );110 if ( locns[i] == 0 ) abort( "malloc/free out of memory" ); 111 111 locns[i][0] = '\345'; locns[i][s - 1] = '\345'; // fill first/last 112 112 locns[i][malloc_usable_size( locns[i] ) - 1] = '\345'; // fill ultimate byte … … 124 124 size_t s = (i + 1) * 20; 125 125 char * area = (char *)calloc( 5, s ); 126 if ( area == 0 p) abort( "calloc/free out of memory" );126 if ( area == 0 ) abort( "calloc/free out of memory" ); 127 127 if ( area[0] != '\0' || area[s - 1] != '\0' || 128 128 area[malloc_usable_size( area ) - 1] != '\0' || … … 136 136 size_t s = i + 1; 137 137 locns[i] = (char *)calloc( 5, s ); 138 if ( locns[i] == 0 p) abort( "calloc/free out of memory" );138 if ( locns[i] == 0 ) abort( "calloc/free out of memory" ); 139 139 if ( locns[i][0] != '\0' || locns[i][s - 1] != '\0' || 140 140 locns[i][malloc_usable_size( locns[i] ) - 1] != '\0' || … … 155 155 size_t s = i + default_mmap_start(); // cross over point 156 156 char * area = (char *)calloc( 1, s ); 157 if ( area == 0 p) abort( "calloc/free out of memory" );157 if ( area == 0 ) abort( "calloc/free out of memory" ); 158 158 if ( area[0] != '\0' || area[s - 1] != '\0' ) abort( "calloc/free corrupt storage4.1" ); 159 159 if ( area[malloc_usable_size( area ) - 1] != '\0' ) abort( "calloc/free corrupt storage4.2" ); … … 167 167 size_t s = i + default_mmap_start(); // cross over point 168 168 locns[i] = (char *)calloc( 1, s ); 169 if ( locns[i] == 0 p) abort( "calloc/free out of memory" );169 if ( locns[i] == 0 ) abort( "calloc/free out of memory" ); 170 170 if ( locns[i][0] != '\0' || locns[i][s - 1] != '\0' || 171 171 locns[i][malloc_usable_size( locns[i] ) - 1] != '\0' || … … 189 189 for ( s; 1 ~ NoOfAllocs ) { // allocation of size 0 can return null 190 190 char * area = (char *)memalign( a, s ); 191 if ( area == 0 p) abort( "memalign/free out of memory" );192 //sout | i | area;191 if ( area == 0 ) abort( "memalign/free out of memory" ); 192 //sout | i | " " | area; 193 193 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment 194 194 abort( "memalign/free bad alignment : memalign(%d,%d) = %p", (int)a, s, area ); 195 195 } // if 196 area[0] = '\345'; area[s - 1] = '\345'; // fill first/last byte196 area[0] = '\345'; area[s - 1] = '\345'; // fill first/last byte 197 197 area[malloc_usable_size( area ) - 1] = '\345'; // fill ultimate byte 198 198 free( area ); … … 207 207 size_t s = i + default_mmap_start(); // cross over point 208 208 char * area = (char *)memalign( a, s ); 209 if ( area == 0 p) abort( "memalign/free out of memory" );210 //sout | i | area;209 if ( area == 0 ) abort( "memalign/free out of memory" ); 210 //sout | i | " " | area; 211 211 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment 212 212 abort( "memalign/free bad alignment : memalign(%d,%d) = %p", (int)a, (int)s, area ); … … 223 223 // initial N byte allocation 224 224 char * area = (char *)calloc( 5, i ); 225 if ( area == 0 p) abort( "calloc/realloc/free out of memory" );225 if ( area == 0 ) abort( "calloc/realloc/free out of memory" ); 226 226 if ( area[0] != '\0' || area[i - 1] != '\0' || 227 227 area[malloc_usable_size( area ) - 1] != '\0' || … … 231 231 for ( s; i ~ 256 * 1024 ~ 26 ) { // start at initial memory request 232 232 area = (char *)realloc( area, s ); // attempt to reuse storage 233 if ( area == 0 p) abort( "calloc/realloc/free out of memory" );233 if ( area == 0 ) abort( "calloc/realloc/free out of memory" ); 234 234 if ( area[0] != '\0' || area[s - 1] != '\0' || 235 235 area[malloc_usable_size( area ) - 1] != '\0' || … … 245 245 size_t s = i + default_mmap_start(); // cross over point 246 246 char * area = (char *)calloc( 1, s ); 247 if ( area == 0 p) abort( "calloc/realloc/free out of memory" );247 if ( area == 0 ) abort( "calloc/realloc/free out of memory" ); 248 248 if ( area[0] != '\0' || area[s - 1] != '\0' || 249 249 area[malloc_usable_size( area ) - 1] != '\0' || … … 253 253 for ( r; i ~ 256 * 1024 ~ 26 ) { // start at initial memory request 254 254 area = (char *)realloc( area, r ); // attempt to reuse storage 255 if ( area == 0 p) abort( "calloc/realloc/free out of memory" );255 if ( area == 0 ) abort( "calloc/realloc/free out of memory" ); 256 256 if ( area[0] != '\0' || area[r - 1] != '\0' || 257 257 area[malloc_usable_size( area ) - 1] != '\0' || … … 267 267 // initial N byte allocation 268 268 char * area = (char *)memalign( a, amount ); // aligned N-byte allocation 269 if ( area == 0 p) abort( "memalign/realloc/free out of memory" ); // no storage ?270 //sout | alignments[a] | area;269 if ( area == 0 ) abort( "memalign/realloc/free out of memory" ); // no storage ? 270 //sout | alignments[a] | " " | area; 271 271 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment 272 272 abort( "memalign/realloc/free bad alignment : memalign(%d,%d) = %p", (int)a, (int)amount, area ); … … 278 278 if ( area[0] != '\345' || area[s - 2] != '\345' ) abort( "memalign/realloc/free corrupt storage" ); 279 279 area = (char *)realloc( area, s ); // attempt to reuse storage 280 if ( area == 0 p) abort( "memalign/realloc/free out of memory" ); // no storage ?281 //sout | i | area;280 if ( area == 0 ) abort( "memalign/realloc/free out of memory" ); // no storage ? 281 //sout | i | " " | area; 282 282 if ( (size_t)area % a != 0 ) { // check for initial alignment 283 283 abort( "memalign/realloc/free bad alignment %p", area ); … … 294 294 for ( s; 1 ~ limit ) { // allocation of size 0 can return null 295 295 char * area = (char *)cmemalign( a, 1, s ); 296 if ( area == 0 p) abort( "cmemalign/free out of memory" );297 //sout | i | area;296 if ( area == 0 ) abort( "cmemalign/free out of memory" ); 297 //sout | i | " " | area; 298 298 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment 299 299 abort( "cmemalign/free bad alignment : cmemalign(%d,%d) = %p", (int)a, s, area ); … … 313 313 // initial N byte allocation 314 314 char * area = (char *)cmemalign( a, 1, amount ); // aligned N-byte allocation 315 if ( area == 0 p) abort( "cmemalign/realloc/free out of memory" ); // no storage ?316 //sout | alignments[a] | area;315 if ( area == 0 ) abort( "cmemalign/realloc/free out of memory" ); // no storage ? 316 //sout | alignments[a] | " " | area; 317 317 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment 318 318 abort( "cmemalign/realloc/free bad alignment : cmemalign(%d,%d) = %p", (int)a, (int)amount, area ); … … 327 327 if ( area[0] != '\345' || area[s - 2] != '\345' ) abort( "cmemalign/realloc/free corrupt storage2" ); 328 328 area = (char *)realloc( area, s ); // attempt to reuse storage 329 if ( area == 0 p) abort( "cmemalign/realloc/free out of memory" ); // no storage ?330 //sout | i | area;329 if ( area == 0 ) abort( "cmemalign/realloc/free out of memory" ); // no storage ? 330 //sout | i | " " | area; 331 331 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment 332 332 abort( "cmemalign/realloc/free bad alignment %p", area ); 333 } // if334 if ( area[s - 1] != '\0' || area[s - 1] != '\0' ||335 area[malloc_usable_size( area ) - 1] != '\0' ||336 ! malloc_zero_fill( area ) ) abort( "cmemalign/realloc/free corrupt storage3" );337 area[s - 1] = '\345'; // fill last byte338 } // for339 free( area );340 } // for341 342 // check memalign/realloc with align/free343 344 amount = 2;345 for ( a; libAlign() ~= limit ~ a ) { // generate powers of 2346 // initial N byte allocation347 char * area = (char *)memalign( a, amount ); // aligned N-byte allocation348 if ( area == 0p ) abort( "memalign/realloc with align/free out of memory" ); // no storage ?349 //sout | alignments[a] | area | endl;350 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment351 abort( "memalign/realloc with align/free bad alignment : memalign(%d,%d) = %p", (int)a, (int)amount, area );352 } // if353 area[0] = '\345'; area[amount - 2] = '\345'; // fill first/penultimate byte354 355 // Do not start this loop index at 0 because realloc of 0 bytes frees the storage.356 for ( s; amount ~ 256 * 1024 ) { // start at initial memory request357 if ( area[0] != '\345' || area[s - 2] != '\345' ) abort( "memalign/realloc/free corrupt storage" );358 area = (char *)realloc( area, a * 2, s ); // attempt to reuse storage359 if ( area == 0p ) abort( "memalign/realloc with align/free out of memory" ); // no storage ?360 //sout | i | area | endl;361 if ( (size_t)area % a * 2 != 0 ) { // check for initial alignment362 abort( "memalign/realloc with align/free bad alignment %p", area );363 } // if364 area[s - 1] = '\345'; // fill last byte365 } // for366 free( area );367 } // for368 369 // check cmemalign/realloc with align/free370 371 amount = 2;372 for ( size_t a = libAlign() + libAlign(); a <= limit; a += a ) { // generate powers of 2373 // initial N byte allocation374 char *area = (char *)cmemalign( a, 1, amount ); // aligned N-byte allocation375 if ( area == 0p ) abort( "cmemalign/realloc with align/free out of memory" ); // no storage ?376 //sout | alignments[a] | area | endl;377 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment378 abort( "cmemalign/realloc with align/free bad alignment : cmemalign(%d,%d) = %p", (int)a, (int)amount, area );379 } // if380 if ( area[0] != '\0' || area[amount - 1] != '\0' ||381 area[malloc_usable_size( area ) - 1] != '\0' ||382 ! malloc_zero_fill( area ) ) abort( "cmemalign/realloc with align/free corrupt storage1" );383 area[0] = '\345'; area[amount - 2] = '\345'; // fill first/penultimate byte384 385 // Do not start this loop index at 0 because realloc of 0 bytes frees the storage.386 for ( int s = amount; s < 256 * 1024; s += 1 ) { // start at initial memory request387 if ( area[0] != '\345' || area[s - 2] != '\345' ) abort( "cmemalign/realloc with align/free corrupt storage2" );388 area = (char *)realloc( area, a * 2, s ); // attempt to reuse storage389 if ( area == 0p ) abort( "cmemalign/realloc with align/free out of memory" ); // no storage ?390 //sout | i | area | endl;391 if ( (size_t)area % a * 2 != 0 || malloc_alignment( area ) != a * 2 ) { // check for initial alignment392 abort( "cmemalign/realloc with align/free bad alignment %p %jd %jd", area, malloc_alignment( area ), a * 2 );393 333 } // if 394 334 if ( area[s - 1] != '\0' || area[s - 1] != '\0' ||
Note:
See TracChangeset
for help on using the changeset viewer.