diff options
author | des <des@FreeBSD.org> | 2008-01-03 17:54:26 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2008-01-03 17:54:26 +0000 |
commit | f836e69a7ed8e00a307d584a3919b53a6b67ce63 (patch) | |
tree | a8c2068a9a89a96837a2923ff4be4030426746af /lib/libarchive/archive_read.c | |
parent | 69daf9ac7f41d56f1d036122980df04659fa111f (diff) | |
download | FreeBSD-src-f836e69a7ed8e00a307d584a3919b53a6b67ce63.zip FreeBSD-src-f836e69a7ed8e00a307d584a3919b53a6b67ce63.tar.gz |
Add an internal utility function to simplify the many, many places where
the number of bytes read is actually not important as long as we have at
least what we ask for. Illustrate its benefits by using it throughout
the ZIP support code, except for the few cases where it doesn't apply.
Approved by: kientzle
Diffstat (limited to 'lib/libarchive/archive_read.c')
-rw-r--r-- | lib/libarchive/archive_read.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/libarchive/archive_read.c b/lib/libarchive/archive_read.c index 8ef839a..1028c5d 100644 --- a/lib/libarchive/archive_read.c +++ b/lib/libarchive/archive_read.c @@ -741,3 +741,14 @@ __archive_read_register_compression(struct archive_read *a, __archive_errx(1, "Not enough slots for compression registration"); return (NULL); /* Never actually executed. */ } + +/* used internally to simplify read-ahead */ +const void * +__archive_read_ahead(struct archive_read *a, size_t len) +{ + const void *h; + + if ((a->decompressor->read_ahead)(a, &h, len) < (ssize_t)len) + return (NULL); + return (h); +} |