[gtksourceview/wip/update-test-widget] test-widget: remove TEST_XML_MEM



commit fa7e21e3d9595e83098cd5abcb310c20fb5df341
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sun Sep 1 15:19:17 2013 +0200

    test-widget: remove TEST_XML_MEM
    
    The GtkSourceView website says:
    
        We have not an official tutorial, but the source of test-widget
        program is a good starting point for learning how to use the
        GtkSourceView API.
    
    So testing the xml memory in test-widget is not really a good place. If
    that's really needed, another test program can be written.

 tests/test-widget.c |   91 ---------------------------------------------------
 1 files changed, 0 insertions(+), 91 deletions(-)
---
diff --git a/tests/test-widget.c b/tests/test-widget.c
index 21cfd31..3f43939 100644
--- a/tests/test-widget.c
+++ b/tests/test-widget.c
@@ -20,11 +20,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-/* If TEST_XML_MEM is defined the test program will try to detect memory
- * allocated by xmlMalloc() but not freed by xmlFree() or freed by xmlFree()
- * but not allocated by xmlMalloc(). */
-#define TEST_XML_MEM
-
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
@@ -32,10 +27,6 @@
 #include <gio/gio.h>
 #include <gtksourceview/gtksource.h>
 
-#ifdef TEST_XML_MEM
-#include <libxml/xmlreader.h>
-#endif
-
 /* Global list of open windows */
 
 static GList *windows = NULL;
@@ -1391,84 +1382,6 @@ create_main_window (GtkSourceBuffer *buffer)
        return window;
 }
 
-
-/* XML memory management and verification functions ----------------------------- */
-
-#ifdef TEST_XML_MEM
-
-#define ALIGN 8
-
-/* my_free(malloc(n)) and free(my_malloc(n)) are invalid and
- * abort on glibc */
-
-static gpointer
-my_malloc (gsize n_bytes)
-{
-       char *mem = malloc (n_bytes + ALIGN);
-       return mem ? mem + ALIGN : NULL;
-}
-
-static gpointer
-my_realloc (gpointer mem,
-           gsize    n_bytes)
-{
-       if (mem)
-       {
-               char *new_mem = realloc ((char*) mem - ALIGN, n_bytes + ALIGN);
-               return new_mem ? new_mem + ALIGN : NULL;
-       }
-       else
-       {
-               return my_malloc (n_bytes);
-       }
-}
-
-static char *
-my_strdup (const char *s)
-{
-       if (s)
-       {
-               char *new_s = my_malloc (strlen (s) + 1);
-               strcpy (new_s, s);
-               return new_s;
-       }
-       else
-       {
-               return NULL;
-       }
-}
-
-static void
-my_free (gpointer mem)
-{
-       if (mem)
-               free ((char*) mem - ALIGN);
-}
-
-static void
-init_mem_stuff (void)
-{
-       if (1)
-       {
-               if (xmlMemSetup (my_free, my_malloc, my_realloc, my_strdup) != 0)
-                       g_warning ("xmlMemSetup() failed");
-       }
-       else
-       {
-               GMemVTable mem_table = {
-                       my_malloc,
-                       my_realloc,
-                       my_free,
-                       NULL, NULL, NULL
-               };
-
-               g_mem_set_vtable (&mem_table);
-       }
-}
-
-#endif /* TEST_XML_MEM */
-
-
 /* Program entry point ------------------------------------------------------------ */
 
 int
@@ -1496,10 +1409,6 @@ main (int argc, char *argv[])
          { NULL }
        };
 
-#ifdef TEST_XML_MEM
-       init_mem_stuff ();
-#endif
-
        context = g_option_context_new ("- test GtkSourceView widget");
        g_option_context_add_main_entries (context, entries, NULL);
        g_option_context_add_group (context, gtk_get_option_group (TRUE));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]