diff options
Diffstat (limited to 'capture-wpcap.c')
-rw-r--r-- | capture-wpcap.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/capture-wpcap.c b/capture-wpcap.c index 66bfc3652a..90baec774b 100644 --- a/capture-wpcap.c +++ b/capture-wpcap.c @@ -111,6 +111,10 @@ static int (*p_pcap_list_datalinks)(pcap_t *, int **); static int (*p_pcap_set_datalink)(pcap_t *, int); #endif +#ifdef HAVE_FREE_DATALINKS +static int (*p_pcap_free_datalinks)(int *); +#endif + typedef struct { const char *name; gpointer *ptr; @@ -174,6 +178,9 @@ load_wpcap(void) #ifdef HAVE_PCAP_SET_DATALINK SYM(pcap_set_datalink, FALSE), #endif +#ifdef HAVE_PCAP_FREE_DATALINKS + SYM(pcap_free_datalinks, TRUE), +#endif { NULL, NULL, FALSE } }; @@ -503,6 +510,25 @@ pcap_list_datalinks(pcap_t *p, int **ddlt) } #endif +#ifdef HAVE_PCAP_FREE_DATALINKS +void +pcap_free_datalinks(int *ddlt) +{ + g_assert(has_wpcap); + + /* + * If we don't have pcap_free_datalinks() in WinPcap, + * we don't free the memory - we can't use free(), as + * we might not have been built with the same version + * of the C runtime library as WinPcap was, and, if we're + * not, free() isn't guaranteed to work on something + * allocated by WinPcap. + */ + if (p_pcap_free_datalinks != NULL) + p_pcap_free_datalinks(ddlt); +} +#endif + #ifdef HAVE_PCAP_DATALINK_VAL_TO_NAME const char * pcap_datalink_val_to_name(int dlt) |