struct vgz * VGZ_NewGzip(struct vsl_log *vsl, const char *id) { struct vgz *vg; int i; vg = vgz_alloc_vgz(vsl, id); vg->dir = VGZ_GZ; VSC_C_main->n_gzip++; /* * From zconf.h: * * mem_needed = "a few kb" * + (1 << (windowBits+2)) * + (1 << (memLevel+9)) * * windowBits [8..15] (-> 1K..128K) * memLevel [1..9] (-> 1K->256K) */ i = deflateInit2(&vg->vz, cache_param->gzip_level, /* Level */ Z_DEFLATED, /* Method */ 16 + 15, /* Window bits (16=gzip) */ cache_param->gzip_memlevel, /* memLevel */ Z_DEFAULT_STRATEGY); assert(Z_OK == i); return (vg); }
struct vgz * VGZ_NewGzip(struct vsl_log *vsl, const char *id) { struct vgz *vg; int i; vg = vgz_alloc_vgz(vsl, id); vg->dir = VGZ_GZ; VSC_C_main->n_gzip++; /* * From zconf.h: * * mem_needed = "a few kb" * + (1 << (windowBits+2)) * + (1 << (memLevel+9)) * * windowBits [8..15] (-> 1K..128K) * memLevel [1..9] (-> 1K->256K) * * XXX: They probably needs to be params... * * XXX: It may be more efficent to malloc them, rather than have * XXX: too many worker threads grow the stacks. */ i = deflateInit2(&vg->vz, cache_param->gzip_level, /* Level */ Z_DEFLATED, /* Method */ 16 + 15, /* Window bits (16=gzip) */ cache_param->gzip_memlevel, /* memLevel */ Z_DEFAULT_STRATEGY); assert(Z_OK == i); return (vg); }
static struct vgz * VGZ_NewUngzip(struct vsl_log *vsl, const char *id) { struct vgz *vg; vg = vgz_alloc_vgz(vsl, id); vg->dir = VGZ_UN; VSC_C_main->n_gunzip++; /* * Max memory usage according to zonf.h: * mem_needed = "a few kb" + (1 << (windowBits)) * Since we don't control windowBits, we have to assume * it is 15, so 34-35KB or so. */ assert(Z_OK == inflateInit2(&vg->vz, 31)); return (vg); }