mirror of
https://github.com/ioacademy-jikim/debugging
synced 2025-06-09 00:46:12 +00:00
20 lines
617 B
C
20 lines
617 B
C
#include <stdlib.h>
|
|
|
|
int main(void)
|
|
{ // All sizes are multiples of 16 -- no slop.
|
|
int* x = realloc(NULL, 800); // equivalent to malloc(800), and ends up
|
|
int* y __attribute__((unused)); // calling Valgrind's (and Massif's) malloc
|
|
|
|
x = realloc(x, 800); // same size
|
|
|
|
x = realloc(x, 400); // smaller
|
|
|
|
x = realloc(x, 1200); // bigger
|
|
|
|
y = realloc(x+10, 1600); // bogus realloc
|
|
|
|
x = realloc(x, 0); // equivalent to free(x), and ends up
|
|
// calling Valgrind's (and Massif's) free
|
|
return 0;
|
|
}
|