[Xcb] zeroing out

Jamey Sharp jamey at minilop.net
Sat Dec 31 11:36:45 PST 2005


On Sat, Dec 31, 2005 at 10:38:47AM -0500, Jeremy A. Kolb wrote:
> Why can't we just extract the string and force a null at the end and 
> return it when calling the XCBExtString function?

Two reasons.

> On Fri, 30 Dec 2005, Barton C Massey wrote:
> > Sounds like in principle, significant null bytes could
> > appear in some count/chars strings sent by the X server.  In
> > practice I would be shocked, but that's standards for you.

... in which case any code relying on null-terminated strings would lose
the end of the string. (I seem to recall that some common properties
have null-separated strings, for what it's worth.)

And XCB's job is to hand back to the client exactly what it got from the
X server.

> I think that would be easier than requiring people using XCB to write
> and use their own functions for every single string returned.  The API
> is hard enough to read already and I think it would be a win in the
> useability department.
> 
> > What we probably want is a few convenience functions in XCB
> > for dealing with these things, like the nstrcmp() [horrible
> > name, maybe not right API] I wrote for xcbxvinfo.  I'm not
> > sure what else to do, really...

You're probably both right, except that's probably a job for a separate
library. If you have code you'd suggest for this purpose, it could go in
xcbaux for now.

I'd like to point out one pattern I've used, for passing counted strings
to printf. It doesn't correctly handle strings that contain nulls
though.

	printf("%.*s", name_len, name);

--Jamey
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.freedesktop.org/archives/xcb/attachments/20051231/81c30deb/attachment.pgp


More information about the Xcb mailing list