Fix compiler warning
The compiler warning is harmless, since we exec immediately after using the const char* but since I have a no warning policy...
This commit is contained in:
parent
3ec66c0b9f
commit
c2679eff9a
@ -17,7 +17,13 @@ serialize_string_tuple(PyObject *src) {
|
||||
Py_ssize_t sz = PyTuple_GET_SIZE(src);
|
||||
char **ans = calloc(sz + 1, sizeof(char*));
|
||||
if (!ans) fatal("Out of memory");
|
||||
for (Py_ssize_t i = 0; i < sz; i++) ans[i] = PyUnicode_AsUTF8(PyTuple_GET_ITEM(src, i));
|
||||
for (Py_ssize_t i = 0; i < sz; i++) {
|
||||
const char *pysrc = PyUnicode_AsUTF8(PyTuple_GET_ITEM(src, i));
|
||||
size_t len = strlen(pysrc);
|
||||
ans[i] = calloc(len + 1, sizeof(char));
|
||||
if (ans[i] == NULL) fatal("Out of memory");
|
||||
memcpy(ans[i], pysrc, len);
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user