Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 14 Oct 2019 15:57:31 +0200
From: Micha Nelissen <nelissen.micha@...il.com>
To: musl@...ts.openwall.com
Subject: Re: [PATCH] Use open_memstream(3) for more efficient asprintf

On 14-10-2019 14:07, Rich Felker wrote:
> - avoiding quadratic-time worst-case (from the memcpy in realloc with
>    linear buffer size growth at each step) or internal fragmentation
>    (from geometric buffer growth at each step). Our current memstream
>    implementation uses linear growth I think so it would be the former
>    (quadratic time)

This seems to imply linear buffer size growth doesn't cause 
fragmentation? In general it does I would assume.

> - avoiding fragmentation produced by realloc

I guess the idea behind the original malloc(GUESS) (and also this 
memstream implementation?) is that it allocates from end of heap, and 
therefore realloc is very cheap: just move end of heap pointer. Although 
in a multi-threaded world this becomes less likely depending on the 
intensity of malloc/realloc usage by other threads.

Micha

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.