nus/cs2106/labs/lab4/linkedlist/mymalloc.c

26 lines
570 B
C

#include <stdio.h>
#include <stdlib.h>
#include "mymalloc.h"
char _heap[MEMSIZE] = {0};
TNode *_memlist = NULL; // To maintain information about length
// Do not change this. Used by the test harness.
// You may however use this function in your code if necessary.
long get_index(void *ptr) {
if(ptr == NULL)
return -1;
else
return (long) ((char *) ptr - &_heap[0]);
}
// Allocates size bytes of memory and returns a pointer
// to the first byte.
void *mymalloc(size_t size) {
}
// Frees memory pointer to by ptr.
void myfree(void *ptr) {
}