<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2658.24">
<TITLE>Crash bug - with fix</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=2>freeFeatureList (mapfile.c) frees a list recursively, so if you have a lot of things on the list it causes a stack fault. This happens (on my machine) with a line layer with overlays with about 4000 objects. It should be changed to free in a loop so that it doesn't blow out the stack. The old code and new fixed code is below. Can someone review it and check it in to CVS for me? Note my loop does change the order of freeing from last->first to first->last. It doesn't appear to matter in this situation.</FONT></P>
<P><FONT SIZE=2>// old code</FONT>
<BR><FONT SIZE=2>void freeFeatureList(featureListNodeObjPtr list)</FONT>
<BR><FONT SIZE=2>{</FONT>
<BR><FONT SIZE=2> if(list) {</FONT>
<BR><FONT SIZE=2> freeFeatureList(list->next); /* free any children */</FONT>
<BR><FONT SIZE=2> msFreeShape(&(list->shape));</FONT>
<BR><FONT SIZE=2> msFree(list);</FONT>
<BR><FONT SIZE=2> }</FONT>
<BR><FONT SIZE=2> return;</FONT>
<BR><FONT SIZE=2>}</FONT>
</P>
<P><FONT SIZE=2>// new fixed code</FONT>
<BR><FONT SIZE=2>void freeFeatureList(featureListNodeObjPtr list)</FONT>
<BR><FONT SIZE=2>{</FONT>
<BR> <FONT SIZE=2>featureListNodeObjPtr listNext = NULL;</FONT>
<BR> <FONT SIZE=2>while (list!=NULL)</FONT>
<BR> <FONT SIZE=2>{</FONT>
<BR> <FONT SIZE=2>listNext = list->next;</FONT>
<BR> <FONT SIZE=2>msFreeShape(&(list->shape));</FONT>
<BR> <FONT SIZE=2>msFree(list);</FONT>
<BR> <FONT SIZE=2>list = listNext;</FONT>
<BR> <FONT SIZE=2>}</FONT>
<BR><FONT SIZE=2>} </FONT>
</P>
<P><FONT SIZE=2>Thanks,</FONT>
<BR><FONT SIZE=2> </FONT>
<BR><FONT SIZE=2>Ned Harding</FONT>
<BR><FONT SIZE=2>Chief Technology Officer</FONT>
<BR><FONT SIZE=2>SRC - Extending the Reach of Micromarketing</FONT>
<BR><FONT SIZE=2>3825 Iris Ave Suite 150</FONT>
<BR><FONT SIZE=2>Boulder, CO 80303</FONT>
<BR><FONT SIZE=2>(303) 440-8896 x104</FONT>
</P>
<P><FONT SIZE=2><A HREF="http://www.extendthereach.com" TARGET="_blank">http://www.extendthereach.com</A> <<A HREF="http://www.extendthereach.com/" TARGET="_blank">http://www.extendthereach.com/</A>> </FONT>
</P>
<P><FONT SIZE=2>Technology in Action:</FONT>
</P>
<P><FONT SIZE=2><A HREF="http://www.DemographicsNow.com" TARGET="_blank">http://www.DemographicsNow.com</A> <<A HREF="http://www.demographicsnow.com/" TARGET="_blank">http://www.demographicsnow.com/</A>> </FONT>
</P>
</BODY>
</HTML>