Skip to content

Commit

Permalink
libdeng: Added Str_Size() that returns size_t
Browse files Browse the repository at this point in the history
Str_Length() exists as before and returns a signed integer.
  • Loading branch information
skyjake committed Aug 24, 2012
1 parent 471ab62 commit bfeed3d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
17 changes: 16 additions & 1 deletion doomsday/libdeng/include/de/str.h
Expand Up @@ -212,10 +212,25 @@ DENG_PUBLIC Str* Str_Prepend(Str* ds, const char* prependText);
DENG_PUBLIC Str* Str_PrependChar(Str* ds, char ch);

/**
* This is safe for all strings.
* Determines the length of the string in characters.
* This is safe for all strings. @see Str_Size()
*
* @param ds String instance.
*
* @return Length of the string as an integer.
*/
DENG_PUBLIC int Str_Length(const Str* ds);

/**
* Determines the length of the string in characters.
* This is safe for all strings. @see Str_Length()
*
* @param ds String instance.
*
* @return Length of the string.
*/
DENG_PUBLIC size_t Str_Size(const Str* ds);

DENG_PUBLIC boolean Str_IsEmpty(const Str* ds);

/**
Expand Down
7 changes: 6 additions & 1 deletion doomsday/libdeng/src/str.c
Expand Up @@ -390,6 +390,11 @@ char* Str_Text(const ddstring_t* str)
}

int Str_Length(const ddstring_t* str)
{
return (int) Str_Size(str);
}

size_t Str_Size(const Str* str)
{
DENG_ASSERT(str);

Expand All @@ -398,7 +403,7 @@ int Str_Length(const ddstring_t* str)
{
return str->length;
}
return (int)strlen(Str_Text(str));
return strlen(Str_Text(str));
}

boolean Str_IsEmpty(const ddstring_t* str)
Expand Down

0 comments on commit bfeed3d

Please sign in to comment.