discomfitor pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=cbcd9c3718ead0a363fe4688aaba29735fb0e9b9

commit cbcd9c3718ead0a363fe4688aaba29735fb0e9b9
Author: Mike Blumenkrantz <[email protected]>
Date:   Tue Sep 23 16:15:34 2014 -0400

    +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
---
 src/lib/eina/eina_inline_str.x | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/src/lib/eina/eina_inline_str.x b/src/lib/eina/eina_inline_str.x
index 2daeb85..451f35f 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);
+}
+
+/**
  * @}
  */
 

-- 


Reply via email to