Re the problem caused by using the difference between ptrs:
initially I thought that the problem was that the difference between
raw pointers to stack/heap allocated objects could exceed
2^31 * sizeof(cairo_bo_event_t) and so not representable as an int.
But reading better the code the problem is that you're computing the
difference between addresses of objects of different types
(cairo_bo_start_event_t and cairo_bo_queue_event_t) using pointers to
another type (cairo_bo_event_t).
When the raw difference is not divisible by 'sizeof(cairo_bo_event_t)'
the result is random.
In C, technically, relational operations between pointers are defined
only for pointers to objects from the same array etc. (in C++ it is
possible to use std::less that hides the magic necessary to make it
well defined).
To be on the safe side you'd better cast the pointers to uintptr_t and
return -1 or 0 or 1 for <, ==, >.
Re the problem caused by using the difference between ptrs:
initially I thought that the problem was that the difference between cairo_bo_ event_t) and so not representable as an int.
raw pointers to stack/heap allocated objects could exceed
2^31 * sizeof(
But reading better the code the problem is that you're computing the bo_start_ event_t and cairo_bo_ queue_event_ t) using pointers to
difference between addresses of objects of different types
(cairo_
another type (cairo_bo_event_t).
When the raw difference is not divisible by 'sizeof( cairo_bo_ event_t) '
the result is random.
In C, technically, relational operations between pointers are defined
only for pointers to objects from the same array etc. (in C++ it is
possible to use std::less that hides the magic necessary to make it
well defined).
To be on the safe side you'd better cast the pointers to uintptr_t and
return -1 or 0 or 1 for <, ==, >.