Skip to content

Instantly share code, notes, and snippets.

@ethercflow
Last active April 6, 2018 14:55
Show Gist options
  • Save ethercflow/93264355d98e0c7b6dc194bb2db11c07 to your computer and use it in GitHub Desktop.
Save ethercflow/93264355d98e0c7b6dc194bb2db11c07 to your computer and use it in GitHub Desktop.
#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;
}
@ethercflow
Copy link
Author

ethercflow commented Apr 6, 2018

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment