From 1be2afb81df887ed664ac31d0641da808cfb8888 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sat, 2 Jun 2012 08:04:02 +0100 Subject: legacy/i810/video: Release memory after creating adaptors Signed-off-by: Chris Wilson --- src/legacy/i810/i810_video.c | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) (limited to 'src/legacy/i810') diff --git a/src/legacy/i810/i810_video.c b/src/legacy/i810/i810_video.c index 2999ee0b..729aa8b3 100644 --- a/src/legacy/i810/i810_video.c +++ b/src/legacy/i810/i810_video.c @@ -155,40 +155,34 @@ static Atom xvBrightness, xvContrast, xvColorKey; void I810InitVideo(ScreenPtr screen) { ScrnInfoPtr pScrn = xf86ScreenToScrn(screen); - XF86VideoAdaptorPtr *adaptors, *newAdaptors = NULL; - XF86VideoAdaptorPtr newAdaptor = NULL; + XF86VideoAdaptorPtr *adaptors; int num_adaptors; - - if (pScrn->bitsPerPixel != 8) - { + + num_adaptors = xf86XVListGenericAdaptors(pScrn, &adaptors); + + if (pScrn->bitsPerPixel != 8) { + XF86VideoAdaptorPtr newAdaptor; + newAdaptor = I810SetupImageVideo(screen); I810InitOffscreenImages(screen); - } - num_adaptors = xf86XVListGenericAdaptors(pScrn, &adaptors); + if (newAdaptor) { + XF86VideoAdaptorPtr *newAdaptors; - if(newAdaptor) { - if(!num_adaptors) { - num_adaptors = 1; - adaptors = &newAdaptor; - } else { - newAdaptors = /* need to free this someplace */ - malloc((num_adaptors + 1) * sizeof(XF86VideoAdaptorPtr*)); - if(newAdaptors) { - memcpy(newAdaptors, adaptors, num_adaptors * - sizeof(XF86VideoAdaptorPtr)); - newAdaptors[num_adaptors] = newAdaptor; + newAdaptors = + realloc(adaptors, + (num_adaptors + 1) * sizeof(XF86VideoAdaptorPtr)); + if (newAdaptors != NULL) { + newAdaptors[num_adaptors++] = newAdaptor; adaptors = newAdaptors; - num_adaptors++; } } } - if(num_adaptors) - xf86XVScreenInit(screen, adaptors, num_adaptors); + if (num_adaptors) + xf86XVScreenInit(screen, adaptors, num_adaptors); - if(newAdaptors) - free(newAdaptors); + free(adaptors); } /* *INDENT-OFF* */ -- cgit v1.2.3