summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReuben Thomas <rrt@sc3d.org>2012-10-04 18:59:27 +0100
committerReuben Thomas <rrt@sc3d.org>2012-10-04 18:59:27 +0100
commitba7c99ebf3758e8c9fba10f946a6b35e8d7b4fbf (patch)
tree964e03abc36967860834b6915cfc44c1baafd9f7
parentbb7fefc410b84fcfea40b0abc84383fd9d081f88 (diff)
downloadlrexlib-ba7c99ebf3758e8c9fba10f946a6b35e8d7b4fbf.tar.gz
common.c: remove last use of non-Lua state malloc
-rw-r--r--NEWS1
-rw-r--r--src/common.c4
2 files changed, 4 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 2ab071a..ecdb565 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,7 @@
* Allow POSIX REG_STARTEND to be used on any system supporting it.
* Add a test set for POSIX regex engine (thanks, Enrico Tassi).
* Simplify some code.
+ * Always use Lua state memory allocator.
2012-04-13 Release 2.6.0
diff --git a/src/common.c b/src/common.c
index 3ae87f0..fabbd80 100644
--- a/src/common.c
+++ b/src/common.c
@@ -28,7 +28,9 @@ void set_int_field (lua_State *L, const char* field, int val)
}
void *Lmalloc(lua_State *L, size_t size) {
- void *p = malloc(size);
+ void *ud;
+ lua_Alloc lalloc = lua_getallocf(L, &ud);
+ void *p = lalloc(L, NULL, 0, size);
if(p == NULL)
luaL_error(L, "malloc failed");
return p;