]> mj.ucw.cz Git - libucw.git/commit
Added a new mempool primitive mp_spread().
authorMartin Mares <mj@ucw.cz>
Thu, 29 Mar 2007 08:48:06 +0000 (10:48 +0200)
committerMartin Mares <mj@ucw.cz>
Thu, 29 Mar 2007 08:48:06 +0000 (10:48 +0200)
commitbd4bf4734cf190c494caa3d283f2d9c3377e5dfa
treeb6a27b20c6955da944af1d62318d834fd2026e28
parent1645bab5164b42caf235e0bcfeb4b9833f6a6647
Added a new mempool primitive mp_spread().

Gradual construction of strings via the growing mempool interface was still
too complicated, so I have introduced a new primitive for this case and also
modified mp_end() to return a pointer to the beginning of the just closed
block (which gets optimized out if unused). This allows to write:

byte *p = mp_start(pool, 1);
for (...) {
p = mp_spread(pool, p, 2);
*p++ = ...;
}
*p++ = 0;
return mp_end(pool);

Pavel, if you agree, I will merge this into mainline.
lib/mempool.c
lib/mempool.h