Skip to content

Commit 794dde7

Browse files
committed
Rename _module_state to mod_state
1 parent 7634e5b commit 794dde7

File tree

3 files changed

+110
-110
lines changed

3 files changed

+110
-110
lines changed

Modules/_zstd/_zstdmodule.c

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,8 @@ _zstd__train_dict_impl(PyObject *module, PyBytesObject *samples_bytes,
263263

264264
/* Check zstd dict error */
265265
if (ZDICT_isError(zstd_ret)) {
266-
_zstd_state* const _module_state = get_zstd_state(module);
267-
set_zstd_error(_module_state, ERR_TRAIN_DICT, zstd_ret);
266+
_zstd_state* const mod_state = get_zstd_state(module);
267+
set_zstd_error(mod_state, ERR_TRAIN_DICT, zstd_ret);
268268
goto error;
269269
}
270270

@@ -391,8 +391,8 @@ _zstd__finalize_dict_impl(PyObject *module, PyBytesObject *custom_dict_bytes,
391391

392392
/* Check zstd dict error */
393393
if (ZDICT_isError(zstd_ret)) {
394-
_zstd_state* const _module_state = get_zstd_state(module);
395-
set_zstd_error(_module_state, ERR_FINALIZE_DICT, zstd_ret);
394+
_zstd_state* const mod_state = get_zstd_state(module);
395+
set_zstd_error(mod_state, ERR_FINALIZE_DICT, zstd_ret);
396396
goto error;
397397
}
398398

@@ -432,15 +432,15 @@ _zstd__get_param_bounds_impl(PyObject *module, int is_compress,
432432
if (is_compress) {
433433
bound = ZSTD_cParam_getBounds(parameter);
434434
if (ZSTD_isError(bound.error)) {
435-
_zstd_state* const _module_state = get_zstd_state(module);
436-
set_zstd_error(_module_state, ERR_GET_C_BOUNDS, bound.error);
435+
_zstd_state* const mod_state = get_zstd_state(module);
436+
set_zstd_error(mod_state, ERR_GET_C_BOUNDS, bound.error);
437437
return NULL;
438438
}
439439
} else {
440440
bound = ZSTD_dParam_getBounds(parameter);
441441
if (ZSTD_isError(bound.error)) {
442-
_zstd_state* const _module_state = get_zstd_state(module);
443-
set_zstd_error(_module_state, ERR_GET_D_BOUNDS, bound.error);
442+
_zstd_state* const mod_state = get_zstd_state(module);
443+
set_zstd_error(mod_state, ERR_GET_D_BOUNDS, bound.error);
444444
return NULL;
445445
}
446446
}
@@ -468,8 +468,8 @@ _zstd_get_frame_size_impl(PyObject *module, Py_buffer *frame_buffer)
468468

469469
frame_size = ZSTD_findFrameCompressedSize(frame_buffer->buf, frame_buffer->len);
470470
if (ZSTD_isError(frame_size)) {
471-
_zstd_state* const _module_state = get_zstd_state(module);
472-
PyErr_Format(_module_state->ZstdError,
471+
_zstd_state* const mod_state = get_zstd_state(module);
472+
PyErr_Format(mod_state->ZstdError,
473473
"Error when finding the compressed size of a zstd frame. "
474474
"Make sure the frame_buffer argument starts from the "
475475
"beginning of a frame, and its length not less than this "
@@ -504,8 +504,8 @@ _zstd__get_frame_info_impl(PyObject *module, Py_buffer *frame_buffer)
504504
/* #define ZSTD_CONTENTSIZE_UNKNOWN (0ULL - 1)
505505
#define ZSTD_CONTENTSIZE_ERROR (0ULL - 2) */
506506
if (decompressed_size == ZSTD_CONTENTSIZE_ERROR) {
507-
_zstd_state* const _module_state = get_zstd_state(module);
508-
PyErr_SetString(_module_state->ZstdError,
507+
_zstd_state* const mod_state = get_zstd_state(module);
508+
PyErr_SetString(mod_state->ZstdError,
509509
"Error when getting information from the header of "
510510
"a zstd frame. Make sure the frame_buffer argument "
511511
"starts from the beginning of a frame, and its length "
@@ -539,7 +539,7 @@ _zstd__set_parameter_types_impl(PyObject *module, PyObject *c_parameter_type,
539539
PyObject *d_parameter_type)
540540
/*[clinic end generated code: output=a13d4890ccbd2873 input=3e7d0d37c3a1045a]*/
541541
{
542-
_zstd_state* const _module_state = get_zstd_state(module);
542+
_zstd_state* const mod_state = get_zstd_state(module);
543543

544544
if (!PyType_Check(c_parameter_type) || !PyType_Check(d_parameter_type)) {
545545
PyErr_SetString(PyExc_ValueError,
@@ -548,13 +548,13 @@ _zstd__set_parameter_types_impl(PyObject *module, PyObject *c_parameter_type,
548548
return NULL;
549549
}
550550

551-
Py_XDECREF(_module_state->CParameter_type);
551+
Py_XDECREF(mod_state->CParameter_type);
552552
Py_INCREF(c_parameter_type);
553-
_module_state->CParameter_type = (PyTypeObject*) c_parameter_type;
553+
mod_state->CParameter_type = (PyTypeObject*) c_parameter_type;
554554

555-
Py_XDECREF(_module_state->DParameter_type);
555+
Py_XDECREF(mod_state->DParameter_type);
556556
Py_INCREF(d_parameter_type);
557-
_module_state->DParameter_type = (PyTypeObject*)d_parameter_type;
557+
mod_state->DParameter_type = (PyTypeObject*)d_parameter_type;
558558

559559
Py_RETURN_NONE;
560560
}
@@ -719,8 +719,8 @@ add_vars_to_module(PyObject *module)
719719

720720
#define ADD_STR_TO_STATE_MACRO(STR) \
721721
do { \
722-
_module_state->str_##STR = PyUnicode_FromString(#STR); \
723-
if (_module_state->str_##STR == NULL) { \
722+
mod_state->str_##STR = PyUnicode_FromString(#STR); \
723+
if (mod_state->str_##STR == NULL) { \
724724
return -1; \
725725
} \
726726
} while(0)
@@ -762,17 +762,17 @@ add_constant_to_type(PyTypeObject *type, const char *name, const long value)
762762
}
763763

764764
static int _zstd_exec(PyObject *module) {
765-
_zstd_state* const _module_state = get_zstd_state(module);
765+
_zstd_state* const mod_state = get_zstd_state(module);
766766

767767
/* Reusable objects & variables */
768-
_module_state->empty_bytes = PyBytes_FromStringAndSize(NULL, 0);
769-
if (_module_state->empty_bytes == NULL) {
768+
mod_state->empty_bytes = PyBytes_FromStringAndSize(NULL, 0);
769+
if (mod_state->empty_bytes == NULL) {
770770
return -1;
771771
}
772772

773-
_module_state->empty_readonly_memoryview =
774-
PyMemoryView_FromMemory((char*)_module_state, 0, PyBUF_READ);
775-
if (_module_state->empty_readonly_memoryview == NULL) {
773+
mod_state->empty_readonly_memoryview =
774+
PyMemoryView_FromMemory((char*)mod_state, 0, PyBUF_READ);
775+
if (mod_state->empty_readonly_memoryview == NULL) {
776776
return -1;
777777
}
778778

@@ -782,59 +782,59 @@ static int _zstd_exec(PyObject *module) {
782782
ADD_STR_TO_STATE_MACRO(write);
783783
ADD_STR_TO_STATE_MACRO(flush);
784784

785-
_module_state->CParameter_type = NULL;
786-
_module_state->DParameter_type = NULL;
785+
mod_state->CParameter_type = NULL;
786+
mod_state->DParameter_type = NULL;
787787

788788
/* Add variables to module */
789789
if (add_vars_to_module(module) < 0) {
790790
return -1;
791791
}
792792

793793
/* ZstdError */
794-
_module_state->ZstdError = PyErr_NewExceptionWithDoc(
794+
mod_state->ZstdError = PyErr_NewExceptionWithDoc(
795795
"_zstd.ZstdError",
796796
"Call to the underlying zstd library failed.",
797797
NULL, NULL);
798-
if (_module_state->ZstdError == NULL) {
798+
if (mod_state->ZstdError == NULL) {
799799
return -1;
800800
}
801801

802-
Py_INCREF(_module_state->ZstdError);
803-
if (PyModule_AddObject(module, "ZstdError", _module_state->ZstdError) < 0) {
804-
Py_DECREF(_module_state->ZstdError);
802+
Py_INCREF(mod_state->ZstdError);
803+
if (PyModule_AddObject(module, "ZstdError", mod_state->ZstdError) < 0) {
804+
Py_DECREF(mod_state->ZstdError);
805805
return -1;
806806
}
807807

808808
/* ZstdDict */
809809
if (add_type_to_module(module,
810810
"ZstdDict",
811811
&zstddict_type_spec,
812-
&_module_state->ZstdDict_type) < 0) {
812+
&mod_state->ZstdDict_type) < 0) {
813813
return -1;
814814
}
815815

816816
// ZstdCompressor
817817
if (add_type_to_module(module,
818818
"ZstdCompressor",
819819
&zstdcompressor_type_spec,
820-
&_module_state->ZstdCompressor_type) < 0) {
820+
&mod_state->ZstdCompressor_type) < 0) {
821821
return -1;
822822
}
823823

824824
// Add EndDirective enum to ZstdCompressor
825-
if (add_constant_to_type(_module_state->ZstdCompressor_type,
825+
if (add_constant_to_type(mod_state->ZstdCompressor_type,
826826
"CONTINUE",
827827
ZSTD_e_continue) < 0) {
828828
return -1;
829829
}
830830

831-
if (add_constant_to_type(_module_state->ZstdCompressor_type,
831+
if (add_constant_to_type(mod_state->ZstdCompressor_type,
832832
"FLUSH_BLOCK",
833833
ZSTD_e_flush) < 0) {
834834
return -1;
835835
}
836836

837-
if (add_constant_to_type(_module_state->ZstdCompressor_type,
837+
if (add_constant_to_type(mod_state->ZstdCompressor_type,
838838
"FLUSH_FRAME",
839839
ZSTD_e_end) < 0) {
840840
return -1;
@@ -844,7 +844,7 @@ static int _zstd_exec(PyObject *module) {
844844
if (add_type_to_module(module,
845845
"ZstdDecompressor",
846846
&ZstdDecompressor_type_spec,
847-
&_module_state->ZstdDecompressor_type) < 0) {
847+
&mod_state->ZstdDecompressor_type) < 0) {
848848
return -1;
849849
}
850850

@@ -854,48 +854,48 @@ static int _zstd_exec(PyObject *module) {
854854
static int
855855
_zstd_traverse(PyObject *module, visitproc visit, void *arg)
856856
{
857-
_zstd_state* const _module_state = get_zstd_state(module);
857+
_zstd_state* const mod_state = get_zstd_state(module);
858858

859-
Py_VISIT(_module_state->empty_bytes);
860-
Py_VISIT(_module_state->empty_readonly_memoryview);
861-
Py_VISIT(_module_state->str_read);
862-
Py_VISIT(_module_state->str_readinto);
863-
Py_VISIT(_module_state->str_write);
864-
Py_VISIT(_module_state->str_flush);
859+
Py_VISIT(mod_state->empty_bytes);
860+
Py_VISIT(mod_state->empty_readonly_memoryview);
861+
Py_VISIT(mod_state->str_read);
862+
Py_VISIT(mod_state->str_readinto);
863+
Py_VISIT(mod_state->str_write);
864+
Py_VISIT(mod_state->str_flush);
865865

866-
Py_VISIT(_module_state->ZstdDict_type);
867-
Py_VISIT(_module_state->ZstdCompressor_type);
866+
Py_VISIT(mod_state->ZstdDict_type);
867+
Py_VISIT(mod_state->ZstdCompressor_type);
868868

869-
Py_VISIT(_module_state->ZstdDecompressor_type);
869+
Py_VISIT(mod_state->ZstdDecompressor_type);
870870

871-
Py_VISIT(_module_state->ZstdError);
871+
Py_VISIT(mod_state->ZstdError);
872872

873-
Py_VISIT(_module_state->CParameter_type);
874-
Py_VISIT(_module_state->DParameter_type);
873+
Py_VISIT(mod_state->CParameter_type);
874+
Py_VISIT(mod_state->DParameter_type);
875875
return 0;
876876
}
877877

878878
static int
879879
_zstd_clear(PyObject *module)
880880
{
881-
_zstd_state* const _module_state = get_zstd_state(module);
881+
_zstd_state* const mod_state = get_zstd_state(module);
882882

883-
Py_CLEAR(_module_state->empty_bytes);
884-
Py_CLEAR(_module_state->empty_readonly_memoryview);
885-
Py_CLEAR(_module_state->str_read);
886-
Py_CLEAR(_module_state->str_readinto);
887-
Py_CLEAR(_module_state->str_write);
888-
Py_CLEAR(_module_state->str_flush);
883+
Py_CLEAR(mod_state->empty_bytes);
884+
Py_CLEAR(mod_state->empty_readonly_memoryview);
885+
Py_CLEAR(mod_state->str_read);
886+
Py_CLEAR(mod_state->str_readinto);
887+
Py_CLEAR(mod_state->str_write);
888+
Py_CLEAR(mod_state->str_flush);
889889

890-
Py_CLEAR(_module_state->ZstdDict_type);
891-
Py_CLEAR(_module_state->ZstdCompressor_type);
890+
Py_CLEAR(mod_state->ZstdDict_type);
891+
Py_CLEAR(mod_state->ZstdCompressor_type);
892892

893-
Py_CLEAR(_module_state->ZstdDecompressor_type);
893+
Py_CLEAR(mod_state->ZstdDecompressor_type);
894894

895-
Py_CLEAR(_module_state->ZstdError);
895+
Py_CLEAR(mod_state->ZstdError);
896896

897-
Py_CLEAR(_module_state->CParameter_type);
898-
Py_CLEAR(_module_state->DParameter_type);
897+
Py_CLEAR(mod_state->CParameter_type);
898+
Py_CLEAR(mod_state->DParameter_type);
899899
return 0;
900900
}
901901

0 commit comments

Comments
 (0)