Commit bf1486af authored by Alexandre Julliard's avatar Alexandre Julliard

dnsapi: Use CRT memory allocation functions.

parent da65aa5b
...@@ -18,18 +18,18 @@ ...@@ -18,18 +18,18 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include <stdlib.h>
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
#include "winnls.h" #include "winnls.h"
#include "winternl.h" #include "winternl.h"
#include "wine/heap.h"
#include "wine/unixlib.h" #include "wine/unixlib.h"
static inline char *strdup_a( const char *src ) static inline char *strdup_a( const char *src )
{ {
char *dst; char *dst;
if (!src) return NULL; if (!src) return NULL;
dst = heap_alloc( (lstrlenA( src ) + 1) * sizeof(char) ); dst = malloc( (lstrlenA( src ) + 1) * sizeof(char) );
if (dst) lstrcpyA( dst, src ); if (dst) lstrcpyA( dst, src );
return dst; return dst;
} }
...@@ -38,7 +38,7 @@ static inline char *strdup_u( const char *src ) ...@@ -38,7 +38,7 @@ static inline char *strdup_u( const char *src )
{ {
char *dst; char *dst;
if (!src) return NULL; if (!src) return NULL;
dst = heap_alloc( (strlen( src ) + 1) * sizeof(char) ); dst = malloc( (strlen( src ) + 1) * sizeof(char) );
if (dst) strcpy( dst, src ); if (dst) strcpy( dst, src );
return dst; return dst;
} }
...@@ -47,7 +47,7 @@ static inline WCHAR *strdup_w( const WCHAR *src ) ...@@ -47,7 +47,7 @@ static inline WCHAR *strdup_w( const WCHAR *src )
{ {
WCHAR *dst; WCHAR *dst;
if (!src) return NULL; if (!src) return NULL;
dst = heap_alloc( (lstrlenW( src ) + 1) * sizeof(WCHAR) ); dst = malloc( (lstrlenW( src ) + 1) * sizeof(WCHAR) );
if (dst) lstrcpyW( dst, src ); if (dst) lstrcpyW( dst, src );
return dst; return dst;
} }
...@@ -58,7 +58,7 @@ static inline WCHAR *strdup_aw( const char *str ) ...@@ -58,7 +58,7 @@ static inline WCHAR *strdup_aw( const char *str )
if (str) if (str)
{ {
DWORD len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 ); DWORD len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
if ((ret = heap_alloc( len * sizeof(WCHAR) ))) if ((ret = malloc( len * sizeof(WCHAR) )))
MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len ); MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
} }
return ret; return ret;
...@@ -70,7 +70,7 @@ static inline WCHAR *strdup_uw( const char *str ) ...@@ -70,7 +70,7 @@ static inline WCHAR *strdup_uw( const char *str )
if (str) if (str)
{ {
DWORD len = MultiByteToWideChar( CP_UTF8, 0, str, -1, NULL, 0 ); DWORD len = MultiByteToWideChar( CP_UTF8, 0, str, -1, NULL, 0 );
if ((ret = heap_alloc( len * sizeof(WCHAR) ))) if ((ret = malloc( len * sizeof(WCHAR) )))
MultiByteToWideChar( CP_UTF8, 0, str, -1, ret, len ); MultiByteToWideChar( CP_UTF8, 0, str, -1, ret, len );
} }
return ret; return ret;
...@@ -82,7 +82,7 @@ static inline char *strdup_wa( const WCHAR *str ) ...@@ -82,7 +82,7 @@ static inline char *strdup_wa( const WCHAR *str )
if (str) if (str)
{ {
DWORD len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL ); DWORD len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL );
if ((ret = heap_alloc( len ))) if ((ret = malloc( len )))
WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL ); WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
} }
return ret; return ret;
...@@ -94,7 +94,7 @@ static inline char *strdup_wu( const WCHAR *str ) ...@@ -94,7 +94,7 @@ static inline char *strdup_wu( const WCHAR *str )
if (str) if (str)
{ {
DWORD len = WideCharToMultiByte( CP_UTF8, 0, str, -1, NULL, 0, NULL, NULL ); DWORD len = WideCharToMultiByte( CP_UTF8, 0, str, -1, NULL, 0, NULL, NULL );
if ((ret = heap_alloc( len ))) if ((ret = malloc( len )))
WideCharToMultiByte( CP_UTF8, 0, str, -1, ret, len, NULL, NULL ); WideCharToMultiByte( CP_UTF8, 0, str, -1, ret, len, NULL, NULL );
} }
return ret; return ret;
...@@ -107,7 +107,7 @@ static inline char *strdup_au( const char *src ) ...@@ -107,7 +107,7 @@ static inline char *strdup_au( const char *src )
if (ret) if (ret)
{ {
dst = strdup_wu( ret ); dst = strdup_wu( ret );
heap_free( ret ); free( ret );
} }
return dst; return dst;
} }
...@@ -119,7 +119,7 @@ static inline char *strdup_ua( const char *src ) ...@@ -119,7 +119,7 @@ static inline char *strdup_ua( const char *src )
if (ret) if (ret)
{ {
dst = strdup_wa( ret ); dst = strdup_wa( ret );
heap_free( ret ); free( ret );
} }
return dst; return dst;
} }
......
...@@ -47,8 +47,8 @@ BOOL WINAPI DnsNameCompare_A( PCSTR name1, PCSTR name2 ) ...@@ -47,8 +47,8 @@ BOOL WINAPI DnsNameCompare_A( PCSTR name1, PCSTR name2 )
ret = DnsNameCompare_W( name1W, name2W ); ret = DnsNameCompare_W( name1W, name2W );
heap_free( name1W ); free( name1W );
heap_free( name2W ); free( name2W );
return ret; return ret;
} }
...@@ -89,7 +89,7 @@ DNS_STATUS WINAPI DnsValidateName_A( PCSTR name, DNS_NAME_FORMAT format ) ...@@ -89,7 +89,7 @@ DNS_STATUS WINAPI DnsValidateName_A( PCSTR name, DNS_NAME_FORMAT format )
nameW = strdup_aw( name ); nameW = strdup_aw( name );
ret = DnsValidateName_W( nameW, format ); ret = DnsValidateName_W( nameW, format );
heap_free( nameW ); free( nameW );
return ret; return ret;
} }
...@@ -107,7 +107,7 @@ DNS_STATUS WINAPI DnsValidateName_UTF8( PCSTR name, DNS_NAME_FORMAT format ) ...@@ -107,7 +107,7 @@ DNS_STATUS WINAPI DnsValidateName_UTF8( PCSTR name, DNS_NAME_FORMAT format )
nameW = strdup_uw( name ); nameW = strdup_uw( name );
ret = DnsValidateName_W( nameW, format ); ret = DnsValidateName_W( nameW, format );
heap_free( nameW ); free( nameW );
return ret; return ret;
} }
......
...@@ -65,7 +65,7 @@ static DNS_STATUS do_query_netbios( PCSTR name, DNS_RECORDA **recp ) ...@@ -65,7 +65,7 @@ static DNS_STATUS do_query_netbios( PCSTR name, DNS_RECORDA **recp )
for (i = 0; i < header->node_count; i++) for (i = 0; i < header->node_count; i++)
{ {
record = heap_alloc_zero( sizeof(DNS_RECORDA) ); record = calloc( 1, sizeof(DNS_RECORDA) );
if (!record) if (!record)
{ {
status = ERROR_NOT_ENOUGH_MEMORY; status = ERROR_NOT_ENOUGH_MEMORY;
...@@ -156,7 +156,7 @@ DNS_STATUS WINAPI DnsQuery_A( PCSTR name, WORD type, DWORD options, PVOID server ...@@ -156,7 +156,7 @@ DNS_STATUS WINAPI DnsQuery_A( PCSTR name, WORD type, DWORD options, PVOID server
DnsRecordListFree( (DNS_RECORD *)resultW, DnsFreeRecordList ); DnsRecordListFree( (DNS_RECORD *)resultW, DnsFreeRecordList );
} }
heap_free( nameW ); free( nameW );
return status; return status;
} }
...@@ -246,7 +246,7 @@ DNS_STATUS WINAPI DnsQuery_W( PCWSTR name, WORD type, DWORD options, PVOID serve ...@@ -246,7 +246,7 @@ DNS_STATUS WINAPI DnsQuery_W( PCWSTR name, WORD type, DWORD options, PVOID serve
DnsRecordListFree( (DNS_RECORD *)resultA, DnsFreeRecordList ); DnsRecordListFree( (DNS_RECORD *)resultA, DnsFreeRecordList );
} }
heap_free( nameU ); free( nameU );
return status; return status;
} }
...@@ -306,8 +306,8 @@ static DNS_STATUS get_dns_server_list( IP4_ARRAY *out, DWORD *len ) ...@@ -306,8 +306,8 @@ static DNS_STATUS get_dns_server_list( IP4_ARRAY *out, DWORD *len )
} }
if (!ret) break; if (!ret) break;
if ((char *)servers != buf) heap_free( servers ); if ((char *)servers != buf) free( servers );
servers = heap_alloc( array_len ); servers = malloc( array_len );
if (!servers) if (!servers)
{ {
ret = ERROR_NOT_ENOUGH_MEMORY; ret = ERROR_NOT_ENOUGH_MEMORY;
...@@ -322,7 +322,7 @@ static DNS_STATUS get_dns_server_list( IP4_ARRAY *out, DWORD *len ) ...@@ -322,7 +322,7 @@ static DNS_STATUS get_dns_server_list( IP4_ARRAY *out, DWORD *len )
ret = ERROR_SUCCESS; ret = ERROR_SUCCESS;
err: err:
if ((char *)servers != buf) heap_free( servers ); if ((char *)servers != buf) free( servers );
return ret; return ret;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment