<div dir="auto"><div>4 lip 2017 14:25 "Robert Foss" <<a href="mailto:robert.foss@collabora.com" target="_blank">robert.foss@collabora.com</a>> napisał(a):<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="m_-8438463812721533739quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Add local strlcpy implementation.<br>
<br>
Signed-off-by: Robert Foss <<a href="mailto:robert.foss@collabora.com" target="_blank">robert.foss@collabora.com</a>><br>
---<br>
Changes since v3:<br>
Matt Turner <<a href="mailto:mattst88@gmail.com" target="_blank">mattst88@gmail.com</a>><br>
- Change name of util_strncpy to util_strlcpy<br>
<br>
Changes since v2:<br>
Brian Paul <<a href="mailto:brianp@vmware.com" target="_blank">brianp@vmware.com</a>><br>
- Patch added<br>
<br>
src/util/u_string.h | 9 +++++++++<br>
1 file changed, 9 insertions(+)<br>
<br>
diff --git a/src/util/u_string.h b/src/util/u_string.h<br>
index e88e13f42c..77014bc744 100644<br>
--- a/src/util/u_string.h<br>
+++ b/src/util/u_string.h<br>
@@ -48,6 +48,15 @@<br>
extern "C" {<br>
#endif<br>
<br>
+static inline char*<br>
+util_strlcpy(char *dst, const char *src, size_t n)<br>
+{<br>
+ strncpy(dst, src, n);<br>
+ dst[n-1] = '\0';<br>
+<br>
+ return dst;<br>
+}<br></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">The original strlcpy returns the amount of characters of the source string which can be used in order to know whether the truncation happened or not.</div><div dir="auto"><br></div><div dir="auto">It's probably unnecessary right know but might be useful in the future.</div><div dir="auto"><br></div><div dir="auto">Gustaw</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="m_-8438463812721533739quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
#ifdef _GNU_SOURCE<br>
<br>
#define util_strchrnul strchrnul<br>
<font color="#888888">--<br>
2.11.0<br>
<br>
</font></blockquote></div><br></div></div></div>