MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / luaL_prepbuffsize

Function luaL_prepbuffsize

extlibs/sol3/include/sol/sol.hpp:3035–3051  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3033}
3034
3035COMPAT53_API char *luaL_prepbuffsize(luaL_Buffer_53 *B, size_t s) {
3036 if (B->capacity - B->nelems < s) { /* needs to grow */
3037 char* newptr = NULL;
3038 size_t newcap = B->capacity * 2;
3039 if (newcap - B->nelems < s)
3040 newcap = B->nelems + s;
3041 if (newcap < B->capacity) /* overflow */
3042 luaL_error(B->L2, "buffer too large");
3043 newptr = (char*)lua_newuserdata(B->L2, newcap);
3044 memcpy(newptr, B->ptr, B->nelems);
3045 if (B->ptr != B->b.buffer)
3046 lua_replace(B->L2, -2); /* remove old buffer */
3047 B->ptr = newptr;
3048 B->capacity = newcap;
3049 }
3050 return B->ptr + B->nelems;
3051}
3052
3053COMPAT53_API void luaL_addlstring(luaL_Buffer_53 *B, const char *s, size_t l) {
3054 memcpy(luaL_prepbuffsize(B, l), s, l);

Callers 1

luaL_addlstringFunction · 0.70

Calls 1

luaL_errorFunction · 0.85

Tested by

no test coverage detected