summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoe <joe@61a7d7f5-40b7-0310-9c16-bb0ea8cb1845>2018-09-24 09:21:26 +0000
committerjoe <joe@61a7d7f5-40b7-0310-9c16-bb0ea8cb1845>2018-09-24 09:21:26 +0000
commit0c3077b974bae385d2af92328cda158a1e713fbd (patch)
tree48cf1ca7597081105b1b5e19c372b5f1f239070c
parent1f65038e790f7217d34414289f81c9c0a9ac9817 (diff)
downloadneon-0c3077b974bae385d2af92328cda158a1e713fbd.tar.gz
* src/ne_defs.h: Define ne_attribute_alloc_size.
* src/ne_alloc.h (ne_malloc, ne_calloc, ne_realloc): Use it. git-svn-id: http://svn.webdav.org/repos/projects/neon/trunk@2006 61a7d7f5-40b7-0310-9c16-bb0ea8cb1845
-rw-r--r--src/ne_alloc.h6
-rw-r--r--src/ne_defs.h3
2 files changed, 6 insertions, 3 deletions
diff --git a/src/ne_alloc.h b/src/ne_alloc.h
index 0322fa7..17eea56 100644
--- a/src/ne_alloc.h
+++ b/src/ne_alloc.h
@@ -43,9 +43,9 @@ void ne_oom_callback(ne_oom_callback_fn callback);
* neon will abort(); calling an OOM callback beforehand if one is
* registered. The C library will only ever return NULL if the
* operating system does not use optimistic memory allocation. */
-void *ne_malloc(size_t size) ne_attribute_malloc;
-void *ne_calloc(size_t size) ne_attribute_malloc;
-void *ne_realloc(void *ptr, size_t s);
+void *ne_malloc(size_t size) ne_attribute_alloc_size(1);
+void *ne_calloc(size_t size) ne_attribute_alloc_size(1);
+void *ne_realloc(void *ptr, size_t s) ne_attribute_alloc_size(2);
char *ne_strdup(const char *s) ne_attribute_malloc;
char *ne_strndup(const char *s, size_t n) ne_attribute_malloc;
#ifdef WIN32
diff --git a/src/ne_defs.h b/src/ne_defs.h
index 4283454..bd31257 100644
--- a/src/ne_defs.h
+++ b/src/ne_defs.h
@@ -58,8 +58,10 @@ typedef off_t ne_off_t;
#define NE_PRIVATE __attribute__((visibility ("hidden")))
#endif
#define ne_attribute_malloc __attribute__((malloc))
+#define ne_attribute_alloc_size(x) __attribute__((alloc_size(x)))
#else
#define ne_attribute_malloc
+#define ne_attribute_alloc_size(x)
#endif
#if __GNUC__ > 3
#define ne_attribute_sentinel __attribute__((sentinel))
@@ -70,6 +72,7 @@ typedef off_t ne_off_t;
#else
#define ne_attribute(x)
#define ne_attribute_malloc
+#define ne_attribute_alloc_size(x)
#define ne_attribute_sentinel
#endif