Change in libosmocore[master]: utils: introduce osmo_talloc_replace_string_fmt()

fixeria gerrit-no-reply at lists.osmocom.org
Mon Jun 7 14:39:34 UTC 2021


fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/24598 )


Change subject: utils: introduce osmo_talloc_replace_string_fmt()
......................................................................

utils: introduce osmo_talloc_replace_string_fmt()

Change-Id: I6b84fa0525555a98c531fc558e5dc1298fec00c1
---
M include/osmocom/core/utils.h
1 file changed, 17 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/98/24598/1

diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h
index c9d5560..45dc3f7 100644
--- a/include/osmocom/core/utils.h
+++ b/include/osmocom/core/utils.h
@@ -117,6 +117,23 @@
 	*dst = talloc_strdup(ctx, newstr);
 }
 
+static inline void osmo_talloc_replace_string_fmt(void *ctx, char **dst,
+						  const char *fmt, ...)
+{
+	char *name = NULL;
+
+	if (fmt != NULL) {
+		va_list ap;
+
+		va_start(ap, fmt);
+		name = talloc_vasprintf(ctx, fmt, ap);
+		va_end(ap);
+	}
+
+	talloc_free(*dst);
+	*dst = name;
+}
+
 /*! Append to a string and re-/allocate if necessary.
  * \param[in] ctx  Talloc context to use for initial allocation.
  * \param[in,out] dest  char* to re-/allocate and append to.

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I6b84fa0525555a98c531fc558e5dc1298fec00c1
Gerrit-Change-Number: 24598
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210607/62be3bc8/attachment.htm>


More information about the gerrit-log mailing list