Momo said:
i m just wondering is there any replacement of using malloc, realloc
and free. Like will i able to make my our version of malloc realloc
and free, if so, any idea how to do it??
any help will be good
There are at least two answers.
First, the Standard answer: No, an implementation of C
is indivisible, and you cannot safely substitute your own
implementations for any of its functions. Some systems
incorporate the entire library into every program as a unit,
and have no way to omit pieces of it to avoid clashes with
functions you've defined. Others are capable of omitting
pieces, but have non-public "back doors" for the library's
internal use; if you provide a memory management package
that meets all the "public" specifications but fails to
provide the implementation-private interfaces, you can get
mysterious breakage in unexpected places.
Second, the practical answer: Many systems *do* permit
various pieces of the C library to be replaced by user-
written functions, and the memory management functions may
well be the most frequently replaced (followed by the math
functions, I'd guess). Common reasons for replacement are
to introduce debugging features (watch for leaks, double-
frees, area overruns, and so on) or for improved efficiency
(when the design point of a "general purpose" implementation
isn't a good match for the needs of the program). It's like
driving faster than the speed limit: illegal, but Everybody
Does It -- and if you use care and enjoy a certain amount of
luck, you'll get to your destination sooner.