Bug 497723 - forgot to restore callgrind output cleanup
[valgrind.git] / dhat / tests / basic.c
blob96b2410aa159069c6e48484ddcb785cabb99ecae
1 // Some basic allocations and accesses.
3 #include <stdint.h>
4 #include <stdlib.h>
5 #include <string.h>
6 #include "dhat/dhat.h"
8 int main(void)
10 int64_t* m = malloc(1000);
11 m[0] = 1; // write 8 bytes
12 m[10] = m[1]; // read and write 8 bytes
14 char* c = calloc(1, 2000);
15 for (int i = 0; i < 1000; i++) {
16 c[i + 1000] = c[i]; // read and write 1000 bytes
19 char* r = realloc(m, 3000); // read and write 1000 bytes (memcpy)
20 for (int i = 0; i < 500; i++) {
21 r[i + 2000] = 99; // write 500 bytes
24 c = realloc(c, 1000); // read and write 1000 bytes (memcpy)
26 free(c);
27 // totals: 3008 read, 3516 write
29 // Should be ignored because we're not in ad hoc mode.
30 DHAT_AD_HOC_EVENT(100);
32 return 0;