Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-lysiuk committed Jan 5, 2024
1 parent b5a279c commit fc48f80
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Quake/imgui_lua_bindings/imgui_lua_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,20 @@ static ImVector<char> ioTextBuffer;
#define IOTEXT_ARG(name) \
size_t i_##name##_size; \
const char * i_##name##_const = luaL_checklstring(L, arg++, &(i_##name##_size)); \
const size_t bufferSize = (size_t)luaL_checknumber(L, arg); \
const lua_Integer bufferSizeInt = luaL_checkinteger(L, arg); \
static constexpr lua_Integer BUFFER_SIZE_MIN = 1024; \
static constexpr lua_Integer BUFFER_SIZE_MAX = 1024 * 1024; \
const size_t bufferSize = bufferSizeInt < BUFFER_SIZE_MIN ? BUFFER_SIZE_MIN : (bufferSizeInt > BUFFER_SIZE_MAX ? BUFFER_SIZE_MAX : bufferSizeInt); \
ioTextBuffer.resize(bufferSize); \
if (bufferSize <= i_##name##_size) \
if (bufferSize <= i_##name##_size) { \
i_##name##_size = bufferSize - 1; \
ioTextBuffer[i_##name##_size] = '\0'; \
} \
char* name = &ioTextBuffer[0]; \
strncpy(name, i_##name##_const, i_##name##_size);
if (i_##name##_size > 0) \
strncpy(name, i_##name##_const, i_##name##_size); \
else \
name[0] = '\0';

#define END_IOTEXT(name) \
const char* o_##name = name;\
Expand Down

0 comments on commit fc48f80

Please sign in to comment.