diff options
author | Michael McConville <mmcco@mykolab.com> | 2015-12-11 23:04:36 -0500 |
---|---|---|
committer | Will Estes <westes575@gmail.com> | 2015-12-12 15:25:40 -0500 |
commit | 77e54b25ee67ff066d8619d790b43cb2da227ae6 (patch) | |
tree | dd4f5be2eafbb738d731193c76c94d6509af9c90 /src/flexdef.h | |
parent | 13b5b214f53d1c3354a7ab910bd160c126df1331 (diff) |
Added new function reallocarray.
This is taken from OpenSSH Portable, which in turn takes it from
OpenBSD.
reallocarray wraps the stdlib's realloc function. It takes two size
arguments and checks for overflow, like calloc, but doesn't zero the
memory. Therefore, it allows us to do overflow-safe array reallocations
and overflow-safe unzeroed array allocations, which the stdlib
allocation functions don't.
We have a bunch of specific array allocation macros, none of
which check for overflow. reallocarray should be able to replace them.
Diffstat (limited to 'src/flexdef.h')
-rw-r--r-- | src/flexdef.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/flexdef.h b/src/flexdef.h index ee75efc..406ae70 100644 --- a/src/flexdef.h +++ b/src/flexdef.h @@ -645,6 +645,10 @@ extern int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs; extern int tmpuses, totnst, peakpairs, numuniq, numdup, hshsave; extern int num_backing_up, bol_needed; +#ifndef HAVE_REALLOCARRAY +void *reallocarray(void *, size_t, size_t); +#endif + void *allocate_array PROTO ((int, size_t)); void *reallocate_array PROTO ((void *, int, size_t)); |