*cfg = xbt_cfg_new();
xbt_assert(type >= xbt_cfgelm_int && type <= xbt_cfgelm_peer,
"type of %s not valid (%d should be between %d and %d)",
*cfg = xbt_cfg_new();
xbt_assert(type >= xbt_cfgelm_int && type <= xbt_cfgelm_peer,
"type of %s not valid (%d should be between %d and %d)",
- name, type, xbt_cfgelm_int, xbt_cfgelm_peer);
+ name, (int)type, xbt_cfgelm_int, xbt_cfgelm_peer);
res = xbt_new(s_xbt_cfgelm_t, 1);
XBT_DEBUG("Register cfg elm %s (%s) (%d to %d %s (=%d) @%p in set %p)",
res = xbt_new(s_xbt_cfgelm_t, 1);
XBT_DEBUG("Register cfg elm %s (%s) (%d to %d %s (=%d) @%p in set %p)",
- name, desc, min, max, xbt_cfgelm_type_name[type], type, res,
+ name, desc, min, max, xbt_cfgelm_type_name[type], (int)type, res,
- xbt_dict_set((xbt_dict_t) * cfg, name, res, &xbt_cfgelm_free);
+ xbt_dict_set((xbt_dict_t) * cfg, name, res, NULL);
type < xbt_cfgelm_type_count
&& strcmp(tok, xbt_cfgelm_type_name[type]); type++);
xbt_assert(type < xbt_cfgelm_type_count,
type < xbt_cfgelm_type_count
&& strcmp(tok, xbt_cfgelm_type_name[type]); type++);
xbt_assert(type < xbt_cfgelm_type_count,
if (e.category == not_found_error) {
xbt_ex_free(e);
THROWF(not_found_error, 0,
if (e.category == not_found_error) {
xbt_ex_free(e);
THROWF(not_found_error, 0,
- name = xbt_strdup(name);
- free(optionlist_cpy);
- THROWF(not_found_error, 0,
- "No registered variable corresponding to '%s'.", name);
+ TRY {
+ THROWF(not_found_error, 0,
+ "No registered variable corresponding to '%s'.", name);
+ }
+ TRY_CLEANUP {
+ /* name points into optionlist_cpy, it cannot be freed before */
+ free(optionlist_cpy);
+ }
+ CATCH_ANONYMOUS {
+ RETHROW;
+ }
variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_int);
if (variable->max == 1) {
variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_int);
if (variable->max == 1) {
- if (variable->cb_rm && xbt_dynar_length(variable->content))
- (*variable->cb_rm) (name, 0);
+ if (variable->cb_rm && !xbt_dynar_is_empty(variable->content))
+ variable->cb_rm(name, 0);
variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_double);
if (variable->max == 1) {
variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_double);
if (variable->max == 1) {
- if (variable->cb_rm && xbt_dynar_length(variable->content))
- (*variable->cb_rm) (name, 0);
+ if (variable->cb_rm && !xbt_dynar_is_empty(variable->content))
+ variable->cb_rm(name, 0);
variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_string);
XBT_DEBUG("Variable: %d to %d %s (=%d) @%p",
variable->min, variable->max,
variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_string);
XBT_DEBUG("Variable: %d to %d %s (=%d) @%p",
variable->min, variable->max,
else if (variable->type == xbt_cfgelm_string) {
char *sval = xbt_dynar_get_as(variable->content, 0, char *);
free(sval);
else if (variable->type == xbt_cfgelm_string) {
char *sval = xbt_dynar_get_as(variable->content, 0, char *);
free(sval);
variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_peer);
if (variable->max == 1) {
variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_peer);
if (variable->max == 1) {
- if (variable->cb_rm && xbt_dynar_length(variable->content))
- (*variable->cb_rm) (name, 0);
+ if (variable->cb_rm && !xbt_dynar_is_empty(variable->content))
+ variable->cb_rm(name, 0);
xbt_dynar_foreach(variable->content, cpt, seen) {
if (!strcpy(seen, val)) {
if (variable->cb_rm)
xbt_dynar_foreach(variable->content, cpt, seen) {
if (!strcpy(seen, val)) {
if (variable->cb_rm)
xbt_dynar_foreach(variable->content, cpt, seen) {
if (!strcpy(seen->name, peer) && seen->port == port) {
if (variable->cb_rm)
xbt_dynar_foreach(variable->content, cpt, seen) {
if (!strcpy(seen->name, peer) && seen->port == port) {
if (variable->cb_rm)
XBT_WARN
("You asked for the first value of the config element '%s', but there is %lu values\n",
name, xbt_dynar_length(variable->content));
XBT_WARN
("You asked for the first value of the config element '%s', but there is %lu values\n",
name, xbt_dynar_length(variable->content));
if (e.category == not_found_error) {
xbt_ex_free(e);
THROWF(not_found_error, 0,
if (e.category == not_found_error) {
xbt_ex_free(e);
THROWF(not_found_error, 0,