summaryrefslogtreecommitdiff
path: root/src/memfile.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-05-28 23:08:19 +0200
committerBram Moolenaar <Bram@vim.org>2019-05-28 23:08:19 +0200
commitc799fe206e61f2e2c1231bc46cbe4bb354f3da69 (patch)
tree68b3d2a8bb82519e29fc95f317d2ee02b07f95fa /src/memfile.c
parentb58a4b938c4bc7e0499700859bd7abba9acc5b11 (diff)
downloadvim-git-c799fe206e61f2e2c1231bc46cbe4bb354f3da69.tar.gz
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type castsv8.1.1414
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.
Diffstat (limited to 'src/memfile.c')
-rw-r--r--src/memfile.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/memfile.c b/src/memfile.c
index 5bc587c1f..f3af7ebc8 100644
--- a/src/memfile.c
+++ b/src/memfile.c
@@ -130,7 +130,7 @@ mf_open(char_u *fname, int flags)
struct STATFS stf;
#endif
- if ((mfp = (memfile_T *)alloc(sizeof(memfile_T))) == NULL)
+ if ((mfp = ALLOC_ONE(memfile_T)) == NULL)
return NULL;
if (fname == NULL) /* no file for this memfile, use memory only */
@@ -362,7 +362,7 @@ mf_new(memfile_T *mfp, int negative, int page_count)
}
else if (hp == NULL) /* need to allocate memory for this block */
{
- if ((p = (char_u *)alloc(mfp->mf_page_size * page_count)) == NULL)
+ if ((p = alloc(mfp->mf_page_size * page_count)) == NULL)
return NULL;
hp = mf_rem_free(mfp);
hp->bh_data = p;
@@ -893,10 +893,9 @@ mf_alloc_bhdr(memfile_T *mfp, int page_count)
{
bhdr_T *hp;
- if ((hp = (bhdr_T *)alloc(sizeof(bhdr_T))) != NULL)
+ if ((hp = ALLOC_ONE(bhdr_T)) != NULL)
{
- if ((hp->bh_data = (char_u *)alloc(mfp->mf_page_size * page_count))
- == NULL)
+ if ((hp->bh_data = alloc(mfp->mf_page_size * page_count)) == NULL)
{
vim_free(hp); /* not enough memory */
return NULL;
@@ -1131,7 +1130,7 @@ mf_trans_add(memfile_T *mfp, bhdr_T *hp)
if (hp->bh_bnum >= 0) /* it's already positive */
return OK;
- if ((np = (NR_TRANS *)alloc(sizeof(NR_TRANS))) == NULL)
+ if ((np = ALLOC_ONE(NR_TRANS)) == NULL)
return FAIL;
/*
@@ -1460,7 +1459,7 @@ mf_hash_grow(mf_hashtab_T *mht)
size_t size;
size = (mht->mht_mask + 1) * MHT_GROWTH_FACTOR * sizeof(void *);
- buckets = (mf_hashitem_T **)lalloc_clear(size, FALSE);
+ buckets = lalloc_clear(size, FALSE);
if (buckets == NULL)
return FAIL;