Fix fpcrtl_strncompareA, also replace strncmp with memcmp for more efficiency
authorunc0rr
Wed, 14 May 2014 01:07:43 +0400
changeset 10241 2dc9ff47c5b9
parent 10240 bfae7354d42f
child 10242 0ab0d7fa1c62
Fix fpcrtl_strncompareA, also replace strncmp with memcmp for more efficiency
project_files/hwc/rtl/misc.c
--- a/project_files/hwc/rtl/misc.c	Fri May 09 22:36:15 2014 +0400
+++ b/project_files/hwc/rtl/misc.c	Wed May 14 01:07:43 2014 +0400
@@ -108,13 +108,7 @@
 
 bool fpcrtl_strcompare(string255 str1, string255 str2)
 {
-    FIX_STRING(str1);
-    FIX_STRING(str2);
-    if(strncmp(str1.str, str2.str, 256) == 0){
-        return true;
-    }
-
-    return false;
+    return memcmp(str1.s, str2.s, str1.len + 1) == 0;
 }
 
 bool fpcrtl_strcomparec(string255 a, char b)
@@ -133,14 +127,14 @@
 
 bool fpcrtl_strncompareA(astring a, astring b)
 {
-    return (a.len == b.len) && (strncmp(a.s, b.s, MAX_ANSISTRING_LENGTH) == 0);
+    return (a.len != b.len) || (memcmp(a.s, b.s, a.len + 1) != 0);
 }
 
 
 string255 fpcrtl_pchar2str(const char *s)
 {
     string255 result;
-    
+
     if(!s)
     {
         result.len = 0;