Mercurial > vim
comparison src/memline.c @ 16764:ef00b6bc186b v8.1.1384
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
commit https://github.com/vim/vim/commit/964b3746b9c81e65887e2ac9a335f181db2bb592
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri May 24 18:54:09 2019 +0200
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Problem: Using "int" for alloc() often results in compiler warnings.
Solution: Use "size_t" and remove type casts. Remove alloc_check(), Vim
only works with 32 bit ints anyway.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 24 May 2019 19:00:07 +0200 |
parents | b52ea9c5f1db |
children | 98ca522e6453 |
comparison
equal
deleted
inserted
replaced
16763:fccf84413b53 | 16764:ef00b6bc186b |
---|---|
1187 | 1187 |
1188 /* | 1188 /* |
1189 * Allocate a buffer structure for the swap file that is used for recovery. | 1189 * Allocate a buffer structure for the swap file that is used for recovery. |
1190 * Only the memline and crypt information in it are really used. | 1190 * Only the memline and crypt information in it are really used. |
1191 */ | 1191 */ |
1192 buf = (buf_T *)alloc((unsigned)sizeof(buf_T)); | 1192 buf = (buf_T *)alloc(sizeof(buf_T)); |
1193 if (buf == NULL) | 1193 if (buf == NULL) |
1194 goto theend; | 1194 goto theend; |
1195 | 1195 |
1196 /* | 1196 /* |
1197 * init fields in memline struct | 1197 * init fields in memline struct |
1785 | 1785 |
1786 /* | 1786 /* |
1787 * Do the loop for every directory in 'directory'. | 1787 * Do the loop for every directory in 'directory'. |
1788 * First allocate some memory to put the directory name in. | 1788 * First allocate some memory to put the directory name in. |
1789 */ | 1789 */ |
1790 dir_name = alloc((unsigned)STRLEN(p_dir) + 1); | 1790 dir_name = alloc(STRLEN(p_dir) + 1); |
1791 dirp = p_dir; | 1791 dirp = p_dir; |
1792 while (dir_name != NULL && *dirp) | 1792 while (dir_name != NULL && *dirp) |
1793 { | 1793 { |
1794 /* | 1794 /* |
1795 * Isolate a directory name from *dirp and put it in dir_name (we know | 1795 * Isolate a directory name from *dirp and put it in dir_name (we know |
1911 ); | 1911 ); |
1912 if (swapname != NULL) | 1912 if (swapname != NULL) |
1913 { | 1913 { |
1914 if (mch_stat((char *)swapname, &st) != -1) /* It exists! */ | 1914 if (mch_stat((char *)swapname, &st) != -1) /* It exists! */ |
1915 { | 1915 { |
1916 files = (char_u **)alloc((unsigned)sizeof(char_u *)); | 1916 files = (char_u **)alloc(sizeof(char_u *)); |
1917 if (files != NULL) | 1917 if (files != NULL) |
1918 { | 1918 { |
1919 files[0] = swapname; | 1919 files[0] = swapname; |
1920 swapname = NULL; | 1920 swapname = NULL; |
1921 num_files = 1; | 1921 num_files = 1; |
2013 char_u *d = NULL, *s, *f; | 2013 char_u *d = NULL, *s, *f; |
2014 | 2014 |
2015 f = fix_fname(name != NULL ? name : (char_u *)""); | 2015 f = fix_fname(name != NULL ? name : (char_u *)""); |
2016 if (f != NULL) | 2016 if (f != NULL) |
2017 { | 2017 { |
2018 s = alloc((unsigned)(STRLEN(f) + 1)); | 2018 s = alloc(STRLEN(f) + 1); |
2019 if (s != NULL) | 2019 if (s != NULL) |
2020 { | 2020 { |
2021 STRCPY(s, f); | 2021 STRCPY(s, f); |
2022 for (d = s; *d != NUL; MB_PTR_ADV(d)) | 2022 for (d = s; *d != NUL; MB_PTR_ADV(d)) |
2023 if (vim_ispathsep(*d)) | 2023 if (vim_ispathsep(*d)) |
2672 if (round == 2) | 2672 if (round == 2) |
2673 { | 2673 { |
2674 if (new_prop_count == 0) | 2674 if (new_prop_count == 0) |
2675 return; // nothing to do | 2675 return; // nothing to do |
2676 new_len = *len + new_prop_count * sizeof(textprop_T); | 2676 new_len = *len + new_prop_count * sizeof(textprop_T); |
2677 new_line = alloc((unsigned)new_len); | 2677 new_line = alloc(new_len); |
2678 if (new_line == NULL) | 2678 if (new_line == NULL) |
2679 return; | 2679 return; |
2680 mch_memmove(new_line, *line, *len); | 2680 mch_memmove(new_line, *line, *len); |
2681 new_prop_count = 0; | 2681 new_prop_count = 0; |
2682 } | 2682 } |
4199 /* may have to increase the stack size */ | 4199 /* may have to increase the stack size */ |
4200 if (top == buf->b_ml.ml_stack_size) | 4200 if (top == buf->b_ml.ml_stack_size) |
4201 { | 4201 { |
4202 CHECK(top > 0, _("Stack size increases")); /* more than 5 levels??? */ | 4202 CHECK(top > 0, _("Stack size increases")); /* more than 5 levels??? */ |
4203 | 4203 |
4204 newstack = (infoptr_T *)alloc((unsigned)sizeof(infoptr_T) * | 4204 newstack = (infoptr_T *)alloc(sizeof(infoptr_T) * |
4205 (buf->b_ml.ml_stack_size + STACK_INCR)); | 4205 (buf->b_ml.ml_stack_size + STACK_INCR)); |
4206 if (newstack == NULL) | 4206 if (newstack == NULL) |
4207 return -1; | 4207 return -1; |
4208 if (top > 0) | 4208 if (top > 0) |
4209 mch_memmove(newstack, buf->b_ml.ml_stack, | 4209 mch_memmove(newstack, buf->b_ml.ml_stack, |
4594 | 4594 |
4595 /* | 4595 /* |
4596 * Isolate a directory name from *dirp and put it in dir_name. | 4596 * Isolate a directory name from *dirp and put it in dir_name. |
4597 * First allocate some memory to put the directory name in. | 4597 * First allocate some memory to put the directory name in. |
4598 */ | 4598 */ |
4599 dir_name = alloc((unsigned)STRLEN(*dirp) + 1); | 4599 dir_name = alloc(STRLEN(*dirp) + 1); |
4600 if (dir_name == NULL) | 4600 if (dir_name == NULL) |
4601 *dirp = NULL; | 4601 *dirp = NULL; |
4602 else | 4602 else |
4603 (void)copy_option_part(dirp, dir_name, 31000, ","); | 4603 (void)copy_option_part(dirp, dir_name, 31000, ","); |
4604 | 4604 |
4918 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) | 4918 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) |
4919 if (swap_exists_action != SEA_NONE && choice == 0) | 4919 if (swap_exists_action != SEA_NONE && choice == 0) |
4920 { | 4920 { |
4921 char_u *name; | 4921 char_u *name; |
4922 | 4922 |
4923 name = alloc((unsigned)(STRLEN(fname) | 4923 name = alloc(STRLEN(fname) |
4924 + STRLEN(_("Swap file \"")) | 4924 + STRLEN(_("Swap file \"")) |
4925 + STRLEN(_("\" already exists!")) + 5)); | 4925 + STRLEN(_("\" already exists!")) + 5); |
4926 if (name != NULL) | 4926 if (name != NULL) |
4927 { | 4927 { |
4928 STRCPY(name, _("Swap file \"")); | 4928 STRCPY(name, _("Swap file \"")); |
4929 home_replace(NULL, fname, name + STRLEN(name), | 4929 home_replace(NULL, fname, name + STRLEN(name), |
4930 1000, TRUE); | 4930 1000, TRUE); |
5369 | 5369 |
5370 if (buf->b_ml.ml_usedchunks == -1 || len == 0) | 5370 if (buf->b_ml.ml_usedchunks == -1 || len == 0) |
5371 return; | 5371 return; |
5372 if (buf->b_ml.ml_chunksize == NULL) | 5372 if (buf->b_ml.ml_chunksize == NULL) |
5373 { | 5373 { |
5374 buf->b_ml.ml_chunksize = (chunksize_T *) | 5374 buf->b_ml.ml_chunksize = |
5375 alloc((unsigned)sizeof(chunksize_T) * 100); | 5375 (chunksize_T *)alloc(sizeof(chunksize_T) * 100); |
5376 if (buf->b_ml.ml_chunksize == NULL) | 5376 if (buf->b_ml.ml_chunksize == NULL) |
5377 { | 5377 { |
5378 buf->b_ml.ml_usedchunks = -1; | 5378 buf->b_ml.ml_usedchunks = -1; |
5379 return; | 5379 return; |
5380 } | 5380 } |