Skip to content

Commit 9548b6a

Browse files
committed
Make _zstdmodule static
1 parent a71aa3c commit 9548b6a

File tree

2 files changed

+6
-22
lines changed

2 files changed

+6
-22
lines changed

Modules/_zstd/_zstdmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ static struct PyModuleDef_Slot _zstd_slots[] = {
733733
{0, NULL},
734734
};
735735

736-
struct PyModuleDef _zstdmodule = {
736+
static struct PyModuleDef _zstdmodule = {
737737
.m_base = PyModuleDef_HEAD_INIT,
738738
.m_name = "_zstd",
739739
.m_doc = "Implementation module for Zstandard compression.",

Modules/_zstd/_zstdmodule.h

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,38 +9,22 @@ Python module.
99
#define ZSTD_MODULE_H
1010
#include "Python.h"
1111

12-
/* Forward declaration of module state */
13-
typedef struct _zstd_state _zstd_state;
14-
15-
/* Forward reference of module def */
16-
extern PyModuleDef _zstdmodule;
17-
18-
/* For clinic type calculations */
19-
static inline _zstd_state *
20-
get_zstd_state_from_type(PyTypeObject *type)
21-
{
22-
PyObject *module = PyType_GetModuleByDef(type, &_zstdmodule);
23-
if (module == NULL) {
24-
return NULL;
25-
}
26-
void *state = PyModule_GetState(module);
27-
assert(state != NULL);
28-
return (_zstd_state *)state;
29-
}
30-
12+
/* Type specs */
3113
extern PyType_Spec zstd_dict_type_spec;
3214
extern PyType_Spec zstd_compressor_type_spec;
3315
extern PyType_Spec zstd_decompressor_type_spec;
3416

35-
struct _zstd_state {
17+
typedef struct {
18+
/* Module heap types. */
3619
PyTypeObject *ZstdDict_type;
3720
PyTypeObject *ZstdCompressor_type;
3821
PyTypeObject *ZstdDecompressor_type;
3922
PyObject *ZstdError;
4023

24+
/* enum types set by set_parameter_types. */
4125
PyTypeObject *CParameter_type;
4226
PyTypeObject *DParameter_type;
43-
};
27+
} _zstd_state;
4428

4529
typedef enum {
4630
ERR_DECOMPRESS,

0 commit comments

Comments
 (0)