[Xcb] lists, replies, and freeing
Vincent.Torri at iecn.u-nancy.fr
Wed May 11 09:01:50 PDT 2005
On Wed, 11 May 2005, Jamey Sharp wrote:
> On Wed, 2005-05-11 at 06:40 +0200, Vincent Torri wrote:
>> On Tue, 10 May 2005, Jamey Sharp wrote:
>>> On Tue, 2005-05-10 at 21:31 -0400, Jeremy Kolb wrote:
>>>> If you have a reply return a list and you free the reply does that free
>>>> the list is free as well or should that be freed later?
>>> All the memory for a reply, including any lists in that reply, is
>>> allocated in a single malloc call. So you must not free any lists from
>>> replies, and you should free the reply pointer returned by whatever
>>> XCB*Reply function you called.
>> is that why there is always a "Length" method associated to each "Value"
>> one ?
> I find the question interesting because I don't understand how you got
> there from what I said... I think I would learn something if I
> understood that. :-)
Maybe I was not clear. For example:
XCBTIMECOORD *XCBGetMotionEventsEvents(XCBGetMotionEventsRep *R);
int XCBGetMotionEventsEventsLength(XCBGetMotionEventsRep *R);
the first function returns an array of timecoord, while the second returns
the number of elements in this array. Am I wrong ?
> No, those are an attempt at providing consistency to XCB's users. In all
> cases the caller can find the length of a list by evaluating some
> expression composed of fields of the reply, but in a number of cases XCB
> needs to be able to evaluate those expressions internally anyway. So I
> chose to make them public so users don't have to figure out what the
> right expression is for a particular list.
it was what i wanted to say, I think
More information about the xcb