Mercurial > hg-stable
comparison mercurial/cext/charencode.c @ 33780:a22339d389d4
cext: modernize charencode.c to use Py_ssize_t
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Mon, 31 Jul 2017 22:58:06 +0900 |
parents | 0f4ac3b6dee4 |
children | 4ba863c88135 |
comparison
equal
deleted
inserted
replaced
33779:0f4ac3b6dee4 | 33780: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; |