From d59e69783b91feb5d3ee5d2ba802c279ecf021c5 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 26 Oct 1996 13:21:21 +0000 Subject: Include mx.h, fix a memory leak. svn path=/trunk/; revision=395 --- imap.c | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) (limited to 'imap.c') diff --git a/imap.c b/imap.c index 286d469c..fbacc3cb 100644 --- a/imap.c +++ b/imap.c @@ -111,39 +111,34 @@ int *countp, *newp; return(0); } -static int *imap_getsizes(socket, count) +static int imap_getsizes(socket, count, sizes) /* capture the sizes of all messages */ int socket; int count; +int *sizes; { - int ok, *sizes; + char buf [POPBUFSIZE+1]; - if ((sizes = (int *)malloc(sizeof(int) * count)) == (int *)NULL) - return((int *)NULL); - else + gen_send(socket, "FETCH 1:%d RFC822.SIZE", count); + while (SockGets(socket, buf, sizeof(buf)) >= 0) { - char buf [POPBUFSIZE+1]; - - gen_send(socket, "FETCH 1:%d RFC822.SIZE", count); - while (SockGets(socket, buf, sizeof(buf)) >= 0) - { - int num, size; - - if (outlevel == O_VERBOSE) - fprintf(stderr,"%s\n",buf); - if (strstr(buf, "OK")) - break; - else if (sscanf(buf, "* %d FETCH (RFC822.SIZE %d)", &num, &size) == 2) - sizes[num - 1] = size; - else - sizes[num - 1] = -1; - } + int num, size; - return(sizes); + if (outlevel == O_VERBOSE) + fprintf(stderr,"%s\n",buf); + if (strstr(buf, "OK")) + break; + else if (sscanf(buf, "* %d FETCH (RFC822.SIZE %d)", &num, &size) == 2) + sizes[num - 1] = size; + else + sizes[num - 1] = -1; } + + return(0); } static imap_is_old(socket, ctl, num) +/* is the given message old? */ int socket; struct query *ctl; int num; @@ -182,7 +177,7 @@ int *lenp; } static imap_trail(socket, ctl, number) -/* discard tail of FETCH response */ +/* discard tail of FETCH response after reading message text */ int socket; struct query *ctl; int number; -- cgit v1.2.3