Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Catch up with the lastest API breakage
[simgrid.git] / src / gras / DataDesc / cbps.c
index 69b3ed2..d4ac84b 100644 (file)
@@ -60,6 +60,17 @@ void gras_cbps_free(gras_cbps_t *state) {
   *state = NULL;
 }
 
+void gras_cbps_reset(gras_cbps_t state) {
+
+  xbt_dynar_reset(state->lints);
+
+  xbt_dict_free ( &(state->space) );
+  state->space = xbt_dict_new();
+
+  xbt_dynar_reset(state->frames);
+  xbt_dynar_reset(state->globals);
+}
+
 /** \brief Declare a new element in the PS, and give it a value.
  *
  * If an element of that
@@ -88,7 +99,7 @@ gras_cbps_v_push(gras_cbps_t          ps,
     DEBUG1("Create a new variable stack for '%s' into the space",name);
     varstack = xbt_dynar_new(sizeof (gras_cbps_elm_t *), NULL);
     xbt_dict_set(ps->space, varname, (void **)varstack, NULL);
-    xbt_ex_free(e);
+    xbt_ex_free(&e);
     /* leaking, you think? only if you do not close all the openned blocks ;)*/
   }
  
@@ -126,7 +137,7 @@ gras_cbps_v_pop (gras_cbps_t            ps,
     if (e.category != mismatch_error)
       RETHROW;
 
-    xbt_ex_free(e);
+    xbt_ex_free(&e);
     THROW1(not_found_error,1,"Asked to pop the non-existant %s", name);
   }
   xbt_dynar_pop(varstack, &var);
@@ -309,30 +320,68 @@ gras_cbps_i_pop(gras_cbps_t ps) {
  * Used by \ref gras_datadesc_ref_pop_arr
  */
 int gras_datadesc_cb_pop(gras_datadesc_type_t ignored, gras_cbps_t vars, void *data) {
-  return gras_cbps_i_pop(vars);
+  int res =  gras_cbps_i_pop(vars);
+  DEBUG1("Pop %d as a size",res);
+  return res;
 }
 
+/* ************************* */
+/* **** PUSHy callbacks **** */
+/* ************************* */
+
 /** \brief Cb to push an integer. Must be attached to the field you want to push */
 void gras_datadesc_cb_push_int(gras_datadesc_type_t ignored, gras_cbps_t vars, void *data) {
-   int *i = (int*)data;
-   gras_cbps_i_push(vars, (int) *i);
+  int *i = (int*)data;
+  gras_cbps_i_push(vars, (int) *i);
 }
 
 /** \brief Cb to push an unsigned integer. Must be attached to the field you want to push */
 void gras_datadesc_cb_push_uint(gras_datadesc_type_t ignored, gras_cbps_t vars, void *data) {
-   unsigned int *i = (unsigned int*)data;
-   gras_cbps_i_push(vars, (int) *i);
+  unsigned int *i = (unsigned int*)data;
+  gras_cbps_i_push(vars, (int) *i);
 }
 
 /** \brief Cb to push an long integer. Must be attached to the field you want to push
  */
 void gras_datadesc_cb_push_lint(gras_datadesc_type_t ignored, gras_cbps_t vars, void *data) {
-   long int *i = (long int*)data;
-   gras_cbps_i_push(vars, (int) *i);
+  long int *i = (long int*)data;
+  gras_cbps_i_push(vars, (int) *i);
 }
-/** \brief Cb to push an long integer. Must be attached to the field you want to push
+/** \brief Cb to push an unsigned long integer. Must be attached to the field you want to push
  */
 void gras_datadesc_cb_push_ulint(gras_datadesc_type_t ignored, gras_cbps_t vars, void *data) {
-   unsigned long int *i = (unsigned long int*)data;
-   gras_cbps_i_push(vars, (int) *i);
+  unsigned long int *i = (unsigned long int*)data;
+  gras_cbps_i_push(vars, (int) *i);
+}
+
+/* ************************************ */
+/* **** PUSHy multiplier callbacks **** */
+/* ************************************ */
+/** \brief Cb to push an integer as multiplier. Must be attached to the field you want to push */
+void gras_datadesc_cb_push_int_mult(gras_datadesc_type_t ignored, gras_cbps_t vars, void *data) {
+  int i = *(int*)data;
+  i *= gras_cbps_i_pop(vars);
+  gras_cbps_i_push(vars, i);
+}
+
+/** \brief Cb to push an unsigned integer as multiplier. Must be attached to the field you want to push */
+void gras_datadesc_cb_push_uint_mult(gras_datadesc_type_t ignored, gras_cbps_t vars, void *data) {
+  unsigned int i = *(unsigned int*)data;
+  i *= gras_cbps_i_pop(vars);
+  gras_cbps_i_push(vars, (int) i);
+}
+
+/** \brief Cb to push an long integer as multiplier. Must be attached to the field you want to push
+ */
+void gras_datadesc_cb_push_lint_mult(gras_datadesc_type_t ignored, gras_cbps_t vars, void *data) {
+  long int i = *(long int*)data;
+  i *= gras_cbps_i_pop(vars);
+  gras_cbps_i_push(vars, (int) i);
+}
+/** \brief Cb to push an unsigned long integer as multiplier. Must be attached to the field you want to push
+ */
+void gras_datadesc_cb_push_ulint_mult(gras_datadesc_type_t ignored, gras_cbps_t vars, void *data) {
+  unsigned long int i = *(unsigned long int*)data;
+  i *= gras_cbps_i_pop(vars);
+  gras_cbps_i_push(vars, (int) i);
 }