use taloc_zero() rather than talloc() and explisit memset()

This commit is contained in:
Harald Welte 2009-06-26 20:25:23 +02:00
parent c05677b036
commit 470ec29b0d
7 changed files with 10 additions and 19 deletions

View File

@ -2079,12 +2079,11 @@ static int bs11_read_swl_file(struct abis_nm_bs11_sw *bs11_sw)
if (rc < 2)
continue;
fle = talloc(tall_fle_ctx, struct file_list_entry);
fle = talloc_zero(tall_fle_ctx, struct file_list_entry);
if (!fle) {
rc = -ENOMEM;
goto out;
}
memset(fle, 0, sizeof(*fle));
/* construct new filename */
strncpy(dir, bs11_sw->swl_fname, sizeof(dir));

View File

@ -25,10 +25,9 @@ int e1_config(struct gsm_bts *bts, int cardnr, int release_l2)
struct e1inp_ts *sign_ts;
struct e1inp_sign_link *oml_link, *rsl_link;
line = talloc(tall_bsc_ctx, struct e1inp_line);
line = talloc_zero(tall_bsc_ctx, struct e1inp_line);
if (!line)
return -ENOMEM;
memset(line, 0, sizeof(*line));
/* create E1 timeslots for signalling and TRAU frames */
e1inp_ts_config(&line->ts[1-1], line, E1INP_TS_TYPE_SIGN);
@ -80,10 +79,9 @@ int ia_config_connect(struct gsm_bts *bts, struct sockaddr_in *sin)
struct e1inp_ts *sign_ts, *rsl_ts;
struct e1inp_sign_link *oml_link, *rsl_link;
line = talloc(tall_bsc_ctx, struct e1inp_line);
line = talloc_zero(tall_bsc_ctx, struct e1inp_line);
if (!line)
return -ENOMEM;
memset(line, 0, sizeof(*line));
/* create E1 timeslots for signalling and TRAU frames */
e1inp_ts_config(&line->ts[1-1], line, E1INP_TS_TYPE_SIGN);

View File

@ -373,12 +373,10 @@ e1inp_sign_link_create(struct e1inp_ts *ts, enum e1inp_sign_type type,
tall_sigl_ctx = talloc_named_const(tall_bsc_ctx, 1,
"e1inp_sign_link");
link = talloc(tall_sigl_ctx, struct e1inp_sign_link);
link = talloc_zero(tall_sigl_ctx, struct e1inp_sign_link);
if (!link)
return NULL;
memset(link, 0, sizeof(*link));
link->ts = ts;
link->type = type;
INIT_LLIST_HEAD(&link->tx_list);

View File

@ -354,9 +354,8 @@ static void allocate_loc_updating_req(struct gsm_lchan *lchan)
if (!tall_locop_ctx)
tall_locop_ctx = talloc_named_const(tall_bsc_ctx, 1,
"loc_updating_oper");
lchan->loc_operation = talloc(tall_locop_ctx,
struct gsm_loc_updating_operation);
memset(lchan->loc_operation, 0, sizeof(*lchan->loc_operation));
lchan->loc_operation = talloc_zero(tall_locop_ctx,
struct gsm_loc_updating_operation);
}
static int gsm0408_authorize(struct gsm_lchan *lchan, struct msgb *msg)

View File

@ -228,8 +228,7 @@ static void _paging_request(struct gsm_bts *bts, struct gsm_subscriber *subscr,
}
DEBUGP(DPAG, "Start paging on bts %d.\n", bts->nr);
req = talloc(tall_paging_ctx, struct gsm_paging_request);
memset(req, 0, sizeof(*req));
req = talloc_zero(tall_paging_ctx, struct gsm_paging_request);
req->subscr = subscr_get(subscr);
req->bts = bts;
req->chan_type = type;

View File

@ -291,12 +291,11 @@ int subchan_mux_enqueue(struct subch_mux *mx, int s_nr, const u_int8_t *data,
{
struct mux_subch *sch = &mx->subch[s_nr];
int list_len = llist_len(&sch->tx_queue);
struct subch_txq_entry *tqe = talloc_size(tall_tqe_ctx,
sizeof(*tqe) + len);
struct subch_txq_entry *tqe = talloc_zero_size(tall_tqe_ctx,
sizeof(*tqe) + len);
if (!tqe)
return -ENOMEM;
memset(tqe, 0, sizeof(*tqe));
tqe->bit_len = len;
memcpy(tqe->bits, data, len);

View File

@ -167,8 +167,7 @@ static int telnet_new_connection(struct bsc_fd *fd, unsigned int what) {
}
connection = talloc(tall_telnet_ctx, struct telnet_connection);
memset(connection, 0, sizeof(*connection));
connection = talloc_zero(tall_telnet_ctx, struct telnet_connection);
connection->network = (struct gsm_network*)fd->data;
connection->fd.data = connection;
connection->fd.fd = new_connection;