From owner-freebsd-hackers@FreeBSD.ORG Sat May 24 04:19:45 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CF6BA37B404 for ; Sat, 24 May 2003 04:19:45 -0700 (PDT) Received: from flood.ping.uio.no (flood.ping.uio.no [129.240.78.31]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3879D43F3F for ; Sat, 24 May 2003 04:19:45 -0700 (PDT) (envelope-from des@ofug.org) Received: by flood.ping.uio.no (Postfix, from userid 2602) id 376EE530F; Sat, 24 May 2003 13:19:43 +0200 (CEST) X-URL: http://www.ofug.org/~des/ X-Disclaimer: The views expressed in this message do not necessarily coincide with those of any organisation or company with which I am or have been affiliated. To: kientzle@acm.org References: <3ECEFA18.7060706@acm.org> From: Dag-Erling Smorgrav Date: Sat, 24 May 2003 13:19:42 +0200 In-Reply-To: <3ECEFA18.7060706@acm.org> (Tim Kientzle's message of "Fri, 23 May 2003 21:50:32 -0700") Message-ID: User-Agent: Gnus/5.1001 (Gnus v5.10.1) Emacs/21.3 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii cc: freebsd-hackers@freebsd.org Subject: Re: fetchListFTP: implemented, but crippled X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 24 May 2003 11:19:46 -0000 Tim Kientzle writes: > Easiest fix: move 'name' field to end (which > permits variably-sizing it) and redefine API > to return a linked-list That would work. > Better fix: redesign API to return one > entry at a time. Then client code can manage > storage as appropriate. With this approach, > struct url_ent could remain unchanged. You'd run into trouble if the caller tried to perform another operation before reaching the end of the list. > The current API makes fetchListFTP pretty much > unusable for me; I'm not comfortable with that > kind of memory usage. If there's any concensus > about which fix is appropriate, I can start > putting it together. Have you tried contacting the author? > + /* Use last whitespace-separated token as filename */ That won't work for symlinks. > + if(url_index >= url_list_length) { > + new_url_list_length = url_list_length * 2; > + new_url_list = malloc(sizeof(struct url_ent) > + * new_url_list_length); > + fprintf(stderr,"fetchListFTP: malloc(%d)\n", > + sizeof(struct url_ent) > + * new_url_list_length); > + memcpy(new_url_list, url_list, > + sizeof(struct url_ent)*url_list_length); > + memset(new_url_list+url_list_length,0, > + sizeof(struct url_ent) > + *(new_url_list_length - url_list_length)); > + free(url_list); > + url_list = new_url_list; > + url_list_length = new_url_list_length; > + } You know, we have realloc() for a reason... DES -- Dag-Erling Smorgrav - des@ofug.org