From: "H. Peter Anvin" <hpa@zytor.com>
To: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Andi Kleen <ak@suse.de>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Matt Mackall <mpm@selenic.com>
Subject: Re: [PATCH] deflate inflate_dynamic too
Date: Mon, 07 May 2007 13:53:03 -0700 [thread overview]
Message-ID: <463F91AF.6060005@zytor.com> (raw)
In-Reply-To: <463F8C22.40902@goop.org>
Jeremy Fitzhardinge wrote:
> H. Peter Anvin wrote:
>> It might be worth reverting some of the code back to the zlib original.
>> The use of stack allocations here is actually a Linux divergence from
>> zlib (done by Linus), in order to reduce the number of dynamic allocations.
>>
>> In general, the use of dynamic allocations is highly dangerous, because
>> any time you have dynamic allocations you have the choice of either
>> sleeping or failing, unless you have a pre-reserved memory pool.
>>
>
> Well, every time this code is instantiated, it gets its own malloc/free
> definitions, so they can decide how to handle the dynamic allocations.
> Seems better than assuming that every caller will have enough stack
> space. If you want to approximate that, it would be easy enough to have
> a stack-like malloc/free, in which freeing the last allocation will
> always release space.
Indeed, however, the point still holds:
- Going to something more like the upstream zlib code makes it
worthwhile to see whatever else should be merged;
- Users must be audited for correctness.
In particular, it would be good to have a "preallocate me enough memory
so it can be guaranteed that this will succeed" operation.
-hpa
prev parent reply other threads:[~2007-05-07 20:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-28 2:20 [PATCH] deflate inflate_dynamic too Jeremy Fitzhardinge
2007-04-28 16:22 ` Matt Mackall
2007-05-07 18:34 ` H. Peter Anvin
2007-05-07 20:29 ` Jeremy Fitzhardinge
2007-05-07 20:53 ` H. Peter Anvin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=463F91AF.6060005@zytor.com \
--to=hpa@zytor.com \
--cc=ak@suse.de \
--cc=akpm@linux-foundation.org \
--cc=jeremy@goop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mpm@selenic.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox