aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Schmidt <john.schmidt.h@gmail.com>2014-04-18 01:52:48 +0200
committerThiago de Arruda <tpadilha84@gmail.com>2014-04-19 09:36:17 -0300
commit63cc8b6934e74da2fd13aa5d9f2254c257a45b1c (patch)
tree0af45b07e1d92d19529b69172431606def237102
parent204d3dfafcc5b285d112e023dd5e5b6f1e861146 (diff)
downloadrneovim-63cc8b6934e74da2fd13aa5d9f2254c257a45b1c.tar.gz
rneovim-63cc8b6934e74da2fd13aa5d9f2254c257a45b1c.tar.bz2
rneovim-63cc8b6934e74da2fd13aa5d9f2254c257a45b1c.zip
Remove `lalloc_clear`
Use `xcalloc` instead. Change some local variables to avoid casting.
-rw-r--r--src/memfile.c2
-rw-r--r--src/memory.c8
-rw-r--r--src/memory.h1
-rw-r--r--src/ops.c12
-rw-r--r--src/screen.c3
-rw-r--r--src/search.c3
-rw-r--r--src/spell.c2
7 files changed, 9 insertions, 22 deletions
diff --git a/src/memfile.c b/src/memfile.c
index 18d8712e27..4aad5470d2 100644
--- a/src/memfile.c
+++ b/src/memfile.c
@@ -1264,7 +1264,7 @@ static void mf_hash_grow(mf_hashtab_T *mht)
size_t size;
size = (mht->mht_mask + 1) * MHT_GROWTH_FACTOR * sizeof(void *);
- buckets = (mf_hashitem_T **)lalloc_clear(size, FALSE);
+ buckets = xcalloc(1, size);
shift = 0;
while ((mht->mht_mask >> shift) != 0)
diff --git a/src/memory.c b/src/memory.c
index 5a5a22aa1e..16e98dae2d 100644
--- a/src/memory.c
+++ b/src/memory.c
@@ -72,14 +72,6 @@ char_u *alloc_clear(unsigned size)
return (char_u *)xcalloc(1, (size_t)size);
}
-/*
- * Allocate memory like lalloc() and set all bytes to zero.
- */
-char_u *lalloc_clear(long_u size, int message)
-{
- return (char_u *)xcalloc(1, (size_t)size);
-}
-
/// Try to free memory. Used when trying to recover from out of memory errors.
/// @see {xmalloc}
static void try_to_free_memory()
diff --git a/src/memory.h b/src/memory.h
index 4231ce8435..7a9b9053f3 100644
--- a/src/memory.h
+++ b/src/memory.h
@@ -7,7 +7,6 @@
char_u *alloc(unsigned size) FUNC_ATTR_MALLOC FUNC_ATTR_ALLOC_SIZE(1);
char_u *alloc_clear(unsigned size) FUNC_ATTR_MALLOC FUNC_ATTR_ALLOC_SIZE(1);
-char_u *lalloc_clear(long_u size, int message) FUNC_ATTR_MALLOC FUNC_ATTR_ALLOC_SIZE(1);
/// malloc() wrapper
///
diff --git a/src/ops.c b/src/ops.c
index a4e2e55297..a2822bf6a0 100644
--- a/src/ops.c
+++ b/src/ops.c
@@ -2415,8 +2415,7 @@ int op_yank(oparg_T *oap, int deleting, int mess)
y_current->y_size = yanklines;
y_current->y_type = yanktype; /* set the yank register type */
y_current->y_width = 0;
- y_current->y_array = (char_u **)lalloc_clear((long_u)(sizeof(char_u *) *
- yanklines), TRUE);
+ y_current->y_array = xcalloc(yanklines, sizeof(char_u *));
y_idx = 0;
lnum = oap->start.lnum;
@@ -3465,9 +3464,9 @@ int do_join(long count, int insert_space, int save_undo, int use_formatoptions)
/* Allocate an array to store the number of spaces inserted before each
* line. We will use it to pre-compute the length of the new line and the
* proper placement of each original line in the new one. */
- spaces = lalloc_clear((long_u)count, TRUE);
+ spaces = xcalloc(count, 1);
if (remove_comments) {
- comments = (int *)lalloc_clear((long_u)count * sizeof(int), TRUE);
+ comments = xcalloc(count, sizeof(*comments));
}
/*
@@ -4862,7 +4861,7 @@ str_to_reg (
long start;
long i;
int extra;
- int newlines; /* number of lines added */
+ size_t newlines; /* number of lines added */
int extraline = 0; /* extra line at the end */
int append = FALSE; /* append to last line in register */
char_u *s;
@@ -4898,8 +4897,7 @@ str_to_reg (
* Allocate an array to hold the pointers to the new register lines.
* If the register was not empty, move the existing lines to the new array.
*/
- pp = (char_u **)lalloc_clear((y_ptr->y_size + newlines)
- * sizeof(char_u *), TRUE);
+ pp = xcalloc((y_ptr->y_size + newlines), sizeof(char_u *));
for (lnum = 0; lnum < y_ptr->y_size; ++lnum)
pp[lnum] = y_ptr->y_array[lnum];
vim_free(y_ptr->y_array);
diff --git a/src/screen.c b/src/screen.c
index bfa51973b7..fde1fb7856 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -6265,8 +6265,7 @@ retry:
new_ScreenLinesUC = (u8char_T *)lalloc((long_u)(
(Rows + 1) * Columns * sizeof(u8char_T)), FALSE);
for (i = 0; i < p_mco; ++i)
- new_ScreenLinesC[i] = (u8char_T *)lalloc_clear((long_u)(
- (Rows + 1) * Columns * sizeof(u8char_T)), FALSE);
+ new_ScreenLinesC[i] = xcalloc((Rows + 1) * Columns, sizeof(u8char_T));
}
if (enc_dbcs == DBCS_JPNU)
new_ScreenLines2 = (schar_T *)lalloc((long_u)(
diff --git a/src/search.c b/src/search.c
index 37f7f27eeb..f3eec5227d 100644
--- a/src/search.c
+++ b/src/search.c
@@ -4057,8 +4057,7 @@ find_pattern_in_path (
goto fpip_end;
def_regmatch.rm_ic = FALSE; /* don't ignore case in define pat. */
}
- files = (SearchedFile *)lalloc_clear((long_u)
- (max_path_depth * sizeof(SearchedFile)), TRUE);
+ files = xcalloc(max_path_depth, sizeof(SearchedFile));
if (files == NULL)
goto fpip_end;
old_files = max_path_depth;
diff --git a/src/spell.c b/src/spell.c
index 7e43596a95..ec8d3db296 100644
--- a/src/spell.c
+++ b/src/spell.c
@@ -3657,7 +3657,7 @@ spell_read_tree (
*bytsp = bp;
/* Allocate the index array. */
- ip = (idx_T *)lalloc_clear((long_u)(len * sizeof(int)), TRUE);
+ ip = xcalloc(len, sizeof(*ip));
*idxsp = ip;
/* Recursively read the tree and store it in the array. */