Re: Use of strbuf.buf when strbuf.len == 0

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux