Lasse Collin dixit:

>There's also calloc, but with a quick and inaccurate test with glibc,
>it doesn't seem faster than malloc+memset.

With omalloc I know it’s implemented the same as malloc
for allocations larger than the threshold of calling mmap
(IIRC, a page size).

If xz does indeed know it needs a zero’d allocation and
can express that in page sizes (pretty non-portable),
_and_ has fallback code for mmap-less architectutes (e.g.
several POSIX-for-Windows systems or ancient OSes) then
sure. But I’d say, leave malloc speedups to the OS. Or
the porter; they should know what they do.

(calloc is indeed faster than malloc+memset here for
large allocations. About 1750 vs. 20 milliseconds.)

bye,
//mirabilos
-- 
  “Having a smoking section in a restaurant is like having
          a peeing section in a swimming pool.”
                                                -- Edward Burr

Reply via email to