Today, I appeared for an interview and the interviewer asked me this,
- Tell me the steps how will you design your own
f
Tell me the steps how will you design your own free( ) function for deallocate the allocated memory.
#include
#undef free
#define free(X) my_free(X)
inline void my_free(void *ptr) { }
How can it be more efficient than C's default free() function ?
It is extremely fast, requiring zero machine cycles. It also makes use-after-free bugs go away. It's a very useful free function for use in programs which are instantiated as short-lived batch processes; it can usefully be deployed in some production situations.
What can you conclude ?
I really want this job, but in another company.