Wow...do I feel stupid...hehe.<br>
<br>
It works now, and I can call freealldevs() in the Cleanup() code like I orignally had, and it doesn't crash anymore.<br>
<br>
Thank you very much Mr. Harris.<br><br><div><span class="gmail_quote">On 11/16/05, <b class="gmail_sendername">Guy Harris</b> &lt;<a href="mailto:guy@alum.mit.edu">guy@alum.mit.edu</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Eric Hansen wrote:<br><br>&gt; What I do, is store the info like so:<br>&gt;<br>&gt; cDevice[iCount] = d-&gt;name;<br><br>In C, that's not copying a string.&nbsp;&nbsp;That's copying the pointer *to* the<br>string.<br><br>Even in C++, it doesn't copy the string, it copies the pointer to the
<br>string - unless somehow operator overloading works on &quot;char *&quot;, causing<br>a copy of the string to be allocated and the copy assigned to<br>cDevice[iCount].<br><br>Unless somehow that operation causes a copy of the string pointed to by
<br>d-&gt;name to be made, and a pointer to that *copy* assigned to<br>cDevice[iCount], then cdevice[iCount] will *NOT* be valid after<br>pcap_freealldevs() is called.<br><br>Try doing<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cDevice[iCount] = strdup(d-&gt;name);
<br><br>instead (make sure you include &lt;string.h&gt; to declare strdup()).<br><br>(BTW, presumably you're growing the array if iCount is larger than its<br>current size, or quitting once iCount reaches the size of the array, right?)
<br><br>&gt; Then, when I goto list the info, I do this:<br>&gt;<br>&gt; for(i = 0; i &lt; iCount; i++){<br>&gt; m_devices.AddString(cDevice[i]);<br>&gt; }<br><br>Are you doing that *before* calling pcap_freealldevs()?&nbsp;&nbsp;If not, that
<br>won't work unless you're using strdup() to copy d-&gt;name (or whatever<br>language environment you're using does that, or the equivalent of that,<br>for you).<br>_______________________________________________<br>Winpcap-users mailing list
<br><a href="mailto:Winpcap-users@winpcap.org">Winpcap-users@winpcap.org</a><br><a href="https://www.winpcap.org/mailman/listinfo/winpcap-users">https://www.winpcap.org/mailman/listinfo/winpcap-users</a><br></blockquote></div>
<br><br clear="all"><br>-- <br><a href="http://tenshi.honeyblade.net">http://tenshi.honeyblade.net</a> (my poetry)<br><br>&quot;You wanted this ending to happen...ROMANTISUTO!&quot;