Last active
April 6, 2018 14:55
-
-
Save ethercflow/93264355d98e0c7b6dc194bb2db11c07 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#define NEW_BASE_ADDR 98765 | |
void *mymalloc(size_t size) { | |
return (void *)size; | |
} | |
void myfree(void *ptr) { | |
(void)ptr; | |
} | |
void *myrealloc(void *ptr, size_t size) { | |
myfree(ptr); | |
return (void*)mymalloc(size); | |
} | |
int main(void) { | |
void *ptr = NULL; | |
void *new_ptr = NULL; | |
for (int i = 1; i <= 10; i++) { | |
ptr = mymalloc(i); | |
new_ptr = myrealloc(ptr, NEW_BASE_ADDR + i); | |
myfree(new_ptr); | |
sleep(1); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment