Here is a patch I promised - it replaces strcpy with faster mempcy in the
most used string functions HTSACopy and HTSACat (used via macros StrAllocCopy
and StrAllocCat).

 Best regards,
  -Vlad

diff -ru old/WWW/Library/Implementation/HTString.c 
fixed/WWW/Library/Implementation/HTString.c
--- old/WWW/Library/Implementation/HTString.c   Thu Nov  4 00:31:15 1999
+++ fixed/WWW/Library/Implementation/HTString.c Mon Mar 27 20:06:58 2000
@@ -269,11 +269,12 @@
 {
     if (src != 0) {
        if (src != *dest) {
+           int srclen = strlen(src);
            FREE(*dest);
-           *dest = (char *) malloc (strlen(src) + 1);
+           *dest = (char *) malloc (srclen + 1);
            if (*dest == NULL)
                outofmem(__FILE__, "HTSACopy");
-           strcpy (*dest, src);
+           memcpy(*dest,src,srclen+1);
        }
     } else {
        FREE(*dest);
@@ -288,17 +289,18 @@
        CONST char *,   src)
 {
     if (src && *src && (src != *dest)) {
+        int srclen = strlen(src);
        if (*dest) {
            int length = strlen(*dest);
-           *dest = (char *)realloc(*dest, length + strlen(src) + 1);
+           *dest = (char *)realloc(*dest, length + srclen + 1);
            if (*dest == NULL)
                outofmem(__FILE__, "HTSACat");
-           strcpy (*dest + length, src);
+           memcpy(*dest  + length,src, srclen + 1);
        } else {
-           *dest = (char *)malloc(strlen(src) + 1);
+           *dest = (char *)malloc(srclen + 1);
            if (*dest == NULL)
                outofmem(__FILE__, "HTSACat");
-           strcpy (*dest, src);
+           memcpy(*dest,src,srclen+1);
        }
     }
     return *dest;

Reply via email to