aboutsummaryrefslogtreecommitdiff
path: root/src/ex_cmds.c
diff options
context:
space:
mode:
authorFelipe Oliveira Carvalho <felipekde@gmail.com>2014-05-01 15:07:48 -0300
committerJustin M. Keyes <justinkz@gmail.com>2014-05-07 15:52:27 -0400
commit8704a5832b6d70d0ebc3872468beaea0367f4680 (patch)
treee34df96b21b68162f43713c4f37d4540c0fe3ac7 /src/ex_cmds.c
parent973baa2a06216931747404587461184d83cbdabe (diff)
downloadrneovim-8704a5832b6d70d0ebc3872468beaea0367f4680.tar.gz
rneovim-8704a5832b6d70d0ebc3872468beaea0367f4680.tar.bz2
rneovim-8704a5832b6d70d0ebc3872468beaea0367f4680.zip
Replace lalloc() with xmalloc()
Diffstat (limited to 'src/ex_cmds.c')
-rw-r--r--src/ex_cmds.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index 6a6b2fc615..0ef98b4c2a 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -344,7 +344,6 @@ void ex_sort(exarg_T *eap)
int len;
linenr_T lnum;
long maxlen = 0;
- sorti_T *nrs;
size_t count = (size_t)(eap->line2 - eap->line1 + 1);
size_t i;
char_u *p;
@@ -367,9 +366,7 @@ void ex_sort(exarg_T *eap)
sortbuf1 = NULL;
sortbuf2 = NULL;
regmatch.regprog = NULL;
- nrs = (sorti_T *)lalloc((long_u)(count * sizeof(sorti_T)), TRUE);
- if (nrs == NULL)
- goto sortend;
+ sorti_T *nrs = xmalloc(count * sizeof(sorti_T));
sort_abort = sort_ic = sort_rx = sort_nr = sort_oct = sort_hex = 0;
@@ -621,10 +618,8 @@ void ex_retab(exarg_T *eap)
/* len is actual number of white characters used */
len = num_spaces + num_tabs;
old_len = (long)STRLEN(ptr);
- new_line = lalloc(old_len - col + start_col + len + 1,
- TRUE);
- if (new_line == NULL)
- break;
+ new_line = xmalloc(old_len - col + start_col + len + 1);
+
if (start_col > 0)
memmove(new_line, ptr, (size_t)start_col);
memmove(new_line + start_col + len,
@@ -1893,16 +1888,11 @@ viminfo_readstring (
{
char_u *retval;
char_u *s, *d;
- long len;
if (virp->vir_line[off] == Ctrl_V && vim_isdigit(virp->vir_line[off + 1])) {
- len = atol((char *)virp->vir_line + off + 1);
- retval = lalloc(len, TRUE);
- if (retval == NULL) {
- /* Line too long? File messed up? Skip next line. */
- (void)vim_fgets(virp->vir_line, 10, virp->vir_fd);
- return NULL;
- }
+ ssize_t len = atol((char *)virp->vir_line + off + 1);
+ retval = xmalloc(len);
+ // TODO(philix): change type of vim_fgets() size argument to size_t
(void)vim_fgets(retval, (int)len, virp->vir_fd);
s = retval + 1; /* Skip the leading '<' */
} else {