summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-06-02 08:04:02 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2012-06-02 08:38:21 +0100
commit1be2afb81df887ed664ac31d0641da808cfb8888 (patch)
tree06434e9416be927944f9b3b3e1552cf980eb5387
parent261d086265fff6c9b28a67d2fcceed8f107d5cb0 (diff)
legacy/i810/video: Release memory after creating adaptors
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/legacy/i810/i810_video.c40
1 files changed, 17 insertions, 23 deletions
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* */