#include "xbt/ex.h"
#include "xbt/dynar.h"
#include "xbt/dict.h"
+#include "xbt/host.h"
#include "xbt/config.h" /* prototypes of this module */
static void xbt_cfg_str_free(void *d){
free(*(void**)d);
}
-static void xbt_cfg_host_free(void *d){
- xbt_host_t h=(xbt_host_t) *(void**)d;
- if (h) {
- if (h->name) free(h->name);
- free(h);
- }
-}
/*----[ Memory management ]-----------------------------------------------*/
} CATCH(e) {
if (e.category == not_found_error) {
found = 1;
- xbt_ex_free(&e);
+ xbt_ex_free(e);
} else {
RETHROW;
}
break;
case xbt_cfgelm_host:
- res->content = xbt_dynar_new(sizeof(xbt_host_t),&xbt_cfg_host_free);
+ res->content = xbt_dynar_new(sizeof(xbt_host_t),&xbt_host_free_voidp);
break;
default:
res = xbt_dict_get((xbt_dict_t)cfg,name);
} CATCH(e) {
if (e.category == not_found_error) {
- xbt_ex_free(&e);
+ xbt_ex_free(e);
THROW1(not_found_error,0,
"No registered variable '%s' in this config set",name);
}
variable = xbt_dict_get((xbt_dict_t)cfg,name);
} CATCH(e) {
if (e.category == not_found_error) {
- xbt_ex_free(&e);
+ xbt_ex_free(e);
THROW1(not_found_error,0,
"Can't get the type of '%s' since this variable does not exist",name);
}
type = xbt_cfg_get_type(cfg,name);
} CATCH(e) {
if (e.category == not_found_error) {
- xbt_ex_free(&e);
+ xbt_ex_free(e);
THROW1(not_found_error,0,"Can't set the property '%s' since it's not registered",name);
}
RETHROW;
name = (char*) (optionlist_cpy-name + options);
free(optionlist_cpy);
if (e.category == not_found_error) {
- xbt_ex_free(&e);
+ xbt_ex_free(e);
THROW1(not_found_error,0,"No registrated variable corresponding to '%s'.",name);
}
RETHROW;
xbt_cfg_set_host(xbt_cfg_t cfg,const char*name,
const char *host,int port) {
xbt_cfgelm_t variable;
- xbt_host_t val=xbt_new(s_xbt_host_t,1);
+ xbt_host_t val=xbt_host_new(host,port);
VERB3("Configuration setting: %s=%s:%d",name,host,port);
- val->name = xbt_strdup(name);
- val->port = port;
-
variable = xbt_cfgelm_get(cfg,name,xbt_cfgelm_host);
if (variable->max == 1) {
if (e.category != not_found_error)
RETHROW;
- xbt_ex_free(&e);
+ xbt_ex_free(e);
THROW1(not_found_error,0,
"Can't empty '%s' since this config element does not exist", name);
}
variable = xbt_dict_get((xbt_dict_t)cfg,name);
} CATCH(e) {
if (e.category == not_found_error) {
- xbt_ex_free(&e);
+ xbt_ex_free(e);
THROW1(not_found_error,0,
"No registered variable %s in this config set",name);
}
if (e.category != mismatch_error ||
strncmp(e.msg,"Config elem speed needs",strlen("Config elem speed needs")))
xbt_test_fail1("Got an exception. msg=%s",e.msg);
- xbt_ex_free(&e);
+ xbt_ex_free(e);
}
xbt_cfg_free(&set);
xbt_cfg_free(&set);
strncmp(e.msg,"Cannot add value 34 to the config elem speed",
strlen("Config elem speed needs")))
xbt_test_fail1("Got an exception. msg=%s",e.msg);
- xbt_ex_free(&e);
+ xbt_ex_free(e);
}
xbt_cfg_check(set);
xbt_cfg_free(&set);
} CATCH(e) {
if (e.category != not_found_error)
xbt_test_exception(e);
- xbt_ex_free(&e);
+ xbt_ex_free(e);
}
xbt_cfg_free(&myset);
}