I am reading the source code of the drive's memory allocator, and the following code is in the gnuwrapper.cpp file
#define CUSTOM_MALLOC(x) CUSTOM_PREFIX(malloc)(x)
What is the value of CUSTOM_PREFIX(malloc)(x) ? is there a CUSTOM_PREFIX function? But as a function, it was not defined anywhere. If a variable, then how can we use a variable of type var(malloc)(x) ?
More code:
#ifndef __GNUC__ #error "This file requires the GNU compiler." #endif #include <string.h> #include <stdlib.h> #include <stdio.h> #include <malloc.h> #ifndef CUSTOM_PREFIX ==> here looks like it a variable, so if it doesn't define, then define here. #define CUSTOM_PREFIX #endif #define CUSTOM_MALLOC(x) CUSTOM_PREFIX(malloc)(x) ===> what the meaning of this? #define CUSTOM_FREE(x) CUSTOM_PREFIX(free)(x) #define CUSTOM_REALLOC(x,y) CUSTOM_PREFIX(realloc)(x,y) #define CUSTOM_MEMALIGN(x,y) CUSTOM_PREFIX(memalign)(x,y)
source share