As I understand it, you can compare void pointers because they just store addresses.
static int glist_dofinderror(t_glist *gl, void *error_object)
{
t_gobj *g;
for (g = gl->gl_list; g; g = g->g_next)
{
if ((void *)g == error_object)
{
/* got it... now show it. */
glist_noselect(gl);
canvas_vis(glist_getcanvas(gl), 1);
canvas_editmode(glist_getcanvas(gl), 1.);
glist_select(gl, g);
return (1);
}
else if (g->g_pd == canvas_class)
{
if (glist_dofinderror((t_canvas *)g, error_object))
return (1);
}
}
return (0);
}
this function takes a pointer to void (storing the address of an object) as its second argument void *error_object. It can't know what the type of that object is, because it's being called from somewhere else, and it could be any kind of Pd object. That somewhere else knows what kind of object it is and (more importantly) where that object's address is, and just passes that address in. Then t_gobj *g; traverses the canvas, and since the address of each object is known, each of those can be compared to the object address passed in until there's a match. This is kind of a way of getting around the usual strong typing in c; as long as we know from both ends of the transaction that we can get valid addresses of what we're interested in, there's no problem just comparing those addresses to see if we've found the same object.