]> Pileus Git - ~andy/fetchmail/commitdiff
Minor optimizations from Federico.
authorEric S. Raymond <esr@thyrsus.com>
Sun, 26 Dec 1999 22:53:25 +0000 (22:53 -0000)
committerEric S. Raymond <esr@thyrsus.com>
Sun, 26 Dec 1999 22:53:25 +0000 (22:53 -0000)
svn path=/trunk/; revision=2689

env.c
fetchmail.c
unmime.c

diff --git a/env.c b/env.c
index cda43ea8ee96be0a58b763d3d2a8188b201d81f9..355f3a16b3cd1ca6ef1d844c55965a978df72a7d 100644 (file)
--- a/env.c
+++ b/env.c
@@ -81,7 +81,7 @@ void envquery(int argc, char **argv)
        program_name = argv[0];
 
 #define RCFILE_NAME    ".fetchmailrc"
-    rcfile = (char *) xmalloc(strlen(home)+strlen(RCFILE_NAME)+2);
+    rcfile = (char *) xmalloc(strlen(home)+sizeof(RCFILE_NAME)+1);
     /* avoid //.fetchmailrc */
     if (strcmp(home, "/") != 0) {
        strcpy(rcfile, home);
index fc8490fbdbfdbc8bb4629d194dd35fd4fc011ef0..6015411ddab3d31fb835a8e7b038b890baaabff2 100644 (file)
@@ -34,6 +34,7 @@
 #ifdef HAVE_SYS_WAIT_H
 #include <sys/wait.h>
 #endif /* HAVE_SYS_WAIT_H */
+#include <sys/utsname.h>
 
 #ifdef HAVE_GETHOSTBYNAME
 #include <netdb.h>
@@ -183,7 +184,7 @@ int main(int argc, char **argv)
 #endif
 
 #define IDFILE_NAME    ".fetchids"
-    run.idfile = (char *) xmalloc(strlen(home)+strlen(IDFILE_NAME)+2);
+    run.idfile = (char *) xmalloc(strlen(home)+sizeof(IDFILE_NAME)+1);
     strcpy(run.idfile, home);
     strcat(run.idfile, "/");
     strcat(run.idfile, IDFILE_NAME);
@@ -267,10 +268,10 @@ int main(int argc, char **argv)
 #define        FETCHMAIL_PIDFILE       "fetchmail.pid"
     if (!getuid()) {
        xalloca(tmpbuf, char *,
-               strlen(PID_DIR) + strlen(FETCHMAIL_PIDFILE) + 2);
+               sizeof(PID_DIR) + sizeof(FETCHMAIL_PIDFILE));
        sprintf(tmpbuf, "%s/%s", PID_DIR, FETCHMAIL_PIDFILE);
     } else {
-       xalloca(tmpbuf, char *, strlen(home) + strlen(FETCHMAIL_PIDFILE) + 3);
+       xalloca(tmpbuf, char *, strlen(home) + sizeof(FETCHMAIL_PIDFILE) + 2);
        strcpy(tmpbuf, home);
        strcat(tmpbuf, "/.");
        strcat(tmpbuf, FETCHMAIL_PIDFILE);
@@ -294,7 +295,7 @@ int main(int argc, char **argv)
 
 #define        NETRC_FILE      ".netrc"
     /* parse the ~/.netrc file (if present) for future password lookups. */
-    xalloca(netrc_file, char *, strlen (home) + strlen(NETRC_FILE) + 2);
+    xalloca(netrc_file, char *, strlen (home) + sizeof(NETRC_FILE) + 1);
     strcpy (netrc_file, home);
     strcat (netrc_file, "/");
     strcat (netrc_file, NETRC_FILE);
index 6e7362b4f8dd282ec3183c2d2c7717e89cff7e67..57f7f8f30464485096b7cf10ab7f5cc5e1ea55e6 100644 (file)
--- a/unmime.c
+++ b/unmime.c
@@ -211,7 +211,7 @@ void UnMimeHeader(unsigned char *hdr)
            * and prepare to process the new MIME charset/encoding
           * header.
           */
-         p_in = p + strlen(MIMEHDR_INIT);
+         p_in = p + sizeof(MIMEHDR_INIT) - 1;
          state = S_SKIP_MIMEINIT;
         }
       }
@@ -270,10 +270,10 @@ static void SetEncoding8bit(unsigned char *XferEncOfs)
   unsigned char *p;
 
   if (XferEncOfs != NULL) {
-     memcpy(XferEncOfs, ENC8BIT, strlen(ENC8BIT));
+     memcpy(XferEncOfs, ENC8BIT, sizeof(ENC8BIT) - 1);
 
      /* If anything left, in this header, replace with whitespace */
-     for (p=XferEncOfs+strlen(ENC8BIT); (*p >= ' '); p++) *p=' ';
+     for (p=XferEncOfs+sizeof(ENC8BIT)-1; (*p >= ' '); p++) *p=' ';
   }
 }