From: Guus Sliepen Date: Mon, 21 Apr 2014 18:49:28 +0000 (+0200) Subject: Temporarily add a global meshlink_handle_t *mesh. X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=98376916eae96a058d4291187d3960eeea218fee;p=meshlink Temporarily add a global meshlink_handle_t *mesh. This helps keeping the compiler happy while we refactor the global variables into meshlink_handle_t one by one. --- diff --git a/src/meshlink.c b/src/meshlink.c index d9da584a..6fe57c02 100644 --- a/src/meshlink.c +++ b/src/meshlink.c @@ -33,7 +33,13 @@ const char *meshlink_strerror(meshlink_errno_t errno) { return errstr[errno]; } +// TODO: hack, remove once all global variables are gone. +static void set_mesh(meshlink_handle_t *localmesh) { + mesh = localmesh; +} + static meshlink_handle_t *meshlink_setup(meshlink_handle_t *mesh) { + set_mesh(mesh); return mesh; } @@ -111,6 +117,7 @@ meshlink_handle_t *meshlink_open(const char *confbase, const char *name) { return meshlink_close(mesh), NULL; } + set_mesh(mesh); return mesh; } diff --git a/src/meshlink_internal.h b/src/meshlink_internal.h index fa1017d0..a41fa09b 100644 --- a/src/meshlink_internal.h +++ b/src/meshlink_internal.h @@ -52,4 +52,10 @@ struct meshlink_node { void *priv; }; +// This is a *temporary* global variable which will keep the compiler happy +// while refactoring the code to get rid of global variables. +// TODO: remove this when no other global variables remain. + +extern meshlink_handle_t *mesh; + #endif // MESHLINK_INTERNAL_H