Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: <20040219185629.75069.qmail@web14302.mail.yahoo.com> Date: Thu, 19 Feb 2004 10:56:29 -0800 (PST) From: Thomas Mellman Subject: Re: ftp bug report To: cygwin AT cygwin DOT com MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii >I fixed the bug (which could only show up when using nmap) and uploaded >a new version of inetutils. Wow! I'm impressed. Thank you! >As an exercise for the reader: > > buf = (char *) malloc (size); > to = buf; > [...] > if (newsize > size) > buf = realloc (buf, newsize); > while (newsize--) > *to++ = *src++; > >What's wrong with this picture? Oh, I hope there's an answer section in the back of the book. Proving my ignorance once again ... 0v~/eg/c>cat malmalloc.c main () { char *buf, *to, *src = "hello world"; int size = 8, newsize; newsize = strlen (src) + 1; buf = (char *) malloc (size); to = buf; if (newsize > size) buf = (char *)realloc (buf, newsize); while (newsize--) *to++ = *src++; printf ("%s\n", buf); } 0v~/eg/c>./malmalloc.exe hello world 12v~/eg/c> (assumes newsize is initialized). __________________________________ Do you Yahoo!? Yahoo! Mail SpamGuard - Read only the mail you want. http://antispam.yahoo.com/tools -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/