Exporting shared data in C

Jannis Pohlmann info at sten-net.de
Fri Jul 28 02:45:55 CEST 2006

Hi all,

as we were just talking about libfrapmenu/libxfce4menu, I'd like to ask
the more experienced people how I can export global data which should
be shared between client applications.

E.g., we have the root menu (/etc/xdg/menus/applications.menu) which -
once it's loaded - should be shared among all other applications (e.g.
a menu panel plugin and the appfinder). Currently, the root menu is
defined static inside the function frap_menu_get_root:

  static FrapMenu* root = NULL;

  if (G_UNLIKELY (root == NULL))
       ... load menu ...

  return root;

Free'ing works by calling g_object_unref() on the returned object - the
last caller destroys the menu -, but at the moment all clients perform
the "... load menu ..." part. How can I avoid this?

Thanks in advance,

More information about the Xfce4-dev mailing list