res = xbt_new(s_gras_cbps_t, 1);
res->lints = xbt_dynar_new(sizeof(int), NULL);
- res->space = xbt_dict_new();
+ res->space = xbt_dict_new_homogeneous(NULL);
/* no leak, the content is freed manually on block_end */
res->frames = xbt_dynar_new(sizeof(xbt_dynar_t), NULL);
res->globals = xbt_dynar_new(sizeof(char *), NULL);
char *varname = (char *) xbt_strdup(name);
xbt_ex_t e;
- DEBUG2("push(%s,%p)", name, (void *) data);
+ XBT_DEBUG("push(%s,%p)", name, (void *) data);
TRY {
varstack = xbt_dict_get(ps->space, name);
- } CATCH(e) {
+ }
+ CATCH(e) {
if (e.category != mismatch_error)
RETHROW;
- DEBUG1("Create a new variable stack for '%s' into the space", name);
+ XBT_DEBUG("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_dict_set(ps->space, name, (void **) varstack, NULL);
xbt_ex_free(e);
/* leaking, you think? only if you do not close all the openned blocks ;) */
}
xbt_dynar_push(varstack, &var);
xbt_dynar_pop(ps->frames, &frame);
- DEBUG4("Push %s (%p @%p) into frame %p", varname, (void *) varname,
+ XBT_DEBUG("Push %s (%p @%p) into frame %p", varname, (void *) varname,
(void *) &varname, (void *) frame);
xbt_dynar_push(frame, &varname);
xbt_dynar_push(ps->frames, &frame);
gras_cbps_v_pop(gras_cbps_t ps,
const char *name, gras_datadesc_type_t * ddt, void **res)
{
- xbt_dynar_t varstack=NULL, frame=NULL;
+ xbt_dynar_t varstack = NULL, frame = NULL;
gras_cbps_elm_t var = NULL;
void *data = NULL;
xbt_ex_t e;
- DEBUG1("pop(%s)", name);
+ XBT_DEBUG("pop(%s)", name);
TRY {
varstack = xbt_dict_get(ps->space, name);
- } CATCH(e) {
+ }
+ CATCH(e) {
if (e.category != mismatch_error)
RETHROW;
xbt_ex_free(e);
- THROW1(not_found_error, 1, "Asked to pop the non-existant %s", name);
+ THROWF(not_found_error, 1, "Asked to pop the non-existant %s", name);
}
xbt_dynar_pop(varstack, &var);
- if (!xbt_dynar_length(varstack)) {
- DEBUG1("Last incarnation of %s poped. Kill it", name);
+ if (xbt_dynar_is_empty(varstack)) {
+ XBT_DEBUG("Last incarnation of %s poped. Kill it", name);
xbt_dict_remove(ps->space, name);
xbt_dynar_free(&varstack);
}
xbt_dynar_t dynar = NULL;
gras_cbps_elm_t elm = NULL;
- DEBUG1("set(%s)", name);
+ XBT_DEBUG("set(%s)", name);
dynar = xbt_dict_get_or_null(ps->space, name);
if (dynar == NULL) {
xbt_dynar_t dynar = NULL;
gras_cbps_elm_t elm = NULL;
- DEBUG1("get(%s)", name);
+ XBT_DEBUG("get(%s)", name);
dynar = xbt_dict_get(ps->space, name);
xbt_dynar_pop(dynar, &elm);
xbt_dynar_push(dynar, &elm);
xbt_dynar_t dynar = NULL;
- DEBUG0(">>> Block begin");
+ XBT_DEBUG(">>> Block begin");
dynar = xbt_dynar_new(sizeof(char *), NULL);
xbt_dynar_push(ps->frames, &dynar);
}
unsigned int cursor = 0;
char *name = NULL;
- xbt_assert0(xbt_dynar_length(ps->frames),
+ xbt_assert(xbt_dynar_length(ps->frames),
"More block_end than block_begin");
xbt_dynar_pop(ps->frames, &frame);
xbt_dynar_t varstack = NULL;
gras_cbps_elm_t var = NULL;
- DEBUG2("Get ride of %s (%p)", name, (void *) name);
+ XBT_DEBUG("Get ride of %s (%p)", name, (void *) name);
varstack = xbt_dict_get(ps->space, name);
xbt_dynar_pop(varstack, &var);
- if (!xbt_dynar_length(varstack)) {
+ if (xbt_dynar_is_empty(varstack)) {
xbt_dict_remove(ps->space, name);
xbt_dynar_free_container(&varstack); /*already empty, save a test ;) */
}
- if (var->data)
- free(var->data);
+ free(var->data);
free(var);
free(name);
}
xbt_dynar_free_container(&frame); /* we just emptied it */
- DEBUG0("<<< Block end");
+ XBT_DEBUG("<<< Block end");
}
/** \brief Push a new integer value into the cbps. */
void gras_cbps_i_push(gras_cbps_t ps, int val)
{
- DEBUG1("push %d as a size", val);
+ XBT_DEBUG("push %d as a size", val);
xbt_dynar_push_as(ps->lints, int, val);
}
{
int ret;
- xbt_assert0(xbt_dynar_length(ps->lints) > 0,
+ xbt_assert(!xbt_dynar_is_empty(ps->lints),
"gras_cbps_i_pop: no value to pop");
ret = xbt_dynar_pop_as(ps->lints, int);
- DEBUG1("pop %d as a size", ret);
+ XBT_DEBUG("pop %d as a size", ret);
return ret;
}
/* ************************* */
/** \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)
+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 old = *(int *) data;
int new = gras_cbps_i_pop(vars);
- DEBUG2("push %d x %d as a size", old, new);
+ XBT_DEBUG("push %d x %d as a size", old, new);
gras_cbps_i_push(vars, old * new);
}
unsigned int old = *(unsigned int *) data;
unsigned int new = gras_cbps_i_pop(vars);
- DEBUG2("push %d x %d as a size", old, new);
+ XBT_DEBUG("push %d x %d as a size", old, new);
gras_cbps_i_push(vars, (int) (old * new));
}
unsigned long int old = *(unsigned long int *) data;
unsigned long int new = gras_cbps_i_pop(vars);
- DEBUG2("push %ld x %ld as a size", old, new);
+ XBT_DEBUG("push %ld x %ld as a size", old, new);
gras_cbps_i_push(vars, (int) (old * new));
}