avoid 'Agobj_t' casts
There are a number of places in the code where an Agedge_t*
, Agraph_t*
, or Agnode_t*
is cast to a Agobj_t*
. We should probably refactor these to use the base
member instead:
-(Agobj_t*)ptr
+&ptr->base
This has no effect on semantics (though it’s possible the current casts are a form of UB), but it improves safety. In particular, the current casts let you discard const-ness and also accidentally pass in something that isn’t one of the above 3 types, with the compiler having no way of knowing you didn’t intend this. C casts are unfortunately a bit of a heavy hammer in this respect.