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: [PATCH v2 1/3] Fix __check_pf()/make_request() stack overflow segfault (convert to malloc)


On Fri, Jan 17, 2014 at 01:22:46AM +0100, OndÅej BÃlka wrote:
> which only copies list into malloced array while preserving ordering.
> 
> A better way would be to malloc result at start and write into in6ai
> array directly, calling realloc to double size as necessary. At end we
> could optionally trim memory at end.
> 
> This should also be more effective as one big copy is faster when you
> need to copy same amount of data in small chunks.

Interface configuration shouldn't change all the time, so the
reallocation event ought to be infrequent enough that we need not
worry about it.  In fact in the common case of the interfaces not
changing, we should end up with just one allocation, with subsequent
getaddrinfo calls resulting in only copies.

nscd makes this even better by caching the interfaces so that the
query itself is avoided.

Siddhesh


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