[waffle] [PATCH 2/3] examples: make use of waffle_teardown

Emil Velikov emil.l.velikov at gmail.com
Thu Jan 15 07:21:58 PST 2015


Using this we clear the global state thus the user can call waffle_init()
multiple times, as things won't get clobbered.
According to gl_basic we cleanup ~20K of leaks (still reachable) and catch
a bug in the GL/dri2 loader :-)

Before:
    definitely lost: 63 bytes in 4 blocks
    still reachable: 43,695 bytes in 116 blocks

After:
    definitely lost: 87 bytes in 5 blocks
    still reachable: 23,451 bytes in 55 blocks

Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
 examples/gl_basic.c       | 6 +++++-
 examples/simple-x11-egl.c | 5 +++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/examples/gl_basic.c b/examples/gl_basic.c
index 69418c8..050b8f8 100644
--- a/examples/gl_basic.c
+++ b/examples/gl_basic.c
@@ -34,7 +34,7 @@
 ///        each buffer swap.
 
 #define _POSIX_C_SOURCE 199309L // glibc feature macro for nanosleep.
-#define WAFFLE_API_VERSION 0x0103
+#define WAFFLE_API_VERSION 0x0106
 #define WAFFLE_API_EXPERIMENTAL
 
 #include <getopt.h>
@@ -674,6 +674,10 @@ main(int argc, char **argv)
     if (!ok)
         error_waffle();
 
+    ok = waffle_teardown();
+    if (!ok)
+        error_waffle();
+
     #ifdef __APPLE__
         cocoa_finish();
     #endif
diff --git a/examples/simple-x11-egl.c b/examples/simple-x11-egl.c
index 9e218ac..c08fc04 100644
--- a/examples/simple-x11-egl.c
+++ b/examples/simple-x11-egl.c
@@ -33,6 +33,9 @@
 /// This example is too simple; it does not perform proper error checking. For
 /// a complete example with error checking, see gl_basic.c.
 
+#define WAFFLE_API_VERSION 0x0106
+#define WAFFLE_API_EXPERIMENTAL
+
 #include <stdlib.h>
 #include <unistd.h>
 
@@ -134,5 +137,7 @@ main()
     waffle_config_destroy(config);
     waffle_display_disconnect(dpy);
 
+    waffle_teardown();
+
     return 0;
 }
-- 
2.1.3



More information about the waffle mailing list