comparison src/tag.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 5278e5a2a4e3
comparison
equal deleted inserted replaced
16824:1f6bb29738d2 16825:ce04ebdf26b8
1428 } 1428 }
1429 1429
1430 if (name_only) 1430 if (name_only)
1431 mfp = vim_strsave(res_name); 1431 mfp = vim_strsave(res_name);
1432 else 1432 else
1433 mfp = (char_u *)alloc(sizeof(char_u) + len + 1); 1433 mfp = alloc(sizeof(char_u) + len + 1);
1434 1434
1435 if (mfp == NULL) 1435 if (mfp == NULL)
1436 continue; 1436 continue;
1437 1437
1438 if (!name_only) 1438 if (!name_only)
2534 * detecting duplicates. 2534 * detecting duplicates.
2535 * The format is {tagname}@{lang}NUL{heuristic}NUL 2535 * The format is {tagname}@{lang}NUL{heuristic}NUL
2536 */ 2536 */
2537 *tagp.tagname_end = NUL; 2537 *tagp.tagname_end = NUL;
2538 len = (int)(tagp.tagname_end - tagp.tagname); 2538 len = (int)(tagp.tagname_end - tagp.tagname);
2539 mfp = (char_u *)alloc(sizeof(char_u) 2539 mfp = alloc(sizeof(char_u) + len + 10 + ML_EXTRA + 1);
2540 + len + 10 + ML_EXTRA + 1);
2541 if (mfp != NULL) 2540 if (mfp != NULL)
2542 { 2541 {
2543 int heuristic; 2542 int heuristic;
2544 2543
2545 p = mfp; 2544 p = mfp;
2572 temp_end++; 2571 temp_end++;
2573 2572
2574 if (tagp.command + 2 < temp_end) 2573 if (tagp.command + 2 < temp_end)
2575 { 2574 {
2576 len = (int)(temp_end - tagp.command - 2); 2575 len = (int)(temp_end - tagp.command - 2);
2577 mfp = (char_u *)alloc(len + 2); 2576 mfp = alloc(len + 2);
2578 if (mfp != NULL) 2577 if (mfp != NULL)
2579 vim_strncpy(mfp, tagp.command + 2, len); 2578 vim_strncpy(mfp, tagp.command + 2, len);
2580 } 2579 }
2581 else 2580 else
2582 mfp = NULL; 2581 mfp = NULL;
2583 get_it_again = FALSE; 2582 get_it_again = FALSE;
2584 } 2583 }
2585 else 2584 else
2586 { 2585 {
2587 len = (int)(tagp.tagname_end - tagp.tagname); 2586 len = (int)(tagp.tagname_end - tagp.tagname);
2588 mfp = (char_u *)alloc(sizeof(char_u) + len + 1); 2587 mfp = alloc(sizeof(char_u) + len + 1);
2589 if (mfp != NULL) 2588 if (mfp != NULL)
2590 vim_strncpy(mfp, tagp.tagname, len); 2589 vim_strncpy(mfp, tagp.tagname, len);
2591 2590
2592 /* if wanted, re-read line to get long form too */ 2591 /* if wanted, re-read line to get long form too */
2593 if (State & INSERT) 2592 if (State & INSERT)
2618 len += (int)ebuf_len + 1; 2617 len += (int)ebuf_len + 1;
2619 } 2618 }
2620 else 2619 else
2621 ++len; 2620 ++len;
2622 #endif 2621 #endif
2623 mfp = (char_u *)alloc(sizeof(char_u) + len + 1); 2622 mfp = alloc(sizeof(char_u) + len + 1);
2624 if (mfp != NULL) 2623 if (mfp != NULL)
2625 { 2624 {
2626 p = mfp; 2625 p = mfp;
2627 p[0] = mtt + 1; 2626 p[0] = mtt + 1;
2628 STRCPY(p + 1, tag_fname); 2627 STRCPY(p + 1, tag_fname);
2787 */ 2786 */
2788 if (retval == FAIL) 2787 if (retval == FAIL)
2789 match_count = 0; 2788 match_count = 0;
2790 2789
2791 if (match_count > 0) 2790 if (match_count > 0)
2792 matches = (char_u **)alloc(match_count * sizeof(char_u *)); 2791 matches = ALLOC_MULT(char_u *, match_count);
2793 else 2792 else
2794 matches = NULL; 2793 matches = NULL;
2795 match_count = 0; 2794 match_count = 0;
2796 for (mtt = 0; mtt < MT_COUNT; ++mtt) 2795 for (mtt = 0; mtt < MT_COUNT; ++mtt)
2797 { 2796 {