Change in libosmocore[master]: signal: Introduce API osmo_signal_talloc_ctx_init

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/.

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Thu Aug 16 17:08:13 UTC 2018


Pau Espin Pedrol has uploaded this change for review. ( https://gerrit.osmocom.org/10481


Change subject: signal: Introduce API osmo_signal_talloc_ctx_init
......................................................................

signal: Introduce API osmo_signal_talloc_ctx_init

Otherwise applications need to use "extern void* tall_sigh_ctx" and set
it manually (that symbol is not exported in any header file) or end up
allocating struct signal_handler into the NULL talloc ctx.

API created in a similar way as already existing msgb_talloc_ctx_init(),
but without the pool_size because it's not considered necessary in this
case.

Change-Id: Id58ca18eb826b8f4183a7cf0dbb2b38cba702a09
---
M include/osmocom/core/signal.h
M src/signal.c
2 files changed, 11 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/81/10481/1

diff --git a/include/osmocom/core/signal.h b/include/osmocom/core/signal.h
index ae78f15..449b976 100644
--- a/include/osmocom/core/signal.h
+++ b/include/osmocom/core/signal.h
@@ -34,6 +34,7 @@
 
 
 /* Management */
+void *osmo_signal_talloc_ctx_init(void *root_ctx);
 int osmo_signal_register_handler(unsigned int subsys, osmo_signal_cbfn *cbfn, void *data);
 void osmo_signal_unregister_handler(unsigned int subsys, osmo_signal_cbfn *cbfn, void *data);
 
diff --git a/src/signal.c b/src/signal.c
index 745d7c3..1212afe 100644
--- a/src/signal.c
+++ b/src/signal.c
@@ -46,6 +46,16 @@
 	void *data;
 };
 
+/*! Initialize a signal_handler talloc context for \ref osmo_signal_register_handler.
+ * Create a talloc context called "osmo_signal".
+ *  \param[in] root_ctx talloc context used as parent for the new "osmo_signal" ctx.
+ *  \returns the new osmo_signal talloc context, e.g. for reporting
+ */
+void *osmo_signal_talloc_ctx_init(void *root_ctx) {
+	tall_sigh_ctx = talloc_size(root_ctx, 0);
+	talloc_set_name_const(tall_sigh_ctx, "osmo_signal");
+	return tall_sigh_ctx;
+}
 
 /*! Register a new signal handler
  *  \param[in] subsys Subsystem number

-- 
To view, visit https://gerrit.osmocom.org/10481
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id58ca18eb826b8f4183a7cf0dbb2b38cba702a09
Gerrit-Change-Number: 10481
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180816/8fa41916/attachment.htm>


More information about the gerrit-log mailing list