Commit 7de7f9af authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

wldap32: Use the global memory allocation helpers.

parent e76066be
......@@ -276,8 +276,7 @@ INT CDECL ldap_create_vlv_controlW( WLDAP32_LDAP *ld, WLDAP32_LDAPVLVInfo *info,
static inline void bv_val_dup( const struct WLDAP32_berval *src, struct WLDAP32_berval *dst )
{
dst->bv_val = HeapAlloc( GetProcessHeap(), 0, src->bv_len );
if (dst->bv_val)
if ((dst->bv_val = heap_alloc( src->bv_len )))
{
memcpy( dst->bv_val, src->bv_val, src->bv_len );
dst->bv_len = src->bv_len;
......
......@@ -62,10 +62,9 @@ static char **split_hostnames( const char *hostnames )
p++;
}
res = HeapAlloc( GetProcessHeap(), 0, (i + 1) * sizeof(char *) );
if (!res)
if (!(res = heap_alloc( (i + 1) * sizeof(char *) )))
{
HeapFree( GetProcessHeap(), 0, str );
heap_free( str );
return NULL;
}
......@@ -74,7 +73,7 @@ static char **split_hostnames( const char *hostnames )
q = p;
i = 0;
while (*p)
{
if (p[1] != '\0')
......@@ -85,7 +84,7 @@ static char **split_hostnames( const char *hostnames )
res[i] = strdupU( q );
if (!res[i]) goto oom;
i++;
while (isspace( *p )) p++;
q = p;
}
......@@ -100,14 +99,14 @@ static char **split_hostnames( const char *hostnames )
}
res[i] = NULL;
HeapFree( GetProcessHeap(), 0, str );
heap_free( str );
return res;
oom:
while (i > 0) strfreeU( res[--i] );
HeapFree( GetProcessHeap(), 0, res );
HeapFree( GetProcessHeap(), 0, str );
heap_free( res );
heap_free( str );
return NULL;
}
......@@ -154,9 +153,7 @@ static char *join_hostnames( const char *scheme, char **hostnames, ULONG portnum
}
size += (i - 1) * strlen( sep );
res = HeapAlloc( GetProcessHeap(), 0, size + 1 );
if (!res) return NULL;
if (!(res = heap_alloc( size + 1 ))) return NULL;
p = res;
for (v = hostnames; *v; v++)
......
......@@ -99,17 +99,15 @@ static ULONG create_page_control( ULONG pagesize, struct WLDAP32_berval *cookie,
return WLDAP32_LDAP_NO_MEMORY;
/* copy the berval so it can be properly freed by the caller */
val = HeapAlloc( GetProcessHeap(), 0, berval->bv_len );
if (!val) return WLDAP32_LDAP_NO_MEMORY;
if (!(val = heap_alloc( berval->bv_len ))) return WLDAP32_LDAP_NO_MEMORY;
len = berval->bv_len;
memcpy( val, berval->bv_val, len );
ber_bvfree( berval );
ctrl = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPControlW) );
if (!ctrl)
if (!(ctrl = heap_alloc( sizeof(LDAPControlW) )))
{
HeapFree( GetProcessHeap(), 0, val );
heap_free( val );
return WLDAP32_LDAP_NO_MEMORY;
}
......
......@@ -156,8 +156,7 @@ static char *bv2str( struct berval *bv )
char *str = NULL;
unsigned int len = bv->bv_len;
str = HeapAlloc( GetProcessHeap(), 0, len + 1 );
if (str)
if ((str = heap_alloc( len + 1 )))
{
memcpy( str, bv->bv_val, len );
str[len] = '\0';
......@@ -176,8 +175,7 @@ static char **bv2str_array( struct berval **bv )
len++;
p++;
}
str = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(char *) );
if (!str) return NULL;
if (!(str = heap_alloc( (len + 1) * sizeof(char *) ))) return NULL;
p = bv;
while (*p)
......@@ -185,8 +183,8 @@ static char **bv2str_array( struct berval **bv )
str[i] = bv2str( *p );
if (!str[i])
{
while (i > 0) HeapFree( GetProcessHeap(), 0, str[--i] );
HeapFree( GetProcessHeap(), 0, str );
while (i > 0) heap_free( str[--i] );
heap_free( str );
return NULL;
}
i++;
......
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