[PATCH xdriinfo] Resource cleanup fixes

Jeff Smith whydoubt at yahoo.com
Sat Mar 20 07:11:42 PDT 2010


Running xdriinfo through valgrind (with no arguments to xdriinfo) and
screen 'not direct rendering capable' produced
"still reachable: 41,240 bytes in 30 blocks."  This patch reduces this to
"still reachable: 35 bytes in 2 blocks."

Signed-off-by: Jeff Smith <whydoubt at yahoo.com>
---
 xdriinfo.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/xdriinfo.c b/xdriinfo.c
index 865b4bf..e2ca687 100644
--- a/xdriinfo.c
+++ b/xdriinfo.c
@@ -132,6 +132,7 @@ int main (int argc, char *argv[]) {
   /* final check on the screen number argument (if any)*/
     if ((func == DRIVER || func == OPTIONS) && screenNum >= nScreens) {
 	fprintf (stderr, "Screen number \"%d\" out of range.\n", screenNum);
+	XCloseDisplay (dpy);
 	return 1;
     }
 
@@ -146,6 +147,7 @@ int main (int argc, char *argv[]) {
 	  if (!name) {
 	      fprintf (stderr, "Screen \"%d\" is not direct rendering capable.\n",
 		       screenNum);
+	      XCloseDisplay (dpy);
 	      return 1;
 	  }
 	  printf ("%s", name);
@@ -158,6 +160,7 @@ int main (int argc, char *argv[]) {
 	  if (!name) {
 	      fprintf (stderr, "Screen \"%d\" is not direct rendering capable.\n",
 		       screenNum);
+	      XCloseDisplay (dpy);
 	      return 1;
 	  }
 	  options = (*GetDriverConfig) (name);
@@ -165,6 +168,7 @@ int main (int argc, char *argv[]) {
 	      fprintf (stderr,
 		       "Driver \"%s\" is not installed or does not support configuration.\n",
 		       name);
+	      XCloseDisplay (dpy);
 	      return 1;
 	  }
 	  printf ("%s", options);
@@ -182,5 +186,6 @@ int main (int argc, char *argv[]) {
 	}
     }
 
+    XCloseDisplay (dpy);
     return 0;
 }
-- 
1.6.0.6

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the xorg-devel mailing list