From 1c56ac63c040280498c4a9d67b48c35b60070821 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 21 Mar 2015 13:42:12 -0700 Subject: Convert top level extensions to new *allocarray functions v2: remove now useless parentheses Signed-off-by: Alan Coopersmith Reviewed-by: Matt Turner --- render/filter.c | 12 ++++++------ render/miindex.c | 2 +- render/mipict.c | 4 ++-- render/picture.c | 2 +- render/render.c | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-) (limited to 'render') diff --git a/render/filter.c b/render/filter.c index 019ea7f94..2741f406c 100644 --- a/render/filter.c +++ b/render/filter.c @@ -67,7 +67,7 @@ PictureGetFilterId(const char *filter, int len, Bool makeit) memcpy(name, filter, len); name[len] = '\0'; if (filterNames) - names = realloc(filterNames, (nfilterNames + 1) * sizeof(char *)); + names = reallocarray(filterNames, nfilterNames + 1, sizeof(char *)); else names = malloc(sizeof(char *)); if (!names) { @@ -145,7 +145,7 @@ PictureAddFilter(ScreenPtr pScreen, return -1; if (ps->filters) filters = - realloc(ps->filters, (ps->nfilters + 1) * sizeof(PictFilterRec)); + reallocarray(ps->filters, ps->nfilters + 1, sizeof(PictFilterRec)); else filters = malloc(sizeof(PictFilterRec)); if (!filters) @@ -177,9 +177,9 @@ PictureSetFilterAlias(ScreenPtr pScreen, const char *filter, const char *alias) PictFilterAliasPtr aliases; if (ps->filterAliases) - aliases = realloc(ps->filterAliases, - (ps->nfilterAliases + 1) * - sizeof(PictFilterAliasRec)); + aliases = reallocarray(ps->filterAliases, + ps->nfilterAliases + 1, + sizeof(PictFilterAliasRec)); else aliases = malloc(sizeof(PictFilterAliasRec)); if (!aliases) @@ -336,7 +336,7 @@ SetPicturePictFilter(PicturePtr pPicture, PictFilterPtr pFilter, return BadMatch; if (nparams != pPicture->filter_nparams) { - xFixed *new_params = malloc(nparams * sizeof(xFixed)); + xFixed *new_params = xallocarray(nparams, sizeof(xFixed)); if (!new_params && nparams) return BadAlloc; diff --git a/render/miindex.c b/render/miindex.c index 0375e8f88..4119eef66 100644 --- a/render/miindex.c +++ b/render/miindex.c @@ -254,7 +254,7 @@ miInitIndexed(ScreenPtr pScreen, PictFormatPtr pFormat) return FALSE; pFormat->index.nvalues = num; - pFormat->index.pValues = malloc(num * sizeof(xIndexValue)); + pFormat->index.pValues = xallocarray(num, sizeof(xIndexValue)); if (!pFormat->index.pValues) { free(pIndexed); return FALSE; diff --git a/render/mipict.c b/render/mipict.c index a72510480..2571fda17 100644 --- a/render/mipict.c +++ b/render/mipict.c @@ -510,7 +510,7 @@ miTriStrip(CARD8 op, int ntri; ntri = npoints - 2; - tris = malloc(ntri * sizeof(xTriangle)); + tris = xallocarray(ntri, sizeof(xTriangle)); if (!tris) return; @@ -535,7 +535,7 @@ miTriFan(CARD8 op, int ntri; ntri = npoints - 2; - tris = malloc(ntri * sizeof(xTriangle)); + tris = xallocarray(ntri, sizeof(xTriangle)); if (!tris) return; diff --git a/render/picture.c b/render/picture.c index 6ff31ba02..60517a4ee 100644 --- a/render/picture.c +++ b/render/picture.c @@ -837,7 +837,7 @@ initGradient(SourcePictPtr pGradient, int stopCount, dpos = stopPoints[i]; } - pGradient->gradient.stops = malloc(stopCount * sizeof(PictGradientStop)); + pGradient->gradient.stops = xallocarray(stopCount, sizeof(PictGradientStop)); if (!pGradient->gradient.stops) { *error = BadAlloc; return; diff --git a/render/render.c b/render/render.c index 723f380c2..88d8a2669 100644 --- a/render/render.c +++ b/render/render.c @@ -1318,14 +1318,14 @@ ProcRenderCompositeGlyphs(ClientPtr client) if (nglyph <= NLOCALGLYPH) glyphsBase = glyphsLocal; else { - glyphsBase = (GlyphPtr *) malloc(nglyph * sizeof(GlyphPtr)); + glyphsBase = xallocarray(nglyph, sizeof(GlyphPtr)); if (!glyphsBase) return BadAlloc; } if (nlist <= NLOCALDELTA) listsBase = listsLocal; else { - listsBase = (GlyphListPtr) malloc(nlist * sizeof(GlyphListRec)); + listsBase = xallocarray(nlist, sizeof(GlyphListRec)); if (!listsBase) { rc = BadAlloc; goto bail; @@ -1793,7 +1793,7 @@ ProcRenderCreateAnimCursor(ClientPtr client) ncursor = (client->req_len - (bytes_to_int32(sizeof(xRenderCreateAnimCursorReq)))) >> 1; - cursors = malloc(ncursor * (sizeof(CursorPtr) + sizeof(CARD32))); + cursors = xallocarray(ncursor, sizeof(CursorPtr) + sizeof(CARD32)); if (!cursors) return BadAlloc; deltas = (CARD32 *) (cursors + ncursor); -- cgit v1.2.3