Abstract out some common buffer operations.

This commit is contained in:
Mike Pall
2013-04-26 19:20:21 +02:00
parent f9421f2b9f
commit a98e6a70c1
5 changed files with 24 additions and 17 deletions

View File

@@ -205,7 +205,7 @@ LJLIB_CF(os_date)
const char *q;
for (q = s; *q; q++)
sz += (*q == '%') ? 30 : 1; /* Overflow doesn't matter. */
setmref(sb->L, L);
setsbufL(sb, L);
for (;;) {
char *buf = lj_buf_need(sb, sz);
size_t len = strftime(buf, sbufsz(sb), s, stm);