From c799fe206e61f2e2c1231bc46cbe4bb354f3da69 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 28 May 2019 23:08:19 +0200 Subject: 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. --- src/tag.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/tag.c') diff --git a/src/tag.c b/src/tag.c index ef2ebbe8fa..03587938bb 100644 --- a/src/tag.c +++ b/src/tag.c @@ -1430,7 +1430,7 @@ find_tagfunc_tags( if (name_only) mfp = vim_strsave(res_name); else - mfp = (char_u *)alloc(sizeof(char_u) + len + 1); + mfp = alloc(sizeof(char_u) + len + 1); if (mfp == NULL) continue; @@ -2536,8 +2536,7 @@ parse_line: */ *tagp.tagname_end = NUL; len = (int)(tagp.tagname_end - tagp.tagname); - mfp = (char_u *)alloc(sizeof(char_u) - + len + 10 + ML_EXTRA + 1); + mfp = alloc(sizeof(char_u) + len + 10 + ML_EXTRA + 1); if (mfp != NULL) { int heuristic; @@ -2574,7 +2573,7 @@ parse_line: if (tagp.command + 2 < temp_end) { len = (int)(temp_end - tagp.command - 2); - mfp = (char_u *)alloc(len + 2); + mfp = alloc(len + 2); if (mfp != NULL) vim_strncpy(mfp, tagp.command + 2, len); } @@ -2585,7 +2584,7 @@ parse_line: else { len = (int)(tagp.tagname_end - tagp.tagname); - mfp = (char_u *)alloc(sizeof(char_u) + len + 1); + mfp = alloc(sizeof(char_u) + len + 1); if (mfp != NULL) vim_strncpy(mfp, tagp.tagname, len); @@ -2620,7 +2619,7 @@ parse_line: else ++len; #endif - mfp = (char_u *)alloc(sizeof(char_u) + len + 1); + mfp = alloc(sizeof(char_u) + len + 1); if (mfp != NULL) { p = mfp; @@ -2789,7 +2788,7 @@ findtag_end: match_count = 0; if (match_count > 0) - matches = (char_u **)alloc(match_count * sizeof(char_u *)); + matches = ALLOC_MULT(char_u *, match_count); else matches = NULL; match_count = 0; -- cgit v1.2.3