[Winpcap-users] Problem Freeing Array Returned by pcap_list_datalinks

Guy Harris guy at alum.mit.edu
Sun Sep 10 07:52:07 GMT 2006


Yaser Zhian wrote:

> The following code also generates the same failure:
> 
>  int * dltlist = 0;
>  int r = pcap_list_datalinks (m_capturehnd, &dltlist);
>  free (dltlist);
> 
> The problem occurs in the free() call. Am I doing something wrong?

No.

That code should work.  If it doesn't work, it's either

	1) a bug in WinPcap;

	2) a bug in the C runtime;

	3) possibly a result of WinPcap being built for a different version of 
the C runtime than your application (so that the version of malloc() 
called by pcap_list_datalinks() doesn't match the version of free() 
called by your application), but I'm not an expert in the MSVC++ C 
runtime so I don't know whether that could or would be the case (UN*X C 
runtimes tend not to come in as many flavors and tend not to have that 
particular problem).


More information about the Winpcap-users mailing list