This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]