git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@5638
48e7efb5-ca39-0410-a469-
dd3cf9ba447f
static xbt_cfgelm_t xbt_cfgelm_get(xbt_cfg_t cfg, const char *name,
e_xbt_cfgelm_type_t type);
static xbt_cfgelm_t xbt_cfgelm_get(xbt_cfg_t cfg, const char *name,
e_xbt_cfgelm_type_t type);
-static void xbt_cfg_str_free(void *d){
- free(*(void**)d);
-}
-
/*----[ Memory management ]-----------------------------------------------*/
/** @brief Constructor
/*----[ Memory management ]-----------------------------------------------*/
/** @brief Constructor
xbt_cfgelm_t variable=NULL;
char *name=NULL;
xbt_cfgelm_t variable=NULL;
char *name=NULL;
+ DEBUG1("Copy cfg set %p",tocopy);
*whereto=NULL;
xbt_assert0(tocopy,"cannot copy NULL config");
*whereto=NULL;
xbt_assert0(tocopy,"cannot copy NULL config");
/** @brief Destructor */
void xbt_cfg_free(xbt_cfg_t *cfg) {
/** @brief Destructor */
void xbt_cfg_free(xbt_cfg_t *cfg) {
+ DEBUG1("Frees cfg set %p",cfg);
xbt_dict_free((xbt_dict_t*)cfg);
}
xbt_dict_free((xbt_dict_t*)cfg);
}
void xbt_cfgelm_free(void *data) {
xbt_cfgelm_t c=(xbt_cfgelm_t)data;
void xbt_cfgelm_free(void *data) {
xbt_cfgelm_t c=(xbt_cfgelm_t)data;
+ DEBUG1("Frees cfgelm %p",c);
if (!c) return;
xbt_dynar_free(&(c->content));
free(c);
if (!c) return;
xbt_dynar_free(&(c->content));
free(c);
int min, int max,
xbt_cfg_cb_t cb_set, xbt_cfg_cb_t cb_rm){
xbt_cfgelm_t res;
int min, int max,
xbt_cfg_cb_t cb_set, xbt_cfg_cb_t cb_rm){
xbt_cfgelm_t res;
- xbt_ex_t e;
- int found=0;
xbt_assert(cfg);
xbt_assert4(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);
xbt_assert(cfg);
xbt_assert4(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);
- DEBUG5("Register cfg elm %s (%d to %d %s (=%d))",
- name,min,max,xbt_cfgelm_type_name[type],type);
- TRY {
- res = xbt_dict_get((xbt_dict_t)cfg,name);
- } CATCH(e) {
- if (e.category == not_found_error) {
- found = 1;
- xbt_ex_free(e);
- } else {
- RETHROW;
- }
- }
+ res = xbt_dict_get_or_null((xbt_dict_t)cfg,name);
WARN1("Config elem %s registered twice.",name);
/* Will be removed by the insertion of the new one */
}
res=xbt_new(s_xbt_cfgelm_t,1);
WARN1("Config elem %s registered twice.",name);
/* Will be removed by the insertion of the new one */
}
res=xbt_new(s_xbt_cfgelm_t,1);
+ DEBUG7("Register cfg elm %s (%d to %d %s (=%d) @%p in set %p)",
+ name,min,max,xbt_cfgelm_type_name[type],type,res,cfg);
res->type=type;
res->min=min;
res->type=type;
res->min=min;
break;
case xbt_cfgelm_string:
break;
case xbt_cfgelm_string:
- res->content = xbt_dynar_new(sizeof(char*),xbt_cfg_str_free);
+ res->content = xbt_dynar_new(sizeof(char*),xbt_free_ref);
break;
case xbt_cfgelm_peer:
break;
case xbt_cfgelm_peer:
void
xbt_cfg_unregister(xbt_cfg_t cfg,const char *name) {
void
xbt_cfg_unregister(xbt_cfg_t cfg,const char *name) {
+ DEBUG2("Unregister elm '%s' from set %p",name,cfg);
xbt_dict_remove((xbt_dict_t)cfg,name);
}
xbt_dict_remove((xbt_dict_t)cfg,name);
}
int min,max;
e_xbt_cfgelm_type_t type;
int min,max;
e_xbt_cfgelm_type_t type;
+ DEBUG1("Register string '%s'",entry);
tok=strchr(entrycpy, ':');
xbt_assert2(tok,"Invalid config element descriptor: %s%s",
tok=strchr(entrycpy, ':');
xbt_assert2(tok,"Invalid config element descriptor: %s%s",
int size;
xbt_assert0(cfg,"NULL config set.");
int size;
xbt_assert0(cfg,"NULL config set.");
+ DEBUG1("Check cfg set %p",cfg);
xbt_dict_foreach((xbt_dict_t)cfg,cursor,name,variable) {
size = xbt_dynar_length(variable->content);
xbt_dict_foreach((xbt_dict_t)cfg,cursor,name,variable) {
size = xbt_dynar_length(variable->content);
const char *name,
e_xbt_cfgelm_type_t type){
xbt_cfgelm_t res=NULL;
const char *name,
e_xbt_cfgelm_type_t type){
xbt_cfgelm_t res=NULL;
- TRY {
- res = xbt_dict_get((xbt_dict_t)cfg,name);
- } CATCH(e) {
- if (e.category == not_found_error) {
- xbt_ex_free(e);
- THROW1(not_found_error,0,
- "No registered variable '%s' in this config set",name);
- }
- RETHROW;
- }
+ res = xbt_dict_get_or_null((xbt_dict_t)cfg,name);
+ if (!res)
+ THROW1(not_found_error,0,
+ "No registered variable '%s' in this config set",name);
xbt_assert3(type == xbt_cfgelm_any || res->type == type,
"You tried to access to the config element %s as an %s, but its type is %s.",
xbt_assert3(type == xbt_cfgelm_any || res->type == type,
"You tried to access to the config element %s as an %s, but its type is %s.",
xbt_cfg_get_type(xbt_cfg_t cfg, const char *name) {
xbt_cfgelm_t variable = NULL;
xbt_cfg_get_type(xbt_cfg_t cfg, const char *name) {
xbt_cfgelm_t variable = NULL;
- TRY {
- variable = xbt_dict_get((xbt_dict_t)cfg,name);
- } CATCH(e) {
- if (e.category == not_found_error) {
- xbt_ex_free(e);
- THROW1(not_found_error,0,
- "Can't get the type of '%s' since this variable does not exist",name);
- }
- RETHROW;
- }
+ variable = xbt_dict_get_or_null((xbt_dict_t)cfg,name);
+ if (!variable)
+ THROW1(not_found_error,0,
+ "Can't get the type of '%s' since this variable does not exist",name);
INFO1("type in variable = %d",variable->type);
INFO1("type in variable = %d",variable->type);
VERB2("Configuration setting: %s=%s",name,val);
variable = xbt_cfgelm_get(cfg,name,xbt_cfgelm_string);
VERB2("Configuration setting: %s=%s",name,val);
variable = xbt_cfgelm_get(cfg,name,xbt_cfgelm_string);
+ DEBUG5("Variable: %d to %d %s (=%d) @%p",
+ variable->min,variable->max,xbt_cfgelm_type_name[variable->type],variable->type,variable);
if (variable->max == 1) {
if (xbt_dynar_length(variable->content)) {
if (variable->max == 1) {
if (xbt_dynar_length(variable->content)) {