gnustep-dev
[Top][All Lists]
Advanced

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

Re: Release ready?


From: Richard Frith-Macdonald
Subject: Re: Release ready?
Date: Sat, 14 Jun 2008 05:46:27 +0100


On 14 Jun 2008, at 04:22, Adam Fedor wrote:

I'll branch a new stable release tomorrow unless anyone has any objections.

Sounds good.

Just one thing though ...

In base/Source/Additions/Unicode.m I've changed the GROW() macro for the case where characterset conversion output is being discarded (we are just finding the length of a string in a particular encoding) to try to fix a crash that David Wetzel found. It would be good if someone could sanity check and confirm that the new code:
    ptr = buf - dpos; \
    bsize = dpos + BUFSIZ; \
    if (extra != 0) \
      { \
        bsize--; \
      } \
is finally correct.

buf is an on-stack temporary storage area of size BUFSIZ
ptr is the start of the buffer we are writing output to
dpos is the write offset in ptr
bsize is the size of the buffer ptr
if extra is non-zero, we are leaving space for a nul terminator

GROW() is called when adding bytes to the buffer would take dpos beyond bsize. The number of bytes added should never be more than eight at any one time (the maximum length of a utf-8 representation of a unicode character), so the macro should only be called when dpos >= bsize - 8

The rationale is that, as we are calculating string length rather than producing an output string, we can use buf as the physical storage for a sliding window into the virtual output buffer, thus avoiding having to make expensive calls to malloc/realloc growing a big physical buffer which will only be discarded. So here GROW() should be adjusting ptr and bsize so that converted output is actually all written into buf.





reply via email to

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