diff options
Diffstat (limited to 'src/nvim/sign.c')
-rw-r--r-- | src/nvim/sign.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/nvim/sign.c b/src/nvim/sign.c index e211b0069e..00e282b76e 100644 --- a/src/nvim/sign.c +++ b/src/nvim/sign.c @@ -99,16 +99,16 @@ static signgroup_T *sign_group_ref(const char *groupname) hashitem_T *hi; signgroup_T *group; - hash = hash_hash((char_u *)groupname); + hash = hash_hash(groupname); hi = hash_lookup(&sg_table, (char *)groupname, strlen(groupname), hash); if (HASHITEM_EMPTY(hi)) { // new group - group = xmalloc(sizeof(signgroup_T) + strlen(groupname)); + group = xmalloc(offsetof(signgroup_T, sg_name) + strlen(groupname) + 1); STRCPY(group->sg_name, groupname); group->sg_refcount = 1; group->sg_next_sign_id = 1; - hash_add_item(&sg_table, hi, (char_u *)group->sg_name, hash); + hash_add_item(&sg_table, hi, group->sg_name, hash); } else { // existing group group = HI2SG(hi); @@ -122,17 +122,17 @@ static signgroup_T *sign_group_ref(const char *groupname) /// removed, then remove the group. static void sign_group_unref(char *groupname) { - signgroup_T *group; - hashitem_T *hi = hash_find(&sg_table, groupname); - if (!HASHITEM_EMPTY(hi)) { - group = HI2SG(hi); - group->sg_refcount--; - if (group->sg_refcount == 0) { - // All the signs in this group are removed - hash_remove(&sg_table, hi); - xfree(group); - } + if (HASHITEM_EMPTY(hi)) { + return; + } + + signgroup_T *group = HI2SG(hi); + group->sg_refcount--; + if (group->sg_refcount == 0) { + // All the signs in this group are removed + hash_remove(&sg_table, hi); + xfree(group); } } |