#pragma once
-#include <wine/unicode.h>
+#include "wine/heap.h"
+#include "wine/unicode.h"
extern HINSTANCE hwldap32 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;
}
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;
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;
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;
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;
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 )
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;
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;
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;
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;
{
LPSTR *p = strarray;
while (*p) strfreeA( *p++ );
- HeapFree( GetProcessHeap(), 0, strarray );
+ heap_free( strarray );
}
}
{
LPWSTR *p = strarray;
while (*p) strfreeW( *p++ );
- HeapFree( GetProcessHeap(), 0, strarray );
+ heap_free( strarray );
}
}
{
char **p = strarray;
while (*p) strfreeU( *p++ );
- HeapFree( GetProcessHeap(), 0, strarray );
+ heap_free( strarray );
}
}
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);
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;
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 );
{
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 );
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 )
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 )
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;
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;
{
LDAPModW **p = modarray;
while (*p) modfreeW( *p++ );
- HeapFree( GetProcessHeap(), 0, modarray );
+ heap_free( modarray );
}
}
{
LDAPMod **p = modarray;
while (*p) modfreeU( *p++ );
- HeapFree( GetProcessHeap(), 0, modarray );
+ heap_free( modarray );
}
}
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;
}
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;
}
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;
}
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;
}
controlW->ldctl_value.bv_len = len;
controlW->ldctl_value.bv_val = val;
controlW->ldctl_iscritical = control->ldctl_iscritical;
-
+
return controlW;
}
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 );
}
}
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 );
}
}
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 );
}
}
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;
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;
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;
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;
{
LDAPControlA **p = controlarray;
while (*p) controlfreeA( *p++ );
- HeapFree( GetProcessHeap(), 0, controlarray );
+ heap_free( controlarray );
}
}
{
LDAPControlW **p = controlarray;
while (*p) controlfreeW( *p++ );
- HeapFree( GetProcessHeap(), 0, controlarray );
+ heap_free( controlarray );
}
}
{
LDAPControl **p = controlarray;
while (*p) controlfreeU( *p++ );
- HeapFree( GetProcessHeap(), 0, controlarray );
+ heap_free( controlarray );
}
}
{
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 );
{
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 );
{
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 );
{
strfreeA( sortkey->sk_attrtype );
strfreeA( sortkey->sk_matchruleoid );
- HeapFree( GetProcessHeap(), 0, sortkey );
+ heap_free( sortkey );
}
}
{
strfreeW( sortkey->sk_attrtype );
strfreeW( sortkey->sk_matchruleoid );
- HeapFree( GetProcessHeap(), 0, sortkey );
+ heap_free( sortkey );
}
}
{
strfreeU( sortkey->attributeType );
strfreeU( sortkey->orderingRule );
- HeapFree( GetProcessHeap(), 0, sortkey );
+ heap_free( sortkey );
}
}
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;
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;
{
LDAPSortKeyW **p = sortkeyarray;
while (*p) sortkeyfreeW( *p++ );
- HeapFree( GetProcessHeap(), 0, sortkeyarray );
+ heap_free( sortkeyarray );
}
}
{
LDAPSortKey **p = sortkeyarray;
while (*p) sortkeyfreeU( *p++ );
- HeapFree( GetProcessHeap(), 0, sortkeyarray );
+ heap_free( sortkeyarray );
}
}
#endif /* HAVE_LDAP */