8000 Use casts and make slot function signatures correct · python/cpython@428677d · GitHub
[go: up one dir, main page]

Skip to content

Commit 428677d

Browse files
committed
Use casts and make slot function signatures correct
1 parent 40c653c commit 428677d

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

Modules/_zstd/compressor.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ class _zstd.ZstdCompressor "ZstdCompressor *" "clinic_state()->ZstdCompressor_ty
2323
#include <stddef.h> // offsetof()
2424

2525

26+
#define ZstdCompressor_CAST(op) ((ZstdCompressor *)op)
27+
2628
int
2729
_PyZstd_set_c_parameters(ZstdCompressor *self, PyObject *level_or_options,
2830
const char *arg_name, const char* arg_type)
@@ -321,8 +323,9 @@ _zstd_ZstdCompressor_new(PyTypeObject *type, PyObject *Py_UNUSED(args), PyObject
321323
}
322324

323325
static void
324-
ZstdCompressor_dealloc(ZstdCompressor *self)
326+
ZstdCompressor_dealloc(PyObject *ob)
325327
{
328+
ZstdCompressor *self = ZstdCompressor_CAST(ob);
326329
/* Free compression context */
327330
ZSTD_freeCCtx(self->cctx);
328331

Modules/_zstd/decompressor.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ class _zstd.ZstdDecompressor "ZstdDecompressor *" "clinic_state()->ZstdDecompres
2121

2222
#include <stddef.h> // offsetof()
2323

24+
#define ZstdDecompressor_CAST(op) ((ZstdDecompressor *)op)
25+
2426
static inline ZSTD_DDict *
2527
_get_DDict(ZstdDict *self)
2628
{
@@ -630,8 +632,9 @@ _zstd_ZstdDecompressor_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
630632
}
631633

632634
static void
633-
ZstdDecompressor_dealloc(ZstdDecompressor *self)
635+
ZstdDecompressor_dealloc(PyObject *ob)
634636
{
637+
ZstdDecompressor *self = ZstdDecompressor_CAST(ob);
635638
/* Free decompression context */
636639
ZSTD_freeDCtx(self->dctx);
637640

Modules/_zstd/zdict.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class _zstd.ZstdDict "ZstdDict *" "clinic_state()->ZstdDict_type"
1919

2020
#include <stddef.h> // offsetof()
2121

22+
#define ZstdDict_CAST(op) ((ZstdDict *)op)
2223

2324
static PyObject *
2425
_zstd_ZstdDict_new(PyTypeObject *type, PyObject *Py_UNUSED(args), PyObject *Py_UNUSED(kwargs))
@@ -48,8 +49,9 @@ _zstd_ZstdDict_new(PyTypeObject *type, PyObject *Py_UNUSED(args), PyObject *Py_U
4849
}
4950

5051
static void
51-
ZstdDict_dealloc(ZstdDict *self)
52+
ZstdDict_dealloc(PyObject *ob)
5253
{
54+
ZstdDict *self = ZstdDict_CAST(ob);
5355
/* Free ZSTD_CDict instances */
5456
Py_XDECREF(self->c_dicts);
5557

@@ -145,8 +147,9 @@ PyDoc_STRVAR(ZstdDict_dictcontent_doc,
145147
"argument in ZstdDict.__init__() method. It can be used with other programs.");
146148

147149
static PyObject *
148-
ZstdDict_str(ZstdDict *dict)
150+
ZstdDict_str(PyObject *ob)
149151
{
152+
ZstdDict *dict = ZstdDict_CAST(ob);
150153
return PyUnicode_FromFormat("<ZstdDict dict_id=%u dict_size=%zd>",
151154
dict->dict_id, Py_SIZE(dict->dict_content));
152155
}
@@ -233,8 +236,9 @@ static PyGetSetDef ZstdDict_getset[] = {
233236
};
234237

235238
static Py_ssize_t
236-
ZstdDict_length(ZstdDict *self)
239+
ZstdDict_length(PyObject *ob)
237240
{
241+
ZstdDict *self = ZstdDict_CAST(ob);
238242
assert(PyBytes_Check(self->dict_content));
239243
return Py_SIZE(self->dict_content);
240244
}

0 commit comments

Comments
 (0)
0