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] calloc should not duplicate malloc logic.


On 02/21/2014 04:04 PM, OndÅej BÃlka wrote:
Hi,

To make future improvements of allocator simpler we could for now calloc
just call malloc and memset. With that we could omit a changes that
would duplicate malloc changes anyway.

It would temporarily decrease its performance, which is not primary
concern now as we just started release cycle.

I tested the current implementation (well, in 2.18 in Fedora 20), and it does not avoid the memset for large arrays, at least I see an RSS value that matches the size of the allocated array. So I suppose this change is okay because it does not seem likely it adds further breakage for applications which rely on memory overcommit.

> In long time horizon it would improve maintainability and performance,
> my plan now is add a parameter used_by_calloc to internal malloc to
> keep logic together. We could not do it without some refactoring as
> int_malloc now has arena in parameter which is thing that I want to
> deduplicate.

An additional return value from the internal malloc, indicating whether the memory is fresh/zeroed might be more appropriate.

--
Florian Weimer / Red Hat Product Security Team


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