Implement xcalloc and use it in klist.h (use xrealloc as well)

Bonus: implement lalloc_clear and alloc_clear using xcalloc
This commit is contained in:
Felipe Oliveira Carvalho
2014-04-05 16:54:01 -03:00
committed by Thiago de Arruda
parent fa02ada732
commit fac85c1724
3 changed files with 41 additions and 12 deletions

View File

@@ -2,6 +2,8 @@
#define NEOVIM_MEMORY_H
#include "func_attr.h"
#include "types.h"
#include "vim.h"
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);
@@ -19,6 +21,15 @@ char_u *lalloc_clear(long_u size, int message) FUNC_ATTR_MALLOC FUNC_ATTR_ALLOC_
void *xmalloc(size_t size)
FUNC_ATTR_MALLOC FUNC_ATTR_ALLOC_SIZE(1) FUNC_ATTR_NONNULL_RET;
/// calloc() wrapper
///
/// @see {xmalloc}
/// @param count
/// @param size
/// @return pointer to allocated space. Never NULL
void *xcalloc(size_t count, size_t size)
FUNC_ATTR_MALLOC FUNC_ATTR_ALLOC_SIZE_PROD(1, 2) FUNC_ATTR_NONNULL_RET;
/// realloc() wrapper
///
/// @see {xmalloc}