> -----Original Message-----
> From: Mike Frysinger [mailto:[email protected]]
> Sent: den 28 oktober 2009 10:13
> To: Peter Kjellerstedt
> Cc: [email protected]
> Subject: Re: Quick and dirty malloc() support for realpath.
> 
> On Wednesday 28 October 2009 04:57:01 Peter Kjellerstedt wrote:
> > From: Mike Frysinger
> >
> > [ cut ]
> >
> > > @@ -114,6 +114,8 @@ char got_path[];
> > >           while (*path != '\0' && *path != '/') {
> > >                   if (new_path > max_path) {
> > >                           __set_errno(ENAMETOOLONG);
> > > + err:
> > > +                         free(allocated_path);
> > >                           return NULL;
> >
> > Fore readability, wouldn't it be better to put the three lines
> > above at the end of the function, and just put another goto err
> > here? Or is there some other reason to have the error exit path
> > in the middle of the function?
> 
> i stated the reason for doing this in the part you "[ cut ]".  it was
> all of two sentences :P.
> -mike

Well, it wasn't in the code which explains why I didn't see it. ;)
 
[ Re-add the cut part: ]
> > > our friend goto solves the leak.  stick it in the middle of the file to 
> > > maximize short forward/backward jumps and we only get a small increase:

So, in effect it is an architecture specific optimization.
With that kind of optimization, isn't it a sign that the 
function is too long and should be split?

In any case, there should be a comment explaining why the exit path 
is in the middle of the function, or someone is bound to rearrange 
the code for readability at a later stage.

//Peter

_______________________________________________
uClibc mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/uclibc

Reply via email to