String buffer refactoring, part 1.

Move string buffer handling to lj_buf.*.
Use common buffer resizing function.
This commit is contained in:
Mike Pall
2013-02-27 17:11:31 +01:00
parent d44337a566
commit 28cfcf7744
22 changed files with 197 additions and 184 deletions

View File

@@ -37,14 +37,4 @@ LJ_FUNC const char *lj_str_pushf(lua_State *L, const char *fmt, ...)
#endif
;
/* Resizable string buffers. Struct definition in lj_obj.h. */
LJ_FUNC char *lj_str_needbuf(lua_State *L, SBuf *sb, MSize sz);
#define lj_str_initbuf(sb) ((sb)->buf = NULL, (sb)->sz = 0)
#define lj_str_resetbuf(sb) ((sb)->n = 0)
#define lj_str_resizebuf(L, sb, size) \
((sb)->buf = (char *)lj_mem_realloc(L, (sb)->buf, (sb)->sz, (size)), \
(sb)->sz = (size))
#define lj_str_freebuf(g, sb) lj_mem_free(g, (void *)(sb)->buf, (sb)->sz)
#endif