mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
some cleanups and changes for memory allocation (more valgrind tests to come..)
git-svn-id: https://zerberus.eonerc.rwth-aachen.de:8443/svn/s2ss/trunk@268 8ec27952-4edc-4aab-86aa-e87bb2611832
This commit is contained in:
parent
6cdcdc0239
commit
4514c38f59
5 changed files with 16 additions and 11 deletions
|
@ -37,7 +37,7 @@ struct hist {
|
|||
/** The number of values which are lower than #low. */
|
||||
hist_cnt_t lower;
|
||||
|
||||
/** Pointer to dynamically allocated array of bucket counters. */
|
||||
/** Pointer to dynamically allocated array of size length. */
|
||||
hist_cnt_t *data;
|
||||
};
|
||||
|
||||
|
|
|
@ -100,8 +100,8 @@ int config_parse_path(config_setting_t *cfg,
|
|||
struct path *p = (struct path *) malloc(sizeof(struct path));
|
||||
if (!p)
|
||||
error("Failed to allocate memory for path");
|
||||
else
|
||||
memset(p, 0, sizeof(struct path));
|
||||
|
||||
memset(p, 0, sizeof(struct path));
|
||||
|
||||
/* Required settings */
|
||||
if (!config_setting_lookup_string(cfg, "in", &in))
|
||||
|
@ -142,8 +142,8 @@ int config_parse_path(config_setting_t *cfg,
|
|||
struct path *rev = (struct path *) malloc(sizeof(struct path));
|
||||
if (!rev)
|
||||
error("Failed to allocate memory for path");
|
||||
else
|
||||
memcpy(rev, p, sizeof(struct path));
|
||||
|
||||
memcpy(rev, p, sizeof(struct path));
|
||||
|
||||
rev->in = p->out; /* Swap in/out */
|
||||
rev->out = p->in;
|
||||
|
@ -171,8 +171,8 @@ int config_parse_node(config_setting_t *cfg, struct node **nodes)
|
|||
struct node *n = (struct node *) malloc(sizeof(struct node));
|
||||
if (!n)
|
||||
error("Failed to allocate memory for node");
|
||||
else
|
||||
memset(n, 0, sizeof(struct node));
|
||||
|
||||
memset(n, 0, sizeof(struct node));
|
||||
|
||||
/* Required settings */
|
||||
n->cfg = cfg;
|
||||
|
@ -214,7 +214,7 @@ int config_parse_socket(config_setting_t *cfg, struct node *n)
|
|||
|
||||
struct socket *s = (struct socket *) malloc(sizeof(struct socket));
|
||||
if (!s)
|
||||
serror("Failed to allocate memory");
|
||||
serror("Failed to allocate memory for socket");
|
||||
|
||||
memset(s, 0, sizeof(struct socket));
|
||||
|
||||
|
@ -238,6 +238,11 @@ int config_parse_socket(config_setting_t *cfg, struct node *n)
|
|||
config_setting_t *cfg_netem = config_setting_get_member(cfg, "netem");
|
||||
if (cfg_netem) {
|
||||
s->netem = (struct netem *) malloc(sizeof(struct netem));
|
||||
if (!s->netem)
|
||||
error("Failed to allocate memory for netem");
|
||||
|
||||
memset(s->netem, 0, sizeof(struct netem));
|
||||
|
||||
config_parse_netem(cfg_netem, s->netem);
|
||||
}
|
||||
|
||||
|
|
|
@ -134,7 +134,6 @@ int main(int argc, char *argv[])
|
|||
/* Parse configuration and create nodes/paths */
|
||||
config_parse(argv[1], &config, &settings, &nodes, &paths);
|
||||
|
||||
|
||||
/* Connect all nodes and start one thread per path */
|
||||
info("Starting nodes:");
|
||||
for (struct node *n = nodes; n; n = n->next) { INDENT
|
||||
|
|
|
@ -130,7 +130,7 @@ int socket_close(struct node *n)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int socket_read(struct node* n, struct msg *m)
|
||||
int socket_read(struct node *n, struct msg *m)
|
||||
{
|
||||
/* Receive message from socket */
|
||||
int ret = recv(n->socket->sd, m, sizeof(struct msg), 0);
|
||||
|
@ -152,7 +152,7 @@ int socket_read(struct node* n, struct msg *m)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int socket_write(struct node* n, struct msg *m)
|
||||
int socket_write(struct node *n, struct msg *m)
|
||||
{
|
||||
struct socket *s = n->socket;
|
||||
int ret;
|
||||
|
|
|
@ -122,6 +122,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
node_stop(node);
|
||||
config_destroy(&config);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue