Add _c versions of functions that otherwise return static buffers

We have a habit of returning static buffers from some functions,
particularly when generating some kind of string values.  This is
convenient in terms of memory management, but it comes at the expense
of not being thread-safe, and not allowing for two calls of the
related function within one printf() statement.

Let's introduce _c suffix versions of those functions where the
caller passes in a talloc context from which the output buffer shall
be allocated.

Change-Id: I8481c19b68ff67cfa22abb93c405ebcfcb0ab19b
diff --git a/src/gsm/rsl.c b/src/gsm/rsl.c
index 7bc6002..1777479 100644
--- a/src/gsm/rsl.c
+++ b/src/gsm/rsl.c
@@ -258,6 +258,19 @@
 	return rsl_chan_nr_str_buf(str, sizeof(str), chan_nr);
 }
 
+/*! Get human-readable string for RSL channel number, in dynamically-allocated buffer.
+ *  \param[in] ctx talloc context from which to allocate output buffer
+ *  \param[in] chan_nr channel number to be stringified
+ *  \returns dynamically-allocated buffer with string representation
+ */
+char *rsl_chan_nr_str_c(const void *ctx, uint8_t chan_nr)
+{
+	char *str = talloc_size(ctx, 20);
+	if (!str)
+		return NULL;
+	return rsl_chan_nr_str_buf(str, 20, chan_nr);
+}
+
 static const struct value_string rsl_err_vals[] = {
 	{ RSL_ERR_RADIO_IF_FAIL,	"Radio Interface Failure" },
 	{ RSL_ERR_RADIO_LINK_FAIL,	"Radio Link Failure" },