bug-gnu-utils
[Top][All Lists]
Advanced

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

gawk: redundant byte for each string [was: Question about gawk unofficia


From: Julian Foad
Subject: gawk: redundant byte for each string [was: Question about gawk unofficial patch]
Date: Wed, 09 Feb 2005 11:48:52 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8a6) Gecko/20050111

Aharon Robbins wrote:
We need r->wstlen + 1 elements, note the assigment of a L'\0'
after the memcpy.  The + 2 provides a little extra breathing room;
it's been a convention in gawk for ages, before I took over full
time maintanance even.  I've decided to continue using this convention
even though in theory it's enough to just use length + 1 everywhere.

Eugh. Yuck! Unless there is a reason for it (and I'm sure you recognise that "extra breathing room" isn't an argument - or do these strings breathe?), please consider breaking that convention. That sort of thing indicates that the programmer didn't understand the code that they wrote, and forces every reader to stop and think "What have I missed?" and carefully review all uses of the memory, and still feel uneasy about whether it is safe to mix them with standard strings.

I suspect you feel uneasy about removing the redundant bytes because you recognise that you would have to carefully review all of the uses first. Of course you don't need to feel responsible for changing it if it was already that way when you took over, but isn't it better for one person to do that now, than for every person who works on the code to go through that process in their head?

- Julian




reply via email to

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