From 895e9daf27c7e8dcfd5c4d7f5cf1b8edf20b6e11 Mon Sep 17 00:00:00 2001 From: mascarenhas Date: Wed, 16 Jan 2008 22:29:26 +0000 Subject: getcwd no longer passes a buffer --- src/lfs.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/lfs.c b/src/lfs.c index 8142c91..1fa0a5e 100644 --- a/src/lfs.c +++ b/src/lfs.c @@ -15,7 +15,7 @@ ** lfs.touch (filepath [, atime [, mtime]]) ** lfs.unlock (fh) ** -** $Id: lfs.c,v 1.43 2007/12/22 17:19:45 mascarenhas Exp $ +** $Id: lfs.c,v 1.44 2008/01/16 22:29:26 mascarenhas Exp $ */ #include @@ -100,16 +100,17 @@ static int change_dir (lua_State *L) { ** and a string describing the error */ static int get_dir (lua_State *L) { - char path[255+2]; - if (getcwd(path, 255) == NULL) { - lua_pushnil(L); - lua_pushstring(L, getcwd_error); - return 2; - } - else { - lua_pushstring(L, path); - return 1; - } + char *path; + if ((path = getcwd(NULL, 0)) == NULL) { + lua_pushnil(L) + lua_pushstring(L, getcwd_error); + return 2; + } + else { + lua_pushstring(L, path); + free(path); + return 1; + } } /* -- cgit v1.2.3-55-g6feb