Skip to main content

luaur_vm/functions/
lua_l_addchar.rs

1//! `luaL_addchar` (VM/include/lualib.h macro) — append one byte to a
2//! `luaL_Strbuf`, growing it first if the inline/current buffer is full.
3
4use crate::functions::lua_l_prepbuffsize::lua_l_prepbuffsize;
5use crate::records::lua_l_strbuf::LuaLStrbuf;
6use core::ffi::c_char;
7
8pub unsafe fn lua_l_addchar(b: *mut LuaLStrbuf, c: c_char) {
9    if !((*b).p < (*b).end) {
10        lua_l_prepbuffsize(b, 1);
11    }
12    *(*b).p = c;
13    (*b).p = (*b).p.add(1);
14}