mirror of https://gerrit.osmocom.org/libosmocore
src/msgb.c: avoid using internal talloc API
An internal symbol '_talloc_zero' of talloc library was used during a msgb allocation. This is not actually good because: - it may be removed or modified by talloc developers; - the behaviour may be changed by talloc developers; - it's marked as internal using 'underscore'; - there is public API to do the same. So, let's use the public API. Change-Id: I1080c9071e997944cc0f9fc3716129e9395437ad
This commit is contained in:
parent
b42330516f
commit
10959cdea2
|
@ -79,14 +79,16 @@ struct msgb *msgb_alloc(uint16_t size, const char *name)
|
||||||
{
|
{
|
||||||
struct msgb *msg;
|
struct msgb *msg;
|
||||||
|
|
||||||
msg = _talloc_zero(tall_msgb_ctx, sizeof(*msg) + size, name);
|
msg = talloc_named_const(tall_msgb_ctx, sizeof(*msg) + size, name);
|
||||||
|
|
||||||
if (!msg) {
|
if (!msg) {
|
||||||
LOGP(DLGLOBAL, LOGL_FATAL, "Unable to allocate a msgb: "
|
LOGP(DLGLOBAL, LOGL_FATAL, "Unable to allocate a msgb: "
|
||||||
"name='%s', size=%u\n", name, size);
|
"name='%s', size=%u\n", name, size);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Manually zero-initialize allocated memory */
|
||||||
|
memset(msg, 0x00, sizeof(*msg) + size);
|
||||||
|
|
||||||
msg->data_len = size;
|
msg->data_len = size;
|
||||||
msg->len = 0;
|
msg->len = 0;
|
||||||
msg->data = msg->_data;
|
msg->data = msg->_data;
|
||||||
|
|
Loading…
Reference in New Issue