[cairo] [RFC] Color space API (partial proposal)

Mathieu Lacage mathieu.lacage at sophia.inria.fr
Tue Feb 23 07:46:15 PST 2010


On Tue, 2010-02-23 at 07:39 -0800, Jon Cruz wrote:

> >> However I'm not sure if "const char*" is really what is best. Such a
> >> declaration in C is really ambiguous and can represent "random byte
> >> data of a separately specified length" in addition to "a string".
> > 
> > As long as there is no separate length parameter, everyone will
> > understand a const char* to be a NUL-terminated string.  It should,
> > however, be documented to be UTF-8.
> 
> Not necessarily. Remember that the C paradigm is char* == "byte
> array". The *name* of the parameter and the in-line documentation can
> really help.

I concur with zack here: it's best to leave char * for strings. A fairly
widespread convention is to use explicitely unsigned chars to represent
bytes instead of char. i.e., (const uint8_t *buffer, uint32_t size) (or
size_t instead of uint32_t).

Mathieu



More information about the cairo mailing list