Thread (132 messages) 132 messages, 13 authors, 2021-04-29

Re: [dpdk-dev] [PATCH v3 1/7] eal: add wrappers for POSIX string functions

From: Andrew Rybchenko <hidden>
Date: 2021-02-23 07:11:15

On 2/21/21 5:28 PM, Dmitry Kozlyuk wrote:
POSIX strncasecmp(), strdup(), and strtok_r() have different names
on Windows, respectively, strnicmp(), _strdup(), and strtok_s().

Add wrappers as inline functions, because they're used from librte_kvargs,
and thus cannot be in librte_eal; besides, implementation is trivial.

Signed-off-by: Dmitry Kozlyuk <redacted>
[snip]
+/**
+ * @internal
+ * strdup(3) replacement for systems that don't have it.
+ */
+static inline char *
+rte_strdup(const char *str)
+{
+#ifdef RTE_EXEC_ENV_WINDOWS
+	return _strdup(str);
+#else
+	return strdup(str);
+#endif
+}
Allocating memory using rte_strdup() I'd use rte_free()
to release it. I guess it will fail badly.
So, I think that a different, more specific prefix is
required for POSIX wrappers.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help