Skip to content

Commit

Permalink
Cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
raphink committed Sep 24, 2015
1 parent f60fde0 commit 84c018a
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/auglua.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,14 @@
#include <lauxlib.h>
#include <stdbool.h>

typedef struct LuaAug {
augeas *aug;
} LuaAug;

static const char Key = 'k';

static augeas *checkaug(lua_State *L) {
lua_pushlightuserdata(L, (void *)&Key);
lua_gettable(L, LUA_REGISTRYINDEX);
augeas *b = (augeas *)lua_touserdata(L, -1); // Convert value
return b;
augeas *aug = (augeas *)lua_touserdata(L, -1); // Convert value
return aug;
}

static void lua_checkargs(lua_State *L, const char *name, int arity) {
Expand Down Expand Up @@ -470,6 +467,8 @@ struct lua_State *setup_lua(augeas *a) {
lua_State *L = luaL_newstate();
luaL_openlibs(L);

// lightuserdata is shared between libs
// do we really want to use that?
lua_pushlightuserdata(L, (void *)&Key);
lua_pushlightuserdata(L, (void *)a); // Push pointer
lua_settable(L, LUA_REGISTRYINDEX);
Expand Down

0 comments on commit 84c018a

Please sign in to comment.