[cairo] Making cairo_error weak

Vladimir Vukicevic vladimirv at gmail.com
Wed Aug 17 18:57:14 PDT 2005


On 8/17/05, Carl Worth <cworth at cworth.org> wrote:
> PS. The strategy described above is for errors in applications using
> cairo that cairo is able to detect. It would likely also be desirable
> to implement a separate strategy for printing on error as early as
> possible, (as opposed to as late as possible as described above), to
> aid in debugging errors in cairo itself.

In trying to track down the exact spot where an error was being
returned from cairo internals, I ended up doing a sed 's,return
CAIRO_STATUS_NO_MEMORY,CAIRO_RETURN(CAIRO_STATUS_NO_MEMORY);' over all
the files (that was the error I was trying to catch), and then added a

#ifdef DEBUG
#define CAIRO_RETURN(_x) do { assert(0); return((_x)); } while (0)
#else
#define CAIRO_RETURN(_x) return((_x))
#endif

We could just #define it to be "return _cairo_return_status(_x)",
where that function would just return _x, but provide a natural place
to set a breakpoint with some if (ret != CAIRO_STATUS_SUCCESS) { ... }
code.  For opt builds the macro could just be a normal return.

    - Vlad


More information about the cairo mailing list