aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-09-21 22:44:47 +0200
committerMax Kellermann <max@duempel.org>2008-09-21 22:44:47 +0200
commit8beeb6e1d2311a3593a3df0273b778011068e81b (patch)
treed72b762eb28f0a95784922286a11738738d3b26d /src
parentc239d890383d54d717da16a19b7977bf31dfc9b1 (diff)
downloadmpd-8beeb6e1d2311a3593a3df0273b778011068e81b.tar.gz
mpd-8beeb6e1d2311a3593a3df0273b778011068e81b.tar.xz
mpd-8beeb6e1d2311a3593a3df0273b778011068e81b.zip
support: added assertions
Check the function parameters.
Diffstat (limited to 'src')
-rw-r--r--src/support.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/support.c b/src/support.c
index ad0f93bd2..6cf61137c 100644
--- a/src/support.c
+++ b/src/support.c
@@ -21,6 +21,7 @@
#include "support.h"
#include "ncmpc.h"
+#include <assert.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
@@ -36,6 +37,8 @@ static gboolean noconvert = TRUE;
size_t
my_strlen(const char *str)
{
+ assert(str != NULL);
+
if (g_utf8_validate(str, -1, NULL)) {
size_t len = g_utf8_strlen(str, -1);
size_t width = 0;
@@ -91,6 +94,8 @@ basename(char *path)
{
char *end;
+ assert(path != NULL);
+
path = remove_trailing_slash(path);
end = path + strlen(path);
@@ -109,6 +114,9 @@ basename(char *path)
char *
strcasestr(const char *haystack, const char *needle)
{
+ assert(haystack != NULL);
+ assert(needle != NULL);
+
return strstr(lowerstr(haystack), lowerstr(needle));
}
#endif /* HAVE_STRCASESTR */
@@ -120,6 +128,10 @@ strscroll(char *str, char *separator, int width, scroll_state_t *st)
gchar *tmp, *buf;
gsize len, size;
+ assert(str != NULL);
+ assert(separator != NULL);
+ assert(st != NULL);
+
if( st->offset==0 ) {
st->offset++;
return g_strdup(str);
@@ -170,6 +182,8 @@ utf8_to_locale(const char *utf8str)
gsize rb, wb;
GError *error;
+ assert(utf8str != NULL);
+
if (noconvert)
return g_strdup(utf8str);
@@ -201,6 +215,8 @@ locale_to_utf8(const char *localestr)
gsize rb, wb;
GError *error;
+ assert(localestr != NULL);
+
if (noconvert)
return g_strdup(localestr);