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