[Xcb] New aux function

Barton C Massey bart at cs.pdx.edu
Sun Jan 15 12:59:35 PST 2006


The problem with this, as we've talked about before, is that
some strings returned by the server may already have
embedded nulls, in which case all the C functions will do
the wrong thing.

What is needed, I fear, is an aux library for dealing with
X-style counted strings, with the standard stuff in it (from
strings.h and stdio.h, for starters).

Alternatively, your conversion function could transform
embedded nulls in the string into something else.  Maybe the
converter should translate to UTF, and use the null in the
Unicode reserved area as a representation of embedded null
bytes?

	Bart

In message <43CAA789.10206 at brandeis.edu> you wrote:
> I was thinking putting a new function in aux/convenient that takes a
> string in a reply and returns a new string with a terminating null.
> 
> Something like:
> 
> char *XCBAuxExtractString(char *s, int n) {
>     char *str;
>     str = (char *)malloc(sizeof(char) * (n+1));
>     strncpy(str, s, n);
>     str[n] = '\0';
>     return str;
> }
> 
> Good/bad/ugly/thoughts?
> 
> Jeremy
> _______________________________________________
> Xcb mailing list
> Xcb at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/xcb


More information about the Xcb mailing list