Mercurial > vim
comparison src/undo.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 | 58009c45c31c |
children | 695d9ef00b03 |
comparison
equal
deleted
inserted
replaced
16763:fccf84413b53 | 16764:ef00b6bc186b |
---|---|
365 ul->ul_len = 1; | 365 ul->ul_len = 1; |
366 ul->ul_line = vim_strsave((char_u *)""); | 366 ul->ul_line = vim_strsave((char_u *)""); |
367 } | 367 } |
368 else | 368 else |
369 { | 369 { |
370 // This uses the length in the memline, thus text properties are | |
371 // included. | |
370 ul->ul_len = curbuf->b_ml.ml_line_len; | 372 ul->ul_len = curbuf->b_ml.ml_line_len; |
371 ul->ul_line = vim_memsave(line, ul->ul_len); | 373 ul->ul_line = vim_memsave(line, ul->ul_len); |
372 } | 374 } |
373 return ul->ul_line == NULL ? FAIL : OK; | 375 return ul->ul_line == NULL ? FAIL : OK; |
374 } | 376 } |
1119 * Returns a pointer to allocated memory or NULL for failure. | 1121 * Returns a pointer to allocated memory or NULL for failure. |
1120 */ | 1122 */ |
1121 static char_u * | 1123 static char_u * |
1122 read_string_decrypt(bufinfo_T *bi, int len) | 1124 read_string_decrypt(bufinfo_T *bi, int len) |
1123 { | 1125 { |
1124 char_u *ptr = alloc((unsigned)len + 1); | 1126 char_u *ptr = alloc(len + 1); |
1125 | 1127 |
1126 if (ptr != NULL) | 1128 if (ptr != NULL) |
1127 { | 1129 { |
1128 if (len > 0 && undo_read(bi, ptr, len) == FAIL) | 1130 if (len > 0 && undo_read(bi, ptr, len) == FAIL) |
1129 { | 1131 { |
2687 for (i = 0; i < newsize && i < oldsize; ++i) | 2689 for (i = 0; i < newsize && i < oldsize; ++i) |
2688 { | 2690 { |
2689 char_u *p = ml_get(top + 1 + i); | 2691 char_u *p = ml_get(top + 1 + i); |
2690 | 2692 |
2691 if (curbuf->b_ml.ml_line_len != uep->ue_array[i].ul_len | 2693 if (curbuf->b_ml.ml_line_len != uep->ue_array[i].ul_len |
2692 || memcmp(uep->ue_array[i].ul_line, p, curbuf->b_ml.ml_line_len) != 0) | 2694 || memcmp(uep->ue_array[i].ul_line, p, |
2695 curbuf->b_ml.ml_line_len) != 0) | |
2693 break; | 2696 break; |
2694 } | 2697 } |
2695 if (i == newsize && newlnum == MAXLNUM && uep->ue_next == NULL) | 2698 if (i == newsize && newlnum == MAXLNUM && uep->ue_next == NULL) |
2696 { | 2699 { |
2697 newlnum = top; | 2700 newlnum = top; |
2748 for (lnum = top, i = 0; i < newsize; ++i, ++lnum) | 2751 for (lnum = top, i = 0; i < newsize; ++i, ++lnum) |
2749 { | 2752 { |
2750 // If the file is empty, there is an empty line 1 that we | 2753 // If the file is empty, there is an empty line 1 that we |
2751 // should get rid of, by replacing it with the new line. | 2754 // should get rid of, by replacing it with the new line. |
2752 if (empty_buffer && lnum == 0) | 2755 if (empty_buffer && lnum == 0) |
2753 ml_replace_len((linenr_T)1, uep->ue_array[i].ul_line, uep->ue_array[i].ul_len, TRUE, TRUE); | 2756 ml_replace_len((linenr_T)1, uep->ue_array[i].ul_line, |
2757 uep->ue_array[i].ul_len, TRUE, TRUE); | |
2754 else | 2758 else |
2755 ml_append(lnum, uep->ue_array[i].ul_line, (colnr_T)uep->ue_array[i].ul_len, FALSE); | 2759 ml_append(lnum, uep->ue_array[i].ul_line, |
2760 (colnr_T)uep->ue_array[i].ul_len, FALSE); | |
2756 vim_free(uep->ue_array[i].ul_line); | 2761 vim_free(uep->ue_array[i].ul_line); |
2757 } | 2762 } |
2758 vim_free((char_u *)uep->ue_array); | 2763 vim_free((char_u *)uep->ue_array); |
2759 } | 2764 } |
2760 | 2765 |