Commit 76850471 authored by Alan Coopersmith's avatar Alan Coopersmith

Convert src/xcms to use reallocarray()

Signed-off-by: Alan Coopersmith's avatarAlan Coopersmith <alan.coopersmith@oracle.com>
parent 8a62e265
......@@ -39,6 +39,7 @@
#include "Xlibint.h"
#include "Xcmsint.h"
#include "Cv.h"
#include "reallocarray.h"
/*
* LOCAL DEFINES
......@@ -796,7 +797,7 @@ XcmsConvertColors(
* Make copy of array of color specifications
*/
if (nColors > 1) {
pColors_tmp = Xmalloc(nColors * sizeof(XcmsColor));
pColors_tmp = Xmallocarray(nColors, sizeof(XcmsColor));
} else {
pColors_tmp = &Color1;
}
......
......@@ -38,6 +38,7 @@
#include "Xlibint.h"
#include "Xcmsint.h"
#include "Cv.h"
#include "reallocarray.h"
/************************************************************************
......@@ -85,7 +86,7 @@ XcmsStoreColors(
* overwrite the contents.
*/
if (nColors > 1) {
pColors_tmp = Xmalloc(nColors * sizeof(XcmsColor));
pColors_tmp = Xmallocarray(nColors, sizeof(XcmsColor));
} else {
pColors_tmp = &Color1;
}
......
......@@ -41,6 +41,7 @@
#include "Xlibint.h"
#include "Xcmsint.h"
#include "Cv.h"
#include "reallocarray.h"
#ifndef XCMSCOMPPROC
# define XCMSCOMPPROC XcmsTekHVCClipC
......@@ -82,7 +83,7 @@ _XcmsCopyPointerArray(
for (tmp = pap, n = 0; *tmp != NULL; tmp++, n++);
n++; /* add 1 to include the NULL pointer */
if ((newArray = Xmalloc(n * sizeof(XPointer)))) {
if ((newArray = Xmallocarray(n, sizeof(XPointer)))) {
memcpy((char *)newArray, (char *)pap,
(unsigned)(n * sizeof(XPointer)));
}
......@@ -141,7 +142,7 @@ _XcmsPushPointerArray(
/* add 2: 1 for the new pointer and another for the NULL pointer */
n += 2;
if ((newArray = Xmalloc(n * sizeof(XPointer)))) {
if ((newArray = Xmallocarray(n, sizeof(XPointer)))) {
memcpy((char *)(newArray+1),(char *)pap,
(unsigned)((n-1) * sizeof(XPointer)));
*newArray = p;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment