diff --git a/src/actions.cc b/src/actions.cc index d284697..e7cd291 100644 --- a/src/actions.cc +++ b/src/actions.cc @@ -14,7 +14,7 @@ #include "../dlib/dlib.hh" #include -static Dlist *link_actions = NULL; +static std::vector< Action * > link_actions; void action_parse(char *line) @@ -41,7 +41,7 @@ action_parse(char *line) action->label = dStrdup(label); action->cmd = dStrdup(cmd); - dList_append(link_actions, action); + link_actions.push_back( action ); } void @@ -49,8 +49,6 @@ a_Actions_init(void) { int n = dList_length(prefs.link_actions); - link_actions = dList_new(n); - for (int i = 0; i < n; i++) { char *line = reinterpret_cast< char * >( dList_nth_data(prefs.link_actions, i) ); if (line) @@ -58,7 +56,7 @@ a_Actions_init(void) } } -Dlist * +const std::vector< Action * > & a_Actions_link_get(void) { return link_actions; diff --git a/src/actions.hh b/src/actions.hh index 4e96afc..b674a65 100644 --- a/src/actions.hh +++ b/src/actions.hh @@ -12,11 +12,9 @@ #ifndef ACTIONS_H #define ACTIONS_H -#include "dlib/dlib.hh" +#include -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ +#include "dlib/dlib.hh" typedef struct { char *label; @@ -24,9 +22,6 @@ typedef struct { } Action; void a_Actions_init(void); -Dlist *a_Actions_link_get(void); +const std::vector< Action * > &a_Actions_link_get(); -#ifdef __cplusplus -} -#endif /* __cplusplus */ #endif /* ACTIONS_H*/ diff --git a/src/menu.cc b/src/menu.cc index d5ee62d..6cb2354 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -492,8 +492,8 @@ static Fl_Menu_Item *get_link_menu(void) if (link_menu != NULL) return link_menu; - Dlist *actions = a_Actions_link_get(); - int nactions = dList_length(actions); + const auto &actions = a_Actions_link_get(); + int nactions = actions.size(); /* Count static menu entries */ int nstatic = 0; @@ -511,7 +511,7 @@ static Fl_Menu_Item *get_link_menu(void) /* And append the dynamic ones */ for (int i = 0; i < nactions; i++) { - Action *action = (Action *) dList_nth_data(actions, i); + Action *action = actions.at( i ); struct link_menu_item *mitem = &link_menu_item[i]; mitem->url = NULL; /* Not known yet */ mitem->action = action;