diff options
author | Xin LI <delphij@FreeBSD.org> | 2019-08-08 06:27:39 +0000 |
---|---|---|
committer | Xin LI <delphij@FreeBSD.org> | 2019-08-08 06:27:39 +0000 |
commit | 2b0cabbdaeac61bdb07909cb0ec995aba36e06b0 (patch) | |
tree | 09681899a0ab0e504e1ce2315c719522c1f53579 | |
parent | 56e66ce802ebcc59f6a06bb75253468535356651 (diff) | |
download | src-2b0cabbdaeac61bdb07909cb0ec995aba36e06b0.tar.gz src-2b0cabbdaeac61bdb07909cb0ec995aba36e06b0.zip |
Update geom_uzip to use new zlib:
- Use new zlib headers;
- Removed z_alloc and z_free to use the common sys/dev/zlib version.
- Replace z_compressBound with compressBound from zlib.
While there, limit LZMA CFLAGS to apply only for g_uzip_lzma.c.
PR: 229763
Submitted by: Yoshihiro Ota <ota j email ne jp> (with changes,
bugs are mine)
Differential Revision: https://reviews.freebsd.org/D20271
Notes
Notes:
svn path=/head/; revision=350742
-rw-r--r-- | sys/geom/uzip/g_uzip_zlib.c | 35 | ||||
-rw-r--r-- | sys/modules/geom/geom_uzip/Makefile | 2 |
2 files changed, 5 insertions, 32 deletions
diff --git a/sys/geom/uzip/g_uzip_zlib.c b/sys/geom/uzip/g_uzip_zlib.c index 895c92d1c455..91d97feeca54 100644 --- a/sys/geom/uzip/g_uzip_zlib.c +++ b/sys/geom/uzip/g_uzip_zlib.c @@ -33,7 +33,8 @@ __FBSDID("$FreeBSD$"); #include <sys/systm.h> #include <sys/malloc.h> -#include <sys/zlib.h> +#include <contrib/zlib/zlib.h> +#include <dev/zlib/zcalloc.h> #include <geom/uzip/g_uzip.h> #include <geom/uzip/g_uzip_dapi.h> @@ -46,8 +47,6 @@ struct g_uzip_zlib { z_stream zs; }; -static void *z_alloc(void *, u_int, u_int); -static void z_free(void *, void *); static int g_uzip_zlib_rewind(struct g_uzip_dapi *, const char *); static void @@ -97,26 +96,17 @@ g_uzip_zlib_rewind(struct g_uzip_dapi *zpp, const char *gp_name) return (err); } -static int -z_compressBound(int len) -{ - - return (len + (len >> 12) + (len >> 14) + 11); -} - struct g_uzip_dapi * g_uzip_zlib_ctor(uint32_t blksz) { struct g_uzip_zlib *zp; - zp = malloc(sizeof(struct g_uzip_zlib), M_GEOM_UZIP, M_WAITOK); - zp->zs.zalloc = z_alloc; - zp->zs.zfree = z_free; + zp = malloc(sizeof(struct g_uzip_zlib), M_GEOM_UZIP, M_WAITOK | M_ZERO); if (inflateInit(&zp->zs) != Z_OK) { goto e1; } zp->blksz = blksz; - zp->pub.max_blen = z_compressBound(blksz); + zp->pub.max_blen = compressBound(blksz); zp->pub.decompress = &g_uzip_zlib_decompress; zp->pub.free = &g_uzip_zlib_free; zp->pub.rewind = &g_uzip_zlib_rewind; @@ -126,20 +116,3 @@ e1: free(zp, M_GEOM_UZIP); return (NULL); } - -static void * -z_alloc(void *nil, u_int type, u_int size) -{ - void *ptr; - - ptr = malloc(type * size, M_GEOM_UZIP, M_NOWAIT); - - return (ptr); -} - -static void -z_free(void *nil, void *ptr) -{ - - free(ptr, M_GEOM_UZIP); -} diff --git a/sys/modules/geom/geom_uzip/Makefile b/sys/modules/geom/geom_uzip/Makefile index fde2df177ca2..3aa7ea96cd6d 100644 --- a/sys/modules/geom/geom_uzip/Makefile +++ b/sys/modules/geom/geom_uzip/Makefile @@ -10,7 +10,7 @@ SRCS+= g_uzip.h g_uzip_dapi.h g_uzip_lzma.h g_uzip_zlib.h g_uzip_softc.h \ .PATH: ${SRCTOP}/sys/net -CFLAGS+= -I${SRCTOP}/sys/contrib/xz-embedded/freebsd \ +CFLAGS.g_uzip_lzma.c+= -I${SRCTOP}/sys/contrib/xz-embedded/freebsd \ -I${SRCTOP}/sys/contrib/xz-embedded/linux/lib/xz/ SRCS+= opt_geom.h |