MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / addstr2buff

Function addstr2buff

3rd/lua-5.4.3/src/lobject.c:443–453  ·  view source on GitHub ↗

** Add 'str' to the buffer. If string is larger than the buffer space, ** push the string directly to the stack. */

Source from the content-addressed store, hash-verified

441** push the string directly to the stack.
442*/
443static void addstr2buff (BuffFS *buff, const char *str, size_t slen) {
444 if (slen <= BUFVFS) { /* does string fit into buffer? */
445 char *bf = getbuff(buff, cast_int(slen));
446 memcpy(bf, str, slen); /* add string to buffer */
447 addsize(buff, cast_int(slen));
448 }
449 else { /* string larger than buffer */
450 clearbuff(buff); /* string comes after buffer's content */
451 pushstr(buff, str, slen); /* push string */
452 }
453}
454
455
456/*

Callers 1

luaO_pushvfstringFunction · 0.85

Calls 3

getbuffFunction · 0.85
clearbuffFunction · 0.85
pushstrFunction · 0.85

Tested by

no test coverage detected