Currently, the priv_data member of struct item is of type void *, allowing map providers to tack any kind of data to their items. Consequently, the following function prototypes take a void * argument:
To add to the confusion, some map providers (notably route and route graph) tack the map rect's private data (a struct map_rect_priv) to each item. Thus, by examining the code, it is very easy to get confused about what is passed in the first argument of the above functions. Also, there doesn't really seem to be a convenient place to document function prototypes to be implemented by another dev.
Suggestion: change the type of priv_data to struct item_priv * and declare it as an incomplete type, to be implemented independently by each map provider.
Map providers who maintain item-specific private structs could then use this type.
If a map provider decides to stick a different struct to their items (as route.c does), this could be solved either by an explicit cast (though that's ugly) or, more elegantly, by doing:
which would be backward-comptaible with existing code.
Not a major issue—Navit still runs, but devs of future map plugins will likely appreciate the clarification (would have saved me a good deal of debugging).
Assigning to myself; I'll take care of it once my current traffic project approaches completion.
Issue migrated from trac ticket # 1361
component: core | priority: minor
2018-01-04 09:41:16: @mvglasow created the issue