diff options
author | Felipe Oliveira Carvalho <felipekde@gmail.com> | 2014-05-01 15:07:48 -0300 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2014-05-07 15:52:27 -0400 |
commit | 8704a5832b6d70d0ebc3872468beaea0367f4680 (patch) | |
tree | e34df96b21b68162f43713c4f37d4540c0fe3ac7 /src/edit.c | |
parent | 973baa2a06216931747404587461184d83cbdabe (diff) | |
download | rneovim-8704a5832b6d70d0ebc3872468beaea0367f4680.tar.gz rneovim-8704a5832b6d70d0ebc3872468beaea0367f4680.tar.bz2 rneovim-8704a5832b6d70d0ebc3872468beaea0367f4680.zip |
Replace lalloc() with xmalloc()
Diffstat (limited to 'src/edit.c')
-rw-r--r-- | src/edit.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/edit.c b/src/edit.c index 4b1d1878d1..146a8bba70 100644 --- a/src/edit.c +++ b/src/edit.c @@ -6271,32 +6271,31 @@ static int echeck_abbr(int c) */ static char_u *replace_stack = NULL; -static long replace_stack_nr = 0; /* next entry in replace stack */ -static long replace_stack_len = 0; /* max. number of entries */ +static ssize_t replace_stack_nr = 0; /* next entry in replace stack */ +static ssize_t replace_stack_len = 0; /* max. number of entries */ void replace_push ( int c /* character that is replaced (NUL is none) */ ) { - char_u *p; - if (replace_stack_nr < replace_offset) /* nothing to do */ return; + + // TODO(philix): use xrealloc in replace_push() if (replace_stack_len <= replace_stack_nr) { replace_stack_len += 50; - p = lalloc(sizeof(char_u) * replace_stack_len, TRUE); + void *aux = xmalloc(replace_stack_len); if (replace_stack != NULL) { - memmove(p, replace_stack, - (size_t)(replace_stack_nr * sizeof(char_u))); + memmove(aux, replace_stack, replace_stack_nr); free(replace_stack); } - replace_stack = p; + replace_stack = aux; } - p = replace_stack + replace_stack_nr - replace_offset; + char_u *p = replace_stack + replace_stack_nr - replace_offset; if (replace_offset) - memmove(p + 1, p, (size_t)(replace_offset * sizeof(char_u))); - *p = c; + memmove(p + 1, p, replace_offset); + *p = (char_u)c; ++replace_stack_nr; } |