[xcb] Memory management in XCB (was: XCB polling and
Carl Worth
xcb@nickle.org
Mon, 8 Jul 2002 21:19:31 +0000
single-threadedness)
On Jul 8, Jamey Sharp wrote:
> As far as I'm concerned, XCB doesn't have this ambiguity. If it returns
> a pointer, it's the caller's responsibility to free it.
That's also a valid approach to providing a consistent API.
> There is one other exception: XCBQueryExtensionCached. This function
> returns the requested item directly out of the cache. Following a style
> tip I read somewhere, I tagged the return value "const" to indicate that
> it should not be freed. (I also commented this aspect of the function's
> contract.)
Right, when I scanned looking for functions returning pointers, I had
noticed this one, (along with the comment warning against
freeing). That's what got me started thinking about this. I hadn't
noticed the "const".
> However, the application in general has no way of knowing how much
> memory to allocate for replies. For this reason, I think the memory for
> replies must be allocated inside XCB, and a pointer to it returned.
Right. And I wasn't actually proposing changing this. Mostly I was
just rambling. :-)
-Carl
--
Carl Worth
USC Information Sciences Institute cworth@east.isi.edu
3811 N. Fairfax Dr. #200, Arlington VA 22203 703-812-3725