From a2a6c4bdd72ca9839697a54dce10ca7fd01645ca Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sat, 2 Aug 2003 00:01:57 +0000 Subject: [PATCH] Moved and documented compare_string(). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4187 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/storage/Partition.cpp | 39 ++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/src/kits/storage/Partition.cpp b/src/kits/storage/Partition.cpp index 0ccdda8299..269c8837e1 100644 --- a/src/kits/storage/Partition.cpp +++ b/src/kits/storage/Partition.cpp @@ -54,6 +54,31 @@ public: bool fArray; }; +// compare_string +/*! \brief \c NULL aware strcmp(). + + \c NULL is considered the least of all strings. \c NULL equals \c NULL. + + \param str1 First string. + \param str2 Second string. + \return A value less than 0, if \a str1 is less than \a str2, + 0, if they are equal, or a value greater than 0, if + \a str1 is greater \a str2. +*/ +static inline +int +compare_string(const char *str1, const char *str2) +{ + if (str1 == NULL) { + if (str2 == NULL) + return 0; + return 1; + } else if (str2 == NULL) + return -1; + return strcmp(str1, str2); +} + + // constructor BPartition::BPartition() : fDevice(NULL), @@ -977,20 +1002,6 @@ BPartition::_RemoveObsoleteDescendants(user_partition_data *data, return B_OK; } -// compare_string -static -int -compare_string(const char *str1, const char *str2) -{ - if (str1 == NULL) { - if (str2 == NULL) - return 0; - return 1; - } else if (str2 == NULL) - return -1; - return strcmp(str1, str2); -} - // _Update status_t BPartition::_Update(user_partition_data *data, bool *updated)