Convert hw/kdrive to new *allocarray functions

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
This commit is contained in:
Alan Coopersmith 2015-03-21 17:30:05 -07:00
parent ae2dc01cf1
commit dc5acaa28a
6 changed files with 14 additions and 14 deletions

View File

@ -431,8 +431,8 @@ EphyrDuplicateVisual(unsigned int a_screen,
* extend the list of visual IDs in that entry, * extend the list of visual IDs in that entry,
* so to add a_new_id in there. * so to add a_new_id in there.
*/ */
vids = realloc(cur_depth->vids, vids = reallocarray(cur_depth->vids,
(cur_depth->numVids + 1) * sizeof(VisualID)); cur_depth->numVids + 1, sizeof(VisualID));
if (!vids) { if (!vids) {
EPHYR_LOG_ERROR("failed to realloc numids\n"); EPHYR_LOG_ERROR("failed to realloc numids\n");
goto out; goto out;

View File

@ -129,8 +129,8 @@ hostx_add_screen(KdScreenInfo *screen, unsigned long win_id, int screen_num, Boo
int index = HostX.n_screens; int index = HostX.n_screens;
HostX.n_screens += 1; HostX.n_screens += 1;
HostX.screens = realloc(HostX.screens, HostX.screens = reallocarray(HostX.screens,
HostX.n_screens * sizeof(HostX.screens[0])); HostX.n_screens, sizeof(HostX.screens[0]));
HostX.screens[index] = screen; HostX.screens[index] = screen;
scrpriv->screen = screen; scrpriv->screen = screen;
@ -867,7 +867,7 @@ hostx_screen_init(KdScreenInfo *screen,
NULL); NULL);
scrpriv->ximg->data = scrpriv->ximg->data =
malloc(scrpriv->ximg->stride * buffer_height); xallocarray(scrpriv->ximg->stride, buffer_height);
} }
{ {
@ -933,7 +933,7 @@ hostx_screen_init(KdScreenInfo *screen,
*bits_per_pixel = scrpriv->server_depth; *bits_per_pixel = scrpriv->server_depth;
EPHYR_DBG("server bpp %i", bytes_per_pixel); EPHYR_DBG("server bpp %i", bytes_per_pixel);
scrpriv->fb_data = malloc (stride * buffer_height); scrpriv->fb_data = xallocarray (stride, buffer_height);
return scrpriv->fb_data; return scrpriv->fb_data;
} }
} }
@ -1148,9 +1148,9 @@ hostx_get_visuals_info(EphyrHostVisualInfo ** a_visuals, int *a_num_entries)
for (; depths.rem; xcb_depth_next(&depths)) { for (; depths.rem; xcb_depth_next(&depths)) {
xcb_visualtype_t *visuals = xcb_depth_visuals(depths.data); xcb_visualtype_t *visuals = xcb_depth_visuals(depths.data);
EphyrHostVisualInfo *tmp_visuals = EphyrHostVisualInfo *tmp_visuals =
realloc(host_visuals, reallocarray(host_visuals,
(nb_items + depths.data->visuals_len) nb_items + depths.data->visuals_len,
* sizeof(EphyrHostVisualInfo)); sizeof(EphyrHostVisualInfo));
if (!tmp_visuals) { if (!tmp_visuals) {
goto out; goto out;
} }

View File

@ -158,7 +158,7 @@ fakeMapFramebuffer(KdScreenInfo * screen)
priv->bytes_per_line = priv->bytes_per_line =
((screen->width * screen->fb.bitsPerPixel + 31) >> 5) << 2; ((screen->width * screen->fb.bitsPerPixel + 31) >> 5) << 2;
free(priv->base); free(priv->base);
priv->base = malloc(priv->bytes_per_line * screen->height); priv->base = xallocarray(priv->bytes_per_line, screen->height);
if (scrpriv->shadow) { if (scrpriv->shadow) {
if (!KdShadowFbAlloc if (!KdShadowFbAlloc

View File

@ -677,7 +677,7 @@ fbdevCreateColormap(ColormapPtr pmap)
case FB_VISUAL_STATIC_PSEUDOCOLOR: case FB_VISUAL_STATIC_PSEUDOCOLOR:
pVisual = pmap->pVisual; pVisual = pmap->pVisual;
nent = pVisual->ColormapEntries; nent = pVisual->ColormapEntries;
pdefs = malloc(nent * sizeof(xColorItem)); pdefs = xallocarray(nent, sizeof(xColorItem));
if (!pdefs) if (!pdefs)
return FALSE; return FALSE;
for (i = 0; i < nent; i++) for (i = 0; i < nent; i++)

View File

@ -36,7 +36,7 @@ KdShadowFbAlloc(KdScreenInfo * screen, Bool rotate)
/* use fb computation for width */ /* use fb computation for width */
paddedWidth = ((width * bpp + FB_MASK) >> FB_SHIFT) * sizeof(FbBits); paddedWidth = ((width * bpp + FB_MASK) >> FB_SHIFT) * sizeof(FbBits);
buf = malloc(paddedWidth * height); buf = xallocarray(paddedWidth, height);
if (!buf) if (!buf)
return FALSE; return FALSE;
if (screen->fb.shadow) if (screen->fb.shadow)

View File

@ -327,8 +327,8 @@ KdXVInitAdaptors(ScreenPtr pScreen, KdVideoAdaptorPtr infoPtr, int number)
void *moreSpace; void *moreSpace;
totFormat *= 2; totFormat *= 2;
moreSpace = realloc(pFormat, moreSpace = reallocarray(pFormat, totFormat,
totFormat * sizeof(XvFormatRec)); sizeof(XvFormatRec));
if (!moreSpace) if (!moreSpace)
break; break;
pFormat = moreSpace; pFormat = moreSpace;