qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v2 1/4] qjson: replace QString in JSONLexer with


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH v2 1/4] qjson: replace QString in JSONLexer with GString
Date: Wed, 25 Nov 2015 14:34:18 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0


On 25/11/2015 13:48, Markus Armbruster wrote:
> Where does the 3 come from?

My hat. :)  I don't know---it was in the old patches, and I just brought
it on.

Oh, found it.  GString adds 1 to the size (for the \0); allocating 4
bytes probably seemed like a good idea at the time.

However, it also computes the power of two that is >= size + 1, and
g_string_new uses 2 as the default length so it _also_ results in
allocating four bytes (ceil_pow2(2+1) == 4).

Paolo

> As long as g_string_truncate() doesn't reallocate, lexer->token will
> grow to hold the largest token seen so far, and stay there.
> 
> Why not MAX_TOKEN_SIZE and be done with it?  Oh, it's 64 MiB.  Ookay,
> I'd call that... generous.
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]