[Mapserver-dev] [PATCH] mapraster.c - fixing memory leaks

Mladen Turk mturk at apache.org
Wed Jun 16 14:36:31 EDT 2004


This is a multi-part message in MIME format.

------=_NextPart_000_0022_01C453E1.9795F230
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit



> -----Original Message-----
> Subject: Re: [Mapserver-dev] [PATCH] mapraster.c - fixing memory leaks
> 
> Steve Lime wrote:
> > Patch aside, what do folks think about using goto's? They seem a great
> > help with things like clean-up. However there's not one in the code
> > presently so I was wondering if there's a bias...
> >
> 
> I've always avoided them because I was told way back when by some profs
> that they were evil, but I guess if they're properly used they could
> help keep the code cleaner sometimes.
> 

They are evil perhaps if used instead of standard if/then/else or switch
statements.

> If we use them then I think it should only be when absolutely necessary.

Sure, no need to use them everywhere, just for long functions (another big
evil :).

>   It is generally possible to structure a function so that you can
> properly cleanup without the use of gotos and without increasing
> complexity.
> 

Sure it is. The problem is that the number of "if's" rises in that case.
Try running few of the source files with:
"indent -i4 -npsl -di0 -br -nce -d0 -cli0 -npcs -nfc1 -nut -ncs -l72"

I have 1600x1200 monitor, but few lies are more then 200 chars :).

So it's just the coding convention. 

In my patch I've used the goto, although I could just duplicate the object
cleanup before each return, or build a cleanup function, etc...
IMHO using goto's gives a little easier code to read.

MT.

------=_NextPart_000_0022_01C453E1.9795F230
Content-Type: application/x-pkcs7-signature;
	name="smime.p7s"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
	filename="smime.p7s"

MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIJADCCAogw
ggHxoAMCAQICAwxGPTANBgkqhkiG9w0BAQQFADBiMQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhh
d3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNvbmFsIEZyZWVt
YWlsIElzc3VpbmcgQ0EwHhcNMDQwNTA4MTc0OTIyWhcNMDU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