Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2001:
[Freeciv-Dev] Re: Split patch (was Re: [RFC PATCH] init_techs)
Home

[Freeciv-Dev] Re: Split patch (was Re: [RFC PATCH] init_techs)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: "Ross W. Wetmore" <rwetmore@xxxxxxxxxxxx>
Cc: Justin Moore <justin@xxxxxxxxxxx>, Freeciv Developers <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: Split patch (was Re: [RFC PATCH] init_techs)
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 30 Sep 2001 18:52:18 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Fri, Sep 28, 2001 at 07:42:07PM -0400, Ross W. Wetmore wrote:
> At 09:52 AM 01/09/28 +0200, Raimar Falke wrote:
> >On Fri, Sep 28, 2001 at 12:00:07AM -0400, Ross W. Wetmore wrote:
> >> I like your statement of what you claim to be agreeing to followed
> >> by what you actually want to do in practice.
> >> 
> >> Why on earth would you handle the same buffer contents 3 times with
> >> all those allocation and free calls when you could do it once and
> >> let the caller deal with at most one extra copy depending on whether
> >> the original buffer or the results needed to be preserved.
> >> 
> >> But most of the time I would expect that no extra copies were required
> >> in the caller algorithms.
> >
> >> split should treat the buffer it was handed as working memory, return
> >> pointers into the parsed string elements, and let the caller deal with
> >> ALL memory issues.
> >
> >Ok since there is so much resistance: we implement the strdup/free in
> >split if it turns out that every caller of split will copy the string
> >because it is needed later. Ok?
> 
> A better way is to just implement split to take a buffer and do its
> splitting thing in a reasonable and efficient manner.

There should be a big fat comment about the lifetime of the result and
memory issues if split() is be done this way.

> your VERY bad programming practices

Ross: this is a bit insulting. Please stop it.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "Many of my assistants were fans of Tolkien, who wrote 'Lord of the Rings'
  and a number of other children's stories for adults.  The first character
  alphabet that was programmed for my plotter was Elvish rather than Latin."
    -- from SAIs "life as a computer for a quarter of a century"


[Prev in Thread] Current Thread [Next in Thread]