X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ucw%2Fmempool-fmt.c;h=4f81dd8b21a8857750755281ae032687ab72f0a0;hb=ae2b00416589dfe798fc40f0575f62a0c664798f;hp=e58ce275797bf6ed91dd2ff78c399cb01e72ddce;hpb=031256ad2e123eec58521f8e3eb9496c197641d2;p=libucw.git diff --git a/ucw/mempool-fmt.c b/ucw/mempool-fmt.c index e58ce275..4f81dd8b 100644 --- a/ucw/mempool-fmt.c +++ b/ucw/mempool-fmt.c @@ -8,8 +8,8 @@ * of the GNU Lesser General Public License. */ -#include "ucw/lib.h" -#include "ucw/mempool.h" +#include +#include #include #include @@ -37,7 +37,7 @@ mp_vprintf_at(struct mempool *mp, uns ofs, const char *fmt, va_list args) } else if ((uns)cnt >= mp_avail(mp) - ofs) { - ret = mp_grow(mp, cnt + 1) + ofs; + ret = mp_grow(mp, ofs + cnt + 1) + ofs; va_copy(args2, args); int cnt2 = vsnprintf(ret, cnt + 1, fmt, args2); va_end(args2); @@ -68,7 +68,7 @@ char * mp_vprintf_append(struct mempool *mp, char *ptr, const char *fmt, va_list args) { uns ofs = mp_open(mp, ptr); - ASSERT(ofs); + ASSERT(ofs && !ptr[ofs - 1]); return mp_vprintf_at(mp, ofs - 1, fmt, args); }