masqmail

changeset 302:2ffcd38ccf53

improved unused function header_fold()
author markus schnalke <meillo@marmaro.de>
date Thu, 09 Dec 2010 17:50:25 -0300
parents 55c530a83d51
children 3e3c280ca5b2
files src/header.c
diffstat 1 files changed, 19 insertions(+), 21 deletions(-) [+]
line diff
     1.1 --- a/src/header.c	Thu Dec 09 15:42:02 2010 -0300
     1.2 +++ b/src/header.c	Thu Dec 09 17:50:25 2010 -0300
     1.3 @@ -105,29 +105,27 @@
     1.4  void
     1.5  header_unfold(header * hdr)
     1.6  {
     1.7 -	gchar *tmp_hdr = g_malloc(strlen(hdr->header));
     1.8 -	gchar *p = hdr->header, *q = tmp_hdr;
     1.9 -	gboolean flag = FALSE;
    1.10 +        char *src = hdr->header;
    1.11 +        char *dest = src;
    1.12 +        char *p;
    1.13  
    1.14 -	while (*p) {
    1.15 -		if (*p != '\n') {
    1.16 -			*(q++) = *p;
    1.17 -		} else {
    1.18 -			flag = TRUE;
    1.19 -		}
    1.20 -		p++;
    1.21 -	}
    1.22 -	*(q++) = '\n';
    1.23 +        p = strchr(src, '\n');
    1.24 +        if (!p || !p[1]) {
    1.25 +                /* no folded header */
    1.26 +                return;
    1.27 +        }
    1.28  
    1.29 -	if (flag) {
    1.30 -		gchar *new_hdr;
    1.31 -
    1.32 -		g_free(hdr->header);
    1.33 -		new_hdr = g_strdup(tmp_hdr);
    1.34 -		g_free(tmp_hdr);
    1.35 -		hdr->value = new_hdr + (hdr->value - hdr->header);
    1.36 -		hdr->header = new_hdr;
    1.37 -	}
    1.38 +        while (*src) {
    1.39 +                if (*src == '\n') {
    1.40 +                        /* ignore */
    1.41 +                        src++;
    1.42 +                } else {
    1.43 +                        /* copy */
    1.44 +                        *(dest++) = *(src++);
    1.45 +                }
    1.46 +        }
    1.47 +        *(dest++) = '\n';
    1.48 +        *(dest++) = '\0';
    1.49  }
    1.50  
    1.51  #define MAX_HDR_LEN 72