Mercurial > vim
comparison src/buffer.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 | 0154363d3b98 |
comparison
equal
deleted
inserted
replaced
16824:1f6bb29738d2 | 16825:ce04ebdf26b8 |
---|---|
1956 clear_string_option(&buf->b_p_bt); | 1956 clear_string_option(&buf->b_p_bt); |
1957 } | 1957 } |
1958 } | 1958 } |
1959 if (buf != curbuf || curbuf == NULL) | 1959 if (buf != curbuf || curbuf == NULL) |
1960 { | 1960 { |
1961 buf = (buf_T *)alloc_clear(sizeof(buf_T)); | 1961 buf = ALLOC_CLEAR_ONE(buf_T); |
1962 if (buf == NULL) | 1962 if (buf == NULL) |
1963 { | 1963 { |
1964 vim_free(ffname); | 1964 vim_free(ffname); |
1965 return NULL; | 1965 return NULL; |
1966 } | 1966 } |
1983 buf->b_ffname = ffname; | 1983 buf->b_ffname = ffname; |
1984 buf->b_sfname = vim_strsave(sfname); | 1984 buf->b_sfname = vim_strsave(sfname); |
1985 } | 1985 } |
1986 | 1986 |
1987 clear_wininfo(buf); | 1987 clear_wininfo(buf); |
1988 buf->b_wininfo = (wininfo_T *)alloc_clear(sizeof(wininfo_T)); | 1988 buf->b_wininfo = ALLOC_CLEAR_ONE(wininfo_T); |
1989 | 1989 |
1990 if ((ffname != NULL && (buf->b_ffname == NULL || buf->b_sfname == NULL)) | 1990 if ((ffname != NULL && (buf->b_ffname == NULL || buf->b_sfname == NULL)) |
1991 || buf->b_wininfo == NULL) | 1991 || buf->b_wininfo == NULL) |
1992 { | 1992 { |
1993 if (buf->b_sfname != buf->b_ffname) | 1993 if (buf->b_sfname != buf->b_ffname) |
2632 } | 2632 } |
2633 if (count == 0) /* no match found, break here */ | 2633 if (count == 0) /* no match found, break here */ |
2634 break; | 2634 break; |
2635 if (round == 1) | 2635 if (round == 1) |
2636 { | 2636 { |
2637 *file = (char_u **)alloc(count * sizeof(char_u *)); | 2637 *file = ALLOC_MULT(char_u *, count); |
2638 if (*file == NULL) | 2638 if (*file == NULL) |
2639 { | 2639 { |
2640 vim_regfree(regmatch.regprog); | 2640 vim_regfree(regmatch.regprog); |
2641 if (patc != pat) | 2641 if (patc != pat) |
2642 vim_free(patc); | 2642 vim_free(patc); |
2769 if (wip->wi_win == win) | 2769 if (wip->wi_win == win) |
2770 break; | 2770 break; |
2771 if (wip == NULL) | 2771 if (wip == NULL) |
2772 { | 2772 { |
2773 /* allocate a new entry */ | 2773 /* allocate a new entry */ |
2774 wip = (wininfo_T *)alloc_clear(sizeof(wininfo_T)); | 2774 wip = ALLOC_CLEAR_ONE(wininfo_T); |
2775 if (wip == NULL) | 2775 if (wip == NULL) |
2776 return; | 2776 return; |
2777 wip->wi_win = win; | 2777 wip->wi_win = win; |
2778 if (lnum == 0) /* set lnum even when it's 0 */ | 2778 if (lnum == 0) /* set lnum even when it's 0 */ |
2779 lnum = 1; | 2779 lnum = 1; |
3428 int n; | 3428 int n; |
3429 char *p; | 3429 char *p; |
3430 char *buffer; | 3430 char *buffer; |
3431 size_t len; | 3431 size_t len; |
3432 | 3432 |
3433 buffer = (char *)alloc(IOSIZE); | 3433 buffer = alloc(IOSIZE); |
3434 if (buffer == NULL) | 3434 if (buffer == NULL) |
3435 return; | 3435 return; |
3436 | 3436 |
3437 if (fullname > 1) /* 2 CTRL-G: include buffer number */ | 3437 if (fullname > 1) /* 2 CTRL-G: include buffer number */ |
3438 { | 3438 { |