mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-06-27 19:31:46 +00:00
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
1 changed files with 7 additions and 1 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue