本文整理汇总了C++中deflateInit2函数的典型用法代码示例。如果您正苦于以下问题:C++ deflateInit2函数的具体用法?C++ deflateInit2怎么用?C++ deflateInit2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了deflateInit2函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: codec_gzip_create
/**
* \brief Create a cipher \c codec_t object
*
* Create a gzip \c codec_t object at \p *piz suitable for compression or
* decompression (depending on \p op).
*
* \param op one of \c GZIP_COMPRESS or \c GZIP_UNCOMPRESS
* \param piz the created codec as a value-result arguement
*
* \return \c 0 on success, \c ~0 otherwise
*/
int codec_gzip_create(int op, codec_t **piz)
{
codec_gzip_t *iz = NULL;
dbg_return_if (piz == NULL, ~0);
iz = u_zalloc(sizeof(codec_gzip_t));
dbg_err_if(iz == NULL);
iz->codec.transform = gzip_transform;
iz->codec.flush = gzip_flush;
iz->codec.free = gzip_free;
iz->action = op;
switch(op)
{
case GZIP_COMPRESS:
iz->op = deflate;
iz->opEnd = deflateEnd;
dbg_err_if(deflateInit2(&iz->zstr, Z_DEFAULT_COMPRESSION, Z_DEFLATED,
-MAX_WBITS, 8, Z_DEFAULT_STRATEGY));
break;
case GZIP_UNCOMPRESS:
iz->op = inflate;
iz->opEnd = inflateEnd;
dbg_err_if(inflateInit2(&iz->zstr, -MAX_WBITS) != Z_OK);
break;
default:
dbg_err_if("bad gzip op");
}
*piz = (codec_t*)iz;
return 0;
err:
U_FREE(iz);
return ~0;
}
开发者ID:DanielTillett,项目名称:klone,代码行数:49,代码来源:gzip.c
示例2: shooter_compress
int shooter_compress(const char* src, int srcLen, char* dst, int dstLen)
{
z_stream strm;
// zalloc, zfree, opaque, use default
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
strm.avail_in = srcLen;
strm.avail_out = dstLen;
strm.next_in = (Bytef*)src;
strm.next_out = (Bytef*)dst;
int err = -1;
// init z_stream
// deflateInit:zlib, deflateInit2:gzip
// err = deflateInit(&strm, Z_DEFAULT_COMPRESSION);
err = deflateInit2(&strm, Z_DEFAULT_COMPRESSION, Z_DEFLATED, MAX_WBITS + 16, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY);
if (err == Z_OK) {
err = deflate(&strm, Z_FINISH);
if (err == Z_STREAM_END) {
deflateEnd(&strm);
return dstLen - strm.avail_out;
}
else {
deflateEnd(&strm);
m_ErrMsg = "compression failed, deflate return: ";
return -1;
}
}
else {
(void)deflateEnd(&strm);
m_ErrMsg = "compression initialization failed, quit!";
return 0;
}
}
开发者ID:vashstorm,项目名称:shooter_c,代码行数:38,代码来源:compress.c
示例3: gzip_body
static void
gzip_body(const struct http *hp, const char *txt, char **body, int *bodylen)
{
int l, i;
z_stream vz;
memset(&vz, 0, sizeof vz);
l = strlen(txt);
*body = calloc(l + OVERHEAD, 1);
AN(*body);
vz.next_in = TRUST_ME(txt);
vz.avail_in = l;
vz.next_out = TRUST_ME(*body);
vz.avail_out = l + OVERHEAD;
assert(Z_OK == deflateInit2(&vz,
hp->gziplevel, Z_DEFLATED, 31, 9, Z_DEFAULT_STRATEGY));
assert(Z_STREAM_END == deflate(&vz, Z_FINISH));
i = vz.stop_bit & 7;
if (hp->gzipresidual >= 0 && hp->gzipresidual != i)
vtc_log(hp->vl, hp->fatal,
"Wrong gzip residual got %d wanted %d",
i, hp->gzipresidual);
*bodylen = vz.total_out;
vtc_log(hp->vl, 4, "startbit = %ju %ju/%ju",
(uintmax_t)vz.start_bit,
(uintmax_t)vz.start_bit >> 3, (uintmax_t)vz.start_bit & 7);
vtc_log(hp->vl, 4, "lastbit = %ju %ju/%ju",
(uintmax_t)vz.last_bit,
(uintmax_t)vz.last_bit >> 3, (uintmax_t)vz.last_bit & 7);
vtc_log(hp->vl, 4, "stopbit = %ju %ju/%ju",
(uintmax_t)vz.stop_bit,
(uintmax_t)vz.stop_bit >> 3, (uintmax_t)vz.stop_bit & 7);
assert(Z_OK == deflateEnd(&vz));
}
开发者ID:daghf,项目名称:varnish-cache-oldfork,代码行数:38,代码来源:vtc_http.c
示例4: xxx
void
xxx(void)
{
z_stream vz;
int n;
char ibuf[200];
char obuf[200];
int fl[8];
int i, j;
for (n = 0; n < 8; n++)
fl[n] = 9999;
memset(&vz, 0, sizeof vz);
for(n = 0; n < 999999999; n++) {
*ibuf = 0;
for (j = 0; j < 7; j++) {
sprintf(strchr(ibuf, 0), "%x",
(unsigned)random() & 0xffff);
vz.next_in = TRUST_ME(ibuf);
vz.avail_in = strlen(ibuf);
vz.next_out = TRUST_ME(obuf);
vz.avail_out = sizeof obuf;
assert(Z_OK == deflateInit2(&vz,
9, Z_DEFLATED, 31, 9, Z_DEFAULT_STRATEGY));
assert(Z_STREAM_END == deflate(&vz, Z_FINISH));
i = vz.stop_bit & 7;
if (fl[i] > strlen(ibuf)) {
printf("%d %jd <%s>\n", i, vz.stop_bit, ibuf);
fl[i] = strlen(ibuf);
}
assert(Z_OK == deflateEnd(&vz));
}
}
printf("FOO\n");
}
开发者ID:midnightskinhead,项目名称:Varnish-Cache,代码行数:38,代码来源:vtc_http.c
示例5: PyZlib_compressobj
static PyObject *
PyZlib_compressobj(PyObject *selfptr, PyObject *args)
{
compobject *self;
int level=Z_DEFAULT_COMPRESSION, method=DEFLATED;
int wbits=MAX_WBITS, memLevel=DEF_MEM_LEVEL, strategy=0, err;
if (!PyArg_ParseTuple(args, "|iiiii:compressobj", &level, &method, &wbits,
&memLevel, &strategy))
return NULL;
self = newcompobject(&Comptype);
if (self==NULL)
return(NULL);
self->zst.zalloc = (alloc_func)NULL;
self->zst.zfree = (free_func)Z_NULL;
self->zst.next_in = NULL;
self->zst.avail_in = 0;
err = deflateInit2(&self->zst, level, method, wbits, memLevel, strategy);
switch(err) {
case (Z_OK):
self->is_initialised = 1;
return (PyObject*)self;
case (Z_MEM_ERROR):
Py_DECREF(self);
PyErr_SetString(PyExc_MemoryError,
"Can't allocate memory for compression object");
return NULL;
case(Z_STREAM_ERROR):
Py_DECREF(self);
PyErr_SetString(PyExc_ValueError, "Invalid initialization option");
return NULL;
default:
zlib_error(self->zst, err, "while creating compression object");
Py_DECREF(self);
return NULL;
}
}
开发者ID:Oize,项目名称:pspstacklesspython,代码行数:38,代码来源:zlibmodule.c
示例6: gz_init
/* Initialize state for writing a gzip file. Mark initialization by setting
state->size to non-zero. Return -1 on failure or 0 on success. */
local int gz_init(gz_statep state)
{
int ret;
z_streamp strm = &(state->strm);
/* allocate input and output buffers */
state->in = (unsigned char *)malloc(state->want);
state->out = (unsigned char *)malloc(state->want);
if (state->in == NULL || state->out == NULL) {
if (state->out != NULL)
free(state->out);
if (state->in != NULL)
free(state->in);
gz_error(state, Z_MEM_ERROR, "out of memory");
return -1;
}
/* allocate deflate memory, set up for gzip compression */
strm->zalloc = Z_NULL;
strm->zfree = Z_NULL;
strm->opaque = Z_NULL;
ret = deflateInit2(strm, state->level, Z_DEFLATED,
15 + 16, 8, state->strategy);
if (ret != Z_OK) {
free(state->in);
gz_error(state, Z_MEM_ERROR, "out of memory");
return -1;
}
/* mark state as initialized */
state->size = state->want;
/* initialize write buffer */
strm->avail_out = state->size;
strm->next_out = state->out;
state->next = strm->next_out;
return 0;
}
开发者ID:kyotobay,项目名称:ABC_withFD_check,代码行数:40,代码来源:gzwrite.c
示例7: Zlib_compress
// ------ Extern function implementation -------
bool
Zlib_compress (
Zlib *self,
void *data,
size_t dataSize
) {
z_stream stream;
stream.next_in = data;
stream.avail_in = dataSize;
stream.avail_out = sizeof (self->buffer);
stream.next_out = self->buffer;
stream.total_in = 0;
stream.total_out = 0;
stream.zalloc = 0;
stream.zfree = 0;
int result;
if ((result = deflateInit2 (&stream, 1, Z_DEFLATED, -15, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY)) != Z_OK) {
warning ("Can't init compression : error code = %x.", result);
return false;
}
if ((result = deflate (&stream, Z_FINISH) != Z_STREAM_END)) {
warning ("Can't compress : error code = %x.", result);
return false;
}
if ((result = deflateEnd (&stream) != Z_OK)) {
warning ("Can't end compression : error code = %x", result);
return false;
}
self->header.magic = ZLIB_MAGIC_HEADER;
self->header.size = stream.total_out;
return true;
}
开发者ID:Tachiorz,项目名称:R1EMU,代码行数:39,代码来源:zlib.c
示例8: ContentReaderState
ContentReaderState(RESTContentReaderCallback callback_write,
RESTRequestFree callback_free,
void* callback_data,
bool gzip = false)
: callback_write_(callback_write),
callback_free_(callback_free),
callback_data_(callback_data),
gzip_(gzip),
callback_finished_(false),
z_finished_(false)
{
if (gzip_)
{
zstrm_.zalloc = Z_NULL;
zstrm_.zfree = Z_NULL;
zstrm_.opaque = Z_NULL;
/* NOTE: adding 16 to 'windowBits' parameter enables gzip compression */
int rc = deflateInit2(&zstrm_, Z_DEFAULT_COMPRESSION, Z_DEFLATED, 16 + 15, 8, Z_DEFAULT_STRATEGY);
if (rc != Z_OK)
throw std::runtime_error("Illegal state: failed to initialize zlib");
}
}
开发者ID:Yale-LANS,项目名称:ALTO,代码行数:23,代码来源:rest_request_state.cpp
示例9: Java_java_util_zip_Deflater_make
extern "C" JNIEXPORT jlong JNICALL
Java_java_util_zip_Deflater_make(JNIEnv* e,
jclass,
jboolean nowrap,
jint level)
{
z_stream* s = static_cast<z_stream*>(malloc(sizeof(z_stream)));
if (s == 0) {
throwNew(e, "java/lang/OutOfMemoryError", 0);
return 0;
}
memset(s, 0, sizeof(z_stream));
int r = deflateInit2(s, level, (nowrap ? -15 : 15));
if (r != Z_OK) {
free(s);
throwNew(e, "java/lang/RuntimeException", zError(r));
return 0;
}
return reinterpret_cast<jlong>(s);
}
开发者ID:FirstGitHubID,项目名称:avian,代码行数:23,代码来源:java-util-zip.cpp
示例10: zip
int zip(u_char *in, int size, u_char *out, int maxsz) {
z_stream z;
int ret;
z.zalloc = (alloc_func)0;
z.zfree = (free_func)0;
z.opaque = (voidpf)0;
if(deflateInit2(&z, Z_BEST_COMPRESSION, Z_DEFLATED, 15, 9, Z_DEFAULT_STRATEGY)) {
fputs("\nError: zlib initialization error\n", stdout);
exit(1);
}
z.next_in = in;
z.avail_in = size;
z.next_out = out;
z.avail_out = maxsz;
deflate(&z, Z_FINISH);
ret = z.total_out;
deflateEnd(&z);
return(ret);
}
开发者ID:ALurker,项目名称:exploit-database,代码行数:23,代码来源:1285.c
示例11: lz_deflate_new
static int lz_deflate_new(lua_State *L) {
int level = luaL_optint(L, 1, Z_DEFAULT_COMPRESSION);
int window_size = luaL_optint(L, 2, MAX_WBITS);
/* Allocate the stream: */
z_stream* stream = (z_stream*)lua_newuserdata(L, sizeof(z_stream));
stream->zalloc = Z_NULL;
stream->zfree = Z_NULL;
int result = deflateInit2(stream, level, Z_DEFLATED, window_size,
DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);
lz_assert(L, result, stream, __FILE__, __LINE__);
/* Don't allow destructor to execute unless deflateInit2 was successful: */
luaL_getmetatable(L, "lz.deflate.meta");
lua_setmetatable(L, -2);
lua_pushnil(L);
lua_pushcclosure(L, lz_deflate, 2);
return 1;
}
开发者ID:zhangjinde,项目名称:QSF,代码行数:23,代码来源:lua_zlib.c
示例12: BufferedStreamBuf
DeflatingStreamBuf::DeflatingStreamBuf(std::ostream& ostr, StreamType type, int level):
BufferedStreamBuf(STREAM_BUFFER_SIZE, std::ios::out),
_pIstr(0),
_pOstr(&ostr),
_eof(false)
{
_zstr.zalloc = Z_NULL;
_zstr.zfree = Z_NULL;
_zstr.opaque = Z_NULL;
_zstr.next_in = 0;
_zstr.avail_in = 0;
_zstr.next_out = 0;
_zstr.avail_out = 0;
_buffer = new char[DEFLATE_BUFFER_SIZE];
int rc = deflateInit2(&_zstr, level, Z_DEFLATED, 15 + (type == STREAM_GZIP ? 16 : 0), 8, Z_DEFAULT_STRATEGY);
if (rc != Z_OK)
{
delete [] _buffer;
throw IOException(zError(rc));
}
}
开发者ID:Adoni,项目名称:WiEngine,代码行数:23,代码来源:DeflatingStream.cpp
示例13: GZipWriteStream
GZipWriteStream(Common::WriteStream *w) : _wrapped(w) {
assert(w != 0);
_stream.zalloc = Z_NULL;
_stream.zfree = Z_NULL;
_stream.opaque = Z_NULL;
// Adding 16 to windowBits indicates to zlib that it is supposed to
// write gzip headers. This feature was added in zlib 1.2.0.4,
// released 10 August 2003.
// Note: This is *crucial* for savegame compatibility, do *not* remove!
_zlibErr = deflateInit2(&_stream,
Z_DEFAULT_COMPRESSION,
Z_DEFLATED,
MAX_WBITS + 16,
8,
Z_DEFAULT_STRATEGY);
assert(_zlibErr == Z_OK);
_stream.next_out = _buf;
_stream.avail_out = BUFSIZE;
_stream.avail_in = 0;
_stream.next_in = 0;
}
开发者ID:St0rmcrow,项目名称:scummvm,代码行数:23,代码来源:zlib.cpp
示例14: Java_java_util_zip_Deflater_init
JNIEXPORT jlong JNICALL
Java_java_util_zip_Deflater_init(JNIEnv *env, jclass cls, jint level,
jint strategy, jboolean nowrap)
{
z_stream *strm = calloc(1, sizeof(z_stream));
if (strm == 0) {
JNU_ThrowOutOfMemoryError(env, 0);
return jlong_zero;
} else {
const char *msg;
int ret = deflateInit2(strm, level, Z_DEFLATED,
nowrap ? -MAX_WBITS : MAX_WBITS,
DEF_MEM_LEVEL, strategy);
switch (ret) {
case Z_OK:
return ptr_to_jlong(strm);
case Z_MEM_ERROR:
free(strm);
JNU_ThrowOutOfMemoryError(env, 0);
return jlong_zero;
case Z_STREAM_ERROR:
free(strm);
JNU_ThrowIllegalArgumentException(env, 0);
return jlong_zero;
default:
msg = ((strm->msg != NULL) ? strm->msg :
(ret == Z_VERSION_ERROR) ?
"zlib returned Z_VERSION_ERROR: "
"compile time and runtime zlib implementations differ" :
"unknown error initializing zlib library");
free(strm);
JNU_ThrowInternalError(env, msg);
return jlong_zero;
}
}
}
开发者ID:JetBrains,项目名称:jdk8u_jdk,代码行数:37,代码来源:Deflater.c
示例15: terminate
bool KGzipFilter::init(int mode, Flag flag)
{
if (d->isInitialized) {
terminate();
}
d->zStream.next_in = Z_NULL;
d->zStream.avail_in = 0;
if ( mode == QIODevice::ReadOnly )
{
const int windowBits = (flag == RawDeflate)
? -MAX_WBITS /*no zlib header*/
: (flag == GZipHeader) ?
MAX_WBITS + 32 /* auto-detect and eat gzip header */
: MAX_WBITS /*zlib header*/;
const int result = inflateInit2(&d->zStream, windowBits);
if ( result != Z_OK ) {
//qDebug() << "inflateInit2 returned " << result;
return false;
}
} else if ( mode == QIODevice::WriteOnly )
{
int result = deflateInit2(&d->zStream, Z_DEFAULT_COMPRESSION, Z_DEFLATED, -MAX_WBITS, 8, Z_DEFAULT_STRATEGY); // same here
if ( result != Z_OK ) {
//qDebug() << "deflateInit returned " << result;
return false;
}
} else {
//qWarning() << "KGzipFilter: Unsupported mode " << mode << ". Only QIODevice::ReadOnly and QIODevice::WriteOnly supported";
return false;
}
d->mode = mode;
d->compressed = true;
d->headerWritten = false;
d->footerWritten = false;
d->isInitialized = true;
return true;
}
开发者ID:02JanDal,项目名称:soqute,代码行数:37,代码来源:kgzipfilter.cpp
示例16: ZLibCompressChunk
int ZLibCompressChunk(byte *in, int len_in, byte *out, int len_out, int method, int wbits)
{
z_stream zs;
int result;
zs.next_in = in;
zs.avail_in = len_in;
zs.total_in = 0;
zs.next_out = out;
zs.avail_out = len_out;
zs.total_out = 0;
zs.msg = NULL;
zs.state = NULL;
zs.zalloc = Z_NULL;
zs.zfree = Z_NULL;
zs.opaque = NULL;
zs.data_type = Z_BINARY;
zs.adler = 0;
zs.reserved = 0;
result = deflateInit2 (&zs, method, Z_DEFLATED, wbits, 9, Z_DEFAULT_STRATEGY);
if (result != Z_OK)
return -1;
result = deflate(&zs, Z_FINISH);
if (result != Z_STREAM_END)
return -1;
result = deflateEnd(&zs);
if (result != Z_OK)
return -1;
return zs.total_out;
}
开发者ID:chrisnew,项目名称:quake2,代码行数:37,代码来源:common.c
示例17: deflateInit2
struct _writer *deflatewriter_init(struct _writer *parent, unsigned char type) {
struct _deflatewriter *ret = (struct _deflatewriter*)_xalloc(sizeof(struct _deflatewriter));
int windowBits;
int err;
ret->base.destroy = &deflatewriter_destroy;
ret->base.write = &deflatewriter_write;
ret->base.resize = &deflatewriter_resize;
ret->base.seek = &deflatewriter_seek;
ret->base.tell = &deflatewriter_tell;
ret->base.error = 0;
ret->stream.zalloc = (alloc_func)&_deflatewriter_zalloc_func;
ret->stream.zfree = (free_func)&_deflatewriter_zfree_func;
ret->stream.opaque = (voidpf)ret;
ret->stream.next_in = Z_NULL;
ret->stream.avail_in = 0;
ret->parent = parent;
if (type == 255)
windowBits = -DEFLATEWRITER_WINDOW_BITS;
else
windowBits = DEFLATEWRITER_WINDOW_BITS + (int)type * 16;
err = deflateInit2(&ret->stream,
DEFLATEWRITER_LEVEL,
DEFLATEWRITER_METHOD,
windowBits,
DEFLATEWRITER_MEM_LEVEL,
DEFLATEWRITER_STRATEGY);
if (err != Z_OK) {
_deflatewriter_zerror("init",err);
ret->base.error = 1;
}
return(CAST_DOWN(ret,base));
}
开发者ID:MoeXi,项目名称:roint,代码行数:37,代码来源:deflatewriter.c
示例18: deflateInit2
std::vector<char> QblZlib::compress(std::vector<char> data)
{
std::vector<char> result;
int retval;
this->stream.next_in = Z_NULL;
this->stream.avail_in = 0;
retval = deflateInit2(&this->stream, Z_DEFAULT_COMPRESSION, Z_DEFLATED,
windowBits | GZIP_ENCODING, 8, Z_DEFAULT_STRATEGY);
if (retval < 0) {
this->errorMessage(retval);
}
this->stream.next_in = (unsigned char *)data.data();
this->stream.avail_in = data.size();
do {
int n, retval;
unsigned char buffer[CHUNK];
std::vector<char> _buffer;
this->stream.avail_out = CHUNK;
this->stream.next_out = buffer;
retval = deflate(&this->stream, Z_FINISH);
if (retval < 0) {
(void)deflateEnd(&this->stream);
this->errorMessage(retval);
}
n = CHUNK - this->stream.avail_out;
_buffer.insert(_buffer.begin(), buffer, buffer + n);
result.insert(result.end(), _buffer.begin(), _buffer.end());
} while (this->stream.avail_out == 0);
(void)deflateEnd(&this->stream);
return (result);
}
开发者ID:f-porter,项目名称:qabel-lib,代码行数:37,代码来源:qbl-zlib.cpp
示例19: CreateZStream
ZStream *
CreateZStream (gint compress, guchar gzip, read_write_func func, void *gchandle)
{
z_stream *z;
gint retval;
ZStream *result;
if (func == NULL)
return NULL;
#if !defined(ZLIB_VERNUM) || (ZLIB_VERNUM < 0x1204)
/* Older versions of zlib do not support raw deflate or gzip */
return NULL;
#endif
z = g_new0 (z_stream, 1);
if (compress) {
retval = deflateInit2 (z, Z_DEFAULT_COMPRESSION, Z_DEFLATED, gzip ? 31 : -15, 8, Z_DEFAULT_STRATEGY);
} else {
retval = inflateInit2 (z, gzip ? 31 : -15);
}
if (retval != Z_OK) {
g_free (z);
return NULL;
}
z->zalloc = z_alloc;
z->zfree = z_free;
result = g_new0 (ZStream, 1);
result->stream = z;
result->func = func;
result->gchandle = gchandle;
result->compress = compress;
result->buffer = g_new (guchar, BUFFER_SIZE);
return result;
}
开发者ID:ANahr,项目名称:mono,代码行数:36,代码来源:zlib-helper.c
示例20: zlib_deflate_init2
/**
* OCaml binding for _zlib_'s `deflateInit2` function.
*
* This creates a new stream and initializes it for deflate.
*
* This function may raise the following OCaml exceptions:
* - Out_of_memory exception
* - Failure exception: Invalid parameters
* - Failure exception: Invalid version
* - Failure exception: Unknown zlib return code
*
* See:
* https://github.com/madler/zlib/blob/cacf7f1d4e3d44d871b605da3b647f07d718623f/zlib.h#L538
*
* @param levelVal {value} OCaml `int`: the compression level, must be in the range 0..9.
* 0 gives no compression at all, 1 the best speed, 9 the best compression.
* @param windowBitsVal {value} OCaml `int`: base two logarithm of the window size (size of the
* history buffer) used by _zlib_. It should be in the range 9..15 for this version of _zlib_.
* It can also be in the range -15..-8 (the absolute value is used) for raw deflate.
* Finally, it can be greater than 15 for gzip encoding. See _zlib_'s documentation for
* `deflateInit2` for the exact documentation.
* @return {value} An OCaml value representing the new stream, initialized for deflate.
*/
CAMLprim value zlib_deflate_init2(value level_val, value window_bits_val) {
int level = Int_val(level_val);
int window_bits = Int_val(window_bits_val);
value z_streamp_val = zlib_new_stream();
z_streamp stream = ZStreamP_val(z_streamp_val);
int deflate_init2_result = deflateInit2(
stream,
level,
Z_DEFLATED, // method
window_bits,
8, // memLevel
Z_DEFAULT_STRATEGY // strategy
);
if (deflate_init2_result == Z_OK) {
return z_streamp_val;
}
switch (deflate_init2_result) {
case Z_MEM_ERROR:
caml_raise_out_of_memory();
break;
case Z_STREAM_ERROR:
// TODO: use stream->msg to get _zlib_'s text message
failwith("Error in `zlib_deflate_init2` (extc_stubs.c): call to `deflateInit2` failed: Z_STREAM_ERROR");
break;
case Z_VERSION_ERROR:
// TODO: use stream->msg to get _zlib_'s text message
failwith("Error in `zlib_deflate_init2` (extc_stubs.c): call to `deflateInit2` failed: Z_VERSION_ERROR");
break;
default:
failwith("Error in `zlib_deflate_init2` (extc_stubs.c): unknown return code from `deflateInit2`");
}
assert(0);
}
开发者ID:KTXSoftware,项目名称:ocamllibs,代码行数:59,代码来源:extc_stubs.c
注:本文中的deflateInit2函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论