[WLDAP32] Sync with Wine Staging 3.3. CORE-14434
[reactos.git] / dll / win32 / wldap32 / init.c
index 7b3e467..fdb7908 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#include "config.h"
+#include "wine/port.h"
+
+#include <stdio.h>
+#include <stdarg.h>
+#ifdef HAVE_LDAP_H
+#include <ldap.h>
+#endif
+
+#include "windef.h"
+#include "winbase.h"
+#include "winnls.h"
+
 #include "winldap_private.h"
+#include "wldap32.h"
+#include "wine/debug.h"
 
 #ifdef HAVE_LDAP
 /* Should eventually be determined by the algorithm documented on MSDN. */
@@ -47,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;
     }
 
@@ -59,7 +73,7 @@ static char **split_hostnames( const char *hostnames )
 
     q = p;
     i = 0;
-    
+
     while (*p)
     {
         if (p[1] != '\0')
@@ -70,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;
             }
@@ -85,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;
 }
@@ -139,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++)
@@ -189,6 +201,8 @@ static char *urlify_hostnames( const char *scheme, char *hostnames, ULONG port )
 }
 #endif
 
+WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
+
 #ifdef HAVE_LDAP
 static LDAP *create_context( const char *url )
 {