summaryrefslogtreecommitdiff
path: root/source4/lib/util_str.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-08-14 05:57:43 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:57:59 -0500
commitada86316e54320a891d982c653e1070155bc8dbb (patch)
treebfecd758f4f89ff40ff7cc3a70e308516b05061c /source4/lib/util_str.c
parent64082214337e2ab50f0a69ca7f9bcf56762129cc (diff)
downloadsamba-ada86316e54320a891d982c653e1070155bc8dbb.tar.gz
samba-ada86316e54320a891d982c653e1070155bc8dbb.tar.bz2
samba-ada86316e54320a891d982c653e1070155bc8dbb.zip
r1820: added a strcmp_safe() that handles NULL pointers. Needed for the
search torture test, as some servers return really bad entries. (This used to be commit c900ebb3ac18d77ab334d3bf5259b3bba547b09c)
Diffstat (limited to 'source4/lib/util_str.c')
-rw-r--r--source4/lib/util_str.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/source4/lib/util_str.c b/source4/lib/util_str.c
index fd13f86501..a6f54f9a8d 100644
--- a/source4/lib/util_str.c
+++ b/source4/lib/util_str.c
@@ -1464,3 +1464,18 @@ BOOL add_string_to_array(TALLOC_CTX *mem_ctx,
return True;
}
+
+
+/*
+ varient of strcmp() that handles NULL ptrs
+*/
+int strcmp_safe(const char *s1, const char *s2)
+{
+ if (s1 == s2) {
+ return 0;
+ }
+ if (s1 == NULL || s2 == NULL) {
+ return s1?-1:1;
+ }
+ return strcmp(s1, s2);
+}