]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: lua: ensure the memory allocator is used all the time
authorWilly Tarreau <w@1wt.eu>
Wed, 12 Apr 2017 19:40:29 +0000 (21:40 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 13 Apr 2017 15:10:15 +0000 (17:10 +0200)
commit42ef75fb849daeda001aa6b7ad01d66091ef553a
treedcad4647aea4c6d33e8722ade12d8538ba21a978
parent04bf98149bacb4764ae9263fa30ab91dc7c595bc
MINOR: lua: ensure the memory allocator is used all the time

luaL_setstate() uses malloc() to initialize the first objects, and only
after this we replace the allocator. This creates trouble when replacing
the standard memory allocators during debugging sessions since the new
allocator is used to realloc() an area previously allocated using the
default malloc().

Lua provides lua_newstate() in addition to luaL_newstate(), which takes
an allocator for the initial malloc. This is exactly what we need, and
this patch does this and fixes the problem. The now useless call to
lua_setallocf() could be removed.

This has no impact outside of debugging sessions and there's no need to
backport this.
src/hlua.c