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. >