diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2015-03-21 08:58:04 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2015-04-21 16:57:08 -0700 |
commit | c213b29d14aaf2f4523d638abc762eaaa873cf83 (patch) | |
tree | d1aeb60caa2b010229bc6d42344260004db87e8e /include | |
parent | 0887c9463fc7d36d7874e7f978df4109542f7307 (diff) |
Add xallocarray() helper macro
Uses reallocarray to perform integer overflow detection when allocating
an array, using NULL as the previous pointer to force a new allocation.
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.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/include/os.h b/include/os.h index ffa5f3923..263374185 100644 --- a/include/os.h +++ b/include/os.h @@ -74,6 +74,8 @@ typedef struct _NewClientRec *NewClientPtr; #define xstrdup(s) Xstrdup(s) #define xnfstrdup(s) XNFstrdup(s) + +#define xallocarray(num, size) reallocarray(NULL, (num), (size)) #endif #include <stdio.h> |