Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define PY_SSIZE_T_CLEAN, use ssize_t as the index type (PEP 353) #55

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions radix/_radix.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "structmember.h"
#include "_radix/radix.h"
Expand Down Expand Up @@ -256,7 +257,7 @@ Radix_dealloc(RadixObject *self)
}

static prefix_t
*args_to_prefix(prefix_t *prefix, char *addr, char *packed, int packlen, long prefixlen)
*args_to_prefix(prefix_t *prefix, char *addr, char *packed, Py_ssize_t packlen, long prefixlen)
{
prefix_t *old_prefix = prefix;
const char *errmsg;
Expand Down Expand Up @@ -352,7 +353,7 @@ Radix_add(RadixObject *self, PyObject *args, PyObject *kw_args)

char *addr = NULL, *packed = NULL;
long prefixlen = -1;
int packlen = -1;
Py_ssize_t packlen = -1;

if (!PyArg_ParseTupleAndKeywords(args, kw_args, "|zlz#:add", keywords,
&addr, &prefixlen, &packed, &packlen))
Expand Down Expand Up @@ -381,7 +382,7 @@ Radix_delete(RadixObject *self, PyObject *args, PyObject *kw_args)

char *addr = NULL, *packed = NULL;
long prefixlen = -1;
int packlen = -1;
Py_ssize_t packlen = -1;

if (!PyArg_ParseTupleAndKeywords(args, kw_args, "|zlz#:delete", keywords,
&addr, &prefixlen, &packed, &packlen))
Expand Down Expand Up @@ -424,7 +425,7 @@ Radix_search_exact(RadixObject *self, PyObject *args, PyObject *kw_args)

char *addr = NULL, *packed = NULL;
long prefixlen = -1;
int packlen = -1;
Py_ssize_t packlen = -1;

if (!PyArg_ParseTupleAndKeywords(args, kw_args, "|zlz#:search_exact", keywords,
&addr, &prefixlen, &packed, &packlen))
Expand Down Expand Up @@ -462,7 +463,7 @@ Radix_search_best(RadixObject *self, PyObject *args, PyObject *kw_args)

char *addr = NULL, *packed = NULL;
long prefixlen = -1;
int packlen = -1;
Py_ssize_t packlen = -1;

if (!PyArg_ParseTupleAndKeywords(args, kw_args, "|zlz#:search_best", keywords,
&addr, &prefixlen, &packed, &packlen))
Expand Down Expand Up @@ -500,7 +501,7 @@ Radix_search_worst(RadixObject *self, PyObject *args, PyObject *kw_args)

char *addr = NULL, *packed = NULL;
long prefixlen = -1;
int packlen = -1;
Py_ssize_t packlen = -1;

if (!PyArg_ParseTupleAndKeywords(args, kw_args, "|zlz#:search_worst", keywords,
&addr, &prefixlen, &packed, &packlen))
Expand Down Expand Up @@ -543,7 +544,7 @@ Radix_search_covered(RadixObject *self, PyObject *args, PyObject *kw_args)

char *addr = NULL, *packed = NULL;
long prefixlen = -1;
int packlen = -1;
Py_ssize_t packlen = -1;

if (!PyArg_ParseTupleAndKeywords(args, kw_args, "|zlz#:search_covered", keywords, &addr, &prefixlen, &packed, &packlen))
return NULL;
Expand Down Expand Up @@ -576,7 +577,7 @@ Radix_search_covering(RadixObject *self, PyObject *args, PyObject *kw_args)

char *addr = NULL, *packed = NULL;
long prefixlen = -1;
int packlen = -1;
Py_ssize_t packlen = -1;

if (!PyArg_ParseTupleAndKeywords(args, kw_args, "|zlz#:search_covering", keywords, &addr, &prefixlen, &packed, &packlen)) {
return NULL;
Expand Down