mirror of
				https://gitlab.alpinelinux.org/alpine/aports.git
				synced 2025-10-31 16:31:40 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			97 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			97 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
| Patch-Source: https://github.com/hroncok/py-radix/commit/b77a77dadfbcbaa0384d1b87728829bd1683937f
 | |
| From b77a77dadfbcbaa0384d1b87728829bd1683937f Mon Sep 17 00:00:00 2001
 | |
| From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
 | |
| Date: Tue, 31 Aug 2021 00:58:25 +0200
 | |
| Subject: [PATCH] Define PY_SSIZE_T_CLEAN, use ssize_t as the index type (PEP
 | |
|  353)
 | |
| 
 | |
| Fixes https://github.com/mjschultz/py-radix/issues/54
 | |
| ---
 | |
|  radix/_radix.c | 17 +++++++++--------
 | |
|  1 file changed, 9 insertions(+), 8 deletions(-)
 | |
| 
 | |
| diff --git a/radix/_radix.c b/radix/_radix.c
 | |
| index 5a1b88f..287e893 100644
 | |
| --- a/radix/_radix.c
 | |
| +++ b/radix/_radix.c
 | |
| @@ -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"
 | |
| @@ -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;
 | |
| @@ -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))
 | |
| @@ -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))
 | |
| @@ -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))
 | |
| @@ -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))
 | |
| @@ -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))
 | |
| @@ -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;
 | |
| @@ -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;
 |