Mercurial > vim
comparison src/autocmd.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 | eda4d65f232c |
children | f8e28c6ae8ab |
comparison
equal
deleted
inserted
replaced
16824:1f6bb29738d2 | 16825:ce04ebdf26b8 |
---|---|
1191 semsg(_("E680: <buffer=%d>: invalid buffer number "), | 1191 semsg(_("E680: <buffer=%d>: invalid buffer number "), |
1192 buflocal_nr); | 1192 buflocal_nr); |
1193 return FAIL; | 1193 return FAIL; |
1194 } | 1194 } |
1195 | 1195 |
1196 ap = (AutoPat *)alloc(sizeof(AutoPat)); | 1196 ap = ALLOC_ONE(AutoPat); |
1197 if (ap == NULL) | 1197 if (ap == NULL) |
1198 return FAIL; | 1198 return FAIL; |
1199 ap->pat = vim_strnsave(pat, patlen); | 1199 ap->pat = vim_strnsave(pat, patlen); |
1200 ap->patlen = patlen; | 1200 ap->patlen = patlen; |
1201 if (ap->pat == NULL) | 1201 if (ap->pat == NULL) |
1240 * Add the autocmd at the end of the AutoCmd list. | 1240 * Add the autocmd at the end of the AutoCmd list. |
1241 */ | 1241 */ |
1242 prev_ac = &(ap->cmds); | 1242 prev_ac = &(ap->cmds); |
1243 while ((ac = *prev_ac) != NULL) | 1243 while ((ac = *prev_ac) != NULL) |
1244 prev_ac = &ac->next; | 1244 prev_ac = &ac->next; |
1245 ac = (AutoCmd *)alloc(sizeof(AutoCmd)); | 1245 ac = ALLOC_ONE(AutoCmd); |
1246 if (ac == NULL) | 1246 if (ac == NULL) |
1247 return FAIL; | 1247 return FAIL; |
1248 ac->cmd = vim_strsave(cmd); | 1248 ac->cmd = vim_strsave(cmd); |
1249 #ifdef FEAT_EVAL | 1249 #ifdef FEAT_EVAL |
1250 ac->script_ctx = current_sctx; | 1250 ac->script_ctx = current_sctx; |