summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2015-03-21 09:28:07 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2015-04-21 16:57:08 -0700
commitae75d50395fdd7a6bc382ba73e923c460764c702 (patch)
tree17087211fde038f5840535201c0c8768ed1e191a /include
parentc213b29d14aaf2f4523d638abc762eaaa873cf83 (diff)
Add no-fail equivalents of allocarray & reallocarray
v2: Remove extra 's' from comment Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Matt Turner <mattst88@gmail.com>
Diffstat (limited to 'include')
-rw-r--r--include/os.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/os.h b/include/os.h
index 263374185..6638c8443 100644
--- a/include/os.h
+++ b/include/os.h
@@ -76,6 +76,8 @@ typedef struct _NewClientRec *NewClientPtr;
#define xnfstrdup(s) XNFstrdup(s)
#define xallocarray(num, size) reallocarray(NULL, (num), (size))
+#define xnfallocarray(num, size) XNFreallocarray(NULL, (num), (size))
+#define xnfreallocarray(ptr, num, size) XNFreallocarray((ptr), (num), (size))
#endif
#include <stdio.h>
@@ -241,6 +243,13 @@ extern _X_EXPORT void *
XNFrealloc(void * /*ptr */ , unsigned long /*amount */ );
/*
+ * This function reallocarray(3)s passed buffer, terminating the server if
+ * there is not enough memory or the arguments overflow when multiplied.
+ */
+extern _X_EXPORT void *
+XNFreallocarray(void *ptr, size_t nmemb, size_t size);
+
+/*
* This function strdup(3)s passed string. The only difference from the library
* function that it is safe to pass NULL, as NULL will be returned.
*/