mirror of
https://github.com/neovim/neovim.git
synced 2025-09-29 22:48:34 +00:00
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:

committed by
Thiago de Arruda

parent
fa02ada732
commit
fac85c1724
11
src/memory.h
11
src/memory.h
@@ -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}
|
||||
|
Reference in New Issue
Block a user