[Xcb] lists, replies, and freeing

Jamey Sharp jamey at minilop.net
Wed May 11 08:55:48 PDT 2005


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. :-)

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.

--Jamey



More information about the xcb mailing list