aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Hillegeer <nicolas@hillegeer.com>2014-03-31 19:09:54 +0200
committerThiago de Arruda <tpadilha84@gmail.com>2014-03-31 18:42:17 -0300
commit7b14caf6044769483bb6fef9ee8dc71003f91494 (patch)
tree8cad88659558bf282c7804fda3603f1849f1624a
parent22e17e25f11ecabe27c752275da73d8ee75c953e (diff)
downloadrneovim-7b14caf6044769483bb6fef9ee8dc71003f91494.tar.gz
rneovim-7b14caf6044769483bb6fef9ee8dc71003f91494.tar.bz2
rneovim-7b14caf6044769483bb6fef9ee8dc71003f91494.zip
alloc: xmalloc and xrealloc can't return null
With this annotation/function attribute, we can inform gcc that these functions never return null, which can save a lot of redundant null checks.
-rw-r--r--src/misc2.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/misc2.h b/src/misc2.h
index 6f7c7a4768..265f93a430 100644
--- a/src/misc2.h
+++ b/src/misc2.h
@@ -29,9 +29,10 @@ 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);
void try_to_free_memory();
-void *xmalloc(size_t size) FUNC_ATTR_MALLOC FUNC_ATTR_ALLOC_SIZE(1);
+void *xmalloc(size_t size)
+ FUNC_ATTR_MALLOC FUNC_ATTR_ALLOC_SIZE(1) FUNC_ATTR_NONNULL_RET;
void *xrealloc(void *ptr, size_t size)
- FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_ALLOC_SIZE(2);
+ FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_ALLOC_SIZE(2) FUNC_ATTR_NONNULL_RET;
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);