Re: [PATCH 2/2] --pretty=format: on-demand format expansion
- From
René Scharfe <rene.scharfe@lsrfire.ath.cx>
- Date
- Nov 10, 2007, 16:24 UTC
- Message-ID
- <4735DB3A.2020905@lsrfire.ath.cx>
- In-Reply-To
- <Pine.LNX.4.64.0711101605560.4362@racer.site>
Johannes Schindelin schrieb:
Show 12 quoted lines
> Hi, > > On Sat, 10 Nov 2007, René Scharfe wrote: > >> [...] have cooked up a different one on top of a cleaned up version of >> mine. It plays the dirty trick of reading expansions of repeated >> placeholders from the strbuf.. > > ... which would not work (likely even segfault) if you work with the same > private data on different strbufs. > > But I guess it will not matter much in practice.
Only a single strbuf is used, and the function that copies the data around, strbuf_adddup(), operates on a single strbuf, only. Copying data between two strbufs using strbuf_add() etc. would be safe.
What one should *not* do is this:
strbuf_add(sb, sb->buf + offset, length);
This leads to problems when the buffer is realloc()ated by strbuf_add().
What other things can go wrong? A segfault would definitely matter..
Thanks, René