Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2002:
[Freeciv-Dev] Re: Question about attributes
Home

[Freeciv-Dev] Re: Question about attributes

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Cc: freeciv-dev <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: Question about attributes
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 10 Jan 2002 12:56:31 +0100
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Thu, Jan 10, 2002 at 06:37:38AM -0500, Jason Short wrote:
> Raimar Falke wrote:
> 
> > On Thu, Jan 10, 2002 at 05:53:23AM -0500, Jason Short wrote:
> >>Raimar Falke wrote:
> >>
> >>>You see the attributes aren't really used. I agree that a seperate
> >>>attribute_length is the way to go. Please send a patch.
> >>>
> >>What about just malloc'ing the buffer in attribute_get?  This saves the 
> >>extra function call (which will generally always be necessary), at the 
> >>small cost of having to free the buffer later.
> > 
> > This all depends on the usage patterns. So far we have not enough
> > users to make a final decision. The agents I have coded so far doesn't
> > need these attribute_length call at all because they know the size. If
> > more users like the tile markers are created we may have to rethink
> > this. Also note that the tile markers in at least one case needs a
> > slightly larger buffer.
> 
> Interesting.  Keep in mind that this data is unverified; if you connect 
> to a server in place of some former player, and that player has uploaded 
> invalid attributes, your client should not die.  So it is important that 
> error-checking be done in all cases.

I agree. The error-checking which is in place is via asserts.

> > Another solution: attribute_get will allocate a large-enough buffer if
> > the supplied data pointer is NULL.
> 
> And return a pointer to the buffer?  Or will the user pass in a 
> pointer-to-pointer?  Either seems like a reasonable solution.

The return value is currently used for the size of the attribute.

Let us implement attribute_length and reconsider this thing if we have
5 users of the attributes.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 Q:  Do you know what the death rate around here is?
 A:  One per person.


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