Mercurial > vim
comparison src/netbeans.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 | cd5c83115ec6 |
children | 695d9ef00b03 |
comparison
equal
deleted
inserted
replaced
16763:fccf84413b53 | 16764:ef00b6bc186b |
---|---|
788 { | 788 { |
789 char_u *reply; | 789 char_u *reply; |
790 | 790 |
791 nbdebug(("REP %d: %s\n", cmdno, (char *)result)); | 791 nbdebug(("REP %d: %s\n", cmdno, (char *)result)); |
792 | 792 |
793 reply = alloc((unsigned)STRLEN(result) + 32); | 793 reply = alloc(STRLEN(result) + 32); |
794 sprintf((char *)reply, "%d %s\n", cmdno, (char *)result); | 794 sprintf((char *)reply, "%d %s\n", cmdno, (char *)result); |
795 nb_send((char *)reply, "nb_reply_text"); | 795 nb_send((char *)reply, "nb_reply_text"); |
796 | 796 |
797 vim_free(reply); | 797 vim_free(reply); |
798 } | 798 } |
817 * Encode newline, ret, backslash, double quote for transmission to NetBeans. | 817 * Encode newline, ret, backslash, double quote for transmission to NetBeans. |
818 */ | 818 */ |
819 static char_u * | 819 static char_u * |
820 nb_quote(char_u *txt) | 820 nb_quote(char_u *txt) |
821 { | 821 { |
822 char_u *buf = alloc((unsigned)(2 * STRLEN(txt) + 1)); | 822 char_u *buf = alloc(2 * STRLEN(txt) + 1); |
823 char_u *p = txt; | 823 char_u *p = txt; |
824 char_u *q = buf; | 824 char_u *q = buf; |
825 | 825 |
826 if (buf == NULL) | 826 if (buf == NULL) |
827 return NULL; | 827 return NULL; |
949 int len_first, len_other; | 949 int len_first, len_other; |
950 char_u *p; | 950 char_u *p; |
951 | 951 |
952 len_first = (int)STRLEN(ml_get(first)); | 952 len_first = (int)STRLEN(ml_get(first)); |
953 len_other = (int)STRLEN(ml_get(other)); | 953 len_other = (int)STRLEN(ml_get(other)); |
954 p = alloc((unsigned)(len_first + len_other + 1)); | 954 p = alloc(len_first + len_other + 1); |
955 if (p != NULL) | 955 if (p != NULL) |
956 { | 956 { |
957 mch_memmove(p, ml_get(first), len_first); | 957 mch_memmove(p, ml_get(first), len_first); |
958 mch_memmove(p + len_first, ml_get(other), len_other + 1); | 958 mch_memmove(p + len_first, ml_get(other), len_other + 1); |
959 ml_replace(first, p, FALSE); | 959 ml_replace(first, p, FALSE); |
1082 } | 1082 } |
1083 else | 1083 else |
1084 { | 1084 { |
1085 len = get_buf_size(buf->bufp); | 1085 len = get_buf_size(buf->bufp); |
1086 nlines = buf->bufp->b_ml.ml_line_count; | 1086 nlines = buf->bufp->b_ml.ml_line_count; |
1087 text = alloc((unsigned)((len > 0) | 1087 text = alloc((len > 0) ? ((len + nlines) * 2) : 4); |
1088 ? ((len + nlines) * 2) : 4)); | |
1089 if (text == NULL) | 1088 if (text == NULL) |
1090 { | 1089 { |
1091 nbdebug((" nb_do_cmd: getText has null text field\n")); | 1090 nbdebug((" nb_do_cmd: getText has null text field\n")); |
1092 retval = FAIL; | 1091 retval = FAIL; |
1093 } | 1092 } |
1393 { | 1392 { |
1394 char_u *oldline = ml_get(lnum); | 1393 char_u *oldline = ml_get(lnum); |
1395 char_u *newline; | 1394 char_u *newline; |
1396 | 1395 |
1397 /* Insert halfway a line. */ | 1396 /* Insert halfway a line. */ |
1398 newline = alloc_check( | 1397 newline = alloc(STRLEN(oldline) + len + 1); |
1399 (unsigned)(STRLEN(oldline) + len + 1)); | |
1400 if (newline != NULL) | 1398 if (newline != NULL) |
1401 { | 1399 { |
1402 mch_memmove(newline, oldline, (size_t)pos->col); | 1400 mch_memmove(newline, oldline, (size_t)pos->col); |
1403 newline[pos->col] = NUL; | 1401 newline[pos->col] = NUL; |
1404 STRCAT(newline, args); | 1402 STRCAT(newline, args); |