summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2014-09-23 16:15:34 -0400
committerMike Blumenkrantz <zmike@osg.samsung.com>2014-09-23 16:15:34 -0400
commitcbcd9c3718ead0a363fe4688aaba29735fb0e9b9 (patch)
tree93f21acd4cec6505e33d1496be5baa60be8780b2 /src
parent3dd8fb8a5517fe9061148846c44cd9044c726b39 (diff)
downloadefl-cbcd9c3718ead0a363fe4688aaba29735fb0e9b9.tar.gz
+eina_strdup(), eina_streq()
there are macros/inlines for these in most efl projects I've seen, may as well have them standardized here @feature
Diffstat (limited to 'src')
-rw-r--r--src/lib/eina/eina_inline_str.x28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/lib/eina/eina_inline_str.x b/src/lib/eina/eina_inline_str.x
index 2daeb8524c..451f35fc11 100644
--- a/src/lib/eina/eina_inline_str.x
+++ b/src/lib/eina/eina_inline_str.x
@@ -70,6 +70,34 @@ eina_str_join(char *dst, size_t size, char sep, const char *a, const char *b)
}
/**
+ * @brief strdup function which takes @c NULL without crashing
+ * @param str The string to copy
+ * @return the copied string, must be freed
+ * @since 1.12
+ */
+static inline char *
+eina_strdup(const char *str)
+{
+ return str ? strdup(str) : NULL;
+}
+
+/**
+ * @brief streq function which takes @c NULL without crashing
+ * @param a string a
+ * @param b string b
+ * @return true if strings are equal
+ * @since 1.12
+ */
+static inline Eina_Bool
+eina_streq(const char *a, const char *b)
+{
+ if ((!a) && (!b)) return EINA_TRUE;
+ if (!a) return EINA_FALSE;
+ if (!b) return EINA_FALSE;
+ return !strcmp(a, b);
+}
+
+/**
* @}
*/