diff options
author | John Schmidt <john.schmidt.h@gmail.com> | 2014-04-03 17:07:14 +0200 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-04-04 16:33:12 -0300 |
commit | 6f53cb1cc311025f0c21d142af06fbfbda113fc4 (patch) | |
tree | d4381dd18e74f4bec084ed7602e90561fa3ad50c /src/memory.h | |
parent | 3fe0580a8edae062c91fda83fcb2766188088f2e (diff) | |
download | rneovim-6f53cb1cc311025f0c21d142af06fbfbda113fc4.tar.gz rneovim-6f53cb1cc311025f0c21d142af06fbfbda113fc4.tar.bz2 rneovim-6f53cb1cc311025f0c21d142af06fbfbda113fc4.zip |
Extract memory.c from misc2.c
Diffstat (limited to 'src/memory.h')
-rw-r--r-- | src/memory.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/memory.h b/src/memory.h new file mode 100644 index 0000000000..49661d6117 --- /dev/null +++ b/src/memory.h @@ -0,0 +1,38 @@ +#ifndef NEOVIM_MEMORY_H +#define NEOVIM_MEMORY_H + +#include "func_attr.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); +char_u *alloc_check(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 +/// +/// xmalloc() succeeds or gracefully aborts when out of memory. +/// Before aborting try to free some memory and call malloc again. +/// +/// @see {try_to_free_memory} +/// @param size +/// @return pointer to allocated space. Never NULL +void *xmalloc(size_t size) + FUNC_ATTR_MALLOC FUNC_ATTR_ALLOC_SIZE(1) FUNC_ATTR_NONNULL_RET; + +/// realloc() wrapper +/// +/// @see {xmalloc} +/// @param size +/// @return pointer to reallocated space. Never NULL +void *xrealloc(void *ptr, size_t size) + FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_ALLOC_SIZE(2) FUNC_ATTR_NONNULL_RET; + +/// Old low level memory allocation function. +/// +/// @deprecated use xmalloc() directly instead +/// @param size +/// @return pointer to allocated space. Never NULL +char_u *lalloc(long_u size, int message) FUNC_ATTR_MALLOC FUNC_ATTR_ALLOC_SIZE(1); +void do_outofmem_msg(long_u size); +void free_all_mem(void); +#endif |