[PATCH 3/3] glx: don't leak driConfigs
przanoni at gmail.com
przanoni at gmail.com
Sat Oct 29 14:08:14 PDT 2011
From: Paulo Zanoni <paulo.r.zanoni at intel.com>
For dri, dri2 and driswrast.
12,968 (584 direct, 12,384 indirect) bytes in 1 blocks are definitely lost in loss record 569 of 570
at 0x4C2779D: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x7821E3B: driConcatConfigs (utils.c:560)
by 0x7827CF2: dri_fill_in_modes (dri_screen.c:224)
by 0x782831E: dri_init_screen_helper (dri_screen.c:405)
by 0x7826C03: drisw_init_screen (drisw.c:266)
by 0x782225F: driCreateNewScreen (drisw_util.c:69)
by 0x4826E2: __glXDRIscreenProbe (glxdriswrast.c:451)
by 0x4812FA: GlxExtensionInit (glxext.c:327)
by 0x41FB14: InitExtensions (miinitext.c:471)
by 0x568622: main (main.c:208)
Signed-off-by: Paulo Zanoni <paulo.r.zanoni at intel.com>
---
glx/glxdri.c | 15 ++++++++++++---
glx/glxdri2.c | 14 +++++++++++---
glx/glxdriswrast.c | 14 +++++++++++---
3 files changed, 34 insertions(+), 9 deletions(-)
diff --git a/glx/glxdri.c b/glx/glxdri.c
index 244eac6..326f539 100644
--- a/glx/glxdri.c
+++ b/glx/glxdri.c
@@ -78,6 +78,7 @@ struct __GLXDRIscreen {
const __DRIlegacyExtension *legacy;
const __DRIcopySubBufferExtension *copySubBuffer;
const __DRIswapControlExtension *swapControl;
+ const __DRIconfig **driConfigs;
#ifdef __DRI_TEX_OFFSET
const __DRItexOffsetExtension *texOffset;
@@ -585,6 +586,8 @@ static __GLXtextureFromPixmap __glXDRItextureFromPixmap = {
static void
__glXDRIscreenDestroy(__GLXscreen *baseScreen)
{
+ int i;
+
__GLXDRIscreen *screen = (__GLXDRIscreen *) baseScreen;
screen->core->destroyScreen(screen->driScreen);
@@ -593,6 +596,12 @@ __glXDRIscreenDestroy(__GLXscreen *baseScreen)
__glXScreenDestroy(baseScreen);
+ if (screen->driConfigs) {
+ for (i = 0; screen->driConfigs[i] != NULL; i++)
+ free((__DRIconfig **)screen->driConfigs[i]);
+ free(screen->driConfigs);
+ }
+
free(screen);
}
@@ -967,7 +976,6 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
Bool isCapable;
size_t buffer_size;
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- const __DRIconfig **driConfigs;
if (!xf86LoaderCheckSymbol("DRIQueryDirectRenderingCapable") ||
!DRIQueryDirectRenderingCapable(pScreen, &isCapable) ||
@@ -1095,7 +1103,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
pSAREA,
fd,
loader_extensions,
- &driConfigs,
+ &screen->driConfigs,
screen);
if (screen->driScreen == NULL) {
@@ -1105,7 +1113,8 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
}
screen->base.fbconfigs = glxConvertConfigs(screen->core,
- driConfigs, GLX_WINDOW_BIT);
+ screen->driConfigs,
+ GLX_WINDOW_BIT);
initializeExtensions(screen);
diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index e872258..8187a3e 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -73,6 +73,7 @@ struct __GLXDRIscreen {
const __DRIcopySubBufferExtension *copySubBuffer;
const __DRIswapControlExtension *swapControl;
const __DRItexBufferExtension *texBuffer;
+ const __DRIconfig **driConfigs;
unsigned char glx_enable_bits[__GLX_EXT_BYTES];
};
@@ -363,6 +364,8 @@ static __GLXtextureFromPixmap __glXDRItextureFromPixmap = {
static void
__glXDRIscreenDestroy(__GLXscreen *baseScreen)
{
+ int i;
+
__GLXDRIscreen *screen = (__GLXDRIscreen *) baseScreen;
(*screen->core->destroyScreen)(screen->driScreen);
@@ -371,6 +374,12 @@ __glXDRIscreenDestroy(__GLXscreen *baseScreen)
__glXScreenDestroy(baseScreen);
+ if (screen->driConfigs) {
+ for (i = 0; screen->driConfigs[i] != NULL; i++)
+ free((__DRIconfig **)screen->driConfigs[i]);
+ free(screen->driConfigs);
+ }
+
free(screen);
}
@@ -688,7 +697,6 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
__GLXDRIscreen *screen;
size_t buffer_size;
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- const __DRIconfig **driConfigs;
screen = calloc(1, sizeof *screen);
if (screen == NULL)
@@ -720,7 +728,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
(*screen->dri2->createNewScreen)(pScreen->myNum,
screen->fd,
loader_extensions,
- &driConfigs,
+ &screen->driConfigs,
screen);
if (screen->driScreen == NULL) {
@@ -731,7 +739,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
initializeExtensions(screen);
- screen->base.fbconfigs = glxConvertConfigs(screen->core, driConfigs,
+ screen->base.fbconfigs = glxConvertConfigs(screen->core, screen->driConfigs,
GLX_WINDOW_BIT |
GLX_PIXMAP_BIT |
GLX_PBUFFER_BIT);
diff --git a/glx/glxdriswrast.c b/glx/glxdriswrast.c
index ed142c1..d064a05 100644
--- a/glx/glxdriswrast.c
+++ b/glx/glxdriswrast.c
@@ -74,6 +74,7 @@ struct __GLXDRIscreen {
const __DRIswrastExtension *swrast;
const __DRIcopySubBufferExtension *copySubBuffer;
const __DRItexBufferExtension *texBuffer;
+ const __DRIconfig **driConfigs;
};
struct __GLXDRIcontext {
@@ -240,6 +241,8 @@ static __GLXtextureFromPixmap __glXDRItextureFromPixmap = {
static void
__glXDRIscreenDestroy(__GLXscreen *baseScreen)
{
+ int i;
+
__GLXDRIscreen *screen = (__GLXDRIscreen *) baseScreen;
(*screen->core->destroyScreen)(screen->driScreen);
@@ -248,6 +251,12 @@ __glXDRIscreenDestroy(__GLXscreen *baseScreen)
__glXScreenDestroy(baseScreen);
+ if (screen->driConfigs) {
+ for (i = 0; screen->driConfigs[i] != NULL; i++)
+ free((__DRIconfig **)screen->driConfigs[i]);
+ free(screen->driConfigs);
+ }
+
free(screen);
}
@@ -426,7 +435,6 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
{
const char *driverName = "swrast";
__GLXDRIscreen *screen;
- const __DRIconfig **driConfigs;
screen = calloc(1, sizeof *screen);
if (screen == NULL)
@@ -450,7 +458,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
screen->driScreen =
(*screen->swrast->createNewScreen)(pScreen->myNum,
loader_extensions,
- &driConfigs,
+ &screen->driConfigs,
screen);
if (screen->driScreen == NULL) {
@@ -461,7 +469,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
initializeExtensions(screen);
- screen->base.fbconfigs = glxConvertConfigs(screen->core, driConfigs,
+ screen->base.fbconfigs = glxConvertConfigs(screen->core, screen->driConfigs,
GLX_WINDOW_BIT |
GLX_PIXMAP_BIT |
GLX_PBUFFER_BIT);
--
1.7.7
More information about the xorg-devel
mailing list