Re: [PATCHv6 1/4] Read (but not write) from $XDG_CONFIG_HOME/git/config file
- From
- nguyenhu@minatec.inpg.fr <nguyenhu@minatec.inpg.fr>
- Date
- Jun 9, 2012, 10:53 UTC
- Message-ID
- <20120609125336.Horde.iUq0R3wdC4BP0yswpGlGBZA@webmail.minatec.grenoble-inp.fr>
- In-Reply-To
- <7vvcj1dep7.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> a écrit :
Show 20 quoted lines
>> char *mkpathdup(const char *fmt, ...)
>> {
>> char *path;
>> struct strbuf sb = STRBUF_INIT;
>> va_list args;
>>
>> va_start(args, fmt);
>> strbuf_vaddf(&sb, fmt, args);
>> va_end(args);
>> path = sb.buf;
>>
>> strbuf_release(&sb);
>> return xstrdup(cleanup_path(path));
>> }
>
> Modulo
>
> path = strbuf_detach(&sb, NULL);
>
> that is more or less what I meant.So now the mkpathdup() function looks like:
char *mkpathdup(const char *fmt, ...)
{
char *path;
struct strbuf sb = STRBUF_INIT;
va_list args;va_start(args, fmt); strbuf_vaddf(&sb, fmt, args); va_end(args); path = strbuf_detach(&sb, NULL);
strbuf_release(&sb); return path; }
This new variation of mkpathdup() function both fix the bug addressed by commit 05bab3ea and avoid the use of bounded buffer.