mem-pool: add mem_pool_strfmt()
commit8d25663d704d1216d2fd5db5fd3aa431b8c58268
authorRené Scharfe <l.s.r@web.de>
Sun, 25 Feb 2024 11:39:44 +0000 (25 12:39 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 26 Feb 2024 17:35:40 +0000 (26 09:35 -0800)
tree384ea573a038437501a38a4a6195ae52d21ef4ea
parent3c2a3fdc388747b9eaf4a4a4f2035c1c9ddb26d0
mem-pool: add mem_pool_strfmt()

Add a function for building a string, printf style, using a memory pool.
It uses the free space in the current block in the first attempt.  If
that suffices then the result can already be used without copying or
reformatting.

For strings that are significantly shorter on average than the block
size (ca. 1 MiB by default) this is the case most of the time, leading
to a better perfomance than a solution that doesn't access mem-pool
internals.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
mem-pool.c
mem-pool.h