Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define L __LINE__
- int
- main()
- {
- void *a[3];
- int r, i, *ip;
- printf("%02d, stack:%p\n", L, &r);
- for (i = 0; i < 3; i++) {
- a[i] = malloc(4096);
- ip = a[i];
- *ip = 123;
- printf("%02d, malloc:%02d=%p\n", L, i, a[i]);
- }
- for (i = 0; i < 3; i++) {
- printf("%02d, free:%02d\n", L, i);
- free(a[i]);
- }
- for (i = 0; i < 3; i++) {
- a[i] = malloc(4096);
- ip = a[i];
- *ip = 123;
- printf("%02d, malloc:%02d=%p\n", L, i, a[i]);
- printf("%02d, free:%02d\n", L, i);
- free(a[i]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment