Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Catch up with the lastest API breakage
[simgrid.git] / src / xbt / dict_multi.c
index 7b85efa..eadf725 100644 (file)
@@ -58,14 +58,14 @@ xbt_multidict_set_ext(xbt_dict_t  mdict,
     TRY {
       nextlevel = xbt_dict_get_ext(thislevel, thiskey, thislen);
     } CATCH(e) {
-      if (e.category == arg_error || e.category == mismatch_error) {
-       /* make sure the dict of next level exists */
-       nextlevel=xbt_dict_new();
-       VERB1("Create a dict (%p)",nextlevel);
-       xbt_dict_set_ext(thislevel, thiskey, thislen, nextlevel, &_free_dict);
-      } else {
+      if (e.category != not_found_error)
        RETHROW;
-      }
+
+      /* make sure the dict of next level exists */
+      xbt_ex_free(&e);
+      nextlevel=xbt_dict_new();
+      VERB1("Create a dict (%p)",nextlevel);
+      xbt_dict_set_ext(thislevel, thiskey, thislen, nextlevel, &_free_dict);
     }
   }
 
@@ -88,6 +88,7 @@ xbt_multidict_set(xbt_dict_t  mdict,
                   void       *data,  void_f_pvoid_t *free_ctn) {
   xbt_dynar_t lens = xbt_dynar_new(sizeof(unsigned long int),NULL);
   int i;
+  xbt_ex_t e;
 
   for (i = 0; i < xbt_dynar_length(keys); i++) {
     char *thiskey = xbt_dynar_get_as(keys, i, char*);
@@ -96,9 +97,13 @@ xbt_multidict_set(xbt_dict_t  mdict,
     xbt_dynar_push(lens,&thislen);
   }
 
-  xbt_multidict_set_ext(mdict, keys, lens, data, free_ctn);
-  xbt_dynar_free(&lens);         
-
+  TRY {
+    xbt_multidict_set_ext(mdict, keys, lens, data, free_ctn);
+  } CLEANUP {
+    xbt_dynar_free(&lens);         
+  } CATCH(e) {
+    RETHROW;
+  }
 }
 
 /** \brief Insert \e data under all the keys contained in \e keys, providing their sizes in \e lens.
@@ -177,7 +182,7 @@ xbt_multidict_get(xbt_dict_t mdict, xbt_dynar_t keys) {
  * Removing a non-existant key is ok.
  */
 
-xbt_error_t
+void
 xbt_multidict_remove_ext(xbt_dict_t mdict, xbt_dynar_t keys, xbt_dynar_t lens) {
   xbt_dict_t thislevel,nextlevel=NULL;
   int i;
@@ -203,7 +208,7 @@ xbt_multidict_remove_ext(xbt_dict_t mdict, xbt_dynar_t keys, xbt_dynar_t lens) {
     } CATCH(e) {
       /* If non-existant entry, nothing to do */
       if (e.category == arg_error) 
-       xbt_ex_free(e);
+       xbt_ex_free(&e);
       else 
        RETHROW;
     }
@@ -212,13 +217,13 @@ xbt_multidict_remove_ext(xbt_dict_t mdict, xbt_dynar_t keys, xbt_dynar_t lens) {
   xbt_dynar_get_cpy(keys, i, &thiskey);
   xbt_dynar_get_cpy(lens, i, &thislen);
   
-  return xbt_dict_remove_ext(thislevel, thiskey, thislen);
+  xbt_dict_remove_ext(thislevel, thiskey, thislen);
 }
 
-xbt_error_t
+void
 xbt_multidict_remove(xbt_dict_t mdict, xbt_dynar_t keys) {
 
-  xbt_error_t errcode;
+  xbt_ex_t e;
   xbt_dynar_t lens = xbt_dynar_new(sizeof(unsigned long int),NULL);
   int i;
       
@@ -227,8 +232,12 @@ xbt_multidict_remove(xbt_dict_t mdict, xbt_dynar_t keys) {
     unsigned long int thislen = strlen(thiskey);
     xbt_dynar_push(lens,&thislen);
   }
-                      
-  errcode = xbt_multidict_remove_ext(mdict, keys, lens);
-  xbt_dynar_free(&lens);
-  return errcode;
+         
+  TRY {
+    xbt_multidict_remove_ext(mdict, keys, lens);
+  } CLEANUP {
+    xbt_dynar_free(&lens);
+  } CATCH(e) {
+    RETHROW;
+  }
 }