mirror of https://github.com/python/cpython.git
More reformatting.
This commit is contained in:
parent
0965e084cd
commit
4990000077
|
@ -338,34 +338,34 @@ PyZlib_decompress(PyObject *self, PyObject *args)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
PyZlib_compressobj(PyObject *selfptr, PyObject *args)
|
PyZlib_compressobj(PyObject *selfptr, PyObject *args)
|
||||||
{
|
{
|
||||||
compobject *self;
|
compobject *self;
|
||||||
int level=Z_DEFAULT_COMPRESSION, method=DEFLATED;
|
int level=Z_DEFAULT_COMPRESSION, method=DEFLATED;
|
||||||
int wbits=MAX_WBITS, memLevel=DEF_MEM_LEVEL, strategy=0, err;
|
int wbits=MAX_WBITS, memLevel=DEF_MEM_LEVEL, strategy=0, err;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "|iiiii:compressobj", &level, &method, &wbits,
|
if (!PyArg_ParseTuple(args, "|iiiii:compressobj", &level, &method, &wbits,
|
||||||
&memLevel, &strategy))
|
&memLevel, &strategy))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
self = newcompobject(&Comptype);
|
self = newcompobject(&Comptype);
|
||||||
if (self==NULL) return(NULL);
|
if (self==NULL)
|
||||||
self->zst.zalloc = (alloc_func)NULL;
|
return(NULL);
|
||||||
self->zst.zfree = (free_func)Z_NULL;
|
self->zst.zalloc = (alloc_func)NULL;
|
||||||
err = deflateInit2(&self->zst, level, method, wbits, memLevel, strategy);
|
self->zst.zfree = (free_func)Z_NULL;
|
||||||
switch(err)
|
err = deflateInit2(&self->zst, level, method, wbits, memLevel, strategy);
|
||||||
{
|
switch(err) {
|
||||||
case (Z_OK):
|
case (Z_OK):
|
||||||
self->is_initialised = 1;
|
self->is_initialised = 1;
|
||||||
return (PyObject*)self;
|
return (PyObject*)self;
|
||||||
case (Z_MEM_ERROR):
|
case (Z_MEM_ERROR):
|
||||||
Py_DECREF(self);
|
Py_DECREF(self);
|
||||||
PyErr_SetString(PyExc_MemoryError,
|
PyErr_SetString(PyExc_MemoryError,
|
||||||
"Can't allocate memory for compression object");
|
"Can't allocate memory for compression object");
|
||||||
return NULL;
|
return NULL;
|
||||||
case(Z_STREAM_ERROR):
|
case(Z_STREAM_ERROR):
|
||||||
Py_DECREF(self);
|
Py_DECREF(self);
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"Invalid initialization option");
|
"Invalid initialization option");
|
||||||
return NULL;
|
return NULL;
|
||||||
default:
|
default:
|
||||||
zlib_error(self->zst, err, "while creating compression object");
|
zlib_error(self->zst, err, "while creating compression object");
|
||||||
Py_DECREF(self);
|
Py_DECREF(self);
|
||||||
|
@ -376,37 +376,36 @@ PyZlib_compressobj(PyObject *selfptr, PyObject *args)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
PyZlib_decompressobj(PyObject *selfptr, PyObject *args)
|
PyZlib_decompressobj(PyObject *selfptr, PyObject *args)
|
||||||
{
|
{
|
||||||
int wbits=DEF_WBITS, err;
|
int wbits=DEF_WBITS, err;
|
||||||
compobject *self;
|
compobject *self;
|
||||||
if (!PyArg_ParseTuple(args, "|i:decompressobj", &wbits))
|
if (!PyArg_ParseTuple(args, "|i:decompressobj", &wbits))
|
||||||
{
|
return NULL;
|
||||||
return NULL;
|
|
||||||
}
|
self = newcompobject(&Decomptype);
|
||||||
self=newcompobject(&Decomptype);
|
if (self==NULL)
|
||||||
if (self==NULL) return(NULL);
|
return(NULL);
|
||||||
self->zst.zalloc=(alloc_func)NULL;
|
self->zst.zalloc = (alloc_func)NULL;
|
||||||
self->zst.zfree=(free_func)Z_NULL;
|
self->zst.zfree = (free_func)Z_NULL;
|
||||||
err=inflateInit2(&self->zst, wbits);
|
err = inflateInit2(&self->zst, wbits);
|
||||||
switch(err)
|
switch(err) {
|
||||||
{
|
|
||||||
case (Z_OK):
|
case (Z_OK):
|
||||||
self->is_initialised = 1;
|
self->is_initialised = 1;
|
||||||
return (PyObject*)self;
|
return (PyObject*)self;
|
||||||
case(Z_STREAM_ERROR):
|
case(Z_STREAM_ERROR):
|
||||||
Py_DECREF(self);
|
Py_DECREF(self);
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"Invalid initialization option");
|
"Invalid initialization option");
|
||||||
return NULL;
|
return NULL;
|
||||||
case (Z_MEM_ERROR):
|
case (Z_MEM_ERROR):
|
||||||
Py_DECREF(self);
|
Py_DECREF(self);
|
||||||
PyErr_SetString(PyExc_MemoryError,
|
PyErr_SetString(PyExc_MemoryError,
|
||||||
"Can't allocate memory for decompression object");
|
"Can't allocate memory for decompression object");
|
||||||
return NULL;
|
return NULL;
|
||||||
default:
|
default:
|
||||||
zlib_error(self->zst, err, "while creating decompression object");
|
zlib_error(self->zst, err, "while creating decompression object");
|
||||||
Py_DECREF(self);
|
Py_DECREF(self);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -415,7 +414,7 @@ Comp_dealloc(compobject *self)
|
||||||
ENTER_ZLIB
|
ENTER_ZLIB
|
||||||
|
|
||||||
if (self->is_initialised)
|
if (self->is_initialised)
|
||||||
deflateEnd(&self->zst);
|
deflateEnd(&self->zst);
|
||||||
Py_XDECREF(self->unused_data);
|
Py_XDECREF(self->unused_data);
|
||||||
Py_XDECREF(self->unconsumed_tail);
|
Py_XDECREF(self->unconsumed_tail);
|
||||||
PyObject_Del(self);
|
PyObject_Del(self);
|
||||||
|
@ -429,7 +428,7 @@ Decomp_dealloc(compobject *self)
|
||||||
ENTER_ZLIB
|
ENTER_ZLIB
|
||||||
|
|
||||||
if (self->is_initialised)
|
if (self->is_initialised)
|
||||||
inflateEnd(&self->zst);
|
inflateEnd(&self->zst);
|
||||||
Py_XDECREF(self->unused_data);
|
Py_XDECREF(self->unused_data);
|
||||||
Py_XDECREF(self->unconsumed_tail);
|
Py_XDECREF(self->unconsumed_tail);
|
||||||
PyObject_Del(self);
|
PyObject_Del(self);
|
||||||
|
|
Loading…
Reference in New Issue