Mercurial > vim
comparison src/message.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 | 041156ce1d22 |
comparison
equal
deleted
inserted
replaced
16824:1f6bb29738d2 | 16825:ce04ebdf26b8 |
---|---|
873 /* Don't let the message history get too big */ | 873 /* Don't let the message history get too big */ |
874 while (msg_hist_len > MAX_MSG_HIST_LEN) | 874 while (msg_hist_len > MAX_MSG_HIST_LEN) |
875 (void)delete_first_msg(); | 875 (void)delete_first_msg(); |
876 | 876 |
877 /* allocate an entry and add the message at the end of the history */ | 877 /* allocate an entry and add the message at the end of the history */ |
878 p = (struct msg_hist *)alloc(sizeof(struct msg_hist)); | 878 p = ALLOC_ONE(struct msg_hist); |
879 if (p != NULL) | 879 if (p != NULL) |
880 { | 880 { |
881 if (len < 0) | 881 if (len < 0) |
882 len = (int)STRLEN(s); | 882 len = (int)STRLEN(s); |
883 /* remove leading and trailing newlines */ | 883 /* remove leading and trailing newlines */ |
2358 do_clear_sb_text = SB_CLEAR_NONE; | 2358 do_clear_sb_text = SB_CLEAR_NONE; |
2359 } | 2359 } |
2360 | 2360 |
2361 if (s > *sb_str) | 2361 if (s > *sb_str) |
2362 { | 2362 { |
2363 mp = (msgchunk_T *)alloc(sizeof(msgchunk_T) + (s - *sb_str)); | 2363 mp = alloc(sizeof(msgchunk_T) + (s - *sb_str)); |
2364 if (mp != NULL) | 2364 if (mp != NULL) |
2365 { | 2365 { |
2366 mp->sb_eol = finish; | 2366 mp->sb_eol = finish; |
2367 mp->sb_msg_col = *sb_col; | 2367 mp->sb_msg_col = *sb_col; |
2368 mp->sb_attr = attr; | 2368 mp->sb_attr = attr; |