Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <assert.h>
- #include <string.h>
- #include <sys/types.h>
- #include <unistd.h>
- void *malloc(size_t size) {
- void *p = sbrk(0);
- void *request = sbrk(size);
- if (request == (void*) -1) {
- return NULL; // sbrk failed.
- } else {
- assert(p == request); // Not thread safe.
- return p;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement