arm64 front end: add spec rules for {EQ,NE} after {LOGIC32,LOGIC64}.
[valgrind.git] / memcheck / tests / realloc3.c
blob0c6a5f8a09ad1e109f940070c055ee30903c195f
1 /* For a long time (from Valgrind 1.0 to 1.9.6, AFAICT) when realloc() was
2 called and made a block smaller, or didn't change its size, the
3 ExeContext of the block was not updated; therefore any errors that
4 referred to it would state that it was allocated not by the realloc(),
5 but by the previous malloc() or whatever. While this is true in one
6 sense, it is misleading and not what you'd expect. This test
7 demonstrates this -- 'x' and 'y' are unchanged and shrunk, and their
8 ExeContexts should be updated upon their realloc(). I hope that's clear.
9 */
10 #include <stdlib.h>
12 int main(void)
14 int* x = malloc(5);
15 int* y = malloc(10);
16 int* z = malloc(2);
17 int a, b, c;
19 x = realloc(x, 5); // same size
20 y = realloc(y, 5); // make smaller
21 z = realloc(z, 5); // make bigger
23 a = (x[5] == 0xdeadbeef ? 1 : 0);
24 b = (y[5] == 0xdeadbeef ? 1 : 0);
25 c = (z[5] == 0xdeadbeef ? 1 : 0);
27 return a + b + c;