aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/mi/miwideline.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2015-05-26 19:43:34 +0200
committermarha <marha@users.sourceforge.net>2015-05-26 19:43:34 +0200
commit912e881bec8b16f2331225960645c3bdf5a8ba2d (patch)
tree92afd568d4b3eaab1faf26d8d95d8c6df0173079 /xorg-server/mi/miwideline.c
parent2e00f3764228cfc91180bbe9375a8d85e0e65a5b (diff)
parent843964ee791452b197e41dacb0146f5b456ffaa5 (diff)
downloadvcxsrv-912e881bec8b16f2331225960645c3bdf5a8ba2d.tar.gz
vcxsrv-912e881bec8b16f2331225960645c3bdf5a8ba2d.tar.bz2
vcxsrv-912e881bec8b16f2331225960645c3bdf5a8ba2d.zip
Merge remote-tracking branch 'origin/released'
Conflicts: mesalib/src/mapi/glapi/glapi_priv.h mesalib/src/mesa/drivers/dri/swrast/swrast.c xorg-server/dix/dispatch.c xorg-server/os/utils.c xorg-server/record/record.c
Diffstat (limited to 'xorg-server/mi/miwideline.c')
-rw-r--r--xorg-server/mi/miwideline.c42
1 files changed, 19 insertions, 23 deletions
diff --git a/xorg-server/mi/miwideline.c b/xorg-server/mi/miwideline.c
index 606d0e825..9eeafcee1 100644
--- a/xorg-server/mi/miwideline.c
+++ b/xorg-server/mi/miwideline.c
@@ -193,19 +193,16 @@ miSubtractSpans(SpanGroup * spanGroup, Spans * sub)
int *newwid;
#define EXTRA 8
- newPt =
- (DDXPointPtr) realloc(spans->points,
- (spans->count +
- EXTRA) *
- sizeof(DDXPointRec));
+ newPt = reallocarray(spans->points,
+ spans->count + EXTRA,
+ sizeof(DDXPointRec));
if (!newPt)
break;
spansPt = newPt + (spansPt - spans->points);
spans->points = newPt;
- newwid =
- (int *) realloc(spans->widths,
- (spans->count +
- EXTRA) * sizeof(int));
+ newwid = reallocarray(spans->widths,
+ spans->count + EXTRA,
+ sizeof(int));
if (!newwid)
break;
spansWid = newwid + (spansWid - spans->widths);
@@ -244,8 +241,8 @@ miAppendSpans(SpanGroup * spanGroup, SpanGroup * otherGroup, Spans * spans)
if (spansCount > 0) {
if (spanGroup->size == spanGroup->count) {
spanGroup->size = (spanGroup->size + 8) * 2;
- spanGroup->group = (Spans *)
- realloc(spanGroup->group, sizeof(Spans) * spanGroup->size);
+ spanGroup->group =
+ reallocarray(spanGroup->group, sizeof(Spans), spanGroup->size);
}
spanGroup->group[spanGroup->count] = *spans;
@@ -460,8 +457,8 @@ miFillUniqueSpanGroup(DrawablePtr pDraw, GCPtr pGC, SpanGroup * spanGroup)
ylength = spanGroup->ymax - ymin + 1;
/* Allocate Spans for y buckets */
- yspans = malloc(ylength * sizeof(Spans));
- ysizes = malloc(ylength * sizeof(int));
+ yspans = xallocarray(ylength, sizeof(Spans));
+ ysizes = xallocarray(ylength, sizeof(int));
if (!yspans || !ysizes) {
free(yspans);
@@ -495,12 +492,11 @@ miFillUniqueSpanGroup(DrawablePtr pDraw, GCPtr pGC, SpanGroup * spanGroup)
int *newwidths;
ysizes[index] = (ysizes[index] + 8) * 2;
- newpoints = (DDXPointPtr) realloc(newspans->points,
- ysizes[index] *
- sizeof(DDXPointRec));
- newwidths =
- (int *) realloc(newspans->widths,
- ysizes[index] * sizeof(int));
+ newpoints = reallocarray(newspans->points,
+ ysizes[index],
+ sizeof(DDXPointRec));
+ newwidths = reallocarray(newspans->widths,
+ ysizes[index], sizeof(int));
if (!newpoints || !newwidths) {
for (i = 0; i < ylength; i++) {
free(yspans[i].points);
@@ -529,8 +525,8 @@ miFillUniqueSpanGroup(DrawablePtr pDraw, GCPtr pGC, SpanGroup * spanGroup)
} /* for i thorough Spans */
/* Now sort by x and uniquify each bucket into the final array */
- points = malloc(count * sizeof(DDXPointRec));
- widths = malloc(count * sizeof(int));
+ points = xallocarray(count, sizeof(DDXPointRec));
+ widths = xallocarray(count, sizeof(int));
if (!points || !widths) {
for (i = 0; i < ylength; i++) {
free(yspans[i].points);
@@ -577,10 +573,10 @@ miFillUniqueSpanGroup(DrawablePtr pDraw, GCPtr pGC, SpanGroup * spanGroup)
static Bool
InitSpans(Spans * spans, size_t nspans)
{
- spans->points = malloc(nspans * sizeof(*spans->points));
+ spans->points = xallocarray(nspans, sizeof(*spans->points));
if (!spans->points)
return FALSE;
- spans->widths = malloc(nspans * sizeof(*spans->widths));
+ spans->widths = xallocarray(nspans, sizeof(*spans->widths));
if (!spans->widths) {
free(spans->points);
return FALSE;