mercurial/cext/charencode.c
changeset 33759 a22339d389d4
parent 33758 0f4ac3b6dee4
child 33812 4ba863c88135
equal deleted inserted replaced
33758:0f4ac3b6dee4 33759:a22339d389d4
     5 
     5 
     6  This software may be used and distributed according to the terms of
     6  This software may be used and distributed according to the terms of
     7  the GNU General Public License, incorporated herein by reference.
     7  the GNU General Public License, incorporated herein by reference.
     8 */
     8 */
     9 
     9 
       
    10 #define PY_SSIZE_T_CLEAN
    10 #include <Python.h>
    11 #include <Python.h>
    11 
    12 
    12 #include "charencode.h"
    13 #include "charencode.h"
    13 #include "util.h"
    14 #include "util.h"
    14 
    15 
    55 };
    56 };
    56 
    57 
    57 /*
    58 /*
    58  * Turn a hex-encoded string into binary.
    59  * Turn a hex-encoded string into binary.
    59  */
    60  */
    60 PyObject *unhexlify(const char *str, int len)
    61 PyObject *unhexlify(const char *str, Py_ssize_t len)
    61 {
    62 {
    62 	PyObject *ret;
    63 	PyObject *ret;
    63 	char *d;
    64 	char *d;
    64 	int i;
    65 	Py_ssize_t i;
    65 
    66 
    66 	ret = PyBytes_FromStringAndSize(NULL, len / 2);
    67 	ret = PyBytes_FromStringAndSize(NULL, len / 2);
    67 
    68 
    68 	if (!ret)
    69 	if (!ret)
    69 		return NULL;
    70 		return NULL;