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:
Kovid Goyal 2018-06-30 18:15:08 +05:30
parent 3ec66c0b9f
commit c2679eff9a
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -17,7 +17,13 @@ serialize_string_tuple(PyObject *src) {
Py_ssize_t sz = PyTuple_GET_SIZE(src); Py_ssize_t sz = PyTuple_GET_SIZE(src);
char **ans = calloc(sz + 1, sizeof(char*)); char **ans = calloc(sz + 1, sizeof(char*));
if (!ans) fatal("Out of memory"); 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; return ans;
} }