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> <<a href="mailto:guy@alum.mit.edu">guy@alum.mit.edu</a>> 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>> What I do, is store the info like so:<br>><br>> cDevice[iCount] = d->name;<br><br>In C, that's not copying a string. 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 "char *", 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->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> cDevice[iCount] = strdup(d->name);
<br><br>instead (make sure you include <string.h> 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>> Then, when I goto list the info, I do this:<br>><br>> for(i = 0; i < iCount; i++){<br>> m_devices.AddString(cDevice[i]);<br>> }<br><br>Are you doing that *before* calling pcap_freealldevs()? If not, that
<br>won't work unless you're using strdup() to copy d->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>"You wanted this ending to happen...ROMANTISUTO!"