<p>fixeria has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/libosmocore/+/24598">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">utils: introduce osmo_talloc_replace_string_fmt()<br><br>Change-Id: I6b84fa0525555a98c531fc558e5dc1298fec00c1<br>---<br>M include/osmocom/core/utils.h<br>1 file changed, 17 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/98/24598/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h</span><br><span>index c9d5560..45dc3f7 100644</span><br><span>--- a/include/osmocom/core/utils.h</span><br><span>+++ b/include/osmocom/core/utils.h</span><br><span>@@ -117,6 +117,23 @@</span><br><span>        *dst = talloc_strdup(ctx, newstr);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+static inline void osmo_talloc_replace_string_fmt(void *ctx, char **dst,</span><br><span style="color: hsl(120, 100%, 40%);">+                                           const char *fmt, ...)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+    char *name = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  if (fmt != NULL) {</span><br><span style="color: hsl(120, 100%, 40%);">+            va_list ap;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+         va_start(ap, fmt);</span><br><span style="color: hsl(120, 100%, 40%);">+            name = talloc_vasprintf(ctx, fmt, ap);</span><br><span style="color: hsl(120, 100%, 40%);">+                va_end(ap);</span><br><span style="color: hsl(120, 100%, 40%);">+   }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   talloc_free(*dst);</span><br><span style="color: hsl(120, 100%, 40%);">+    *dst = name;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /*! Append to a string and re-/allocate if necessary.</span><br><span>  * \param[in] ctx  Talloc context to use for initial allocation.</span><br><span>  * \param[in,out] dest  char* to re-/allocate and append to.</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmocore/+/24598">change 24598</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/libosmocore/+/24598"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I6b84fa0525555a98c531fc558e5dc1298fec00c1 </div>
<div style="display:none"> Gerrit-Change-Number: 24598 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>