summaryrefslogtreecommitdiff
path: root/lib/libc/stdlib/reallocarr.c
AgeCommit message (Collapse)Author
2015-08-20Minor alterations to reallocarr(3)kamil
Add comment about division. Mark error branches with __predict_false(). Reduce one branch with the OR trick.
2015-08-20Fix portability.joerg
2015-07-28Compatibility fixes in reallocarr(3)kamil
Make this work on !NetBSD platforms: - replace __CTASSERT() with platform agnostic solution SQRT_SIZE_MAX - include nbtool_config.h for cross builds to get definition of __RCSID() - restore errno in the last rare code path for platforms affecting errno(2) in memcpy(2) While there: rename parameter name 'num' to 'number' to be in sync with the calloc(3) parameter naming. Reported by scole_mail at the current-users ml.
2015-07-16Reorder memcpy(3) and save errnokamil
This change is for safety as memcpy(3) might change it. Approved by <riastradh>
2015-02-17Introduce reallocarr(3) for easy (re)allocation of memory with overflowjoerg
checks. Compared to OpenBSD's reallocarray, makes it easier to avoid memory leaks on allocation failures and it doesn't depend on malloc(0) != NULL for correct error checking. Compared to plain realloc, it also avoids the problem of intermediate integer overflows. The trade-off is the use of void * to side step C type system with regard to generic pointer to pointer.