From what is written here, new
allocates in free store while malloc
uses heap and the two terms often mean the same thing.
The only possibly relevant restriction C++ adds to realloc
is that C++'s malloc
/calloc
/realloc
must not be implemented in terms of ::operator new
, and its free
must not be implemented in terms of ::operator delete
(per C++14 [c.malloc]p3-4).
This means the guarantee you are looking for does not exist in C++. It also means, however, that you can implement ::operator new
in terms of malloc
. And if you do that, then in theory, ::operator new
's result can be passed to realloc
.
In practice, you should be concerned about the possibility that new
's result does not match ::operator new
's result. C++ compilers may e.g. combine multiple new
expressions to use one single ::operator new
call. This is something compilers already did when the standard didn't allow it, IIRC, and the standard now does allow it (per C++14 [expr.new]p10). That means that even if you go this route, you still don't have a guarantee that passing your new
pointers to realloc
does anything meaningful, even if it's no longer undefined behaviour.