[BusyBox] [patch] Add bunzip2 support to insmod
rob at landley.net
Wed Aug 17 07:10:09 UTC 2005
On Tuesday 16 August 2005 20:50, Stephen Warren wrote:
> Rob Landley wrote:
> > However, you shouldn't have to modify the generic bunzip code when I
> > designed the sucker to be able to uncompress into a buffer. I designed
> > it so read_bunzip reads into a destination buffer that the caller
> > provides and specifies the length of. Don't muck up uncompressStream
> > with a callback and a wrapper function.
> I would have just done that, except, how do I know how large to make the
> output buffer? I didn't see any APIs in the bunzip code to say "given
> this buffer, how big is the decompressed result".
> If there's a way to do that, then I'd prefer it too.
How are you figuring out how much space you need now?
Unless you store the uncompressed size in the file (which you could do),
determining the size requires decompressing it twice. So what the current
code does instead is fill up a temporary buffer a chunk at a time and pass it
back to you until you stop asking for data.
It _can_ do short writes that way, and resume from them with the next call...
More information about the busybox