Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:19170 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 25168 invoked by uid 1010); 26 Sep 2005 15:00:38 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 25153 invoked from network); 26 Sep 2005 15:00:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Sep 2005 15:00:38 -0000 X-Host-Fingerprint: 69.12.155.130 69-12-155-130.dsl.static.sonic.net Linux 2.4/2.6 Received: from ([69.12.155.130:4756] helo=pigeon.alphaweb.net) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 60/0B-24510-7FC08334 for ; Mon, 26 Sep 2005 11:00:09 -0400 Received: from localhost ([127.0.0.1] helo=lighthammer) by pigeon.alphaweb.net with smtp (Exim 4.10) id 1EJtm0-0004g3-00; Mon, 26 Sep 2005 07:16:04 -0700 Message-ID: <001001c5c2aa$f73a7740$6c051fac@lighthammer> To: "Michael Wallner" Cc: References: <79.1A.24510.546D2334@pb1.pair.com> <91.71.24510.E9A93334@pb1.pair.com> <003501c5c064$4782bc60$5c8be5a9@ohr.berkeley.edu> <35.D0.24510.B52F7334@pb1.pair.com> Date: Mon, 26 Sep 2005 07:59:58 -0700 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Subject: Re: [PATCH] imap_savebody() From: pollita@php.net ("Sara Golemon") Looks basicly alright (with a slight disagreement on how the read loop is implemented (below). In general you've got my vote (for what it's worth given my lack of experience with libc-client. unsigned long i, rest = size % GETS_FETCH_SIZE; char *buf = emalloc(GETS_FETCH_SIZE+1); for (i = GETS_FETCH_SIZE; i < size; i += GETS_FETCH_SIZE) { memset(buf, 0, GETS_FETCH_SIZE+1); f(stream, GETS_FETCH_SIZE, buf); php_stream_write_string(IMAPG(gets_stream), buf); } if (rest) { memset(buf, 0, GETS_FETCH_SIZE+1); f(stream, rest, buf); php_stream_write_string(IMAPG(gets_stream), buf); } efree(buf); return NULL; Here's how I'd write this block, it assumed that f returns the number of bytes actually read, but according to the proto for readfn_t it *should* do that. Feel free to ignore: char buf[GETS_FETCH_SIZE]; unsigned long ret = 1; while (ret > 0) { ret = f(stream, GETS_FETCH_SIZE, buf); php_stream_write_stringl(IMAPG(gets_stream), buf, ret); } return NULL;