Mercurial > vim
comparison src/sign.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 | fc58fee685e2 |
children | 1689b52cf297 |
comparison
equal
deleted
inserted
replaced
16824:1f6bb29738d2 | 16825:ce04ebdf26b8 |
---|---|
83 hash = hash_hash(groupname); | 83 hash = hash_hash(groupname); |
84 hi = hash_lookup(&sg_table, groupname, hash); | 84 hi = hash_lookup(&sg_table, groupname, hash); |
85 if (HASHITEM_EMPTY(hi)) | 85 if (HASHITEM_EMPTY(hi)) |
86 { | 86 { |
87 // new group | 87 // new group |
88 group = (signgroup_T *)alloc(sizeof(signgroup_T) + STRLEN(groupname)); | 88 group = alloc(sizeof(signgroup_T) + STRLEN(groupname)); |
89 if (group == NULL) | 89 if (group == NULL) |
90 return NULL; | 90 return NULL; |
91 STRCPY(group->sg_name, groupname); | 91 STRCPY(group->sg_name, groupname); |
92 group->refcount = 1; | 92 group->refcount = 1; |
93 group->next_sign_id = 1; | 93 group->next_sign_id = 1; |
199 linenr_T lnum, // line number which gets the mark | 199 linenr_T lnum, // line number which gets the mark |
200 int typenr) // typenr of sign we are adding | 200 int typenr) // typenr of sign we are adding |
201 { | 201 { |
202 signlist_T *newsign; | 202 signlist_T *newsign; |
203 | 203 |
204 newsign = (signlist_T *)lalloc_id(sizeof(signlist_T), FALSE, | 204 newsign = lalloc_id(sizeof(signlist_T), FALSE, aid_insert_sign); |
205 aid_insert_sign); | |
206 if (newsign != NULL) | 205 if (newsign != NULL) |
207 { | 206 { |
208 newsign->id = id; | 207 newsign->id = id; |
209 newsign->lnum = lnum; | 208 newsign->lnum = lnum; |
210 newsign->typenr = typenr; | 209 newsign->typenr = typenr; |
734 sign_T *sp; | 733 sign_T *sp; |
735 sign_T *lp; | 734 sign_T *lp; |
736 int start = next_sign_typenr; | 735 int start = next_sign_typenr; |
737 | 736 |
738 // Allocate a new sign. | 737 // Allocate a new sign. |
739 sp = (sign_T *)alloc_clear_id(sizeof(sign_T), aid_sign_define_by_name); | 738 sp = alloc_clear_id(sizeof(sign_T), aid_sign_define_by_name); |
740 if (sp == NULL) | 739 if (sp == NULL) |
741 return NULL; | 740 return NULL; |
742 | 741 |
743 // Check that next_sign_typenr is not already being used. | 742 // Check that next_sign_typenr is not already being used. |
744 // This only happens after wrapping around. Hopefully | 743 // This only happens after wrapping around. Hopefully |