summaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2022-12-10 14:07:18 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2022-12-11 15:36:06 -0800
commit8d85bd1e2f9473958b235caf7af9913b518f73dd (patch)
tree3348aa708638b6dbe31e9b1ca17d49465df85e8d /utils.c
parente02e32f71f6c24fcc69bdaf58f6f9e973a017896 (diff)
downloadxorg-app-xkbcomp-8d85bd1e2f9473958b235caf7af9913b518f73dd.tar.gz
Replace uTypedRecalloc() with direct recallocarray() calls
Retains uRecalloc() as a fallback for platforms without recallocarray() Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/utils.c b/utils.c
index 61f04b6..120ef13 100644
--- a/utils.c
+++ b/utils.c
@@ -33,23 +33,25 @@
/***====================================================================***/
-Opaque
-uRecalloc(Opaque old, unsigned nOld, unsigned nNew, unsigned itemSize)
+#ifndef HAVE_RECALLOCARRAY
+void *
+uRecalloc(void *old, size_t nOld, size_t nNew, size_t itemSize)
{
char *rtrn;
if (old == NULL)
- rtrn = (char *) calloc(nNew, itemSize);
+ rtrn = calloc(nNew, itemSize);
else
{
- rtrn = (char *) realloc((char *) old, nNew * itemSize);
+ rtrn = reallocarray(old, nNew, itemSize);
if ((rtrn) && (nNew > nOld))
{
bzero(&rtrn[nOld * itemSize], (nNew - nOld) * itemSize);
}
}
- return (Opaque) rtrn;
+ return (void *) rtrn;
}
+#endif
/***====================================================================***/