From: Linus Torvalds <torvalds@linux-foundation.org>
To: Pierre Habouzit <madcoder@debian.org>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: Use of strbuf.buf when strbuf.len == 0
Date: Fri, 28 Sep 2007 17:51:36 -0700 (PDT) [thread overview]
Message-ID: <alpine.LFD.0.999.0709281746500.3579@woody.linux-foundation.org> (raw)
In-Reply-To: <20070927101300.GD10289@artemis.corp>
On Thu, 27 Sep 2007, Pierre Habouzit wrote:
>
> I can see a way, that would need special proof-reading of the strbuf
> module, but should not harm its users, that would be to change
> STRBUF_INIT to work this way:
>
> { .buf = "", .len = 0, .alloc = 0 }
I'd like to pipe up a bit here..
I think the above is a good fix for the current problem of wanting to
always be able to use "sb->buf", but I thinkit actually has the potential
to fix another issue entirely.
Namely strbuf's that are initialized from various static strings and/or
strings not directly allocated with malloc().
That's not necessarily something really unusual. Wanting to initialize a
string with a fixed constant value is a common problem.
And wouldn't it be nice if you could actually do that, with
{ .buf = "static initializer", .len = 18, .alloc = 0 }
and have all the strbuf routines that modify the initializer (including
making it shorter!) notice that the allocation is too short, and create a
new allocation?
Hmm?
Linus
next prev parent reply other threads:[~2007-09-29 0:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-27 6:21 Use of strbuf.buf when strbuf.len == 0 Junio C Hamano
2007-09-27 10:13 ` Pierre Habouzit
2007-09-27 10:51 ` [PATCH 1/2] double free in builtin-update-index.c Pierre Habouzit
2007-09-27 10:58 ` [PATCH 2/2] strbuf change: be sure ->buf is never ever NULL Pierre Habouzit
2007-09-29 0:51 ` Linus Torvalds [this message]
2007-09-29 7:48 ` Use of strbuf.buf when strbuf.len == 0 Pierre Habouzit
2007-09-27 11:22 ` Pierre Habouzit
2007-09-27 11:33 ` [PATCH 1/1] Make read_patch_file work on a strbuf Pierre Habouzit
2007-09-27 11:33 ` [PROPER PATCH " Pierre Habouzit
2007-09-27 11:37 ` Use of strbuf.buf when strbuf.len == 0 Pierre Habouzit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LFD.0.999.0709281746500.3579@woody.linux-foundation.org \
--to=torvalds@linux-foundation.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=madcoder@debian.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).