[PATCH] libosmocore[master]: src/msgb.c: avoid using internal talloc API

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Vadim Yanitskiy gerrit-no-reply at lists.osmocom.org
Thu Mar 8 19:39:38 UTC 2018


Review at  https://gerrit.osmocom.org/7165

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
---
M src/msgb.c
1 file changed, 4 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/65/7165/1

diff --git a/src/msgb.c b/src/msgb.c
index 1aecd57..2afe592 100644
--- a/src/msgb.c
+++ b/src/msgb.c
@@ -79,14 +79,16 @@
 {
 	struct msgb *msg;
 
-	msg = _talloc_zero(tall_msgb_ctx, sizeof(*msg) + size, name);
-
+	msg = talloc_zero_size(tall_msgb_ctx, sizeof(*msg) + size);
 	if (!msg) {
 		LOGP(DLGLOBAL, LOGL_FATAL, "Unable to allocate a msgb: "
 			"name='%s', size=%u\n", name, size);
 		return NULL;
 	}
 
+	/* Set msgb name */
+	talloc_set_name_const(msg, name);
+
 	msg->data_len = size;
 	msg->len = 0;
 	msg->data = msg->_data;

-- 
To view, visit https://gerrit.osmocom.org/7165
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1080c9071e997944cc0f9fc3716129e9395437ad
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>



More information about the gerrit-log mailing list