Changes in tests/heap.cfa [dfc13bb:505450a]
- File:
-
- 1 edited
-
tests/heap.cfa (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tests/heap.cfa
rdfc13bb r505450a 10 10 // Created On : Tue Nov 6 17:54:56 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Sep 7 18:37:41202013 // Update Count : 7212 // Last Modified On : Sun Aug 9 08:05:16 2020 13 // Update Count : 57 14 14 // 15 15 … … 207 207 } // for 208 208 209 // check malloc/resize/free (sbrk)210 211 for ( i; 2 ~ NoOfAllocs ~ 12 ) {212 // initial N byte allocation213 char * area = (char *)malloc( i );214 area[0] = '\345'; area[i - 1] = '\345'; // fill first/penultimate byte215 216 // Do not start this loop index at 0 because resize of 0 bytes frees the storage.217 int prev = i;218 for ( s; i ~ 256 * 1024 ~ 26 ) { // start at initial memory request219 if ( area[0] != '\345' || area[prev - 1] != '\345' ) abort( "malloc/resize/free corrupt storage" );220 area = (char *)resize( area, s ); // attempt to reuse storage221 area[0] = area[s - 1] = '\345'; // fill last byte222 prev = s;223 } // for224 free( area );225 } // for226 227 // check malloc/resize/free (mmap)228 229 for ( i; 2 ~ NoOfAllocs ~ 12 ) {230 // initial N byte allocation231 size_t s = i + default_mmap_start(); // cross over point232 char * area = (char *)malloc( s );233 area[0] = '\345'; area[s - 1] = '\345'; // fill first/penultimate byte234 235 // Do not start this loop index at 0 because resize of 0 bytes frees the storage.236 int prev = s;237 for ( r; s ~ 256 * 1024 ~ 26 ) { // start at initial memory request238 if ( area[0] != '\345' || area[prev - 1] != '\345' ) abort( "malloc/resize/free corrupt storage" );239 area = (char *)resize( area, s ); // attempt to reuse storage240 area[0] = area[r - 1] = '\345'; // fill last byte241 prev = r;242 } // for243 free( area );244 } // for245 246 // check malloc/realloc/free (sbrk)247 248 for ( i; 2 ~ NoOfAllocs ~ 12 ) {249 // initial N byte allocation250 char * area = (char *)malloc( i );251 area[0] = '\345'; area[i - 1] = '\345'; // fill first/penultimate byte252 253 // Do not start this loop index at 0 because realloc of 0 bytes frees the storage.254 int prev = i;255 for ( s; i ~ 256 * 1024 ~ 26 ) { // start at initial memory request256 if ( area[0] != '\345' || area[prev - 1] != '\345' ) abort( "malloc/realloc/free corrupt storage" );257 area = (char *)realloc( area, s ); // attempt to reuse storage258 area[s - 1] = '\345'; // fill last byte259 prev = s;260 } // for261 free( area );262 } // for263 264 // check malloc/realloc/free (mmap)265 266 for ( i; 2 ~ NoOfAllocs ~ 12 ) {267 // initial N byte allocation268 size_t s = i + default_mmap_start(); // cross over point269 char * area = (char *)malloc( s );270 area[0] = '\345'; area[s - 1] = '\345'; // fill first/penultimate byte271 272 // Do not start this loop index at 0 because realloc of 0 bytes frees the storage.273 int prev = s;274 for ( r; s ~ 256 * 1024 ~ 26 ) { // start at initial memory request275 if ( area[0] != '\345' || area[prev - 1] != '\345' ) abort( "malloc/realloc/free corrupt storage" );276 area = (char *)realloc( area, s ); // attempt to reuse storage277 area[r - 1] = '\345'; // fill last byte278 prev = r;279 } // for280 free( area );281 } // for282 283 209 // check calloc/realloc/free (sbrk) 284 210 … … 389 315 area[malloc_size( area ) - 1] != '\0' || 390 316 ! malloc_zero_fill( area ) ) abort( "cmemalign/realloc/free corrupt storage3" ); 391 area[s - 1] = '\345'; // fill last byte392 } // for393 free( area );394 } // for395 396 // check memalign/resize with align/free397 398 amount = 2;399 for ( a; libAlign() ~= limit ~ a ) { // generate powers of 2400 // initial N byte allocation401 char * area = (char *)memalign( a, amount ); // aligned N-byte allocation402 //sout | alignments[a] | area | endl;403 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment404 abort( "memalign/resize with align/free bad alignment : memalign(%d,%d) = %p", (int)a, (int)amount, area );405 } // if406 area[0] = '\345'; area[amount - 2] = '\345'; // fill first/penultimate byte407 408 // Do not start this loop index at 0 because resize of 0 bytes frees the storage.409 for ( s; amount ~ 256 * 1024 ) { // start at initial memory request410 area = (char *)resize( area, a * 2, s ); // attempt to reuse storage411 //sout | i | area | endl;412 if ( (size_t)area % a * 2 != 0 ) { // check for initial alignment413 abort( "memalign/resize with align/free bad alignment %p", area );414 } // if415 317 area[s - 1] = '\345'; // fill last byte 416 318 } // for
Note:
See TracChangeset
for help on using the changeset viewer.