Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Last corrections of Tesh tool.
[simgrid.git] / tools / tesh2 / src / excludes.c
index 934c37d..ddfe0e1 100644 (file)
@@ -1,4 +1,5 @@
 #include <excludes.h>\r
+#include <fstream.h>\r
 \r
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);\r
 \r
@@ -7,7 +8,7 @@ excludes_new(void)
 {\r
        excludes_t excludes = xbt_new0(s_excludes_t, 1);\r
 \r
-       excludes->items = xbt_dynar_new(sizeof(fstream_t), NULL);\r
+       excludes->items = xbt_dynar_new(sizeof(fstream_t), (void_f_pvoid_t)fstream_free);\r
        \r
        return excludes;\r
 }\r
@@ -70,25 +71,28 @@ excludes_check(excludes_t excludes, fstreams_t fstreams)
        \r
        if(!excludes || !fstreams)\r
                return EINVAL;\r
-\r
-       xbt_dynar_foreach(excludes->items, i, exclude)\r
-       {\r
-               xbt_dynar_foreach(fstreams->items, i, fstream)\r
+       \r
+       \r
+               xbt_dynar_foreach(excludes->items, i, exclude)\r
                {\r
-                       exists = 0;\r
-                       \r
-                       if(!strcmp(fstream->name, exclude->name) && !strcmp(fstream->directory, exclude->directory))\r
+                       exists = 1;\r
+\r
+                       xbt_dynar_foreach(fstreams->items, i, fstream)\r
                        {\r
-                               exists = 1;\r
-                               break;\r
+                               exists = 0;\r
+                               \r
+                               if(!strcmp(fstream->name, exclude->name) && !strcmp(fstream->directory, exclude->directory))\r
+                               {\r
+                                       exists = 1;\r
+                                       break;\r
+                               }\r
                        }\r
-               }\r
 \r
-               if(!exists)\r
-               {\r
-                       success = 0;\r
-                       WARN1("cannot exclude the file %s",exclude->name);      \r
-               }\r
+                       if(!exists)\r
+                       {\r
+                               success = 0;\r
+                               WARN1("cannot exclude the file %s",exclude->name);      \r
+                       }\r
        }\r
                \r
        return success;\r
@@ -99,8 +103,9 @@ excludes_free(void** excludesptr)
 {\r
        if(!(*excludesptr))\r
                return EINVAL;\r
-\r
-       xbt_dynar_free((&(*((excludes_t*)excludesptr))->items));\r
+       \r
+       if((*((excludes_t*)excludesptr))->items)\r
+               xbt_dynar_free((&(*((excludes_t*)excludesptr))->items));\r
 \r
        free(*excludesptr);\r
        *excludesptr = NULL;    \r