Opened 5 years ago

Last modified 4 years ago

#1361 new defect/bug

item.priv_data type causes confusion

Reported by: mvglasow (2) Owned by: mvglasow (2)
Priority: minor Milestone: version 0.6.0
Component: core Version: git master
Severity: normal Keywords:


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:

typedef struct item_priv {
    struct map_rect_priv mr_priv;

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.

Change History (2)

comment:1 Changed 5 years ago by mvglasow (2)

  • Component changed from CI to core
  • Owner changed from jkoan to mvglasow (2)

comment:2 Changed 4 years ago by

  • Milestone changed from version 0.5.2 to version 0.6.0

Ticket retargeted after milestone closed

Note: See TracTickets for help on using tickets.