refactor: add function xstrnsave

xstrnsave is a clone of vim_strnsave that uses char* instead of char_u*.
Its purpose short-term is to help reduce the number of casts and for
long-term to replace vim_strnsave as the need to use char_u is
eliminated.
This commit is contained in:
Dundar Goc
2022-04-15 19:49:06 +02:00
parent 7a2fcbbbec
commit 88270a5735
4 changed files with 13 additions and 6 deletions

View File

@@ -388,12 +388,12 @@ char *get_exception_string(void *value, except_type_T type, char_u *cmdname, int
mesg = ((struct msglist *)value)->throw_msg;
if (cmdname != NULL && *cmdname != NUL) {
size_t cmdlen = STRLEN(cmdname);
ret = (char *)vim_strnsave((char_u *)"Vim(", 4 + cmdlen + 2 + STRLEN(mesg));
ret = xstrnsave("Vim(", 4 + cmdlen + 2 + STRLEN(mesg));
STRCPY(&ret[4], cmdname);
STRCPY(&ret[4 + cmdlen], "):");
val = ret + 4 + cmdlen + 2;
} else {
ret = (char *)vim_strnsave((char_u *)"Vim:", 4 + STRLEN(mesg));
ret = xstrnsave("Vim:", 4 + STRLEN(mesg));
val = ret + 4;
}