Mercurial > vim
comparison src/if_xcmdsrv.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 | ef00b6bc186b |
children | bbea1f108187 |
comparison
equal
deleted
inserted
replaced
16824:1f6bb29738d2 | 16825:ce04ebdf26b8 |
---|---|
439 * Send the command to target interpreter by appending it to the | 439 * Send the command to target interpreter by appending it to the |
440 * comm window in the communication window. | 440 * comm window in the communication window. |
441 * Length must be computed exactly! | 441 * Length must be computed exactly! |
442 */ | 442 */ |
443 length = STRLEN(name) + STRLEN(p_enc) + STRLEN(cmd) + 14; | 443 length = STRLEN(name) + STRLEN(p_enc) + STRLEN(cmd) + 14; |
444 property = (char_u *)alloc(length + 30); | 444 property = alloc(length + 30); |
445 | 445 |
446 sprintf((char *)property, "%c%c%c-n %s%c-E %s%c-s %s", | 446 sprintf((char *)property, "%c%c%c-n %s%c-E %s%c-s %s", |
447 0, asExpr ? 'c' : 'k', 0, name, 0, p_enc, 0, cmd); | 447 0, asExpr ? 'c' : 'k', 0, name, 0, p_enc, 0, cmd); |
448 if (name == loosename) | 448 if (name == loosename) |
449 vim_free(loosename); | 449 vim_free(loosename); |
748 } | 748 } |
749 if (!WindowValid(dpy, win)) | 749 if (!WindowValid(dpy, win)) |
750 return -1; | 750 return -1; |
751 | 751 |
752 length = STRLEN(p_enc) + STRLEN(str) + 14; | 752 length = STRLEN(p_enc) + STRLEN(str) + 14; |
753 if ((property = (char_u *)alloc(length + 30)) != NULL) | 753 if ((property = alloc(length + 30)) != NULL) |
754 { | 754 { |
755 sprintf((char *)property, "%cn%c-E %s%c-n %s%c-w %x", | 755 sprintf((char *)property, "%cn%c-E %s%c-n %s%c-w %x", |
756 0, 0, p_enc, 0, str, 0, (unsigned int)commWindow); | 756 0, 0, p_enc, 0, str, 0, (unsigned int)commWindow); |
757 /* Add length of what "%x" resulted in. */ | 757 /* Add length of what "%x" resulted in. */ |
758 length += STRLEN(property + length); | 758 length += STRLEN(property + length); |
1155 static void | 1155 static void |
1156 save_in_queue(char_u *propInfo, long_u len) | 1156 save_in_queue(char_u *propInfo, long_u len) |
1157 { | 1157 { |
1158 x_queue_T *node; | 1158 x_queue_T *node; |
1159 | 1159 |
1160 node = (x_queue_T *)alloc(sizeof(x_queue_T)); | 1160 node = ALLOC_ONE(x_queue_T); |
1161 if (node == NULL) | 1161 if (node == NULL) |
1162 return; /* out of memory */ | 1162 return; /* out of memory */ |
1163 node->propInfo = propInfo; | 1163 node->propInfo = propInfo; |
1164 node->len = len; | 1164 node->len = len; |
1165 | 1165 |