A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Enable timestamping of messages emitted out of any user process (such as the terminai...
[simgrid.git]
/
src
/
xbt
/
config.c
diff --git
a/src/xbt/config.c
b/src/xbt/config.c
index
0dadc2f
..
1ab5aec
100644
(file)
--- a/
src/xbt/config.c
+++ b/
src/xbt/config.c
@@
-15,6
+15,7
@@
#include "xbt/ex.h"
#include "xbt/dynar.h"
#include "xbt/dict.h"
#include "xbt/ex.h"
#include "xbt/dynar.h"
#include "xbt/dict.h"
+#include "xbt/host.h"
#include "xbt/config.h" /* prototypes of this module */
#include "xbt/config.h" /* prototypes of this module */
@@
-52,13
+53,6
@@
static xbt_cfgelm_t xbt_cfgelm_get(xbt_cfg_t cfg, const char *name,
static void xbt_cfg_str_free(void *d){
free(*(void**)d);
}
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 ]-----------------------------------------------*/
/*----[ Memory management ]-----------------------------------------------*/
@@
-116,7
+110,7
@@
void xbt_cfg_dump(const char *name,const char *indent,xbt_cfg_t cfg) {
int ival;
char *sval;
double dval;
int ival;
char *sval;
double dval;
- xbt_host_t
*
hval;
+ xbt_host_t hval;
if (name)
printf("%s>> Dumping of the config set '%s':\n",indent,name);
if (name)
printf("%s>> Dumping of the config set '%s':\n",indent,name);
@@
-155,7
+149,7
@@
void xbt_cfg_dump(const char *name,const char *indent,xbt_cfg_t cfg) {
case xbt_cfgelm_host:
for (i=0; i<size; i++) {
case xbt_cfgelm_host:
for (i=0; i<size; i++) {
- hval = xbt_dynar_get_as(variable->content,i,xbt_host_t
*
);
+ hval = xbt_dynar_get_as(variable->content,i,xbt_host_t);
printf ("%s %s:%d\n",indent,hval->name,hval->port);
}
break;
printf ("%s %s:%d\n",indent,hval->name,hval->port);
}
break;
@@
-248,7
+242,7
@@
xbt_cfg_register(xbt_cfg_t cfg,
break;
case xbt_cfgelm_host:
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:
break;
default:
@@
-760,13
+754,10
@@
void
xbt_cfg_set_host(xbt_cfg_t cfg,const char*name,
const char *host,int port) {
xbt_cfgelm_t variable;
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(xbt_host_t,1
);
+ xbt_host_t
val=xbt_host_new(host,port
);
VERB3("Configuration setting: %s=%s:%d",name,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) {
variable = xbt_cfgelm_get(cfg,name,xbt_cfgelm_host);
if (variable->max == 1) {
@@
-895,7
+886,7
@@
void
xbt_cfg_rm_host(xbt_cfg_t cfg,const char*name, const char *host,int port) {
xbt_cfgelm_t variable;
int cpt;
xbt_cfg_rm_host(xbt_cfg_t cfg,const char*name, const char *host,int port) {
xbt_cfgelm_t variable;
int cpt;
- xbt_host_t
*
seen;
+ xbt_host_t seen;
variable = xbt_cfgelm_get(cfg,name,xbt_cfgelm_host);
variable = xbt_cfgelm_get(cfg,name,xbt_cfgelm_host);
@@
-1060,7
+1051,7
@@
char* xbt_cfg_get_string(xbt_cfg_t cfg, const char *name) {
void xbt_cfg_get_host (xbt_cfg_t cfg, const char *name,
char **host, int *port) {
xbt_cfgelm_t variable;
void xbt_cfg_get_host (xbt_cfg_t cfg, const char *name,
char **host, int *port) {
xbt_cfgelm_t variable;
- xbt_host_t
*
val;
+ xbt_host_t val;
variable = xbt_cfgelm_get(cfg,name,xbt_cfgelm_host);
variable = xbt_cfgelm_get(cfg,name,xbt_cfgelm_host);
@@
-1069,7
+1060,7
@@
void xbt_cfg_get_host (xbt_cfg_t cfg, const char *name,
name, xbt_dynar_length(variable->content));
}
name, xbt_dynar_length(variable->content));
}
- val = xbt_dynar_get_as(variable->content, 0, xbt_host_t
*
);
+ val = xbt_dynar_get_as(variable->content, 0, xbt_host_t);
*host=val->name;
*port=val->port;
}
*host=val->name;
*port=val->port;
}
@@
-1134,7
+1125,7
@@
xbt_cfg_get_host_at(xbt_cfg_t cfg, const char *name, int pos,
char **host, int *port) {
xbt_cfgelm_t variable = xbt_cfgelm_get(cfg,name,xbt_cfgelm_int);
char **host, int *port) {
xbt_cfgelm_t variable = xbt_cfgelm_get(cfg,name,xbt_cfgelm_int);
- xbt_host_t
*
val = xbt_dynar_get_ptr(variable->content, pos);
+ xbt_host_t val = xbt_dynar_get_ptr(variable->content, pos);
*port = val->port;
*host = val->name;
*port = val->port;
*host = val->name;
@@
-1249,11
+1240,12
@@
XBT_TEST_UNIT("use",test_config_use,"Data retrieving tests") {
{
/* non-existant_entry */
xbt_cfg_t myset=make_set();
{
/* non-existant_entry */
xbt_cfg_t myset=make_set();
+ xbt_ex_t e;
TRY {
xbt_cfg_set_parse(myset, "color:blue");
} CATCH(e) {
TRY {
xbt_cfg_set_parse(myset, "color:blue");
} CATCH(e) {
- if (e.category !=
mismatch
_error)
+ if (e.category !=
not_found
_error)
xbt_test_exception(e);
xbt_ex_free(e);
}
xbt_test_exception(e);
xbt_ex_free(e);
}