summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2015-03-21 17:30:05 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2015-04-21 16:58:08 -0700
commitdc5acaa28ab9ed091f087e56046400d63f1f192a (patch)
tree6cb49ede9f82e0c0516aea6c96067e5d7bdef635
parentae2dc01cf1a371db69d5deb987f4185e7c3ccedd (diff)
Convert hw/kdrive to new *allocarray functions
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Matt Turner <mattst88@gmail.com>
-rw-r--r--hw/kdrive/ephyr/ephyrdriext.c4
-rw-r--r--hw/kdrive/ephyr/hostx.c14
-rw-r--r--hw/kdrive/fake/fake.c2
-rw-r--r--hw/kdrive/fbdev/fbdev.c2
-rw-r--r--hw/kdrive/src/kshadow.c2
-rw-r--r--hw/kdrive/src/kxv.c4
6 files changed, 14 insertions, 14 deletions
diff --git a/hw/kdrive/ephyr/ephyrdriext.c b/hw/kdrive/ephyr/ephyrdriext.c
index 3d5cf7721..748b608c2 100644
--- a/hw/kdrive/ephyr/ephyrdriext.c
+++ b/hw/kdrive/ephyr/ephyrdriext.c
@@ -431,8 +431,8 @@ EphyrDuplicateVisual(unsigned int a_screen,
* extend the list of visual IDs in that entry,
* so to add a_new_id in there.
*/
- vids = realloc(cur_depth->vids,
- (cur_depth->numVids + 1) * sizeof(VisualID));
+ vids = reallocarray(cur_depth->vids,
+ cur_depth->numVids + 1, sizeof(VisualID));
if (!vids) {
EPHYR_LOG_ERROR("failed to realloc numids\n");
goto out;
diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index c67ff60d3..7163af03e 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -129,8 +129,8 @@ hostx_add_screen(KdScreenInfo *screen, unsigned long win_id, int screen_num, Boo
int index = HostX.n_screens;
HostX.n_screens += 1;
- HostX.screens = realloc(HostX.screens,
- HostX.n_screens * sizeof(HostX.screens[0]));
+ HostX.screens = reallocarray(HostX.screens,
+ HostX.n_screens, sizeof(HostX.screens[0]));
HostX.screens[index] = screen;
scrpriv->screen = screen;
@@ -867,7 +867,7 @@ hostx_screen_init(KdScreenInfo *screen,
NULL);
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;
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;
}
}
@@ -1148,9 +1148,9 @@ hostx_get_visuals_info(EphyrHostVisualInfo ** a_visuals, int *a_num_entries)
for (; depths.rem; xcb_depth_next(&depths)) {
xcb_visualtype_t *visuals = xcb_depth_visuals(depths.data);
EphyrHostVisualInfo *tmp_visuals =
- realloc(host_visuals,
- (nb_items + depths.data->visuals_len)
- * sizeof(EphyrHostVisualInfo));
+ reallocarray(host_visuals,
+ nb_items + depths.data->visuals_len,
+ sizeof(EphyrHostVisualInfo));
if (!tmp_visuals) {
goto out;
}
diff --git a/hw/kdrive/fake/fake.c b/hw/kdrive/fake/fake.c
index 90e3ec9a6..04a727897 100644
--- a/hw/kdrive/fake/fake.c
+++ b/hw/kdrive/fake/fake.c
@@ -158,7 +158,7 @@ fakeMapFramebuffer(KdScreenInfo * screen)
priv->bytes_per_line =
((screen->width * screen->fb.bitsPerPixel + 31) >> 5) << 2;
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 (!KdShadowFbAlloc
diff --git a/hw/kdrive/fbdev/fbdev.c b/hw/kdrive/fbdev/fbdev.c
index 95f64cbef..23f750924 100644
--- a/hw/kdrive/fbdev/fbdev.c
+++ b/hw/kdrive/fbdev/fbdev.c
@@ -677,7 +677,7 @@ fbdevCreateColormap(ColormapPtr pmap)
case FB_VISUAL_STATIC_PSEUDOCOLOR:
pVisual = pmap->pVisual;
nent = pVisual->ColormapEntries;
- pdefs = malloc(nent * sizeof(xColorItem));
+ pdefs = xallocarray(nent, sizeof(xColorItem));
if (!pdefs)
return FALSE;
for (i = 0; i < nent; i++)
diff --git a/hw/kdrive/src/kshadow.c b/hw/kdrive/src/kshadow.c
index 828ea19a6..7f1e2ee19 100644
--- a/hw/kdrive/src/kshadow.c
+++ b/hw/kdrive/src/kshadow.c
@@ -36,7 +36,7 @@ KdShadowFbAlloc(KdScreenInfo * screen, Bool rotate)
/* use fb computation for width */
paddedWidth = ((width * bpp + FB_MASK) >> FB_SHIFT) * sizeof(FbBits);
- buf = malloc(paddedWidth * height);
+ buf = xallocarray(paddedWidth, height);
if (!buf)
return FALSE;
if (screen->fb.shadow)
diff --git a/hw/kdrive/src/kxv.c b/hw/kdrive/src/kxv.c
index 369db3332..844deca0d 100644
--- a/hw/kdrive/src/kxv.c
+++ b/hw/kdrive/src/kxv.c
@@ -327,8 +327,8 @@ KdXVInitAdaptors(ScreenPtr pScreen, KdVideoAdaptorPtr infoPtr, int number)
void *moreSpace;
totFormat *= 2;
- moreSpace = realloc(pFormat,
- totFormat * sizeof(XvFormatRec));
+ moreSpace = reallocarray(pFormat, totFormat,
+ sizeof(XvFormatRec));
if (!moreSpace)
break;
pFormat = moreSpace;