From 7a774f75697eace8a419a18d8a1e107e3b226007 Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Mon, 10 May 2021 15:37:26 +0200 Subject: [PATCH] wpcap: Use CRT memory allocators. Signed-off-by: Hans Leidekker Signed-off-by: Alexandre Julliard --- dlls/wpcap/wpcap.c | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/dlls/wpcap/wpcap.c b/dlls/wpcap/wpcap.c index cb064512e08..3c959a9dbd7 100644 --- a/dlls/wpcap/wpcap.c +++ b/dlls/wpcap/wpcap.c @@ -26,7 +26,6 @@ #define USE_WS_PREFIX #include "winsock2.h" -#include "wine/heap.h" #include "wine/debug.h" #include "unixlib.h" @@ -34,22 +33,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(wpcap); const struct pcap_funcs *pcap_funcs = NULL; -static inline WCHAR *heap_strdupAtoW(const char *str) -{ - LPWSTR ret = NULL; - - if(str) { - DWORD len; - - len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0); - ret = heap_alloc(len*sizeof(WCHAR)); - if(ret) - MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len); - } - - return ret; -} - int CDECL wine_pcap_activate( void *handle ) { TRACE( "%p\n", handle ); @@ -124,6 +107,17 @@ void CDECL wine_pcap_dump( unsigned char *user, const void *hdr, const unsigned pcap_funcs->dump( user, hdr, packet ); } +static inline WCHAR *strdupAW( const char *str ) +{ + WCHAR *ret = NULL; + if (str) + { + int len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 ); + if ((ret = malloc( len * sizeof(WCHAR) ))) MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len ); + } + return ret; +} + void * CDECL wine_pcap_dump_open( void *handle, const char *filename ) { void *dumper; @@ -132,15 +126,15 @@ void * CDECL wine_pcap_dump_open( void *handle, const char *filename ) TRACE( "%p, %s\n", handle, debugstr_a(filename) ); - if (!(filenameW = heap_strdupAtoW( filename ))) return NULL; + if (!(filenameW = strdupAW( filename ))) return NULL; unix_path = wine_get_unix_file_name( filenameW ); - heap_free( filenameW ); + free( filenameW ); if (!unix_path) return NULL; TRACE( "unix_path %s\n", debugstr_a(unix_path) ); dumper = pcap_funcs->dump_open( handle, unix_path ); - heap_free( unix_path ); + RtlFreeHeap( GetProcessHeap(), 0, unix_path ); return dumper; }