[misc] Use talloc_zero instead of talloc and later memset
This commit is contained in:
parent
3265b1a3a4
commit
e4533487d2
|
@ -104,13 +104,12 @@ const char *gsm_chreq_name(enum gsm_chreq_reason_t c)
|
|||
|
||||
struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts)
|
||||
{
|
||||
struct gsm_bts_trx *trx = talloc(bts, struct gsm_bts_trx);
|
||||
struct gsm_bts_trx *trx = talloc_zero(bts, struct gsm_bts_trx);
|
||||
int k;
|
||||
|
||||
if (!trx)
|
||||
return NULL;
|
||||
|
||||
memset(trx, 0, sizeof(*trx));
|
||||
trx->bts = bts;
|
||||
trx->nr = bts->num_trx++;
|
||||
|
||||
|
@ -140,13 +139,12 @@ struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts)
|
|||
struct gsm_bts *gsm_bts_alloc(struct gsm_network *net, enum gsm_bts_type type,
|
||||
u_int8_t tsc, u_int8_t bsic)
|
||||
{
|
||||
struct gsm_bts *bts = talloc(net, struct gsm_bts);
|
||||
struct gsm_bts *bts = talloc_zero(net, struct gsm_bts);
|
||||
int i;
|
||||
|
||||
if (!bts)
|
||||
return NULL;
|
||||
|
||||
memset(bts, 0, sizeof(*bts));
|
||||
bts->network = net;
|
||||
bts->nr = net->num_bts++;
|
||||
bts->type = type;
|
||||
|
@ -179,10 +177,9 @@ struct gsm_network *gsm_network_init(u_int16_t country_code, u_int16_t network_c
|
|||
{
|
||||
struct gsm_network *net;
|
||||
|
||||
net = talloc(tall_bsc_ctx, struct gsm_network);
|
||||
net = talloc_zero(tall_bsc_ctx, struct gsm_network);
|
||||
if (!net)
|
||||
return NULL;
|
||||
memset(net, 0, sizeof(*net));
|
||||
|
||||
net->country_code = country_code;
|
||||
net->network_code = network_code;
|
||||
|
|
|
@ -115,11 +115,10 @@ struct gsm_subscriber *subscr_alloc(void)
|
|||
{
|
||||
struct gsm_subscriber *s;
|
||||
|
||||
s = talloc(tall_subscr_ctx, struct gsm_subscriber);
|
||||
s = talloc_zero(tall_subscr_ctx, struct gsm_subscriber);
|
||||
if (!s)
|
||||
return NULL;
|
||||
|
||||
memset(s, 0, sizeof(*s));
|
||||
llist_add_tail(&s->entry, &active_subscribers);
|
||||
s->use_count = 1;
|
||||
s->tmsi = GSM_RESERVED_TMSI;
|
||||
|
|
|
@ -494,12 +494,11 @@ static int listen_fd_cb(struct bsc_fd *listen_bfd, unsigned int what)
|
|||
}
|
||||
DEBUGP(DINP, "accept()ed new OML link from %s\n", inet_ntoa(sa.sin_addr));
|
||||
|
||||
line = talloc(tall_bsc_ctx, struct e1inp_line);
|
||||
line = talloc_zero(tall_bsc_ctx, struct e1inp_line);
|
||||
if (!line) {
|
||||
close(ret);
|
||||
return -ENOMEM;
|
||||
}
|
||||
memset(line, 0, sizeof(*line));
|
||||
line->driver = &ipaccess_driver;
|
||||
//line->driver_data = e1h;
|
||||
/* create virrtual E1 timeslots for signalling */
|
||||
|
@ -538,10 +537,9 @@ static int rsl_listen_fd_cb(struct bsc_fd *listen_bfd, unsigned int what)
|
|||
if (!(what & BSC_FD_READ))
|
||||
return 0;
|
||||
|
||||
bfd = talloc(tall_bsc_ctx, struct bsc_fd);
|
||||
bfd = talloc_zero(tall_bsc_ctx, struct bsc_fd);
|
||||
if (!bfd)
|
||||
return -ENOMEM;
|
||||
memset(bfd, 0, sizeof(*bfd));
|
||||
|
||||
/* Some BTS has connected to us, but we don't know yet which line
|
||||
* (as created by the OML link) to associate it with. Thus, we
|
||||
|
@ -652,10 +650,9 @@ int ipaccess_setup(struct gsm_network *gsmnet)
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
e1h = talloc(tall_bsc_ctx, struct ia_e1_handle);
|
||||
e1h = talloc_zero(tall_bsc_ctx, struct ia_e1_handle);
|
||||
if (!e1h)
|
||||
return -ENOMEM;
|
||||
memset(e1h, 0, sizeof(*e1h));
|
||||
|
||||
e1h->gsmnet = gsmnet;
|
||||
|
||||
|
|
Loading…
Reference in New Issue