You should not try to depend on system, library, or compiler-dependent mechanisms. Even if you know that realloc calls malloc on one system / compiler / library, you cannot be sure that it will be handled the same way on other systems.
The question at this point would be what you are trying to achieve. If you need to track memory usage, there are better ways in C ++, for example, setting up a global replacement for the new and delete statements. On some versions of Linux, you can also add interceptors to malloc (never used this function). On other systems, you can use other mechanisms to achieve what you need more safely.
LiKao source share