This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
realloc without moving?
- From: chris <caj at cs dot york dot ac dot uk>
- To: libc-alpha at sources dot redhat dot com
- Date: Thu, 28 Oct 2004 22:24:56 +0100
- Subject: realloc without moving?
Hello.
Is there a function in glibc like realloc, except in the case where it
is not possible to extend the existing memory then instead of allocating
a new block of memory and copying the old block into this area the
function simply returns?
This would be very useful in C++ (and I imagine in some cases of C as
well) as if an existing memory block cannot be extended, then in general
we cannot simply bitcopy the classes into a new block, but must instead
allocate a new block and use the class's copy constructors to move them
into the new block. Similarily in C if a large complex data structure
containing many pointers lived within an allocated block of memory then
it probably cannot simply be copied bitwise but must be reassembled in
the new memory segment.
Thank you,
Chris