/* number of bytes of memory to allocate */ void *malloc(size_t nbytes) { if (nbytes == 0) { return NULL; } #if STRATEGY == 1 return malloc_first(nbytes); #elif STRATEGY == 2 return malloc_best(nbytes); #elif STRATEGY == 3 return malloc_worst(nbytes); #elif STRATEGY == 4 return malloc_quick(nbytes); #else exit(1); #endif }
/* malloc * * malloc returns the start address of dynamically allocated memory. * This is simply a wrapper function that calls the different algorithm * implementations depending on the value of STRATEGY. * */ void *malloc( size_t nbytes) /* number of bytes of memory to allocate */ { if (nbytes == 0) { return NULL; } #if STRATEGY == 1 return malloc_first(nbytes); #elif STRATEGY == 2 return malloc_best(nbytes); #elif STRATEGY == 3 return malloc_worst(nbytes); #elif STRATEGY == 4 return malloc_quick(nbytes); #else exit(1); #endif }