Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
remplace -> replace
[simgrid.git] / testsuite / xbt / dynar_int.c
index 90febee..4226d5a 100644 (file)
@@ -18,11 +18,12 @@ int main(int argc,char *argv[]) {
    gras_dynar_t *d;
    gras_error_t errcode;
    int i,cpt,cursor;
    gras_dynar_t *d;
    gras_error_t errcode;
    int i,cpt,cursor;
+   int *iptr;
    
    gras_init_defaultlog(&argc,argv,"dynar.thresh=debug");
 
    INFO0("==== Traverse the empty dynar");
    
    gras_init_defaultlog(&argc,argv,"dynar.thresh=debug");
 
    INFO0("==== Traverse the empty dynar");
-   gras_dynar_new(&d,sizeof(int),NULL);
+   d=gras_dynar_new(sizeof(int),NULL);
    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");
    }
@@ -30,14 +31,14 @@ int main(int argc,char *argv[]) {
 
    INFO1("==== Push %d int, set them again 3 times, traverse them, shift them",
        NB_ELEM);
 
    INFO1("==== Push %d int, set them again 3 times, traverse them, shift them",
        NB_ELEM);
-   gras_dynar_new(&d,sizeof(int),NULL);
+   d=gras_dynar_new(sizeof(int),NULL);
    for (cpt=0; cpt< NB_ELEM; cpt++) {
      gras_dynar_push(d,&cpt);
      DEBUG2("Push %d, length=%lu",cpt, gras_dynar_length(d));
    }
    for (cursor=0; cursor< NB_ELEM; cursor++) {
    for (cpt=0; cpt< NB_ELEM; cpt++) {
      gras_dynar_push(d,&cpt);
      DEBUG2("Push %d, length=%lu",cpt, gras_dynar_length(d));
    }
    for (cursor=0; cursor< NB_ELEM; cursor++) {
-     gras_dynar_get(d,cursor,&cpt);
-     gras_assert2(cursor == cpt,
+     iptr=gras_dynar_get_ptr(d,cursor);
+     gras_assert2(cursor == *iptr,
                  "The retrieved value is not the same than the injected one (%d!=%d)",
                  cursor,cpt);
    }
                  "The retrieved value is not the same than the injected one (%d!=%d)",
                  cursor,cpt);
    }
@@ -77,7 +78,7 @@ int main(int argc,char *argv[]) {
 
    
    INFO1("==== Unshift/pop %d int",NB_ELEM);
 
    
    INFO1("==== Unshift/pop %d int",NB_ELEM);
-   gras_dynar_new(&d,sizeof(int),NULL);
+   d=gras_dynar_new(sizeof(int),NULL);
    for (cpt=0; cpt< NB_ELEM; cpt++) {
      gras_dynar_unshift(d,&cpt);
      DEBUG2("Push %d, length=%lu",cpt, gras_dynar_length(d));
    for (cpt=0; cpt< NB_ELEM; cpt++) {
      gras_dynar_unshift(d,&cpt);
      DEBUG2("Push %d, length=%lu",cpt, gras_dynar_length(d));
@@ -94,7 +95,7 @@ int main(int argc,char *argv[]) {
 
    
    INFO1("==== Push %d int, insert 1000 int in the middle, shift everything",NB_ELEM);
 
    
    INFO1("==== Push %d int, insert 1000 int in the middle, shift everything",NB_ELEM);
-   gras_dynar_new(&d,sizeof(int),NULL);
+   d=gras_dynar_new(sizeof(int),NULL);
    for (cpt=0; cpt< NB_ELEM; cpt++) {
      gras_dynar_push(d,&cpt);
      DEBUG2("Push %d, length=%lu",cpt, gras_dynar_length(d));
    for (cpt=0; cpt< NB_ELEM; cpt++) {
      gras_dynar_push(d,&cpt);
      DEBUG2("Push %d, length=%lu",cpt, gras_dynar_length(d));
@@ -127,7 +128,7 @@ int main(int argc,char *argv[]) {
 
 
    INFO1("==== Push %d int, remove 2000-4000. free the rest",NB_ELEM);
 
 
    INFO1("==== Push %d int, remove 2000-4000. free the rest",NB_ELEM);
-   gras_dynar_new(&d,sizeof(int),NULL);
+   d=gras_dynar_new(sizeof(int),NULL);
    for (cpt=0; cpt< NB_ELEM; cpt++) 
      gras_dynar_push(d,&cpt);
    
    for (cpt=0; cpt< NB_ELEM; cpt++) 
      gras_dynar_push(d,&cpt);