From: Pierre Habouzit Date: Tue, 28 Nov 2006 22:36:01 +0000 (+0100) Subject: remove reallocs, free and fix makedoc compilation X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=commitdiff_plain;h=93333ab4ec39447097a0f2278660626c560adb22;ds=sidebyside remove reallocs, free and fix makedoc compilation Signed-off-by: Pierre Habouzit --- diff --git a/lib-crypt/pgppacket.c b/lib-crypt/pgppacket.c index 2cfddbb..0956076 100644 --- a/lib-crypt/pgppacket.c +++ b/lib-crypt/pgppacket.c @@ -22,17 +22,7 @@ static size_t plen = 0; static int read_material (size_t material, size_t * used, FILE * fp) { if (*used + material >= plen) { - unsigned char *p; - size_t nplen; - - nplen = *used + material + CHUNKSIZE; - - if (!(p = realloc(pbuf, nplen))) { - perror ("realloc"); - return -1; - } - plen = nplen; - pbuf = p; + p_realloc(&pbuf, plen = *used + material + CHUNKSIZE); } if (fread (pbuf + *used, 1, material, fp) < material) { diff --git a/makedoc.c b/makedoc.c index 6451c48..91f6630 100644 --- a/makedoc.c +++ b/makedoc.c @@ -157,7 +157,7 @@ int main (int argc, char *argv[]) static void add_var (const char *name) { - outbuf = realloc (outbuf, (++outcount) * sizeof (var_t)); + p_realloc(&outbuf, ++outcount); outbuf[outcount - 1].seen = 0; outbuf[outcount - 1].name = strdup(name); outbuf[outcount - 1].descr = NULL; @@ -177,9 +177,8 @@ static int add_s (const char *s) if (lold == 0) outbuf[outcount - 1].descr = strdup(s); else { - outbuf[outcount - 1].descr = - realloc (outbuf[outcount - 1].descr, lold + lnew + 1); - memcpy (&(outbuf[outcount - 1].descr[lold - 1]) + 1, s, lnew); + p_realloc(&outbuf[outcount - 1].descr, lold + lnew + 1); + memcpy(&(outbuf[outcount - 1].descr[lold - 1]) + 1, s, lnew); } outbuf[outcount - 1].descr[lold + lnew] = '\0'; return (1); @@ -234,11 +233,11 @@ static void makedoc (FILE * in, FILE * out) for (line = 0; line < outcount; line++) { if (outbuf[line].descr) { fprintf (out, "%s\n", outbuf[line].descr); - free (outbuf[line].descr); + p_delete(&outbuf[line].descr); } - free (outbuf[line].name); + p_delete(&outbuf[line].name); } - free (outbuf); + p_delete(&outbuf); } /* skip whitespace */ @@ -458,23 +457,23 @@ static void handle_confline (char *s) print_confline (varname, type, val); } -static void char_to_escape (char *dest, unsigned int c) +static void char_to_escape (char *dest, int len, unsigned int c) { switch (c) { case '\r': - m_strcpy(dest, "\\r"); + m_strcpy(dest, len, "\\r"); break; case '\n': - m_strcpy(dest, "\\n"); + m_strcpy(dest, len, "\\n"); break; case '\t': - m_strcpy(dest, "\\t"); + m_strcpy(dest, len, "\\t"); break; case '\f': - m_strcpy(dest, "\\f"); + m_strcpy(dest, len, "\\f"); break; default: - sprintf (dest, "\\%03o", c); + sprintf (dest, len, "\\%03o", c); break; } } @@ -482,7 +481,7 @@ static void conf_char_to_escape (unsigned int c) { char buff[16]; - char_to_escape (buff, c); + char_to_escape(buff, sizeof(buff), c); add_s (buff); } @@ -524,7 +523,7 @@ static void sgml_print_strval (const char *v) for (; *v; v++) { if (*v < ' ' || *v & 0x80) { - char_to_escape (buff, (unsigned int) *v); + char_to_escape(buff, sizeof(buff), (unsigned int) *v); sgml_fputs (buff); continue; } diff --git a/mutt_libesmtp.c b/mutt_libesmtp.c index 9df7ffb..3ffb3f0 100644 --- a/mutt_libesmtp.c +++ b/mutt_libesmtp.c @@ -144,7 +144,7 @@ static const char *_mutt_libesmtp_messagefp_cb (void **buf, int *len, int octets; if (*buf == NULL) - *buf = malloc (BUFLEN); + *buf = xmalloc(BUFLEN); if (len == NULL) { rewind ((FILE *) arg);