Commit bf1486af authored by Alexandre Julliard's avatar Alexandre Julliard

dnsapi: Use CRT memory allocation functions.

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