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:
		
							parent
							
								
									ae2dc01cf1
								
							
						
					
					
						commit
						dc5acaa28a
					
				| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
            }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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++)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue