Home | History | Annotate | Download | only in tests
      1 #include <stdlib.h>
      2 
      3 // All sizes are divisible by 16 -- no slop.
      4 
      5 int* ignore1(void)
      6 {
      7    // Allocating/freeing in an ignored function: ignored.
      8    int* ignored_x1 = malloc(400);
      9    int* ignored_x2 = malloc(400);
     10    free(ignored_x2);
     11    return ignored_x1;
     12 }
     13 
     14 void ignore2(int* x, int* ignored_x)
     15 {
     16    // Growing/shrinking a non-ignored block in an ignored function: ignored.
     17    x = realloc(x, 800);
     18    x = realloc(x, 400);
     19 
     20    // Growing/shrinking an ignored block in an ignored function: ignored.
     21    ignored_x = realloc(ignored_x, 800);
     22    ignored_x = realloc(ignored_x, 400);
     23 }
     24 
     25 int main(void)
     26 {
     27    int* x;
     28    int* ignored_x;
     29 
     30    // Not ignored.
     31    x = malloc(400);
     32 
     33    // Get an ignored block.
     34    ignored_x = ignore1();
     35 
     36    // Growing/shrinking a non-ignored block in a non-ignored function:
     37    // not ignored.
     38    x = realloc(x, 800);
     39    x = realloc(x, 400);
     40 
     41    // Growing/shrinking an ignored block in a non-ignored function: ignored.
     42    ignored_x = realloc(ignored_x, 800);
     43    ignored_x = realloc(ignored_x, 400);
     44 
     45    ignore2(x, ignored_x);
     46 
     47    x = realloc(ignored_x, 0);    // equivalent to 'free(ignored_x)'.
     48 
     49    return 0;
     50 }
     51 
     52