NULL PChar is okay
authorunc0rr
Thu, 13 Feb 2014 23:38:16 +0400
changeset 10137 a4537aab4117
parent 10136 f0da90f58c98
child 10138 1a71d28392cb
NULL PChar is okay
project_files/hwc/rtl/misc.c
project_files/hwc/rtl/sysutils.c
--- a/project_files/hwc/rtl/misc.c	Thu Feb 13 14:12:04 2014 -0500
+++ b/project_files/hwc/rtl/misc.c	Thu Feb 13 23:38:16 2014 +0400
@@ -140,15 +140,22 @@
 string255 fpcrtl_pchar2str(const char *s)
 {
     string255 result;
-    int rlen = strlen(s);
+    
+    if(!s)
+    {
+        result.len = 0;
+    } else
+    {
+        int rlen = strlen(s);
 
-    if(rlen > 255){
-        rlen = 255;
+        if(rlen > 255){
+            rlen = 255;
+        }
+
+        result.len = rlen;
+        memcpy(result.str, s, rlen);
     }
 
-    result.len = rlen;
-    memcpy(result.str, s, rlen);
-
     return result;
 }
 
--- a/project_files/hwc/rtl/sysutils.c	Thu Feb 13 14:12:04 2014 -0500
+++ b/project_files/hwc/rtl/sysutils.c	Thu Feb 13 23:38:16 2014 +0400
@@ -163,16 +163,5 @@
 
 string255 fpcrtl_strPas(PChar p)
 {
-    string255 s;
-    int l = strlen(p);
-
-    if(l > 255){
-        printf("strPas: source string length > 255\n");
-        assert(0);
-    }
-
-    s.len = l;
-    strcpy(s.str, p);
-
-    return s;
+    return fpcrtl_pchar2str(p);
 }