}
self->use_multithread = 0;
+ self->dict = NULL;
/* Compression context */
self->cctx = ZSTD_createCCtx();
}
/* Load Zstandard dictionary to compression context */
- self->dict = NULL;
if (zstd_dict != Py_None) {
if (_zstd_load_c_dict(self, zstd_dict) < 0) {
goto error;
return (PyObject*)self;
error:
- if (self != NULL) {
- PyObject_GC_Del(self);
- }
+ Py_XDECREF(self);
return NULL;
}
PyObject_GC_UnTrack(self);
/* Free compression context */
- ZSTD_freeCCtx(self->cctx);
+ if (self->cctx) {
+ ZSTD_freeCCtx(self->cctx);
+ }
/* Py_XDECREF the dict after free the compression context */
Py_CLEAR(self->dict);
self->in_end = -1;
self->unused_data = NULL;
self->eof = 0;
+ self->dict = NULL;
/* needs_input flag */
self->needs_input = 1;
}
/* Load Zstandard dictionary to decompression context */
- self->dict = NULL;
if (zstd_dict != Py_None) {
if (_zstd_load_d_dict(self, zstd_dict) < 0) {
goto error;
return (PyObject*)self;
error:
- if (self != NULL) {
- PyObject_GC_Del(self);
- }
+ Py_XDECREF(self);
return NULL;
}
PyObject_GC_UnTrack(self);
/* Free decompression context */
- ZSTD_freeDCtx(self->dctx);
+ if (self->dctx) {
+ ZSTD_freeDCtx(self->dctx);
+ }
/* Py_CLEAR the dict after free decompression context */
Py_CLEAR(self->dict);
self->dict_content = NULL;
self->d_dict = NULL;
+ self->dict_id = 0;
/* ZSTD_CDict dict */
self->c_dicts = PyDict_New();
return (PyObject*)self;
error:
- if (self != NULL) {
- PyObject_GC_Del(self);
- }
+ Py_XDECREF(self);
return NULL;
}
PyObject_GC_UnTrack(self);
/* Free ZSTD_DDict instance */
- ZSTD_freeDDict(self->d_dict);
+ if (self->d_dict) {
+ ZSTD_freeDDict(self->d_dict);
+ }
/* Release dict_content after Free ZSTD_CDict/ZSTD_DDict instances */
Py_CLEAR(self->dict_content);