diff options
Diffstat (limited to 'src/nvim/misc1.c')
-rw-r--r-- | src/nvim/misc1.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c index df286c3a07..26a660c1b0 100644 --- a/src/nvim/misc1.c +++ b/src/nvim/misc1.c @@ -501,7 +501,7 @@ open_line ( } if (lead_len) { /* allocate buffer (may concatenate p_extra later) */ - leader = alloc(lead_len + lead_repl_len + extra_space + extra_len + leader = xmalloc(lead_len + lead_repl_len + extra_space + extra_len + (second_line_indent > 0 ? second_line_indent : 0) + 1); allocated = leader; /* remember to free it later */ @@ -1702,9 +1702,7 @@ del_bytes ( if (was_alloced) newp = oldp; /* use same allocated memory */ else { /* need to allocate a new line */ - newp = alloc((unsigned)(oldlen + 1 - count)); - if (newp == NULL) - return FAIL; + newp = xmalloc(oldlen + 1 - count); memmove(newp, oldp, (size_t)col); } memmove(newp + col, oldp + col + count, (size_t)movelen); @@ -2395,7 +2393,7 @@ int get_keystroke(void) * bytes. */ maxlen = (buflen - 6 - len) / 3; if (buf == NULL) - buf = alloc(buflen); + buf = xmalloc(buflen); else if (maxlen < 10) { /* Need some more space. This might happen when receiving a long * escape sequence. */ @@ -2715,9 +2713,7 @@ char_u *expand_env_save(char_u *src) */ char_u *expand_env_save_opt(char_u *src, int one) { - char_u *p; - - p = alloc(MAXPATHL); + char_u *p = xmalloc(MAXPATHL); expand_env_esc(src, p, MAXPATHL, FALSE, one, NULL); return p; } @@ -2865,8 +2861,9 @@ expand_env_esc ( if (p_ssl && var != NULL && vim_strchr(var, '\\') != NULL) { char_u *p = vim_strsave(var); - if (mustfree) + if (mustfree) { free(var); + } var = p; mustfree = TRUE; forward_slash(var); @@ -3321,13 +3318,12 @@ home_replace_save ( ) { char_u *dst; - unsigned len; - len = 3; /* space for "~/" and trailing NUL */ + size_t len = 3; /* space for "~/" and trailing NUL */ if (src != NULL) /* just in case */ - len += (unsigned)STRLEN(src); - dst = alloc(len); - home_replace(buf, src, dst, len, TRUE); + len += STRLEN(src); + dst = xmalloc(len); + home_replace(buf, src, dst, (int)len, TRUE); return dst; } @@ -3488,7 +3484,7 @@ get_cmd_output ( len = ftell(fd); /* get size of temp file */ fseek(fd, 0L, SEEK_SET); - buffer = alloc(len + 1); + buffer = xmalloc(len + 1); i = (int)fread((char *)buffer, (size_t)1, (size_t)len, fd); fclose(fd); os_remove((char *)tempname); |