Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
star eradication, mainly (check changelog)
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 2 Nov 2004 11:43:06 +0000 (11:43 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 2 Nov 2004 11:43:06 +0000 (11:43 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@454 48e7efb5-ca39-0410-a469-dd3cf9ba447f

14 files changed:
testsuite/gras/datadesc_usage.c
testsuite/gras/mk_datadesc_structs.pl
testsuite/gras/trp_file_client.c
testsuite/gras/trp_file_server.c
testsuite/gras/trp_tcp_client.c
testsuite/gras/trp_tcp_server.c
testsuite/run_tests.in
testsuite/xbt/config_usage.c
testsuite/xbt/dict_crash.c
testsuite/xbt/dict_usage.c
testsuite/xbt/dynar_double.c
testsuite/xbt/dynar_int.c
testsuite/xbt/dynar_string.c
testsuite/xbt/set_usage.c

index 458a3fa..b6ee2ad 100644 (file)
@@ -22,12 +22,12 @@ int r_arch;
 const char *filename = "datadesc_usage.out";  
 
 gras_error_t
 const char *filename = "datadesc_usage.out";  
 
 gras_error_t
-write_read(gras_datadesc_type_t *type,void *src, void *dst, 
-          gras_socket_t *sock, int direction);
+write_read(gras_datadesc_type_t type,void *src, void *dst, 
+          gras_socket_t sock, int direction);
 
 gras_error_t
 
 gras_error_t
-write_read(gras_datadesc_type_t *type,void *src, void *dst, 
-          gras_socket_t *sock, int direction) {
+write_read(gras_datadesc_type_t type,void *src, void *dst, 
+          gras_socket_t sock, int direction) {
   gras_error_t errcode;
    
   /* write */
   gras_error_t errcode;
    
   /* write */
@@ -51,28 +51,28 @@ write_read(gras_datadesc_type_t *type,void *src, void *dst,
   return no_error;
 }
 
   return no_error;
 }
 
-gras_error_t test_int(gras_socket_t *sock, int direction);
-gras_error_t test_float(gras_socket_t *sock, int direction);
-gras_error_t test_double(gras_socket_t *sock, int direction);
-gras_error_t test_array(gras_socket_t *sock, int direction);
-gras_error_t test_intref(gras_socket_t *sock, int direction);
-gras_error_t test_string(gras_socket_t *sock, int direction);
+gras_error_t test_int(gras_socket_t sock, int direction);
+gras_error_t test_float(gras_socket_t sock, int direction);
+gras_error_t test_double(gras_socket_t sock, int direction);
+gras_error_t test_array(gras_socket_t sock, int direction);
+gras_error_t test_intref(gras_socket_t sock, int direction);
+gras_error_t test_string(gras_socket_t sock, int direction);
 
 
-gras_error_t test_homostruct(gras_socket_t *sock, int direction);
-gras_error_t test_hetestruct(gras_socket_t *sock, int direction);
-gras_error_t test_nestedstruct(gras_socket_t *sock, int direction);
-gras_error_t test_chain_list(gras_socket_t *sock, int direction);
-gras_error_t test_graph(gras_socket_t *sock, int direction);
+gras_error_t test_homostruct(gras_socket_t sock, int direction);
+gras_error_t test_hetestruct(gras_socket_t sock, int direction);
+gras_error_t test_nestedstruct(gras_socket_t sock, int direction);
+gras_error_t test_chain_list(gras_socket_t sock, int direction);
+gras_error_t test_graph(gras_socket_t sock, int direction);
 
 
-gras_error_t test_pbio(gras_socket_t *sock, int direction);
-gras_error_t test_clause(gras_socket_t *sock, int direction);
+gras_error_t test_pbio(gras_socket_t sock, int direction);
+gras_error_t test_clause(gras_socket_t sock, int direction);
 
 /* defined in datadesc_structures.c, which in perl generated */
 
 /* defined in datadesc_structures.c, which in perl generated */
-gras_error_t test_structures(gras_socket_t *sock, int direction); 
+gras_error_t test_structures(gras_socket_t sock, int direction); 
 
 
 
 
 
 
-gras_error_t test_int(gras_socket_t *sock, int direction) {
+gras_error_t test_int(gras_socket_t sock, int direction) {
   gras_error_t errcode;
   int i=5,j;
   
   gras_error_t errcode;
   int i=5,j;
   
@@ -83,7 +83,7 @@ gras_error_t test_int(gras_socket_t *sock, int direction) {
   }
   return no_error;
 }
   }
   return no_error;
 }
-gras_error_t test_float(gras_socket_t *sock, int direction) {
+gras_error_t test_float(gras_socket_t sock, int direction) {
   gras_error_t errcode;
   float i=5.0,j;
   
   gras_error_t errcode;
   float i=5.0,j;
   
@@ -94,7 +94,7 @@ gras_error_t test_float(gras_socket_t *sock, int direction) {
   }
   return no_error;
 }
   }
   return no_error;
 }
-gras_error_t test_double(gras_socket_t *sock, int direction) {
+gras_error_t test_double(gras_socket_t sock, int direction) {
   gras_error_t errcode;
   double i=-3252355.1234,j;
   
   gras_error_t errcode;
   double i=-3252355.1234,j;
   
@@ -108,9 +108,9 @@ gras_error_t test_double(gras_socket_t *sock, int direction) {
 
 #define SIZE 5
 typedef int array[SIZE];
 
 #define SIZE 5
 typedef int array[SIZE];
-gras_error_t test_array(gras_socket_t *sock, int direction) {
+gras_error_t test_array(gras_socket_t sock, int direction) {
   gras_error_t errcode;
   gras_error_t errcode;
-  gras_datadesc_type_t *my_type;
+  gras_datadesc_type_t my_type;
   
   array i = { 35212,-6226,74337,11414,7733};
   array j;
   
   array i = { 35212,-6226,74337,11414,7733};
   array j;
@@ -132,9 +132,9 @@ gras_error_t test_array(gras_socket_t *sock, int direction) {
   }
   return no_error;
 }
   }
   return no_error;
 }
-gras_error_t test_intref(gras_socket_t *sock, int direction) {
+gras_error_t test_intref(gras_socket_t sock, int direction) {
   gras_error_t errcode;
   gras_error_t errcode;
-  gras_datadesc_type_t *my_type;
+  gras_datadesc_type_t my_type;
   int *i,*j;
   
   i=gras_new(int,1);
   int *i,*j;
   
   i=gras_new(int,1);
@@ -147,16 +147,16 @@ gras_error_t test_intref(gras_socket_t *sock, int direction) {
   TRY(write_read(my_type, &i,&j, sock,direction));
   if (direction == READ || direction == RW) {
     gras_assert(*i == *j);
   TRY(write_read(my_type, &i,&j, sock,direction));
   if (direction == READ || direction == RW) {
     gras_assert(*i == *j);
-    gras_free(j);
+    free(j);
   }
   }
-  gras_free(i);
+  free(i);
   return no_error;
 }
 
 /***
  *** string (dynamic array)
  ***/ 
   return no_error;
 }
 
 /***
  *** string (dynamic array)
  ***/ 
-gras_error_t test_string(gras_socket_t *sock, int direction) {
+gras_error_t test_string(gras_socket_t sock, int direction) {
   gras_error_t errcode;
   char *i=gras_strdup("Some data"), *j=NULL;
   int cpt;
   gras_error_t errcode;
   char *i=gras_strdup("Some data"), *j=NULL;
   int cpt;
@@ -169,9 +169,9 @@ gras_error_t test_string(gras_socket_t *sock, int direction) {
       gras_assert4(i[cpt] == j[cpt],"i[%d]=%c  !=  j[%d]=%c",
                   cpt,i[cpt],cpt,j[cpt]);
     } 
       gras_assert4(i[cpt] == j[cpt],"i[%d]=%c  !=  j[%d]=%c",
                   cpt,i[cpt],cpt,j[cpt]);
     } 
-    gras_free(j);
+    free(j);
   }
   }
-  gras_free(i);
+  free(i);
   return no_error;
 }
 
   return no_error;
 }
 
@@ -182,9 +182,9 @@ gras_error_t test_string(gras_socket_t *sock, int direction) {
 typedef struct {
   int a,b,c,d;
 } homostruct;
 typedef struct {
   int a,b,c,d;
 } homostruct;
-gras_error_t test_homostruct(gras_socket_t *sock, int direction) {
+gras_error_t test_homostruct(gras_socket_t sock, int direction) {
   gras_error_t errcode;
   gras_error_t errcode;
-  gras_datadesc_type_t *my_type;
+  gras_datadesc_type_t my_type;
   homostruct *i, *j; 
 
   INFO0("---- Test on homogeneous structure ----");
   homostruct *i, *j; 
 
   INFO0("---- Test on homogeneous structure ----");
@@ -209,13 +209,13 @@ gras_error_t test_homostruct(gras_socket_t *sock, int direction) {
 
   TRY(write_read(my_type, &i,&j, sock,direction));
   if (direction == READ || direction == RW) {
 
   TRY(write_read(my_type, &i,&j, sock,direction));
   if (direction == READ || direction == RW) {
-    gras_assert(i->a == j->a);
+    gras_assert2(i->a == j->a,"i->a=%d != j->a=%d",i->a,j->a);
     gras_assert(i->b == j->b);
     gras_assert(i->c == j->c);
     gras_assert(i->d == j->d);
     gras_assert(i->b == j->b);
     gras_assert(i->c == j->c);
     gras_assert(i->d == j->d);
-    gras_free(j);
+    free(j);
   }
   }
-  gras_free(i);
+  free(i);
   return no_error;
 }
 
   return no_error;
 }
 
@@ -228,9 +228,9 @@ typedef struct {
   unsigned char c2;
   unsigned long int l2;
 } hetestruct;
   unsigned char c2;
   unsigned long int l2;
 } hetestruct;
-gras_error_t test_hetestruct(gras_socket_t *sock, int direction) {
+gras_error_t test_hetestruct(gras_socket_t sock, int direction) {
   gras_error_t errcode;
   gras_error_t errcode;
-  gras_datadesc_type_t *my_type;
+  gras_datadesc_type_t my_type;
   hetestruct *i, *j; 
 
   INFO0("---- Test on heterogeneous structure ----");
   hetestruct *i, *j; 
 
   INFO0("---- Test on heterogeneous structure ----");
@@ -259,9 +259,9 @@ gras_error_t test_hetestruct(gras_socket_t *sock, int direction) {
     gras_assert(i->c2 == j->c2);
     gras_assert2(i->l1 == j->l1,"i->l1(=%ld)  !=  j->l1(=%ld)",i->l1,j->l1);
     gras_assert(i->l2 == j->l2);
     gras_assert(i->c2 == j->c2);
     gras_assert2(i->l1 == j->l1,"i->l1(=%ld)  !=  j->l1(=%ld)",i->l1,j->l1);
     gras_assert(i->l2 == j->l2);
-    gras_free(j);
+    free(j);
   }
   }
-  gras_free(i);
+  free(i);
   return no_error;
 }
 
   return no_error;
 }
 
@@ -272,9 +272,9 @@ typedef struct {
   hetestruct hete;
   homostruct homo;
 } nestedstruct;
   hetestruct hete;
   homostruct homo;
 } nestedstruct;
-gras_error_t test_nestedstruct(gras_socket_t *sock, int direction) {
+gras_error_t test_nestedstruct(gras_socket_t sock, int direction) {
   gras_error_t errcode;
   gras_error_t errcode;
-  gras_datadesc_type_t *my_type;
+  gras_datadesc_type_t my_type;
   nestedstruct *i, *j; 
 
   INFO0("---- Test on nested structures ----");
   nestedstruct *i, *j; 
 
   INFO0("---- Test on nested structures ----");
@@ -305,9 +305,9 @@ gras_error_t test_nestedstruct(gras_socket_t *sock, int direction) {
     gras_assert(i->hete.c2 == j->hete.c2);
     gras_assert(i->hete.l1 == j->hete.l1);
     gras_assert(i->hete.l2 == j->hete.l2);
     gras_assert(i->hete.c2 == j->hete.c2);
     gras_assert(i->hete.l1 == j->hete.l1);
     gras_assert(i->hete.l2 == j->hete.l2);
-    gras_free(j);
+    free(j);
   }
   }
-  gras_free(i);
+  free(i);
   return no_error;
 }
 
   return no_error;
 }
 
@@ -326,7 +326,7 @@ int list_eq(chained_list_t*i,chained_list_t*j);
 
 gras_error_t declare_chained_list_type(void) {
   gras_error_t errcode;
 
 gras_error_t declare_chained_list_type(void) {
   gras_error_t errcode;
-  gras_datadesc_type_t *my_type,*ref_my_type;
+  gras_datadesc_type_t my_type,ref_my_type;
 
   my_type=gras_datadesc_struct("chained_list_t");
   ref_my_type=gras_datadesc_ref("chained_list_t*",my_type);
 
   my_type=gras_datadesc_struct("chained_list_t");
   ref_my_type=gras_datadesc_ref("chained_list_t*",my_type);
@@ -349,7 +349,7 @@ chained_list_t * cons(int v, chained_list_t *l) {
 void list_free(chained_list_t*l) {
   if (l) {
     list_free(l->l);
 void list_free(chained_list_t*l) {
   if (l) {
     list_free(l->l);
-    gras_free(l);
+    free(l);
   }
 }
 int list_eq(chained_list_t*i,chained_list_t*j) {
   }
 }
 int list_eq(chained_list_t*i,chained_list_t*j) {
@@ -358,7 +358,7 @@ int list_eq(chained_list_t*i,chained_list_t*j) {
     return 0;
   return list_eq(i->l, j->l); 
 }
     return 0;
   return list_eq(i->l, j->l); 
 }
-gras_error_t test_chain_list(gras_socket_t *sock, int direction) {
+gras_error_t test_chain_list(gras_socket_t sock, int direction) {
   gras_error_t errcode;
   chained_list_t *i, *j; 
 
   gras_error_t errcode;
   chained_list_t *i, *j; 
 
@@ -382,7 +382,7 @@ gras_error_t test_chain_list(gras_socket_t *sock, int direction) {
 /***
  *** graph
  ***/
 /***
  *** graph
  ***/
-gras_error_t test_graph(gras_socket_t *sock, int direction) {
+gras_error_t test_graph(gras_socket_t sock, int direction) {
   gras_error_t errcode;
   chained_list_t *i, *j; 
 
   gras_error_t errcode;
   chained_list_t *i, *j; 
 
@@ -442,12 +442,12 @@ struct s_pbio{ /* structure presented in the IEEE article */
                 )
 typedef struct s_pbio pbio_t;
 
                 )
 typedef struct s_pbio pbio_t;
 
-gras_error_t test_pbio(gras_socket_t *sock, int direction) {
+gras_error_t test_pbio(gras_socket_t sock, int direction) {
   gras_error_t errcode;
   pbio_t i,j;
   int cpt;
   int cpt2;
   gras_error_t errcode;
   pbio_t i,j;
   int cpt;
   int cpt2;
-  gras_datadesc_type_t *pbio_type;
+  gras_datadesc_type_t pbio_type;
 
   INFO0("---- Test on the PBIO IEEE struct (also tests GRAS DEFINE TYPE) ----");
   pbio_type = gras_datadesc_by_symbol(s_pbio);
 
   INFO0("---- Test on the PBIO IEEE struct (also tests GRAS DEFINE TYPE) ----");
   pbio_type = gras_datadesc_by_symbol(s_pbio);
@@ -522,9 +522,9 @@ struct s_clause {
 };)
 typedef struct s_clause Clause;
 
 };)
 typedef struct s_clause Clause;
 
-gras_error_t test_clause(gras_socket_t *sock, int direction) {
+gras_error_t test_clause(gras_socket_t sock, int direction) {
   gras_error_t errcode;
   gras_error_t errcode;
-  gras_datadesc_type_t *ddt,*array_t;
+  gras_datadesc_type_t ddt,array_t;
   Clause *i,*j;
   int cpt;
   
   Clause *i,*j;
   int cpt;
   
@@ -552,17 +552,17 @@ gras_error_t test_clause(gras_socket_t *sock, int direction) {
     for (cpt=0; cpt<i->num_lits; cpt++)
       gras_assert(i->literals[cpt] == j->literals[cpt]);
     
     for (cpt=0; cpt<i->num_lits; cpt++)
       gras_assert(i->literals[cpt] == j->literals[cpt]);
     
-    gras_free(j->literals);
-    gras_free(j);
+    free(j->literals);
+    free(j);
   }
   }
-  gras_free(i->literals);
-  gras_free(i);
+  free(i->literals);
+  free(i);
   return no_error;
 }
 
 int main(int argc,char *argv[]) {
   gras_error_t errcode;
   return no_error;
 }
 
 int main(int argc,char *argv[]) {
   gras_error_t errcode;
-  gras_socket_t *sock;
+  gras_socket_t sock;
   int direction = RW;
   int cpt;
   char r_arch_char = gras_arch_selfid();
   int direction = RW;
   int cpt;
   char r_arch_char = gras_arch_selfid();
@@ -602,7 +602,7 @@ int main(int argc,char *argv[]) {
   
   TRYFAIL(test_string(sock,direction)); 
 
   
   TRYFAIL(test_string(sock,direction)); 
 
-  TRYFAIL(test_structures(sock,direction));
+     TRYFAIL(test_structures(sock,direction));
 
   TRYFAIL(test_homostruct(sock,direction));
   TRYFAIL(test_hetestruct(sock,direction));
 
   TRYFAIL(test_homostruct(sock,direction));
   TRYFAIL(test_hetestruct(sock,direction));
index 43861b8..bfc0b9c 100755 (executable)
@@ -27,11 +27,12 @@ print "GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(structs,test,\"Logs about the gigantic s
 print "#define READ  0\n#define WRITE 1\n#define RW    2\n\n";
   
 
 print "#define READ  0\n#define WRITE 1\n#define RW    2\n\n";
   
 
-print "gras_error_t write_read(gras_datadesc_type_t *type,void *src, void *dst, gras_socket_t *sock, int direction);\n\n";
+print "gras_error_t write_read(gras_datadesc_type_t type,void *src, void *dst, gras_socket_t *sock, int direction);\n\n";
 
 my ($i,$j,$k,$l);
 my $max=scalar @types;
 
 my ($i,$j,$k,$l);
 my $max=scalar @types;
-for $i (0..$max-1) { for $j (0..$max-1) { for $k (0..$max-1) {my $l=0;
+my $maxl=0; # set it to "$max-1" to do 2401 tests (takes for ever to compile)
+for $i (0..$max-1) { for $j (0..$max-1) { for $k (0..$max-1) { for $l (0..$maxl) {
     print "GRAS_DEFINE_TYPE(".$abrev[$i].$abrev[$j].$abrev[$k].$abrev[$l].",".
       "struct ".$abrev[$i].$abrev[$j].$abrev[$k].$abrev[$l]." { ".
         $types[$i]." a; ".
     print "GRAS_DEFINE_TYPE(".$abrev[$i].$abrev[$j].$abrev[$k].$abrev[$l].",".
       "struct ".$abrev[$i].$abrev[$j].$abrev[$k].$abrev[$l]." { ".
         $types[$i]." a; ".
@@ -39,7 +40,7 @@ for $i (0..$max-1) { for $j (0..$max-1) { for $k (0..$max-1) {my $l=0;
         $types[$k]." c;".
         $types[$l]." d;".
       "};)\n";
         $types[$k]." c;".
         $types[$l]." d;".
       "};)\n";
-}}}
+}}}}
 
 # print "\n#define test(a) do {if (!(a)) { failed = 1; ERROR1(\"%s failed\",#a);}} while (0)\n";
  print "\n#define test(a) gras_assert(a)\n";
 
 # print "\n#define test(a) do {if (!(a)) { failed = 1; ERROR1(\"%s failed\",#a);}} while (0)\n";
  print "\n#define test(a) gras_assert(a)\n";
@@ -47,16 +48,16 @@ for $i (0..$max-1) { for $j (0..$max-1) { for $k (0..$max-1) {my $l=0;
 print "\ngras_error_t test_structures(gras_socket_t *sock, int direction);\n";
 print "\ngras_error_t test_structures(gras_socket_t *sock, int direction) {\n";
 print "  gras_error_t errcode;\n";
 print "\ngras_error_t test_structures(gras_socket_t *sock, int direction);\n";
 print "\ngras_error_t test_structures(gras_socket_t *sock, int direction) {\n";
 print "  gras_error_t errcode;\n";
-for $i (0..$max-1) { for $j (0..$max-1) { for $k (0..$max-1) {my $l=0;
+for $i (0..$max-1) { for $j (0..$max-1) { for $k (0..$max-1) { for $l (0..$maxl) {
     my $struct=$abrev[$i].$abrev[$j].$abrev[$k].$abrev[$l];
     print "  struct $struct my_$struct = {".$val[$i]."+(".$types[$i].")1,"
                                            .$val[$j]."+(".$types[$j].")2,"
                                            .$val[$k]."+(".$types[$k].")3,"
                                            .$val[$l]."+(".$types[$l].")4}, my_${struct}2;\n";
     my $struct=$abrev[$i].$abrev[$j].$abrev[$k].$abrev[$l];
     print "  struct $struct my_$struct = {".$val[$i]."+(".$types[$i].")1,"
                                            .$val[$j]."+(".$types[$j].")2,"
                                            .$val[$k]."+(".$types[$k].")3,"
                                            .$val[$l]."+(".$types[$l].")4}, my_${struct}2;\n";
-}}}
+}}}}
 
 
-print "  INFO0(\"---- Test on all possible struct having 3 fields (".($max*$max*$max)." structs) ----\");\n";
-for $i (0..$max-1) { for $j (0..$max-1) { for $k (0..$max-1) { my $l=0;
+print "  INFO0(\"---- Test on all possible struct having 3 fields (".($max*$max*$max*($maxl+1))." structs) ----\");\n";
+for $i (0..$max-1) { for $j (0..$max-1) { for $k (0..$max-1) { for $l (0..$maxl) {
     my $struct=$abrev[$i].$abrev[$j].$abrev[$k].$abrev[$l];
     print "  TRY(write_read(gras_datadesc_by_symbol($struct), &my_$struct, &my_${struct}2, sock,direction));\n";
     print "  if (direction == READ || direction == RW) {\n";
     my $struct=$abrev[$i].$abrev[$j].$abrev[$k].$abrev[$l];
     print "  TRY(write_read(gras_datadesc_by_symbol($struct), &my_$struct, &my_${struct}2, sock,direction));\n";
     print "  if (direction == READ || direction == RW) {\n";
@@ -67,7 +68,7 @@ for $i (0..$max-1) { for $j (0..$max-1) { for $k (0..$max-1) { my $l=0;
     print "     test(my_$struct.d == my_${struct}2.d);\n";
     print "     if (!failed) VERB0(\"Passed $struct\");\n";
     print "  }\n";
     print "     test(my_$struct.d == my_${struct}2.d);\n";
     print "     if (!failed) VERB0(\"Passed $struct\");\n";
     print "  }\n";
-}}}
+}}}}
     print "  return no_error;\n";
     print "}\n";
     print "  return no_error;\n";
     print "}\n";
-                 ;
+    ;
index a959832..21680c3 100644 (file)
@@ -15,7 +15,7 @@
 /* GRAS_LOG_NEW_DEFAULT_CATEGORY(test); */
 
 int main(int argc,char *argv[]) {
 /* GRAS_LOG_NEW_DEFAULT_CATEGORY(test); */
 
 int main(int argc,char *argv[]) {
-  gras_socket_t *sock;
+  gras_socket_t sock;
   gras_error_t errcode;
   char data_send[256];
 
   gras_error_t errcode;
   char data_send[256];
 
index 0406320..8aac726 100644 (file)
@@ -15,7 +15,7 @@
 /*GRAS_LOG_NEW_DEFAULT_CATEGORY(test);*/
 
 int main(int argc,char *argv[]) {
 /*GRAS_LOG_NEW_DEFAULT_CATEGORY(test);*/
 
 int main(int argc,char *argv[]) {
-  gras_socket_t *sock, *conn;
+  gras_socket_t sock, conn;
   gras_error_t errcode;
   char data_recv[256];
 
   gras_error_t errcode;
   char data_recv[256];
 
index 129e354..d24a208 100644 (file)
@@ -15,7 +15,7 @@
 /*GRAS_LOG_NEW_DEFAULT_CATEGORY(test);*/
 
 int main(int argc,char *argv[]) {
 /*GRAS_LOG_NEW_DEFAULT_CATEGORY(test);*/
 
 int main(int argc,char *argv[]) {
-  gras_socket_t sock;
+  gras_socket_t sock;
   gras_error_t errcode;
   char data_send[256];
   char data_recv[256];
   gras_error_t errcode;
   char data_send[256];
   char data_recv[256];
index be8fb9f..192cc3a 100644 (file)
@@ -15,7 +15,7 @@
 /*GRAS_LOG_NEW_DEFAULT_CATEGORY(test);*/
 
 int main(int argc,char *argv[]) {
 /*GRAS_LOG_NEW_DEFAULT_CATEGORY(test);*/
 
 int main(int argc,char *argv[]) {
-  gras_socket_t *sock, *conn;
+  gras_socket_t sock, conn;
   gras_error_t errcode;
   char data_recv[256];
 
   gras_error_t errcode;
   char data_recv[256];
 
index 8795b91..e3f4170 100755 (executable)
@@ -7,7 +7,7 @@ tests_nb=0
 rm -f test.failed test.success test.ignored
 
 if [ xvalgrind = "x$1" ] ; then
 rm -f test.failed test.success test.ignored
 
 if [ xvalgrind = "x$1" ] ; then
-  valgrind="libtool --mode=execute valgrind"
+  valgrind="libtool --mode=execute valgrind --show-reachable=yes"
 else
   valgrind=
 fi
 else
   valgrind=
 fi
index f03b44a..b85638c 100644 (file)
@@ -6,11 +6,11 @@
 #include <gras.h>
 
 /*====[ Prototypes ]=========================================================*/
 #include <gras.h>
 
 /*====[ Prototypes ]=========================================================*/
-gras_cfg_t *make_set(void); /* build a minimal set */
+gras_cfg_t make_set(void); /* build a minimal set */
 
 /*====[ Code ]===============================================================*/
 
 /*====[ Code ]===============================================================*/
-gras_cfg_t *make_set(){
-  gras_cfg_t *set=NULL; 
+gras_cfg_t make_set(){
+  gras_cfg_t set=NULL; 
   gras_error_t errcode;
 
   set = gras_cfg_new();
   gras_error_t errcode;
 
   set = gras_cfg_new();
@@ -25,9 +25,9 @@ gras_cfg_t *make_set(){
  
 int main(int argc, char **argv) {
   gras_error_t errcode;
  
 int main(int argc, char **argv) {
   gras_error_t errcode;
-  gras_cfg_t *set;
+  gras_cfg_t set;
 
 
-  gras_dynar_t *dyn;
+  gras_dynar_t dyn;
   char *str;
   int ival;
   
   char *str;
   int ival;
   
@@ -37,12 +37,14 @@ int main(int argc, char **argv) {
   set=make_set();
   gras_cfg_dump("test set","",set);
   gras_cfg_free(&set);
   set=make_set();
   gras_cfg_dump("test set","",set);
   gras_cfg_free(&set);
+  gras_cfg_free(&set);
 
 
   fprintf(stderr,"==== Try to use an unregistered option. (ERROR EXPECTED: 'color' not registered)\n");
   set=make_set();
   TRYEXPECT(mismatch_error,gras_cfg_set_parse(set,"color:blue"));
   gras_cfg_free(&set);
 
 
   fprintf(stderr,"==== Try to use an unregistered option. (ERROR EXPECTED: 'color' not registered)\n");
   set=make_set();
   TRYEXPECT(mismatch_error,gras_cfg_set_parse(set,"color:blue"));
   gras_cfg_free(&set);
+  gras_cfg_free(&set);
 
 
   fprintf(stderr,
 
 
   fprintf(stderr,
@@ -58,6 +60,7 @@ int main(int argc, char **argv) {
   gras_cfg_set_parse(set,"speed:42 speed:24 speed:34");
   gras_cfg_check(set);
   gras_cfg_free(&set);
   gras_cfg_set_parse(set,"speed:42 speed:24 speed:34");
   gras_cfg_check(set);
   gras_cfg_free(&set);
+  gras_cfg_free(&set);
 
   fprintf(stderr,"==== Get single value (Expected: 'speed value: 42')\n");
   set=make_set();
 
   fprintf(stderr,"==== Get single value (Expected: 'speed value: 42')\n");
   set=make_set();
@@ -65,6 +68,7 @@ int main(int argc, char **argv) {
   gras_cfg_get_int(set,"speed",&ival);
   fprintf(stderr,"speed value: %d\n",ival); 
   gras_cfg_free(&set);
   gras_cfg_get_int(set,"speed",&ival);
   fprintf(stderr,"speed value: %d\n",ival); 
   gras_cfg_free(&set);
+  gras_cfg_free(&set);
 
   fprintf(stderr,"==== Get multiple values (Expected: 'Count: 3; Options: mquinson;ecaron;alegrand;')\n");
   set=make_set();
 
   fprintf(stderr,"==== Get multiple values (Expected: 'Count: 3; Options: mquinson;ecaron;alegrand;')\n");
   set=make_set();
@@ -77,6 +81,7 @@ int main(int argc, char **argv) {
   }
   fprintf(stderr,"\n");
   gras_cfg_free(&set);
   }
   fprintf(stderr,"\n");
   gras_cfg_free(&set);
+  gras_cfg_free(&set);
 
   gras_exit();
   return 0;
 
   gras_exit();
   return 0;
index 8c4b79b..0a3c623 100644 (file)
@@ -13,7 +13,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 
 #include <stdio.h>
 #include <stdlib.h>
 
-#define NB_ELM 200000
+#define NB_ELM 20000
 #define SIZEOFKEY 1024
 
 static void print_str(void *str);
 #define SIZEOFKEY 1024
 
 static void print_str(void *str);
@@ -23,8 +23,8 @@ static void print_str(void *str) {
 
 GRAS_LOG_NEW_DEFAULT_CATEGORY(test,"Logging specific to this test");
 
 
 GRAS_LOG_NEW_DEFAULT_CATEGORY(test,"Logging specific to this test");
 
-static gras_error_t traverse(gras_dict_t *head) {
-  gras_dict_cursor_t *cursor=NULL;
+static gras_error_t traverse(gras_dict_t head) {
+  gras_dict_cursor_t cursor=NULL;
   char *key;
   char *data;
 
   char *key;
   char *data;
 
@@ -36,8 +36,8 @@ static gras_error_t traverse(gras_dict_t *head) {
   return no_error;
 }
 
   return no_error;
 }
 
-static gras_error_t countelems(gras_dict_t *head,int*count) {
-  gras_dict_cursor_t *cursor;
+static gras_error_t countelems(gras_dict_t head,int*count) {
+  gras_dict_cursor_t cursor;
   char *key;
   void *data;
   *count=0;
   char *key;
   void *data;
   *count=0;
@@ -50,7 +50,7 @@ static gras_error_t countelems(gras_dict_t *head,int*count) {
 
 int main(int argc,char **argv) {
   gras_error_t errcode;
 
 int main(int argc,char **argv) {
   gras_error_t errcode;
-  gras_dict_t *head=NULL;
+  gras_dict_t head=NULL;
   int i,j,k, nb;
   char *key;
   void *data;
   int i,j,k, nb;
   char *key;
   void *data;
@@ -88,6 +88,7 @@ int main(int argc,char **argv) {
     }    
     TRYFAIL(traverse(head));
     gras_dict_free(&head);
     }    
     TRYFAIL(traverse(head));
     gras_dict_free(&head);
+    gras_dict_free(&head);
   }
 
 
   }
 
 
index fe53dda..18d3450 100644 (file)
 GRAS_LOG_EXTERNAL_CATEGORY(dict);
 GRAS_LOG_NEW_DEFAULT_CATEGORY(test,"Logging specific to this test");
 
 GRAS_LOG_EXTERNAL_CATEGORY(dict);
 GRAS_LOG_NEW_DEFAULT_CATEGORY(test,"Logging specific to this test");
 
-static void fill(gras_dict_t **head);
-static void debuged_add(gras_dict_t *head,const char*key);
-static gras_error_t search(gras_dict_t *head,const char*key);
-static gras_error_t debuged_remove(gras_dict_t *head,const char*key);
-static gras_error_t traverse(gras_dict_t *head);
+static void fill(gras_dict_t *head);
+static void debuged_add(gras_dict_t head,const char*key);
+static gras_error_t search(gras_dict_t head,const char*key);
+static gras_error_t debuged_remove(gras_dict_t head,const char*key);
+static gras_error_t traverse(gras_dict_t head);
 
 static void print_str(void *str);
 static void print_str(void *str) {
   printf("%s",(char*)str);
 }
 
 
 static void print_str(void *str);
 static void print_str(void *str) {
   printf("%s",(char*)str);
 }
 
-static void fill(gras_dict_t **head) {
+static void fill(gras_dict_t *head) {
   printf("\n Fill in the dictionnary\n");
 
   *head = gras_dict_new();
   printf("\n Fill in the dictionnary\n");
 
   *head = gras_dict_new();
@@ -43,19 +43,19 @@ static void fill(gras_dict_t **head) {
 
 }
 
 
 }
 
-static void debuged_add(gras_dict_t *head,const char*key)
+static void debuged_add(gras_dict_t head,const char*key)
 {
   char *data=gras_strdup(key);
 
   printf("   - Add %s\n",key);
 {
   char *data=gras_strdup(key);
 
   printf("   - Add %s\n",key);
-  gras_dict_set(head,key,data,&gras_free);
+  gras_dict_set(head,key,data,&free);
   if (GRAS_LOG_ISENABLED(dict,gras_log_priority_debug)) {
     gras_dict_dump(head,(void (*)(void*))&printf);
     fflush(stdout);
   }
 }
 
   if (GRAS_LOG_ISENABLED(dict,gras_log_priority_debug)) {
     gras_dict_dump(head,(void (*)(void*))&printf);
     fflush(stdout);
   }
 }
 
-static gras_error_t search(gras_dict_t *head,const char*key) {
+static gras_error_t search(gras_dict_t head,const char*key) {
   void *data;
   gras_error_t errcode;
 
   void *data;
   gras_error_t errcode;
 
@@ -67,7 +67,7 @@ static gras_error_t search(gras_dict_t *head,const char*key) {
   return errcode;
 }
 
   return errcode;
 }
 
-static gras_error_t debuged_remove(gras_dict_t *head,const char*key)
+static gras_error_t debuged_remove(gras_dict_t head,const char*key)
 {
   gras_error_t errcode;
 
 {
   gras_error_t errcode;
 
@@ -78,8 +78,8 @@ static gras_error_t debuged_remove(gras_dict_t *head,const char*key)
 }
 
 
 }
 
 
-static gras_error_t traverse(gras_dict_t *head) {
-  gras_dict_cursor_t *cursor=NULL;
+static gras_error_t traverse(gras_dict_t head) {
+  gras_dict_cursor_t cursor=NULL;
   char *key;
   char *data;
 
   char *key;
   char *data;
 
@@ -93,7 +93,7 @@ static gras_error_t traverse(gras_dict_t *head) {
 
 int main(int argc,char **argv) {
   gras_error_t errcode;
 
 int main(int argc,char **argv) {
   gras_error_t errcode;
-  gras_dict_t *head=NULL;
+  gras_dict_t head=NULL;
   char *data;
 
   gras_init_defaultlog(&argc,argv,"dict.thresh=verbose");
   char *data;
 
   gras_init_defaultlog(&argc,argv,"dict.thresh=verbose");
@@ -104,22 +104,21 @@ int main(int argc,char **argv) {
   TRYFAIL(traverse(head));
 
   fill(&head);
   TRYFAIL(traverse(head));
 
   fill(&head);
-  printf(" Free the dictionnary\n");
+  printf(" Free the dictionnary (twice)\n");
   gras_dict_free(&head);
   gras_dict_free(&head);
-  printf(" Free the dictionnary again\n");
   gras_dict_free(&head);
   
   fill(&head);
 
   printf(" - Change some values\n");
   printf("   - Change 123 to 'Changed 123'\n");
   gras_dict_free(&head);
   
   fill(&head);
 
   printf(" - Change some values\n");
   printf("   - Change 123 to 'Changed 123'\n");
-  gras_dict_set(head,"123",strdup("Changed 123"),&gras_free);
+  gras_dict_set(head,"123",strdup("Changed 123"),&free);
   printf("   - Change 123 back to '123'\n");
   printf("   - Change 123 back to '123'\n");
-  gras_dict_set(head,"123",strdup("123"),&gras_free);
+  gras_dict_set(head,"123",strdup("123"),&free);
   printf("   - Change 12a to 'Dummy 12a'\n");
   printf("   - Change 12a to 'Dummy 12a'\n");
-  gras_dict_set(head,"12a",strdup("Dummy 12a"),&gras_free);
+  gras_dict_set(head,"12a",strdup("Dummy 12a"),&free);
   printf("   - Change 12a to '12a'\n");
   printf("   - Change 12a to '12a'\n");
-  gras_dict_set(head,"12a",strdup("12a"),&gras_free);
+  gras_dict_set(head,"12a",strdup("12a"),&free);
 
   /*  gras_dict_dump(head,(void (*)(void*))&printf); */
   printf(" - Traverse the resulting dictionnary\n");
 
   /*  gras_dict_dump(head,(void (*)(void*))&printf); */
   printf(" - Traverse the resulting dictionnary\n");
@@ -146,7 +145,7 @@ int main(int argc,char **argv) {
 
   /*  gras_dict_dump(head,(void (*)(void*))&printf); */
 
 
   /*  gras_dict_dump(head,(void (*)(void*))&printf); */
 
-  printf(" Free the dictionnary (twice)\n");
+  printf(" Free the dictionnary twice\n");
   gras_dict_free(&head);
   gras_dict_free(&head);
 
   gras_dict_free(&head);
   gras_dict_free(&head);
 
index 09c295d..b09e788 100644 (file)
@@ -14,7 +14,7 @@
 GRAS_LOG_NEW_DEFAULT_CATEGORY(test,"Logging specific to this test");
 
 int main(int argc,char *argv[]) {
 GRAS_LOG_NEW_DEFAULT_CATEGORY(test,"Logging specific to this test");
 
 int main(int argc,char *argv[]) {
-   gras_dynar_t *d;
+   gras_dynar_t d;
    gras_error_t errcode;
    int cpt,cursor;
    double d1,d2;
    gras_error_t errcode;
    int cpt,cursor;
    double d1,d2;
@@ -27,7 +27,8 @@ int main(int argc,char *argv[]) {
      gras_assert0(FALSE,
             "Damnit, there is something in the empty dynar");
    }
      gras_assert0(FALSE,
             "Damnit, there is something in the empty dynar");
    }
-   gras_dynar_free(d);
+   gras_dynar_free(&d);
+   gras_dynar_free(&d);
 
    INFO0("==== Push/shift 5000 doubles");
    d=gras_dynar_new(sizeof(double),NULL);
 
    INFO0("==== Push/shift 5000 doubles");
    d=gras_dynar_new(sizeof(double),NULL);
@@ -48,7 +49,8 @@ int main(int argc,char *argv[]) {
            "The retrieved value is not the same than the injected one (%f!=%f)",
                  d1,d2);
    }
            "The retrieved value is not the same than the injected one (%f!=%f)",
                  d1,d2);
    }
-   gras_dynar_free(d);
+   gras_dynar_free(&d);
+   gras_dynar_free(&d);
 
 
    INFO0("==== Unshift/pop 5000 doubles");
 
 
    INFO0("==== Unshift/pop 5000 doubles");
@@ -64,7 +66,8 @@ int main(int argc,char *argv[]) {
            "The retrieved value is not the same than the injected one (%f!=%f)",
                   d1,d2);
    }
            "The retrieved value is not the same than the injected one (%f!=%f)",
                   d1,d2);
    }
-   gras_dynar_free(d);
+   gras_dynar_free(&d);
+   gras_dynar_free(&d);
 
 
 
 
 
 
@@ -101,7 +104,8 @@ int main(int argc,char *argv[]) {
            "The retrieved value is not the same than the injected one at the end (%f!=%f)",
                   d1,d2);
    }
            "The retrieved value is not the same than the injected one at the end (%f!=%f)",
                   d1,d2);
    }
-   gras_dynar_free(d);
+   gras_dynar_free(&d);
+   gras_dynar_free(&d);
 
 
    INFO0("==== Push 5000 double, remove 2000-4000. free the rest");
 
 
    INFO0("==== Push 5000 double, remove 2000-4000. free the rest");
@@ -117,7 +121,8 @@ int main(int argc,char *argv[]) {
            "Remove a bad value. Got %f, expected %f",
               d2,d1);
    }
            "Remove a bad value. Got %f, expected %f",
               d2,d1);
    }
-   gras_dynar_free(d);
+   gras_dynar_free(&d);
+   gras_dynar_free(&d);
 
    gras_exit();
    return 0;
 
    gras_exit();
    return 0;
index 4226d5a..68f0d48 100644 (file)
@@ -15,7 +15,7 @@
 GRAS_LOG_NEW_DEFAULT_CATEGORY(test,"Logging specific to this test");
 
 int main(int argc,char *argv[]) {
 GRAS_LOG_NEW_DEFAULT_CATEGORY(test,"Logging specific to this test");
 
 int main(int argc,char *argv[]) {
-   gras_dynar_t *d;
+   gras_dynar_t d;
    gras_error_t errcode;
    int i,cpt,cursor;
    int *iptr;
    gras_error_t errcode;
    int i,cpt,cursor;
    int *iptr;
@@ -27,13 +27,14 @@ int main(int argc,char *argv[]) {
    gras_dynar_foreach(d,cursor,i){
      gras_assert0(0,"Damnit, there is something in the empty dynar");
    }
    gras_dynar_foreach(d,cursor,i){
      gras_assert0(0,"Damnit, there is something in the empty dynar");
    }
-   gras_dynar_free(d);
+   gras_dynar_free(&d);
+   gras_dynar_free(&d);
 
    INFO1("==== Push %d int, set them again 3 times, traverse them, shift them",
        NB_ELEM);
    d=gras_dynar_new(sizeof(int),NULL);
    for (cpt=0; cpt< NB_ELEM; cpt++) {
 
    INFO1("==== Push %d int, set them again 3 times, traverse them, shift them",
        NB_ELEM);
    d=gras_dynar_new(sizeof(int),NULL);
    for (cpt=0; cpt< NB_ELEM; cpt++) {
-     gras_dynar_push(d,&cpt);
+     gras_dynar_push_as(d,int,cpt);
      DEBUG2("Push %d, length=%lu",cpt, gras_dynar_length(d));
    }
    for (cursor=0; cursor< NB_ELEM; cursor++) {
      DEBUG2("Push %d, length=%lu",cpt, gras_dynar_length(d));
    }
    for (cursor=0; cursor< NB_ELEM; cursor++) {
@@ -48,13 +49,14 @@ int main(int argc,char *argv[]) {
                  cursor,cpt);
    }
    for (cpt=0; cpt< NB_ELEM; cpt++)
                  cursor,cpt);
    }
    for (cpt=0; cpt< NB_ELEM; cpt++)
-     gras_dynar_set(d,cpt,&cpt);
+     *(int*)gras_dynar_get_ptr(d,cpt) = cpt;
 
    for (cpt=0; cpt< NB_ELEM; cpt++) 
 
    for (cpt=0; cpt< NB_ELEM; cpt++) 
-     gras_dynar_set(d,cpt,&cpt);
+     *(int*)gras_dynar_get_ptr(d,cpt) = cpt;
+/*     gras_dynar_set(d,cpt,&cpt);*/
    
    for (cpt=0; cpt< NB_ELEM; cpt++) 
    
    for (cpt=0; cpt< NB_ELEM; cpt++) 
-     gras_dynar_set(d,cpt,&cpt);
+     *(int*)gras_dynar_get_ptr(d,cpt) = cpt;
    
    cpt=0;
    gras_dynar_foreach(d,cursor,i){
    
    cpt=0;
    gras_dynar_foreach(d,cursor,i){
@@ -74,7 +76,8 @@ int main(int argc,char *argv[]) {
               i,cpt);
      DEBUG2("Pop %d, length=%lu",cpt, gras_dynar_length(d));
    }
               i,cpt);
      DEBUG2("Pop %d, length=%lu",cpt, gras_dynar_length(d));
    }
-   gras_dynar_free(d);
+   gras_dynar_free(&d);
+   gras_dynar_free(&d);
 
    
    INFO1("==== Unshift/pop %d int",NB_ELEM);
 
    
    INFO1("==== Unshift/pop %d int",NB_ELEM);
@@ -84,24 +87,24 @@ int main(int argc,char *argv[]) {
      DEBUG2("Push %d, length=%lu",cpt, gras_dynar_length(d));
    }
    for (cpt=0; cpt< NB_ELEM; cpt++) {
      DEBUG2("Push %d, length=%lu",cpt, gras_dynar_length(d));
    }
    for (cpt=0; cpt< NB_ELEM; cpt++) {
-     gras_dynar_pop(d,&i);
+     i=gras_dynar_pop_as(d,int);
      gras_assert2(i == cpt,
            "The retrieved value is not the same than the injected one (%d!=%d)",
                 i,cpt);
      DEBUG2("Pop %d, length=%lu",cpt, gras_dynar_length(d));
    }
      gras_assert2(i == cpt,
            "The retrieved value is not the same than the injected one (%d!=%d)",
                 i,cpt);
      DEBUG2("Pop %d, length=%lu",cpt, gras_dynar_length(d));
    }
-   gras_dynar_free(d);
-
+   gras_dynar_free(&d);
+   gras_dynar_free(&d);
 
    
    INFO1("==== Push %d int, insert 1000 int in the middle, shift everything",NB_ELEM);
    d=gras_dynar_new(sizeof(int),NULL);
    for (cpt=0; cpt< NB_ELEM; cpt++) {
 
    
    INFO1("==== Push %d int, insert 1000 int in the middle, shift everything",NB_ELEM);
    d=gras_dynar_new(sizeof(int),NULL);
    for (cpt=0; cpt< NB_ELEM; cpt++) {
-     gras_dynar_push(d,&cpt);
+     gras_dynar_push_as(d,int,cpt);
      DEBUG2("Push %d, length=%lu",cpt, gras_dynar_length(d));
    }
    for (cpt=0; cpt< 1000; cpt++) {
      DEBUG2("Push %d, length=%lu",cpt, gras_dynar_length(d));
    }
    for (cpt=0; cpt< 1000; cpt++) {
-     gras_dynar_insert_at(d,2500,&cpt);
+     gras_dynar_insert_at_as(d,2500,int,cpt);
      DEBUG2("Push %d, length=%lu",cpt, gras_dynar_length(d));
    }
 
      DEBUG2("Push %d, length=%lu",cpt, gras_dynar_length(d));
    }
 
@@ -124,13 +127,14 @@ int main(int argc,char *argv[]) {
            "The retrieved value is not the same than the injected one at the end (%d!=%d)",
               i,cpt);
    }
            "The retrieved value is not the same than the injected one at the end (%d!=%d)",
               i,cpt);
    }
-   gras_dynar_free(d);
+   gras_dynar_free(&d);
+   gras_dynar_free(&d);
 
 
    INFO1("==== Push %d int, remove 2000-4000. free the rest",NB_ELEM);
    d=gras_dynar_new(sizeof(int),NULL);
    for (cpt=0; cpt< NB_ELEM; cpt++) 
 
 
    INFO1("==== Push %d int, remove 2000-4000. free the rest",NB_ELEM);
    d=gras_dynar_new(sizeof(int),NULL);
    for (cpt=0; cpt< NB_ELEM; cpt++) 
-     gras_dynar_push(d,&cpt);
+     gras_dynar_push_as(d,int,cpt);
    
    for (cpt=2000; cpt< 4000; cpt++) {
      gras_dynar_remove_at(d,2000,&i);
    
    for (cpt=2000; cpt< 4000; cpt++) {
      gras_dynar_remove_at(d,2000,&i);
@@ -139,7 +143,8 @@ int main(int argc,char *argv[]) {
                  i,cpt);
      DEBUG2("remove %d, length=%lu",cpt, gras_dynar_length(d));
    }
                  i,cpt);
      DEBUG2("remove %d, length=%lu",cpt, gras_dynar_length(d));
    }
-   gras_dynar_free(d);
+   gras_dynar_free(&d);
+   gras_dynar_free(&d);
 
    gras_exit();
    return 0;
 
    gras_exit();
    return 0;
index 3c5b8af..90abe20 100644 (file)
@@ -18,11 +18,11 @@ GRAS_LOG_NEW_DEFAULT_CATEGORY(test,"Logging specific to this test");
 void free_string(void *d);
 
 void free_string(void *d){
 void free_string(void *d);
 
 void free_string(void *d){
-  gras_free(*(void**)d);
+  free(*(void**)d);
 }
 
 int main(int argc,char *argv[]) {
 }
 
 int main(int argc,char *argv[]) {
-   gras_dynar_t *d;
+   gras_dynar_t d;
    gras_error_t errcode;
    int cpt;
    char buf[1024];
    gras_error_t errcode;
    int cpt;
    char buf[1024];
@@ -36,7 +36,8 @@ int main(int argc,char *argv[]) {
      gras_assert0(FALSE,
                  "Damnit, there is something in the empty dynar");
    }
      gras_assert0(FALSE,
                  "Damnit, there is something in the empty dynar");
    }
-   gras_dynar_free(d);
+   gras_dynar_free(&d);
+   gras_dynar_free(&d);
 
    INFO1("==== Push %d strings, set them again 3 times, shift them",NB_ELEM);
    d=gras_dynar_new(sizeof(char*),&free_string);
 
    INFO1("==== Push %d strings, set them again 3 times, shift them",NB_ELEM);
    d=gras_dynar_new(sizeof(char*),&free_string);
@@ -66,9 +67,10 @@ int main(int argc,char *argv[]) {
      gras_assert2 (!strcmp(buf,s2),
            "The retrieved value is not the same than the injected one (%s!=%s)",
                   buf,s2);
      gras_assert2 (!strcmp(buf,s2),
            "The retrieved value is not the same than the injected one (%s!=%s)",
                   buf,s2);
-     gras_free(s2);
+     free(s2);
    }
    }
-   gras_dynar_free(d);
+   gras_dynar_free(&d);
+   gras_dynar_free(&d);
 
 
    INFO1("==== Unshift, traverse and pop %d strings",NB_ELEM);
 
 
    INFO1("==== Unshift, traverse and pop %d strings",NB_ELEM);
@@ -90,9 +92,10 @@ int main(int argc,char *argv[]) {
      gras_assert2 (!strcmp(buf,s2),
            "The retrieved value is not the same than the injected one (%s!=%s)",
               buf,s2);
      gras_assert2 (!strcmp(buf,s2),
            "The retrieved value is not the same than the injected one (%s!=%s)",
               buf,s2);
-     gras_free(s2);
+     free(s2);
    }
    }
-   gras_dynar_free(d);
+   gras_dynar_free(&d);
+   gras_dynar_free(&d);
 
 
    INFO2("==== Push %d strings, insert %d strings in the middle, shift everything",NB_ELEM,NB_ELEM/5);
 
 
    INFO2("==== Push %d strings, insert %d strings in the middle, shift everything",NB_ELEM,NB_ELEM/5);
@@ -114,7 +117,7 @@ int main(int argc,char *argv[]) {
      gras_assert2(!strcmp(buf,s2),
            "The retrieved value is not the same than the injected one at the begining (%s!=%s)",
               buf,s2);
      gras_assert2(!strcmp(buf,s2),
            "The retrieved value is not the same than the injected one at the begining (%s!=%s)",
               buf,s2);
-      gras_free(s2);
+      free(s2);
    }
    for (cpt=(NB_ELEM/5)-1; cpt>=0; cpt--) {
      sprintf(buf,"%d",cpt);
    }
    for (cpt=(NB_ELEM/5)-1; cpt>=0; cpt--) {
      sprintf(buf,"%d",cpt);
@@ -122,7 +125,7 @@ int main(int argc,char *argv[]) {
      gras_assert2 (!strcmp(buf,s2),
            "The retrieved value is not the same than the injected one in the middle (%s!=%s)",
               buf,s2);
      gras_assert2 (!strcmp(buf,s2),
            "The retrieved value is not the same than the injected one in the middle (%s!=%s)",
               buf,s2);
-     gras_free(s2);
+     free(s2);
    }
    for (cpt=NB_ELEM/2; cpt< NB_ELEM; cpt++) {
      sprintf(buf,"%d",cpt);
    }
    for (cpt=NB_ELEM/2; cpt< NB_ELEM; cpt++) {
      sprintf(buf,"%d",cpt);
@@ -130,9 +133,10 @@ int main(int argc,char *argv[]) {
      gras_assert2 (!strcmp(buf,s2),
            "The retrieved value is not the same than the injected one at the end (%s!=%s)",
               buf,s2);
      gras_assert2 (!strcmp(buf,s2),
            "The retrieved value is not the same than the injected one at the end (%s!=%s)",
               buf,s2);
-     gras_free(s2);
+     free(s2);
    }
    }
-   gras_dynar_free(d);
+   gras_dynar_free(&d);
+   gras_dynar_free(&d);
 
 
    INFO3("==== Push %d strings, remove %d-%d. free the rest",NB_ELEM,2*(NB_ELEM/5),4*(NB_ELEM/5));
 
 
    INFO3("==== Push %d strings, remove %d-%d. free the rest",NB_ELEM,2*(NB_ELEM/5),4*(NB_ELEM/5));
@@ -148,9 +152,10 @@ int main(int argc,char *argv[]) {
      gras_assert2(!strcmp(buf,s2),
                  "Remove a bad value. Got %s, expected %s",
                  s2,buf);
      gras_assert2(!strcmp(buf,s2),
                  "Remove a bad value. Got %s, expected %s",
                  s2,buf);
-      gras_free(s2);
+      free(s2);
    }
    }
-   gras_dynar_free(d);
+   gras_dynar_free(&d);
+   gras_dynar_free(&d);
 
    gras_exit();
    return 0;
 
    gras_exit();
    return 0;
index a92362d..8f0d20e 100644 (file)
@@ -24,36 +24,36 @@ typedef struct  {
 
   /* payload */
   char         *data;
 
   /* payload */
   char         *data;
-}my_elem_t;
+} s_my_elem_t,*my_elem_t;
 
 
-static void fill(gras_set_t **set);
-static void debuged_add(gras_set_t *set,const char*key);
-static void debuged_add_with_data(gras_set_t *set,
+static void fill(gras_set_t *set);
+static void debuged_add(gras_set_t set,const char*key);
+static void debuged_add_with_data(gras_set_t  set,
                                  const char *name,
                                  const char *data);
                                  const char *name,
                                  const char *data);
-static gras_error_t search_name(gras_set_t *set,const char*key);
-static gras_error_t search_id(gras_set_t *head,
+static gras_error_t search_name(gras_set_t set,const char*key);
+static gras_error_t search_id(gras_set_t head,
                              int id,
                              const char*expected_key);
                              int id,
                              const char*expected_key);
-static gras_error_t traverse(gras_set_t *set);
+static gras_error_t traverse(gras_set_t set);
 
 static void my_elem_free(void *e) {
 
 static void my_elem_free(void *e) {
-  my_elem_t *elm=(my_elem_t*)e;
+  my_elem_t elm=(my_elem_t)e;
 
   if (elm) {
 
   if (elm) {
-    gras_free(elm->name);
-    gras_free(elm->data);
-    gras_free(elm);
+    free(elm->name);
+    free(elm->data);
+    free(elm);
   }
 }
 
   }
 }
 
-static void debuged_add_with_data(gras_set_t *set,
+static void debuged_add_with_data(gras_set_t  set,
                                  const char *name,
                                  const char *data) {
 
                                  const char *name,
                                  const char *data) {
 
-  my_elem_t    *elm;
+  my_elem_t    elm;
 
 
-  elm = gras_new(my_elem_t,1);
+  elm = gras_new(s_my_elem_t,1);
   elm->name=gras_strdup(name);
   elm->name_len=0;
 
   elm->name=gras_strdup(name);
   elm->name_len=0;
 
@@ -64,16 +64,16 @@ static void debuged_add_with_data(gras_set_t *set,
     printf("(->%s)",data);
   }
   printf("\n");
     printf("(->%s)",data);
   }
   printf("\n");
-  gras_set_add(set, (gras_set_elm_t*)elm,
+  gras_set_add(set, (gras_set_elm_t)elm,
               &my_elem_free);
 }
 
               &my_elem_free);
 }
 
-static void debuged_add(gras_set_t *set,
+static void debuged_add(gras_set_t  set,
                        const char *name) {
   debuged_add_with_data(set, name, name);
 }
 
                        const char *name) {
   debuged_add_with_data(set, name, name);
 }
 
-static void fill(gras_set_t **set) {
+static void fill(gras_set_t *set) {
   printf("\n Fill in the data set\n");
 
   *set=gras_set_new();
   printf("\n Fill in the data set\n");
 
   *set=gras_set_new();
@@ -88,11 +88,11 @@ static void fill(gras_set_t **set) {
   debuged_add(*set,"123457");
 }
 
   debuged_add(*set,"123457");
 }
 
-static gras_error_t search_name(gras_set_t *head,const char*key) {
+static gras_error_t search_name(gras_set_t head,const char*key) {
   gras_error_t    errcode;
   gras_error_t    errcode;
-  my_elem_t      *elm;
+  my_elem_t       elm;
   
   
-  errcode=gras_set_get_by_name(head,key,(gras_set_elm_t**)&elm);
+  errcode=gras_set_get_by_name(head,key,(gras_set_elm_t*)&elm);
   printf("   - Search by name %s. Found %s (under ID %d)\n",
         key, 
         elm? elm->data:"(null)",
   printf("   - Search by name %s. Found %s (under ID %d)\n",
         key, 
         elm? elm->data:"(null)",
@@ -111,11 +111,11 @@ static gras_error_t search_name(gras_set_t *head,const char*key) {
   return errcode;
 }
 
   return errcode;
 }
 
-static gras_error_t search_id(gras_set_t *head,int id,const char*key) {
-  gras_error_t    errcode;
-  my_elem_t      *elm;
+static gras_error_t search_id(gras_set_t head,int id,const char*key) {
+  gras_error_t errcode;
+  my_elem_t    elm;
   
   
-  errcode=gras_set_get_by_id(head,id,(gras_set_elm_t**)&elm);
+  errcode=gras_set_get_by_id(head,id,(gras_set_elm_t*)&elm);
   printf("   - Search by id %d. Found %s (data %s)\n",
         id, 
         elm? elm->name:"(null)",
   printf("   - Search by id %d. Found %s (data %s)\n",
         id, 
         elm? elm->name:"(null)",
@@ -140,9 +140,9 @@ static gras_error_t search_id(gras_set_t *head,int id,const char*key) {
 }
 
 
 }
 
 
-static gras_error_t traverse(gras_set_t *set) {
-  gras_set_cursor_t *cursor=NULL;
-  my_elem_t *elm=NULL;
+static gras_error_t traverse(gras_set_t set) {
+  gras_set_cursor_t cursor=NULL;
+  my_elem_t         elm=NULL;
 
   gras_set_foreach(set,cursor,elm) {
     gras_assert0(elm,"Dude ! Got a null elm during traversal!");
 
   gras_set_foreach(set,cursor,elm) {
     gras_assert0(elm,"Dude ! Got a null elm during traversal!");
@@ -156,8 +156,8 @@ static gras_error_t traverse(gras_set_t *set) {
 
 int main(int argc,char **argv) {
   gras_error_t errcode;
 
 int main(int argc,char **argv) {
   gras_error_t errcode;
-  gras_set_t *set=NULL;
-  my_elem_t *elm;
+  gras_set_t set=NULL;
+  my_elem_t  elm;
 
   gras_init_defaultlog(&argc,argv,"set.thresh=verbose");
    
 
   gras_init_defaultlog(&argc,argv,"set.thresh=verbose");
    
@@ -189,15 +189,15 @@ int main(int argc,char **argv) {
   TRYFAIL(traverse(set));
 
   printf(" - Retrive values\n");
   TRYFAIL(traverse(set));
 
   printf(" - Retrive values\n");
-  gras_set_get_by_name(set,"123",(gras_set_elm_t**)&elm);
+  gras_set_get_by_name(set,"123",(gras_set_elm_t*)&elm);
   assert(elm);
   TRYFAIL(strcmp("123",elm->data));
 
   assert(elm);
   TRYFAIL(strcmp("123",elm->data));
 
-  TRYEXPECT(gras_set_get_by_name(set,"Can't be found",(gras_set_elm_t**)&elm),
+  TRYEXPECT(gras_set_get_by_name(set,"Can't be found",(gras_set_elm_t*)&elm),
            mismatch_error);
            mismatch_error);
-  TRYEXPECT(gras_set_get_by_name(set,"123 Can't be found",(gras_set_elm_t**)&elm),
+  TRYEXPECT(gras_set_get_by_name(set,"123 Can't be found",(gras_set_elm_t*)&elm),
            mismatch_error);
            mismatch_error);
-  TRYEXPECT(gras_set_get_by_name(set,"12345678 NOT",(gras_set_elm_t**)&elm),
+  TRYEXPECT(gras_set_get_by_name(set,"12345678 NOT",(gras_set_elm_t*)&elm),
            mismatch_error);
 
   TRYFAIL(search_name(set,"12"));
            mismatch_error);
 
   TRYFAIL(search_name(set,"12"));