[PATCH] wldap32: Use the global memory allocation helpers.

Hans Leidekker hans at codeweavers.com
Tue Feb 20 05:06:10 CST 2018


Signed-off-by: Hans Leidekker <hans at codeweavers.com>
---
 dlls/wldap32/control.c |   3 +-
 dlls/wldap32/init.c    |  19 +++---
 dlls/wldap32/page.c    |   8 +--
 dlls/wldap32/value.c   |  10 ++-
 dlls/wldap32/wldap32.h | 175 ++++++++++++++++++-------------------------------
 5 files changed, 81 insertions(+), 134 deletions(-)

diff --git a/dlls/wldap32/control.c b/dlls/wldap32/control.c
index b9d7b3b8f5..1ec8641847 100644
--- a/dlls/wldap32/control.c
+++ b/dlls/wldap32/control.c
@@ -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;
diff --git a/dlls/wldap32/init.c b/dlls/wldap32/init.c
index 6b413f8437..fdb79084b5 100644
--- a/dlls/wldap32/init.c
+++ b/dlls/wldap32/init.c
@@ -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++)
diff --git a/dlls/wldap32/page.c b/dlls/wldap32/page.c
index 15d5119902..7cf7d93245 100644
--- a/dlls/wldap32/page.c
+++ b/dlls/wldap32/page.c
@@ -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;
     }
 
diff --git a/dlls/wldap32/value.c b/dlls/wldap32/value.c
index 69ab040072..bcfa9a2f6b 100644
--- a/dlls/wldap32/value.c
+++ b/dlls/wldap32/value.c
@@ -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++;
diff --git a/dlls/wldap32/wldap32.h b/dlls/wldap32/wldap32.h
index 55852a6617..1d4052002a 100644
--- a/dlls/wldap32/wldap32.h
+++ b/dlls/wldap32/wldap32.h
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#include "wine/heap.h"
 #include "wine/unicode.h"
 
 extern HINSTANCE hwldap32 DECLSPEC_HIDDEN;
@@ -31,22 +32,16 @@ ULONG map_error( int ) DECLSPEC_HIDDEN;
 static inline char *strdupU( const char *src )
 {
     char *dst;
-
     if (!src) return NULL;
-    dst = HeapAlloc( GetProcessHeap(), 0, (strlen( src ) + 1) * sizeof(char) );
-    if (dst)
-        strcpy( dst, src );
+    if ((dst = heap_alloc( (strlen( src ) + 1) * sizeof(char) ))) strcpy( dst, src );
     return dst;
 }
 
 static inline WCHAR *strdupW( const WCHAR *src )
 {
     WCHAR *dst;
-
     if (!src) return NULL;
-    dst = HeapAlloc( GetProcessHeap(), 0, (strlenW( src ) + 1) * sizeof(WCHAR) );
-    if (dst)
-        strcpyW( dst, src );
+    if ((dst = heap_alloc( (strlenW( src ) + 1) * sizeof(WCHAR) ))) strcpyW( dst, src );
     return dst;
 }
 
@@ -56,7 +51,7 @@ static inline LPWSTR strAtoW( LPCSTR str )
     if (str)
     {
         DWORD len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
-        if ((ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
+        if ((ret = heap_alloc( len * sizeof(WCHAR) )))
             MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
     }
     return ret;
@@ -68,7 +63,7 @@ static inline LPSTR strWtoA( LPCWSTR str )
     if (str)
     {
         DWORD len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL );
-        if ((ret = HeapAlloc( GetProcessHeap(), 0, len )))
+        if ((ret = heap_alloc( len )))
             WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
     }
     return ret;
@@ -80,7 +75,7 @@ static inline char *strWtoU( LPCWSTR str )
     if (str)
     {
         DWORD len = WideCharToMultiByte( CP_UTF8, 0, str, -1, NULL, 0, NULL, NULL );
-        if ((ret = HeapAlloc( GetProcessHeap(), 0, len )))
+        if ((ret = heap_alloc( len )))
             WideCharToMultiByte( CP_UTF8, 0, str, -1, ret, len, NULL, NULL );
     }
     return ret;
@@ -92,7 +87,7 @@ static inline LPWSTR strUtoW( char *str )
     if (str)
     {
         DWORD len = MultiByteToWideChar( CP_UTF8, 0, str, -1, NULL, 0 );
-        if ((ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
+        if ((ret = heap_alloc( len * sizeof(WCHAR) )))
             MultiByteToWideChar( CP_UTF8, 0, str, -1, ret, len );
     }
     return ret;
@@ -100,17 +95,17 @@ static inline LPWSTR strUtoW( char *str )
 
 static inline void strfreeA( LPSTR str )
 {
-    HeapFree( GetProcessHeap(), 0, str );
+    heap_free( str );
 }
 
 static inline void strfreeW( LPWSTR str )
 {
-    HeapFree( GetProcessHeap(), 0, str );
+    heap_free( str );
 }
 
 static inline void strfreeU( char *str )
 {
-    HeapFree( GetProcessHeap(), 0, str );
+    heap_free( str );
 }
 
 static inline DWORD strarraylenA( LPSTR *strarray )
@@ -142,9 +137,7 @@ static inline LPWSTR *strarrayAtoW( LPSTR *strarray )
     if (strarray)
     {
         size  = sizeof(WCHAR*) * (strarraylenA( strarray ) + 1);
-        strarrayW = HeapAlloc( GetProcessHeap(), 0, size );
-
-        if (strarrayW)
+        if ((strarrayW = heap_alloc( size )))
         {
             LPSTR *p = strarray;
             LPWSTR *q = strarrayW;
@@ -164,9 +157,7 @@ static inline LPSTR *strarrayWtoA( LPWSTR *strarray )
     if (strarray)
     {
         size = sizeof(LPSTR) * (strarraylenW( strarray ) + 1);
-        strarrayA = HeapAlloc( GetProcessHeap(), 0, size );
-
-        if (strarrayA)
+        if ((strarrayA = heap_alloc( size )))
         {
             LPWSTR *p = strarray;
             LPSTR *q = strarrayA;
@@ -186,9 +177,7 @@ static inline char **strarrayWtoU( LPWSTR *strarray )
     if (strarray)
     {
         size = sizeof(char*) * (strarraylenW( strarray ) + 1);
-        strarrayU = HeapAlloc( GetProcessHeap(), 0, size );
-
-        if (strarrayU)
+        if ((strarrayU = heap_alloc( size )))
         {
             LPWSTR *p = strarray;
             char **q = strarrayU;
@@ -208,9 +197,7 @@ static inline LPWSTR *strarrayUtoW( char **strarray )
     if (strarray)
     {
         size = sizeof(WCHAR*) * (strarraylenU( strarray ) + 1);
-        strarrayW = HeapAlloc( GetProcessHeap(), 0, size );
-
-        if (strarrayW)
+        if ((strarrayW = heap_alloc( size )))
         {
             char **p = strarray;
             LPWSTR *q = strarrayW;
@@ -228,7 +215,7 @@ static inline void strarrayfreeA( LPSTR *strarray )
     {
         LPSTR *p = strarray;
         while (*p) strfreeA( *p++ );
-        HeapFree( GetProcessHeap(), 0, strarray );
+        heap_free( strarray );
     }
 }
 
@@ -238,7 +225,7 @@ static inline void strarrayfreeW( LPWSTR *strarray )
     {
         LPWSTR *p = strarray;
         while (*p) strfreeW( *p++ );
-        HeapFree( GetProcessHeap(), 0, strarray );
+        heap_free( strarray );
     }
 }
 
@@ -248,7 +235,7 @@ static inline void strarrayfreeU( char **strarray )
     {
         char **p = strarray;
         while (*p) strfreeU( *p++ );
-        HeapFree( GetProcessHeap(), 0, strarray );
+        heap_free( strarray );
     }
 }
 
@@ -259,8 +246,7 @@ static inline struct berval *bvdup( struct berval *bv )
     struct berval *berval;
     DWORD size = sizeof(struct berval) + bv->bv_len;
 
-    berval = HeapAlloc( GetProcessHeap(), 0, size );
-    if (berval)
+    if ((berval = heap_alloc( size )))
     {
         char *val = (char *)berval + sizeof(struct berval);
 
@@ -286,9 +272,7 @@ static inline struct berval **bvarraydup( struct berval **bv )
     if (bv)
     {
         size = sizeof(struct berval *) * (bvarraylen( bv ) + 1);
-        berval = HeapAlloc( GetProcessHeap(), 0, size );
-
-        if (berval)
+        if ((berval = heap_alloc( size )))
         {
             struct berval **p = bv;
             struct berval **q = berval;
@@ -303,16 +287,15 @@ static inline struct berval **bvarraydup( struct berval **bv )
 static inline void bvarrayfree( struct berval **bv )
 {
     struct berval **p = bv;
-    while (*p) HeapFree( GetProcessHeap(), 0, *p++ );
-    HeapFree( GetProcessHeap(), 0, bv );
+    while (*p) heap_free( *p++ );
+    heap_free( bv );
 }
 
 static inline LDAPModW *modAtoW( LDAPModA *mod )
 {
     LDAPModW *modW;
 
-    modW = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPModW) );
-    if (modW)
+    if ((modW = heap_alloc( sizeof(LDAPModW) )))
     {
         modW->mod_op = mod->mod_op;
         modW->mod_type = strAtoW( mod->mod_type );
@@ -329,8 +312,7 @@ static inline LDAPMod *modWtoU( LDAPModW *mod )
 {
     LDAPMod *modU;
 
-    modU = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPMod) );
-    if (modU)
+    if ((modU = heap_alloc( sizeof(LDAPMod) )))
     {
         modU->mod_op = mod->mod_op;
         modU->mod_type = strWtoU( mod->mod_type );
@@ -349,7 +331,7 @@ static inline void modfreeW( LDAPModW *mod )
         bvarrayfree( mod->mod_vals.modv_bvals );
     else
         strarrayfreeW( mod->mod_vals.modv_strvals );
-    HeapFree( GetProcessHeap(), 0, mod );
+    heap_free( mod );
 }
 
 static inline void modfreeU( LDAPMod *mod )
@@ -358,7 +340,7 @@ static inline void modfreeU( LDAPMod *mod )
         bvarrayfree( mod->mod_vals.modv_bvals );
     else
         strarrayfreeU( mod->mod_vals.modv_strvals );
-    HeapFree( GetProcessHeap(), 0, mod );
+    heap_free( mod );
 }
 
 static inline DWORD modarraylenA( LDAPModA **modarray )
@@ -383,9 +365,7 @@ static inline LDAPModW **modarrayAtoW( LDAPModA **modarray )
     if (modarray)
     {
         size = sizeof(LDAPModW*) * (modarraylenA( modarray ) + 1);
-        modarrayW = HeapAlloc( GetProcessHeap(), 0, size );
-
-        if (modarrayW)
+        if ((modarrayW = heap_alloc( size )))
         {
             LDAPModA **p = modarray;
             LDAPModW **q = modarrayW;
@@ -405,9 +385,7 @@ static inline LDAPMod **modarrayWtoU( LDAPModW **modarray )
     if (modarray)
     {
         size = sizeof(LDAPMod*) * (modarraylenW( modarray ) + 1);
-        modarrayU = HeapAlloc( GetProcessHeap(), 0, size );
-
-        if (modarrayU)
+        if ((modarrayU = heap_alloc( size )))
         {
             LDAPModW **p = modarray;
             LDAPMod **q = modarrayU;
@@ -425,7 +403,7 @@ static inline void modarrayfreeW( LDAPModW **modarray )
     {
         LDAPModW **p = modarray;
         while (*p) modfreeW( *p++ );
-        HeapFree( GetProcessHeap(), 0, modarray );
+        heap_free( modarray );
     }
 }
 
@@ -435,7 +413,7 @@ static inline void modarrayfreeU( LDAPMod **modarray )
     {
         LDAPMod **p = modarray;
         while (*p) modfreeU( *p++ );
-        HeapFree( GetProcessHeap(), 0, modarray );
+        heap_free( modarray );
     }
 }
 
@@ -447,15 +425,13 @@ static inline LDAPControlW *controlAtoW( LDAPControlA *control )
 
     if (control->ldctl_value.bv_val)
     {
-        val = HeapAlloc( GetProcessHeap(), 0, len );
-        if (!val) return NULL;
+        if (!(val = heap_alloc( len ))) return NULL;
         memcpy( val, control->ldctl_value.bv_val, len );
     }
 
-    controlW = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPControlW) );
-    if (!controlW)
+    if (!(controlW = heap_alloc( sizeof(LDAPControlW) )))
     {
-        HeapFree( GetProcessHeap(), 0, val );
+        heap_free( val );
         return NULL;
     }
 
@@ -475,15 +451,13 @@ static inline LDAPControlA *controlWtoA( LDAPControlW *control )
 
     if (control->ldctl_value.bv_val)
     {
-        val = HeapAlloc( GetProcessHeap(), 0, len );
-        if (!val) return NULL;
+        if (!(val = heap_alloc( len ))) return NULL;
         memcpy( val, control->ldctl_value.bv_val, len );
     }
 
-    controlA = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPControlA) );
-    if (!controlA)
+    if (!(controlA = heap_alloc( sizeof(LDAPControlA) )))
     {
-        HeapFree( GetProcessHeap(), 0, val );
+        heap_free( val );
         return NULL;
     }
 
@@ -503,15 +477,13 @@ static inline LDAPControl *controlWtoU( LDAPControlW *control )
 
     if (control->ldctl_value.bv_val)
     {
-        val = HeapAlloc( GetProcessHeap(), 0, len );
-        if (!val) return NULL;
+        if (!(val = heap_alloc( len ))) return NULL;
         memcpy( val, control->ldctl_value.bv_val, len );
     }
 
-    controlU = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPControl) );
-    if (!controlU)
+    if (!(controlU = heap_alloc( sizeof(LDAPControl) )))
     {
-        HeapFree( GetProcessHeap(), 0, val );
+        heap_free( val );
         return NULL;
     }
 
@@ -531,15 +503,13 @@ static inline LDAPControlW *controlUtoW( LDAPControl *control )
 
     if (control->ldctl_value.bv_val)
     {
-        val = HeapAlloc( GetProcessHeap(), 0, len );
-        if (!val) return NULL;
+        if (!(val = heap_alloc( len ))) return NULL;
         memcpy( val, control->ldctl_value.bv_val, len );
     }
 
-    controlW = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPControlW) );
-    if (!controlW)
+    if (!(controlW = heap_alloc( sizeof(LDAPControlW) )))
     {
-        HeapFree( GetProcessHeap(), 0, val );
+        heap_free( val );
         return NULL;
     }
 
@@ -547,7 +517,7 @@ static inline LDAPControlW *controlUtoW( LDAPControl *control )
     controlW->ldctl_value.bv_len = len; 
     controlW->ldctl_value.bv_val = val; 
     controlW->ldctl_iscritical = control->ldctl_iscritical;
- 
+
     return controlW;
 }
 
@@ -556,8 +526,8 @@ static inline void controlfreeA( LDAPControlA *control )
     if (control)
     {
         strfreeA( control->ldctl_oid );
-        HeapFree( GetProcessHeap(), 0, control->ldctl_value.bv_val );
-        HeapFree( GetProcessHeap(), 0, control );
+        heap_free( control->ldctl_value.bv_val );
+        heap_free( control );
     }
 }
 
@@ -566,8 +536,8 @@ static inline void controlfreeW( LDAPControlW *control )
     if (control)
     {
         strfreeW( control->ldctl_oid );
-        HeapFree( GetProcessHeap(), 0, control->ldctl_value.bv_val );
-        HeapFree( GetProcessHeap(), 0, control );
+        heap_free( control->ldctl_value.bv_val );
+        heap_free( control );
     }
 }
 
@@ -576,8 +546,8 @@ static inline void controlfreeU( LDAPControl *control )
     if (control)
     {
         strfreeU( control->ldctl_oid );
-        HeapFree( GetProcessHeap(), 0, control->ldctl_value.bv_val );
-        HeapFree( GetProcessHeap(), 0, control );
+        heap_free( control->ldctl_value.bv_val );
+        heap_free( control );
     }
 }
 
@@ -610,9 +580,7 @@ static inline LDAPControlW **controlarrayAtoW( LDAPControlA **controlarray )
     if (controlarray)
     {
         size = sizeof(LDAPControlW*) * (controlarraylenA( controlarray ) + 1);
-        controlarrayW = HeapAlloc( GetProcessHeap(), 0, size );
-
-        if (controlarrayW)
+        if ((controlarrayW = heap_alloc( size )))
         {
             LDAPControlA **p = controlarray;
             LDAPControlW **q = controlarrayW;
@@ -632,9 +600,7 @@ static inline LDAPControlA **controlarrayWtoA( LDAPControlW **controlarray )
     if (controlarray)
     {
         size = sizeof(LDAPControl*) * (controlarraylenW( controlarray ) + 1);
-        controlarrayA = HeapAlloc( GetProcessHeap(), 0, size );
-
-        if (controlarrayA)
+        if ((controlarrayA = heap_alloc( size )))
         {
             LDAPControlW **p = controlarray;
             LDAPControlA **q = controlarrayA;
@@ -654,9 +620,7 @@ static inline LDAPControl **controlarrayWtoU( LDAPControlW **controlarray )
     if (controlarray)
     {
         size = sizeof(LDAPControl*) * (controlarraylenW( controlarray ) + 1);
-        controlarrayU = HeapAlloc( GetProcessHeap(), 0, size );
-
-        if (controlarrayU)
+        if ((controlarrayU = heap_alloc( size )))
         {
             LDAPControlW **p = controlarray;
             LDAPControl **q = controlarrayU;
@@ -676,9 +640,7 @@ static inline LDAPControlW **controlarrayUtoW( LDAPControl **controlarray )
     if (controlarray)
     {
         size = sizeof(LDAPControlW*) * (controlarraylenU( controlarray ) + 1);
-        controlarrayW = HeapAlloc( GetProcessHeap(), 0, size );
-
-        if (controlarrayW)
+        if ((controlarrayW = heap_alloc( size )))
         {
             LDAPControl **p = controlarray;
             LDAPControlW **q = controlarrayW;
@@ -696,7 +658,7 @@ static inline void controlarrayfreeA( LDAPControlA **controlarray )
     {
         LDAPControlA **p = controlarray;
         while (*p) controlfreeA( *p++ );
-        HeapFree( GetProcessHeap(), 0, controlarray );
+        heap_free( controlarray );
     }
 }
 
@@ -706,7 +668,7 @@ static inline void controlarrayfreeW( LDAPControlW **controlarray )
     {
         LDAPControlW **p = controlarray;
         while (*p) controlfreeW( *p++ );
-        HeapFree( GetProcessHeap(), 0, controlarray );
+        heap_free( controlarray );
     }
 }
 
@@ -716,7 +678,7 @@ static inline void controlarrayfreeU( LDAPControl **controlarray )
     {
         LDAPControl **p = controlarray;
         while (*p) controlfreeU( *p++ );
-        HeapFree( GetProcessHeap(), 0, controlarray );
+        heap_free( controlarray );
     }
 }
 
@@ -724,8 +686,7 @@ static inline LDAPSortKeyW *sortkeyAtoW( LDAPSortKeyA *sortkey )
 {
     LDAPSortKeyW *sortkeyW;
 
-    sortkeyW = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPSortKeyW) );
-    if (sortkeyW)
+    if ((sortkeyW = heap_alloc( sizeof(LDAPSortKeyW) )))
     {
         sortkeyW->sk_attrtype = strAtoW( sortkey->sk_attrtype );
         sortkeyW->sk_matchruleoid = strAtoW( sortkey->sk_matchruleoid );
@@ -738,8 +699,7 @@ static inline LDAPSortKeyA *sortkeyWtoA( LDAPSortKeyW *sortkey )
 {
     LDAPSortKeyA *sortkeyA;
 
-    sortkeyA = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPSortKeyA) );
-    if (sortkeyA)
+    if ((sortkeyA = heap_alloc( sizeof(LDAPSortKeyA) )))
     {
         sortkeyA->sk_attrtype = strWtoA( sortkey->sk_attrtype );
         sortkeyA->sk_matchruleoid = strWtoA( sortkey->sk_matchruleoid );
@@ -752,8 +712,7 @@ static inline LDAPSortKey *sortkeyWtoU( LDAPSortKeyW *sortkey )
 {
     LDAPSortKey *sortkeyU;
 
-    sortkeyU = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPSortKey) );
-    if (sortkeyU)
+    if ((sortkeyU = heap_alloc( sizeof(LDAPSortKey) )))
     {
         sortkeyU->attributeType = strWtoU( sortkey->sk_attrtype );
         sortkeyU->orderingRule = strWtoU( sortkey->sk_matchruleoid );
@@ -768,7 +727,7 @@ static inline void sortkeyfreeA( LDAPSortKeyA *sortkey )
     {
         strfreeA( sortkey->sk_attrtype );
         strfreeA( sortkey->sk_matchruleoid );
-        HeapFree( GetProcessHeap(), 0, sortkey );
+        heap_free( sortkey );
     }
 }
 
@@ -778,7 +737,7 @@ static inline void sortkeyfreeW( LDAPSortKeyW *sortkey )
     {
         strfreeW( sortkey->sk_attrtype );
         strfreeW( sortkey->sk_matchruleoid );
-        HeapFree( GetProcessHeap(), 0, sortkey );
+        heap_free( sortkey );
     }
 }
 
@@ -788,7 +747,7 @@ static inline void sortkeyfreeU( LDAPSortKey *sortkey )
     {
         strfreeU( sortkey->attributeType );
         strfreeU( sortkey->orderingRule );
-        HeapFree( GetProcessHeap(), 0, sortkey );
+        heap_free( sortkey );
     }
 }
 
@@ -814,9 +773,7 @@ static inline LDAPSortKeyW **sortkeyarrayAtoW( LDAPSortKeyA **sortkeyarray )
     if (sortkeyarray)
     {
         size = sizeof(LDAPSortKeyW*) * (sortkeyarraylenA( sortkeyarray ) + 1);
-        sortkeyarrayW = HeapAlloc( GetProcessHeap(), 0, size );
-
-        if (sortkeyarrayW)
+        if ((sortkeyarrayW = heap_alloc( size )))
         {
             LDAPSortKeyA **p = sortkeyarray;
             LDAPSortKeyW **q = sortkeyarrayW;
@@ -836,9 +793,7 @@ static inline LDAPSortKey **sortkeyarrayWtoU( LDAPSortKeyW **sortkeyarray )
     if (sortkeyarray)
     {
         size = sizeof(LDAPSortKey*) * (sortkeyarraylenW( sortkeyarray ) + 1);
-        sortkeyarrayU = HeapAlloc( GetProcessHeap(), 0, size );
-
-        if (sortkeyarrayU)
+        if ((sortkeyarrayU = heap_alloc( size )))
         {
             LDAPSortKeyW **p = sortkeyarray;
             LDAPSortKey **q = sortkeyarrayU;
@@ -856,7 +811,7 @@ static inline void sortkeyarrayfreeW( LDAPSortKeyW **sortkeyarray )
     {
         LDAPSortKeyW **p = sortkeyarray;
         while (*p) sortkeyfreeW( *p++ );
-        HeapFree( GetProcessHeap(), 0, sortkeyarray );
+        heap_free( sortkeyarray );
     }
 }
 
@@ -866,7 +821,7 @@ static inline void sortkeyarrayfreeU( LDAPSortKey **sortkeyarray )
     {
         LDAPSortKey **p = sortkeyarray;
         while (*p) sortkeyfreeU( *p++ );
-        HeapFree( GetProcessHeap(), 0, sortkeyarray );
+        heap_free( sortkeyarray );
     }
 }
 #endif /* HAVE_LDAP */
-- 
2.11.0




More information about the wine-devel mailing list