[cairo] absract_surface -> cairo_surface_t* vs void*

Enrico Weigelt, metux IT consult enrico.weigelt at gr13.net
Fri Dec 11 04:34:43 PST 2015


Hi folks,


I've seen many places where an (abstract) surface structure is passed
as void* pointer, which is then directly typecaste'd to the actual
structure.

Should we change it to use cairo_surface_t* intead and then use
container_of() for the typecast instead ?

By the way: I'd also propose an additional sanity check:

* put in an magic value (more precisely: an array of magics - for
  deeper inheritance) into cairo_surface_t, so we can check individual
  instances for correct class
* add some macros for the typecasting and type check
* make the whole thing (compile-time) optional



--mtx

mit freundlichen Grüßen
--
Enrico Weigelt,
metux IT consulting
+49-151-27565287


More information about the cairo mailing list