Mercurial > vim
comparison src/if_py_both.h @ 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 | fc58fee685e2 |
children | 1d30eb64a7a2 |
comparison
equal
deleted
inserted
replaced
16824:1f6bb29738d2 | 16825:ce04ebdf26b8 |
---|---|
3136 if (self->argv) | 3136 if (self->argv) |
3137 { | 3137 { |
3138 pt->pt_argc = self->argc; | 3138 pt->pt_argc = self->argc; |
3139 if (exported) | 3139 if (exported) |
3140 { | 3140 { |
3141 pt->pt_argv = (typval_T *)alloc_clear( | 3141 pt->pt_argv = ALLOC_CLEAR_MULT(typval_T, self->argc); |
3142 sizeof(typval_T) * self->argc); | |
3143 for (i = 0; i < pt->pt_argc; ++i) | 3142 for (i = 0; i < pt->pt_argc; ++i) |
3144 copy_tv(&self->argv[i], &pt->pt_argv[i]); | 3143 copy_tv(&self->argv[i], &pt->pt_argv[i]); |
3145 } | 3144 } |
3146 else | 3145 else |
3147 pt->pt_argv = self->argv; | 3146 pt->pt_argv = self->argv; |
4260 } | 4259 } |
4261 | 4260 |
4262 /* Create a copy of the string, with internal nulls replaced by | 4261 /* Create a copy of the string, with internal nulls replaced by |
4263 * newline characters, as is the vim convention. | 4262 * newline characters, as is the vim convention. |
4264 */ | 4263 */ |
4265 save = (char *)alloc(len+1); | 4264 save = alloc(len+1); |
4266 if (save == NULL) | 4265 if (save == NULL) |
4267 { | 4266 { |
4268 PyErr_NoMemory(); | 4267 PyErr_NoMemory(); |
4269 Py_XDECREF(bytes); | 4268 Py_XDECREF(bytes); |
4270 return NULL; | 4269 return NULL; |
6241 else if (PyType_IsSubtype(obj->ob_type, &FunctionType)) | 6240 else if (PyType_IsSubtype(obj->ob_type, &FunctionType)) |
6242 { | 6241 { |
6243 FunctionObject *func = (FunctionObject *) obj; | 6242 FunctionObject *func = (FunctionObject *) obj; |
6244 if (func->self != NULL || func->argv != NULL) | 6243 if (func->self != NULL || func->argv != NULL) |
6245 { | 6244 { |
6246 partial_T *pt = (partial_T *)alloc_clear(sizeof(partial_T)); | 6245 partial_T *pt = ALLOC_CLEAR_ONE(partial_T); |
6246 | |
6247 set_partial(func, pt, TRUE); | 6247 set_partial(func, pt, TRUE); |
6248 tv->vval.v_partial = pt; | 6248 tv->vval.v_partial = pt; |
6249 tv->v_type = VAR_PARTIAL; | 6249 tv->v_type = VAR_PARTIAL; |
6250 } | 6250 } |
6251 else | 6251 else |