This is the mail archive of the libc-alpha@sourceware.org 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]

Re: [RFC] Calling realloc vs. mallo/memcpy/free and _IO_vasprintf.


On Fri, Nov 27, 2015 at 12:38:45AM -0500, Carlos O'Donell wrote:
> I still don't see how realloc is going to be slower since it's just
> one call, and there *might* be enough space in this chunk or the next
> to grow by one byte and that avoids the memcpy.

Agreed, in fact even in the mremap case you mentioned, the
malloc+memcpy+free ought to be slower because you end up calling two
syscalls (mmap followed by munmap) instead of just mremap in case of
realloc.  I don't think there is a situation where realloc calls
mremap and the malloc+memcpy+free combination allocates on the heap.

Siddhesh


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