Changeset 71dfe49 for tests/heap.cfa
- Timestamp:
- Aug 4, 2020, 12:53:48 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 954821df
- Parents:
- 8395152 (diff), 2ff42f4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/heap.cfa
r8395152 r71dfe49 10 10 // Created On : Tue Nov 6 17:54:56 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Nov 24 12:34:51 201913 // Update Count : 2812 // Last Modified On : Tue Aug 4 06:36:17 2020 13 // Update Count : 56 14 14 // 15 15 … … 75 75 size_t s = (i + 1) * 20; 76 76 char * area = (char *)malloc( s ); 77 if ( area == 0p ) abort( "malloc/free out of memory" );78 77 area[0] = '\345'; area[s - 1] = '\345'; // fill first/last 79 78 area[malloc_usable_size( area ) - 1] = '\345'; // fill ultimate byte … … 84 83 size_t s = i + 1; // +1 to make initialization simpler 85 84 locns[i] = (char *)malloc( s ); 86 if ( locns[i] == 0p ) abort( "malloc/free out of memory" );87 85 locns[i][0] = '\345'; locns[i][s - 1] = '\345'; // fill first/last 88 86 locns[i][malloc_usable_size( locns[i] ) - 1] = '\345'; // fill ultimate byte … … 100 98 size_t s = i + default_mmap_start(); // cross over point 101 99 char * area = (char *)malloc( s ); 102 if ( area == 0p ) abort( "malloc/free out of memory" );103 100 area[0] = '\345'; area[s - 1] = '\345'; // fill first/last 104 101 area[malloc_usable_size( area ) - 1] = '\345'; // fill ultimate byte … … 109 106 size_t s = i + default_mmap_start(); // cross over point 110 107 locns[i] = (char *)malloc( s ); 111 if ( locns[i] == 0p ) abort( "malloc/free out of memory" );112 108 locns[i][0] = '\345'; locns[i][s - 1] = '\345'; // fill first/last 113 109 locns[i][malloc_usable_size( locns[i] ) - 1] = '\345'; // fill ultimate byte … … 125 121 size_t s = (i + 1) * 20; 126 122 char * area = (char *)calloc( 5, s ); 127 if ( area == 0p ) abort( "calloc/free out of memory" );128 123 if ( area[0] != '\0' || area[s - 1] != '\0' || 129 area[malloc_ usable_size( area ) - 1] != '\0' ||124 area[malloc_size( area ) - 1] != '\0' || 130 125 ! malloc_zero_fill( area ) ) abort( "calloc/free corrupt storage1" ); 131 126 area[0] = '\345'; area[s - 1] = '\345'; // fill first/last … … 137 132 size_t s = i + 1; 138 133 locns[i] = (char *)calloc( 5, s ); 139 if ( locns[i] == 0p ) abort( "calloc/free out of memory" );140 134 if ( locns[i][0] != '\0' || locns[i][s - 1] != '\0' || 141 locns[i][malloc_ usable_size( locns[i] ) - 1] != '\0' ||135 locns[i][malloc_size( locns[i] ) - 1] != '\0' || 142 136 ! malloc_zero_fill( locns[i] ) ) abort( "calloc/free corrupt storage2" ); 143 137 locns[i][0] = '\345'; locns[i][s - 1] = '\345'; // fill first/last … … 156 150 size_t s = i + default_mmap_start(); // cross over point 157 151 char * area = (char *)calloc( 1, s ); 158 if ( area == 0p ) abort( "calloc/free out of memory" );159 152 if ( area[0] != '\0' || area[s - 1] != '\0' ) abort( "calloc/free corrupt storage4.1" ); 160 if ( area[malloc_ usable_size( area ) - 1] != '\0' ) abort( "calloc/free corrupt storage4.2" );153 if ( area[malloc_size( area ) - 1] != '\0' ) abort( "calloc/free corrupt storage4.2" ); 161 154 if ( ! malloc_zero_fill( area ) ) abort( "calloc/free corrupt storage4.3" ); 162 155 area[0] = '\345'; area[s - 1] = '\345'; // fill first/last … … 168 161 size_t s = i + default_mmap_start(); // cross over point 169 162 locns[i] = (char *)calloc( 1, s ); 170 if ( locns[i] == 0p ) abort( "calloc/free out of memory" );171 163 if ( locns[i][0] != '\0' || locns[i][s - 1] != '\0' || 172 locns[i][malloc_ usable_size( locns[i] ) - 1] != '\0' ||164 locns[i][malloc_size( locns[i] ) - 1] != '\0' || 173 165 ! malloc_zero_fill( locns[i] ) ) abort( "calloc/free corrupt storage5" ); 174 166 locns[i][0] = '\345'; locns[i][s - 1] = '\345'; // fill first/last … … 188 180 for ( s; 1 ~ NoOfAllocs ) { // allocation of size 0 can return null 189 181 char * area = (char *)memalign( a, s ); 190 if ( area == 0p ) abort( "memalign/free out of memory" );191 182 //sout | i | area; 192 183 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment … … 206 197 size_t s = i + default_mmap_start(); // cross over point 207 198 char * area = (char *)memalign( a, s ); 208 if ( area == 0p ) abort( "memalign/free out of memory" );209 199 //sout | i | area; 210 200 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment … … 222 212 // initial N byte allocation 223 213 char * area = (char *)calloc( 5, i ); 224 if ( area == 0p ) abort( "calloc/realloc/free out of memory" );225 214 if ( area[0] != '\0' || area[i - 1] != '\0' || 226 area[malloc_ usable_size( area ) - 1] != '\0' ||215 area[malloc_size( area ) - 1] != '\0' || 227 216 ! malloc_zero_fill( area ) ) abort( "calloc/realloc/free corrupt storage1" ); 228 217 … … 230 219 for ( s; i ~ 256 * 1024 ~ 26 ) { // start at initial memory request 231 220 area = (char *)realloc( area, s ); // attempt to reuse storage 232 if ( area == 0p ) abort( "calloc/realloc/free out of memory" );233 221 if ( area[0] != '\0' || area[s - 1] != '\0' || 234 area[malloc_ usable_size( area ) - 1] != '\0' ||222 area[malloc_size( area ) - 1] != '\0' || 235 223 ! malloc_zero_fill( area ) ) abort( "calloc/realloc/free corrupt storage2" ); 236 224 } // for … … 244 232 size_t s = i + default_mmap_start(); // cross over point 245 233 char * area = (char *)calloc( 1, s ); 246 if ( area == 0p ) abort( "calloc/realloc/free out of memory" );234 // if ( area == 0p ) abort( "calloc/realloc/free out of memory" ); 247 235 if ( area[0] != '\0' || area[s - 1] != '\0' || 248 area[malloc_usable_size( area ) - 1] != '\0' || 249 ! malloc_zero_fill( area ) ) abort( "calloc/realloc/free corrupt storage1" ); 236 area[malloc_size( area ) - 1] != '\0' || 237 ! malloc_zero_fill( area ) ) //abort( "calloc/realloc/free corrupt storage3" ); 238 printf( "C %zd %d %d %d %d\n", s, area[0] != '\0', area[s - 1] != '\0', area[malloc_size( area ) - 1] != '\0', ! malloc_zero_fill( area ) ); 250 239 251 240 // Do not start this loop index at 0 because realloc of 0 bytes frees the storage. 252 241 for ( r; i ~ 256 * 1024 ~ 26 ) { // start at initial memory request 253 242 area = (char *)realloc( area, r ); // attempt to reuse storage 254 if ( area == 0p ) abort( "calloc/realloc/free out of memory" );243 // if ( area == 0p ) abort( "calloc/realloc/free out of memory" ); 255 244 if ( area[0] != '\0' || area[r - 1] != '\0' || 256 area[malloc_ usable_size( area ) - 1] != '\0' ||257 ! malloc_zero_fill( area ) ) abort( "calloc/realloc/free corrupt storage 2" );245 area[malloc_size( area ) - 1] != '\0' || 246 ! malloc_zero_fill( area ) ) abort( "calloc/realloc/free corrupt storage4" ); 258 247 } // for 259 248 free( area ); … … 266 255 // initial N byte allocation 267 256 char * area = (char *)memalign( a, amount ); // aligned N-byte allocation 268 if ( area == 0p ) abort( "memalign/realloc/free out of memory" ); // no storage ?257 // if ( area == 0p ) abort( "memalign/realloc/free out of memory" ); // no storage ? 269 258 //sout | alignments[a] | area; 270 259 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment … … 277 266 if ( area[0] != '\345' || area[s - 2] != '\345' ) abort( "memalign/realloc/free corrupt storage" ); 278 267 area = (char *)realloc( area, s ); // attempt to reuse storage 279 if ( area == 0p ) abort( "memalign/realloc/free out of memory" ); // no storage ?280 268 //sout | i | area; 281 269 if ( (size_t)area % a != 0 ) { // check for initial alignment … … 293 281 for ( s; 1 ~ limit ) { // allocation of size 0 can return null 294 282 char * area = (char *)cmemalign( a, 1, s ); 295 if ( area == 0p ) abort( "cmemalign/free out of memory" );296 283 //sout | i | area; 297 284 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment … … 299 286 } // if 300 287 if ( area[0] != '\0' || area[s - 1] != '\0' || 301 area[malloc_ usable_size( area ) - 1] != '\0' ||288 area[malloc_size( area ) - 1] != '\0' || 302 289 ! malloc_zero_fill( area ) ) abort( "cmemalign/free corrupt storage" ); 303 290 area[0] = '\345'; area[s - 1] = '\345'; // fill first/last byte … … 312 299 // initial N byte allocation 313 300 char * area = (char *)cmemalign( a, 1, amount ); // aligned N-byte allocation 314 if ( area == 0p ) abort( "cmemalign/realloc/free out of memory" ); // no storage ?315 301 //sout | alignments[a] | area; 316 302 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment … … 318 304 } // if 319 305 if ( area[0] != '\0' || area[amount - 1] != '\0' || 320 area[malloc_ usable_size( area ) - 1] != '\0' ||306 area[malloc_size( area ) - 1] != '\0' || 321 307 ! malloc_zero_fill( area ) ) abort( "cmemalign/realloc/free corrupt storage1" ); 322 308 area[0] = '\345'; area[amount - 2] = '\345'; // fill first/penultimate byte … … 326 312 if ( area[0] != '\345' || area[s - 2] != '\345' ) abort( "cmemalign/realloc/free corrupt storage2" ); 327 313 area = (char *)realloc( area, s ); // attempt to reuse storage 328 if ( area == 0p ) abort( "cmemalign/realloc/free out of memory" ); // no storage ?329 314 //sout | i | area; 330 315 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment 331 316 abort( "cmemalign/realloc/free bad alignment %p", area ); 332 317 } // if 333 if ( area[ s - 1] != '\0' || area[s - 1] != '\0' ||334 area[malloc_ usable_size( area ) - 1] != '\0' ||318 if ( area[0] != '\345' || area[s - 1] != '\0' || 319 area[malloc_size( area ) - 1] != '\0' || 335 320 ! malloc_zero_fill( area ) ) abort( "cmemalign/realloc/free corrupt storage3" ); 336 321 area[s - 1] = '\345'; // fill last byte … … 345 330 // initial N byte allocation 346 331 char * area = (char *)memalign( a, amount ); // aligned N-byte allocation 347 if ( area == 0p ) abort( "memalign/realloc with align/free out of memory" ); // no storage ?348 332 //sout | alignments[a] | area | endl; 349 333 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment … … 356 340 if ( area[0] != '\345' || area[s - 2] != '\345' ) abort( "memalign/realloc/free corrupt storage" ); 357 341 area = (char *)realloc( area, a * 2, s ); // attempt to reuse storage 358 if ( area == 0p ) abort( "memalign/realloc with align/free out of memory" ); // no storage ?359 342 //sout | i | area | endl; 360 343 if ( (size_t)area % a * 2 != 0 ) { // check for initial alignment … … 371 354 for ( size_t a = libAlign() + libAlign(); a <= limit; a += a ) { // generate powers of 2 372 355 // initial N byte allocation 373 char *area = (char *)cmemalign( a, 1, amount ); // aligned N-byte allocation 374 if ( area == 0p ) abort( "cmemalign/realloc with align/free out of memory" ); // no storage ? 356 char * area = (char *)cmemalign( a, 1, amount ); // aligned N-byte allocation 375 357 //sout | alignments[a] | area | endl; 376 358 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment … … 378 360 } // if 379 361 if ( area[0] != '\0' || area[amount - 1] != '\0' || 380 area[malloc_ usable_size( area ) - 1] != '\0' ||362 area[malloc_size( area ) - 1] != '\0' || 381 363 ! malloc_zero_fill( area ) ) abort( "cmemalign/realloc with align/free corrupt storage1" ); 382 364 area[0] = '\345'; area[amount - 2] = '\345'; // fill first/penultimate byte … … 386 368 if ( area[0] != '\345' || area[s - 2] != '\345' ) abort( "cmemalign/realloc with align/free corrupt storage2" ); 387 369 area = (char *)realloc( area, a * 2, s ); // attempt to reuse storage 388 if ( area == 0p ) abort( "cmemalign/realloc with align/free out of memory" ); // no storage ?389 370 //sout | i | area | endl; 390 371 if ( (size_t)area % a * 2 != 0 || malloc_alignment( area ) != a * 2 ) { // check for initial alignment 391 abort( "cmemalign/realloc with align/free bad alignment %p % jd %jd", area, malloc_alignment( area ), a * 2 );372 abort( "cmemalign/realloc with align/free bad alignment %p %zd %zd", area, malloc_alignment( area ), a * 2 ); 392 373 } // if 393 374 if ( area[s - 1] != '\0' || area[s - 1] != '\0' || 394 area[malloc_ usable_size( area ) - 1] != '\0' ||375 area[malloc_size( area ) - 1] != '\0' || 395 376 ! malloc_zero_fill( area ) ) abort( "cmemalign/realloc/free corrupt storage3" ); 396 377 area[s - 1] = '\345'; // fill last byte
Note: See TracChangeset
for help on using the changeset viewer.