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

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

Re: gawk: redundant byte for each string [was: Question about gawk unoff


From: Aharon Robbins
Subject: Re: gawk: redundant byte for each string [was: Question about gawk unofficial patch]
Date: Wed, 9 Feb 2005 15:37:39 +0200

Julian,

You're probably right.  I, unfortunately, am just plain out of time.
There are around 42 instances of such in the gawk code at the moment,
not counting the glibc regex routines.  It's been this way for well
over 10 years, and I rather doubt those single extra bytes are
hurting anything.

Probably one day I'll do it, and then run gawk through valgrind to
see if I've missed anything.  But it's really low priority.

Arnold

> Date: Wed, 09 Feb 2005 11:48:52 +0000
> From: Julian Foad <address@hidden>
> Subject: gawk: redundant byte for each string [was: Question about gawk
>  unofficial patch]
>
>
> 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]