Example #1
0
/**
 * @brief Note that the given string @b must be shared.
 *
 * @param str the shared string to know the length. It is safe to
 *        give NULL, in that case -1 is returned.
 *
 * This function is a cheap way to known the length of a shared
 * string. Note that if the given pointer is not shared, bad
 * things will happen, likely a segmentation fault. If in doubt, try
 * strlen().
 */
EAPI int eina_ustringshare_strlen(const Eina_Unicode * str)
{
	int len =
	    eina_share_common_length(ustringshare_share,
				     (const char *) str);
	len = (len > 0) ? len / (int) sizeof(Eina_Unicode) : -1;
	return len;
}
Example #2
0
/**
 * @brief Note that the given string @b must be shared.
 *
 * @param str the shared string to know the length. It is safe to
 *        give NULL, in that case -1 is returned.
 *
 * This function is a cheap way to known the length of a shared
 * string. Note that if the given pointer is not shared, bad
 * things will happen, likely a segmentation fault. If in doubt, try
 * strlen().
 */
EAPI int
eina_stringshare_strlen(const char *str)
{
   int len;
   /* special cases */
   if (str[0] == '\0')
      return 0;

   if (str[1] == '\0')
      return 1;

   if (str[2] == '\0')
      return 2;

   if (str[3] == '\0')
      return 3;

   len = eina_share_common_length(stringshare_share, (const char *)str);
   len = (len > 0) ? len / (int)sizeof(char) : -1;
   return len;
}