Date: Sat, 24 May 2003 13:19:42 +0200 From: Dag-Erling Smorgrav <des@ofug.org> To: kientzle@acm.org Cc: freebsd-hackers@freebsd.org Subject: Re: fetchListFTP: implemented, but crippled Message-ID: <xzp1xyotwvl.fsf@flood.ping.uio.no> In-Reply-To: <3ECEFA18.7060706@acm.org> (Tim Kientzle's message of "Fri, 23 May 2003 21:50:32 -0700") References: <3ECEFA18.7060706@acm.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Tim Kientzle <kientzle@acm.org> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?xzp1xyotwvl.fsf>
