aboutsummaryrefslogtreecommitdiff
path: root/luaconf.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-04-12 11:48:24 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-04-12 11:48:24 -0300
commit2d3f09544895b422eeecf89e0d108da8b8fcdfca (patch)
treedcbb636cecf51d52945c1b0bd378f07781c5b987 /luaconf.h
parentb0810c51c3f075cc8a309bfb3c1714ac42b0f020 (diff)
downloadlua-2d3f09544895b422eeecf89e0d108da8b8fcdfca.tar.gz
lua-2d3f09544895b422eeecf89e0d108da8b8fcdfca.tar.bz2
lua-2d3f09544895b422eeecf89e0d108da8b8fcdfca.zip
Avoid using large buffers in 'string.format'
The result of "string.format("%.99f", -1e308) is 410 characters long, but all other formats have much smaller limits (at most 99 plus a fex extras). This commit avoids 'string.format' asking for a buffer ~400 chars large when ~100 will do.
Diffstat (limited to 'luaconf.h')
-rw-r--r--luaconf.h9
1 files changed, 1 insertions, 8 deletions
diff --git a/luaconf.h b/luaconf.h
index 5c714d4e..76a61616 100644
--- a/luaconf.h
+++ b/luaconf.h
@@ -709,16 +709,9 @@
709 709
710/* 710/*
711@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. 711@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
712** CHANGE it if it uses too much C-stack space. (For long double,
713** 'string.format("%.99f", -1e4932)' needs 5052 bytes, so a
714** smaller buffer would force a memory allocation for each call to
715** 'string.format'.)
716*/ 712*/
717#if LUA_FLOAT_TYPE == LUA_FLOAT_LONGDOUBLE
718#define LUAL_BUFFERSIZE 8192
719#else
720#define LUAL_BUFFERSIZE ((int)(16 * sizeof(void*) * sizeof(lua_Number))) 713#define LUAL_BUFFERSIZE ((int)(16 * sizeof(void*) * sizeof(lua_Number)))
721#endif 714
722 715
723/* 716/*
724@@ LUAI_MAXALIGN defines fields that, when used in a union, ensure 717@@ LUAI_MAXALIGN defines fields that, when used in a union, ensure