Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add the first percent of a wannabe module mecanism allowing me to track memleaks...
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 29 Jan 2004 18:13:37 +0000 (18:13 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 29 Jan 2004 18:13:37 +0000 (18:13 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@21 48e7efb5-ca39-0410-a469-dd3cf9ba447f

include/gras.h
include/module.h [new file with mode: 0644]
src/gras/Makefile.am
src/gras/gras_private.h
testsuite/xbt/dict_crash.c
testsuite/xbt/dict_usage.c
testsuite/xbt/dynar_double.c
testsuite/xbt/log_usage.c

index dc093db..fb941a4 100644 (file)
@@ -32,6 +32,8 @@
 #include <gras/error.h>
 #include <gras/log.h>
 
 #include <gras/error.h>
 #include <gras/log.h>
 
+#include <gras/module.h>
+
 #include <gras/dynar.h>
 #include <gras/dict.h>
 
 #include <gras/dynar.h>
 #include <gras/dict.h>
 
diff --git a/include/module.h b/include/module.h
new file mode 100644 (file)
index 0000000..b9a3ee4
--- /dev/null
@@ -0,0 +1,21 @@
+/* $Id$ */
+
+/* module - modularize the code                                             */
+
+/* Authors: Martin Quinson                                                  */
+/* Copyright (C) 2004 the Martin Quinson.                                   */
+
+/* This program is free software; you can redistribute it and/or modify it
+   under the terms of the license (GNU LGPL) which comes with this package. */
+
+#ifndef _GRAS_MODULE_H
+#define _GRAS_MODULE_H
+
+typedef struct gras_module_ gras_module_t;
+
+typedef gras_module_t (*gras_module_new_fct_t)(int argc, char **argv);
+typedef int (*gras_module_finalize_fct_t)(void);
+
+void gras_init(int argc,char **argv);
+void gras_finalize(void);
+#endif /* _GRAS_MODULE_H */
index abf2381..d9fa036 100644 (file)
@@ -14,6 +14,7 @@ noinst_LIBRARIES=libgrasutils.a
 
 COMMON_S=\
   \
 
 COMMON_S=\
   \
+  core/module.c                                                                 \
   core/log.c         core/log_default_appender.c   core/error.c                 \
   core/dynar.c                                                                  \
   core/dict.c        core/dict_elm.c               core/dict_cursor.c           \
   core/log.c         core/log_default_appender.c   core/error.c                 \
   core/dynar.c                                                                  \
   core/dict.c        core/dict_elm.c               core/dict_cursor.c           \
index c3a1141..f8d1962 100644 (file)
@@ -35,6 +35,7 @@
 
 #include "gras/error.h"
 #include "gras/log.h"
 
 #include "gras/error.h"
 #include "gras/log.h"
+#include "gras/module.h"
 #include "gras/dynar.h"
 #include "gras/dict.h"
 #include "gras/config.h"
 #include "gras/dynar.h"
 #include "gras/dict.h"
 #include "gras/config.h"
index 8da4a7c..cf7c23b 100644 (file)
@@ -131,11 +131,12 @@ int main(int argc,char **argv) {
       }
     }
   }
       }
     }
   }
+  free(key);
 
   printf("\n Remove my 200 000 elements. (a point is 10 000 elements)\n");
   if (!(key=malloc(10))) {
     fprintf(stderr,"Out of memory\n");
 
   printf("\n Remove my 200 000 elements. (a point is 10 000 elements)\n");
   if (!(key=malloc(10))) {
     fprintf(stderr,"Out of memory\n");
-    return 3;
+    abort();
   }
   for (j=0;j<NB_ELM;j++) {
     if (!(j%10000)) printf("."); fflush(stdout);
   }
   for (j=0;j<NB_ELM;j++) {
     if (!(j%10000)) printf("."); fflush(stdout);
@@ -144,6 +145,7 @@ int main(int argc,char **argv) {
     TRYFAIL(gras_dict_remove(head,key));
   }
   printf("\n");
     TRYFAIL(gras_dict_remove(head,key));
   }
   printf("\n");
+  free(key);
 
   
   printf("\n Free the structure (twice)\n");
 
   
   printf("\n Free the structure (twice)\n");
index c7928f5..ef3755f 100644 (file)
@@ -115,7 +115,7 @@ int main(int argc,char **argv) {
   gras_dict_free(&head);
   printf(" Free the dictionnary again\n");
   gras_dict_free(&head);
   gras_dict_free(&head);
   printf(" Free the dictionnary again\n");
   gras_dict_free(&head);
-
+  
   TRYFAIL(fill(&head));
 
   printf(" - Change some values\n");
   TRYFAIL(fill(&head));
 
   printf(" - Change some values\n");
@@ -155,7 +155,7 @@ int main(int argc,char **argv) {
 
   printf(" Free the dictionnary (twice)\n");
   gras_dict_free(&head);
 
   printf(" Free the dictionnary (twice)\n");
   gras_dict_free(&head);
-  gras_dict_free(&head); // frees it twice to see if it triggers an error
+  gras_dict_free(&head);
 
   printf(" - Traverse the resulting dictionnary\n");
   TRYFAIL(traverse(head));
 
   printf(" - Traverse the resulting dictionnary\n");
   TRYFAIL(traverse(head));
@@ -166,6 +166,10 @@ int main(int argc,char **argv) {
   TRYEXPECT(debuged_remove(head,"Does not exist"),mismatch_error);
   TRYFAIL(traverse(head));
 
   TRYEXPECT(debuged_remove(head,"Does not exist"),mismatch_error);
   TRYFAIL(traverse(head));
 
+  gras_dict_free(&head);
+  gras_finalize();
+  return 0;
+
   TRYCATCH(debuged_remove(head,"12345"),mismatch_error);
   TRYFAIL(traverse(head));
 
   TRYCATCH(debuged_remove(head,"12345"),mismatch_error);
   TRYFAIL(traverse(head));
 
@@ -182,7 +186,5 @@ int main(int argc,char **argv) {
   printf(" - Free the dictionnary twice\n");
   gras_dict_free(&head);
   gras_dict_free(&head);
   printf(" - Free the dictionnary twice\n");
   gras_dict_free(&head);
   gras_dict_free(&head);
-  printf("Done\n");
-  fflush(stdout);
   return 0;
 }
   return 0;
 }
index 68b0469..d85025e 100644 (file)
@@ -141,5 +141,6 @@ int main(int argc,char *argv[]) {
    }
    gras_dynar_free(d);
 
    }
    gras_dynar_free(d);
 
+   gras_finalize();
    return 0;
 }
    return 0;
 }
index 14cba8d..c86c44b 100644 (file)
@@ -50,5 +50,6 @@ int main(int argc, char **argv) {
   CDEBUG2(Top, "val=%d%s", 3, "!");
   CRITICAL6("false alarm%s%s%s%s%s%s", "","","","","","!");
   
   CDEBUG2(Top, "val=%d%s", 3, "!");
   CRITICAL6("false alarm%s%s%s%s%s%s", "","","","","","!");
   
+  gras_finalize();
   return 0;
 }
   return 0;
 }