aboutsummaryrefslogtreecommitdiffstats
path: root/unmime.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1998-10-08 05:31:22 +0000
committerEric S. Raymond <esr@thyrsus.com>1998-10-08 05:31:22 +0000
commit632f1335893998041f66a25d3809ad719f8557b7 (patch)
tree4530ed420648800a93d1ccded966c7ef941eb3a6 /unmime.c
parente5cbf59f31c46a8da51b71b16674474be9fe319b (diff)
downloadfetchmail-632f1335893998041f66a25d3809ad719f8557b7.tar.gz
fetchmail-632f1335893998041f66a25d3809ad719f8557b7.tar.bz2
fetchmail-632f1335893998041f66a25d3809ad719f8557b7.zip
Use alloca where possible.
svn path=/trunk/; revision=2076
Diffstat (limited to 'unmime.c')
-rw-r--r--unmime.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/unmime.c b/unmime.c
index 0f0dcf42..32a4ed72 100644
--- a/unmime.c
+++ b/unmime.c
@@ -14,6 +14,13 @@
#include <string.h>
#include <stdlib.h>
+#if defined(HAVE_ALLOCA_H)
+#include <alloca.h>
+#else
+#ifdef _AIX
+ #pragma alloca
+#endif
+#endif
#include <ctype.h>
#include "fetchmail.h"
@@ -363,7 +370,7 @@ int MimeBodyType(unsigned char *hdrs, int WantDecode)
XferEncOfs = NxtHdr;
p = nxtaddr(NxtHdr);
if (p != NULL) {
- XferEnc = (char *)xmalloc(strlen(p) + 1);
+ XferEnc = (char *)alloca(strlen(p) + 1);
strcpy(XferEnc, p);
HdrsFound++;
}
@@ -394,7 +401,7 @@ int MimeBodyType(unsigned char *hdrs, int WantDecode)
} while ( (p != NULL) && ((*(p+1) == '\t') || (*(p+1) == ' ')) );
if (p == NULL) p = NxtHdr + strlen(NxtHdr);
- CntType = (char *)xmalloc(p-NxtHdr+2);
+ CntType = (char *)alloca(p-NxtHdr+2);
strncpy(CntType, NxtHdr, (p-NxtHdr));
*(CntType+(p-NxtHdr)) = '\0';
HdrsFound++;
@@ -402,7 +409,7 @@ int MimeBodyType(unsigned char *hdrs, int WantDecode)
else if (strncasecmp("MIME-Version:", NxtHdr, 13) == 0) {
p = nxtaddr(NxtHdr);
if (p != NULL) {
- MimeVer = (char *)xmalloc(strlen(p) + 1);
+ MimeVer = (char *)alloca(strlen(p) + 1);
strcpy(MimeVer, p);
HdrsFound++;
}
@@ -456,10 +463,6 @@ int MimeBodyType(unsigned char *hdrs, int WantDecode)
}
- if (MimeVer) free(MimeVer);
- if (XferEnc) free(XferEnc);
- if (CntType) free(CntType);
-
return BodyType;
}