From 632f1335893998041f66a25d3809ad719f8557b7 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 8 Oct 1998 05:31:22 +0000 Subject: Use alloca where possible. svn path=/trunk/; revision=2076 --- unmime.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'unmime.c') diff --git a/unmime.c b/unmime.c index 0f0dcf42..32a4ed72 100644 --- a/unmime.c +++ b/unmime.c @@ -14,6 +14,13 @@ #include #include +#if defined(HAVE_ALLOCA_H) +#include +#else +#ifdef _AIX + #pragma alloca +#endif +#endif #include #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; } -- cgit v1.2.3