+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
This commit is contained in:
parent
3dd8fb8a55
commit
cbcd9c3718
|
@ -69,6 +69,34 @@ eina_str_join(char *dst, size_t size, char sep, const char *a, const char *b)
|
||||||
return eina_str_join_len(dst, size, sep, a, strlen(a), b, strlen(b));
|
return eina_str_join_len(dst, size, sep, a, strlen(a), b, strlen(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);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue