Show More
@@ -13,8 +13,10 b'' | |||||
13 |
|
13 | |||
14 | #include "util.h" |
|
14 | #include "util.h" | |
15 |
|
15 | |||
16 |
static int hexdigit(char |
|
16 | static inline int hexdigit(const char *p, Py_ssize_t off) | |
17 | { |
|
17 | { | |
|
18 | char c = p[off]; | |||
|
19 | ||||
18 | if (c >= '0' && c <= '9') |
|
20 | if (c >= '0' && c <= '9') | |
19 | return c - '0'; |
|
21 | return c - '0'; | |
20 | if (c >= 'a' && c <= 'f') |
|
22 | if (c >= 'a' && c <= 'f') | |
@@ -32,8 +34,8 b' static int hexdigit(char c)' | |||||
32 | static PyObject *unhexlify(const char *str, int len) |
|
34 | static PyObject *unhexlify(const char *str, int len) | |
33 | { |
|
35 | { | |
34 | PyObject *ret; |
|
36 | PyObject *ret; | |
35 | const char *c; |
|
|||
36 | char *d; |
|
37 | char *d; | |
|
38 | int i; | |||
37 |
|
39 | |||
38 | ret = PyBytes_FromStringAndSize(NULL, len / 2); |
|
40 | ret = PyBytes_FromStringAndSize(NULL, len / 2); | |
39 |
|
41 | |||
@@ -42,9 +44,9 b' static PyObject *unhexlify(const char *s' | |||||
42 |
|
44 | |||
43 | d = PyBytes_AsString(ret); |
|
45 | d = PyBytes_AsString(ret); | |
44 |
|
46 | |||
45 |
for ( |
|
47 | for (i = 0; i < len;) { | |
46 |
int hi = hexdigit( |
|
48 | int hi = hexdigit(str, i++); | |
47 |
int lo = hexdigit( |
|
49 | int lo = hexdigit(str, i++); | |
48 | *d++ = (hi << 4) | lo; |
|
50 | *d++ = (hi << 4) | lo; | |
49 | } |
|
51 | } | |
50 |
|
52 |
General Comments 0
You need to be logged in to leave comments.
Login now