xref: /linux-tools/perf/uprobe/mallocit.cpp (revision de922be4e919572d28577568db563e691d5e7702)
1 #include <stdio.h>
2 #include <stdlib.h>
3 
4 
5 
6 void *mallocit(int n) {
7     return malloc(n);
8 }
9 char* process(char *p) {
10     int n;
11     if (p) free(p);
12     scanf("%d", &n); if (n==0) return NULL;
13     p = (char *)mallocit(n);
14     return p;
15 }
16 int main() {
17     char *p = NULL;
18     int n;
19     while(1) {
20         p = process(p);
21         if (p==NULL) { printf("Fail to malloc\n"); break; }
22     }
23     return 0;
24 }
25