Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. #include <assert.h>
  2. #include <string.h>
  3. #include <sys/types.h>
  4. #include <unistd.h>
  5.  
  6.  
  7. void *malloc(size_t size) {
  8. void *p = sbrk(0);
  9. void *request = sbrk(size);
  10. if (request == (void*) -1) {
  11. return NULL; // sbrk failed.
  12. } else {
  13. assert(p == request); // Not thread safe.
  14. return p;
  15. }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement