comparison src/if_python3.c @ 16825:ce04ebdf26b8 v8.1.1414

patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts commit https://github.com/vim/vim/commit/c799fe206e61f2e2c1231bc46cbe4bb354f3da69 Author: Bram Moolenaar <Bram@vim.org> Date: Tue May 28 23:08:19 2019 +0200 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts Problem: Alloc() returning "char_u *" causes a lot of type casts. Solution: Have it return "void *". (Mike Williams) Define ALLOC_ONE() to check the simple allocations.
author Bram Moolenaar <Bram@vim.org>
date Tue, 28 May 2019 23:15:10 +0200
parents ef00b6bc186b
children 6b8508ea90d7
comparison
equal deleted inserted replaced
16824:1f6bb29738d2 16825:ce04ebdf26b8
875 if (*p_py3home != NUL) 875 if (*p_py3home != NUL)
876 { 876 {
877 size_t len = mbstowcs(NULL, (char *)p_py3home, 0) + 1; 877 size_t len = mbstowcs(NULL, (char *)p_py3home, 0) + 1;
878 878
879 /* The string must not change later, make a copy in static memory. */ 879 /* The string must not change later, make a copy in static memory. */
880 py_home_buf = (wchar_t *)alloc(len * sizeof(wchar_t)); 880 py_home_buf = ALLOC_MULT(wchar_t, len);
881 if (py_home_buf != NULL && mbstowcs( 881 if (py_home_buf != NULL && mbstowcs(
882 py_home_buf, (char *)p_py3home, len) != (size_t)-1) 882 py_home_buf, (char *)p_py3home, len) != (size_t)-1)
883 Py_SetPythonHome(py_home_buf); 883 Py_SetPythonHome(py_home_buf);
884 } 884 }
885 #ifdef PYTHON3_HOME 885 #ifdef PYTHON3_HOME
1627 { 1627 {
1628 PyObject *result; 1628 PyObject *result;
1629 Py_ssize_t len = strlen(str); 1629 Py_ssize_t len = strlen(str);
1630 char *tmp,*p; 1630 char *tmp,*p;
1631 1631
1632 tmp = (char *)alloc(len + 1); 1632 tmp = alloc(len + 1);
1633 p = tmp; 1633 p = tmp;
1634 if (p == NULL) 1634 if (p == NULL)
1635 { 1635 {
1636 PyErr_NoMemory(); 1636 PyErr_NoMemory();
1637 return NULL; 1637 return NULL;