/* Get rid of deleted bridges and add new bridges. */
svec_sort(&old_br);
@@ -793,7 +780,7 @@ bridge_create(const char *name)
- br = xcalloc(1, sizeof *br);
+ br = xzalloc(sizeof *br);
error = dpif_create(name, &br->dpif);
- if (error == EEXIST) {
{
if (!*msgp) {
/* Allocate and initialize message. */
- *msgp = xcalloc(1, sizeof **msgp);
+ *msgp = xzalloc(sizeof **msgp);
(*msgp)->index = n_messages;
/* Add to list of messages. */
return error;
}
- cli = xcalloc(1, sizeof *cli);
+ cli = xzalloc(sizeof *cli);
cli->modify_request = modify_request;
cli->validate_offer = validate_offer;
cli->aux = aux;
}
/* Create datapath. */
- dp_netdevs[dp_idx] = dp = xcalloc(1, sizeof *dp);
+ dp_netdevs[dp_idx] = dp = xzalloc(sizeof *dp);
list_push_back(&dp_netdev_list, &dp->node);
dp->dp_idx = dp_idx;
dp->open_cnt = 0;
struct dp_netdev_flow *flow;
int error;
- flow = xcalloc(1, sizeof *flow);
+ flow = xzalloc(sizeof *flow);
flow->key = odp_flow->key;
flow->key.reserved = 0;
struct lswitch *sw;
size_t i;
- sw = xcalloc(1, sizeof *sw);
+ sw = xzalloc(sizeof *sw);
sw->max_idle = max_idle;
sw->datapath_id = 0;
sw->last_features_request = time_now() - 1;
int error;
/* Allocate network device. */
- netdev = xcalloc(1, sizeof *netdev);
+ netdev = xzalloc(sizeof *netdev);
netdev_init(&netdev->netdev, suffix, &netdev_linux_class);
netdev->netdev_fd = -1;
netdev->tap_fd = -1;
static struct poll_waiter *
new_waiter(int fd, short int events)
{
- struct poll_waiter *waiter = xcalloc(1, sizeof *waiter);
+ struct poll_waiter *waiter = xzalloc(sizeof *waiter);
assert(fd >= 0);
waiter->fd = fd;
waiter->events = events;
assert(sigchld_is_blocked());
- p = xcalloc(1, sizeof *p);
+ p = xzalloc(sizeof *p);
p->pid = pid;
slash = strrchr(name, '/');
p->name = xstrdup(slash ? slash + 1 : name);
struct rconn *
rconn_create(int probe_interval, int max_backoff)
{
- struct rconn *rc = xcalloc(1, sizeof *rc);
+ struct rconn *rc = xzalloc(sizeof *rc);
rc->state = S_VOID;
rc->state_entered = time_now();
struct stp *stp;
struct stp_port *p;
- stp = xcalloc(1, sizeof *stp);
+ stp = xzalloc(sizeof *stp);
stp->name = xstrdup(name);
stp->bridge_id = bridge_id;
if (!(stp->bridge_id >> 48)) {
return p;
}
+void *
+xzalloc(size_t size)
+{
+ return xcalloc(1, size);
+}
+
void *
xmalloc(size_t size)
{
void out_of_memory(void) NO_RETURN;
void *xmalloc(size_t) MALLOC_LIKE;
void *xcalloc(size_t, size_t) MALLOC_LIKE;
+void *xzalloc(size_t) MALLOC_LIKE;
void *xrealloc(void *, size_t);
void *xmemdup(const void *, size_t) MALLOC_LIKE;
char *xmemdup0(const char *, size_t) MALLOC_LIKE;
char local_name[IF_NAMESIZE];
int error;
- d = xcalloc(1, sizeof *d);
+ d = xzalloc(sizeof *d);
/* Controller regular expression. */
error = discovery_set_accept_controller_re(d, re);
return errno;
}
- e = xcalloc(1, sizeof *e);
+ e = xzalloc(sizeof *e);
e->command_acl = xstrdup(command_acl);
e->command_dir = (command_dir
? xstrdup(command_dir)
return error;
}
- in_band = xcalloc(1, sizeof *in_band);
+ in_band = xzalloc(sizeof *in_band);
in_band->ofproto = ofproto;
in_band->controller = controller;
in_band->ss_cat = switch_status_register(ss, "in-band",
dpif_recv_purge(dpif);
/* Initialize settings. */
- p = xcalloc(1, sizeof *p);
+ p = xzalloc(sizeof *p);
p->fallback_dpid = pick_fallback_dpid();
p->datapath_id = p->fallback_dpid;
p->manufacturer = xstrdup("Nicira Networks, Inc.");
const union ofp_action *actions, size_t n_actions,
uint16_t idle_timeout, uint16_t hard_timeout)
{
- struct rule *rule = xcalloc(1, sizeof *rule);
+ struct rule *rule = xzalloc(sizeof *rule);
rule->idle_timeout = idle_timeout;
rule->hard_timeout = hard_timeout;
rule->used = rule->created = time_msec();
byte_count = rule->byte_count;
n_odp_flows = rule->cr.wc.wildcards ? list_size(&rule->list) : 1;
- odp_flows = xcalloc(1, n_odp_flows * sizeof *odp_flows);
+ odp_flows = xzalloc(n_odp_flows * sizeof *odp_flows);
if (rule->cr.wc.wildcards) {
size_t i = 0;
LIST_FOR_EACH (subrule, struct rule, list, &rule->list) {
{
struct pinsched *ps;
- ps = xcalloc(1, sizeof *ps);
+ ps = xzalloc(sizeof *ps);
port_array_init(&ps->queues);
ps->n_queued = 0;
ps->last_tx_port = PORT_ARRAY_SIZE;
struct pktbuf *
pktbuf_create(void)
{
- return xcalloc(1, sizeof *pktbuf_create());
+ return xzalloc(sizeof *pktbuf_create());
}
void
struct switch_status *
switch_status_create(const struct ofproto *ofproto)
{
- struct switch_status *ss = xcalloc(1, sizeof *ss);
+ struct switch_status *ss = xzalloc(sizeof *ss);
ss->booted = time_now();
list_init(&ss->categories);
ss->config_cat = switch_status_register(ss, "config", config_status_cb,
}
}
- rule = xcalloc(1, sizeof *rule);
+ rule = xzalloc(sizeof *rule);
cls_rule_from_flow(&rule->cls_rule, &flow, wildcards,
!wildcards ? UINT_MAX : priority);
return rule;
int error;
assert(!bridge_lookup(name));
- br = xcalloc(1, sizeof *br);
+ br = xzalloc(sizeof *br);
error = dpif_create(name, &br->dpif);
if (error == EEXIST || error == EBUSY) {
{
struct port *port;
- port = xcalloc(1, sizeof *port);
+ port = xzalloc(sizeof *port);
port->bridge = br;
port->port_idx = br->n_ports;
port->vlan = -1;
{
struct iface *iface;
- iface = xcalloc(1, sizeof *iface);
+ iface = xzalloc(sizeof *iface);
iface->port = port;
iface->port_ifidx = port->n_ifaces;
iface->name = xstrdup(name);
VLOG_INFO("created port mirror %s on bridge %s", name, br->name);
bridge_flush(br);
- br->mirrors[i] = m = xcalloc(1, sizeof *m);
+ br->mirrors[i] = m = xzalloc(sizeof *m);
m->bridge = br;
m->idx = i;
m->name = xstrdup(name);
}
if (!vlan) {
/* Create a new compat_vlan for (trunk_dev,vid). */
- vlan = xcalloc(1, sizeof *vlan);
+ vlan = xzalloc(sizeof *vlan);
vlan->trunk_dev = xstrdup(trunk_dev);
vlan->vid = vid;
vlan->vlan_dev = xasprintf("%s.%d", trunk_dev, vid);