LDAP_BEGIN_DECL
#define LDAP_URL_PREFIX "ldap://"
-#define LDAP_URL_PREFIX_LEN 7
-#define LDAP_URL_URLCOLON "URL:"
-#define LDAP_URL_URLCOLON_LEN 4
+#define LDAP_URL_PREFIX_LEN (sizeof(LDAP_URL_PREFIX)-1)
+#define LDAPS_URL_PREFIX "ldaps://"
+#define LDAPS_URL_PREFIX_LEN (sizeof(LDAPS_URL_PREFIX)-1)
+#define LDAP_URL_URLCOLON "URL:"
+#define LDAP_URL_URLCOLON_LEN (sizeof(LDAP_URL_URLCOLON)-1)
#define NULLLDAPURLDESC ((LDAPURLDesc *)NULL)
#define LDAP_REF_STR "Referral:\n"
-#define LDAP_REF_STR_LEN 10
+#define LDAP_REF_STR_LEN (sizeof(LDAP_REF_STR)-1)
#define LDAP_LDAP_REF_STR LDAP_URL_PREFIX
-#define LDAP_LDAP_REF_STR_LEN LDAP_URL_PREFIX_LEN
-
-#define LDAP_DEFAULT_REFHOPLIMIT 5
+#define LDAP_LDAP_REF_STR_LEN (sizeof(LDAP_LDAP_REF_STR)-1)
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_DNS
#define LDAP_DX_REF_STR "dx://"
-#define LDAP_DX_REF_STR_LEN 5
+#define LDAP_DX_REF_STR_LEN (sizeof(LDAP_DX_REF_STR)-1)
#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_DNS */
+#define LDAP_DEFAULT_REFHOPLIMIT 5
+
#define LDAP_BOOL_REFERRALS 0
#define LDAP_BOOL_RESTART 1
#define LDAP_BOOL_DNS 2
#define LDAP_INT_CALLOC(n,s) (LBER_CALLOC((n),(s)))
#define LDAP_INT_REALLOC(p,s) (LBER_REALLOC((p),(s)))
#define LDAP_INT_FREE(p) (LBER_FREE((p)))
+#define LDAP_INT_VFREE(v) (LBER_VFREE((v)))
#ifndef LDAP_MALLOC
#define LDAP_MALLOC(s) (LBER_MALLOC((s)))
#define LDAP_CALLOC(n,s) (LBER_CALLOC((n),(s)))
#define LDAP_REALLOC(p,s) (LBER_REALLOC((p),(s)))
#define LDAP_FREE(p) (LBER_FREE((p)))
+#define LDAP_VFREE(v) (LBER_VFREE((v)))
#endif
/*
ss = LDAP_MALLOC(sizeof(safe_string));
if ( !ss )
return(NULL);
- ss->size = size;
- ss->pos = 0;
+
ss->val = LDAP_MALLOC(size);
- ss->at_whsp = 0;
if ( !ss->val ) {
LDAP_FREE(ss);
return(NULL);
}
+
+ ss->size = size;
+ ss->pos = 0;
+ ss->at_whsp = 0;
+
return ss;
}
{
if ( !ss )
return;
- ldap_memfree(ss->val);
- ldap_memfree(ss);
+ LDAP_FREE(ss->val);
+ LDAP_FREE(ss);
}
static char *
return(retstring);
}
-/*
- * This is ripped from servers/slapd/charray.c that should be promoted
- * to -lldap or something so that it is used everywhere.
- */
-static void
-charray_free( char **array )
-{
- char **a;
-
- if ( array == NULL ) {
- return;
- }
-
- for ( a = array; *a != NULL; a++ ) {
- if ( *a != NULL ) {
- LDAP_FREE( *a );
- }
- }
- LDAP_FREE( (char *) array );
-}
-
/*
* Now come the parsers. There is one parser for each entity type:
* objectclasses, attributetypes, etc.
size++;
res1 = LDAP_REALLOC(res,size*sizeof(char *));
if ( !res1 ) {
- charray_free(res);
+ LDAP_VFREE(res);
*code = LDAP_SCHERR_OUTOFMEM;
return(NULL);
}
pos++;
parse_whsp(sp);
} else {
- charray_free(res);
+ LDAP_VFREE(res);
*code = LDAP_SCHERR_UNEXPTOKEN;
return(NULL);
}
(*sp)++;
if ( **sp != '}' ) {
*code = LDAP_SCHERR_UNEXPTOKEN;
- ldap_memfree(sval);
+ LDAP_FREE(sval);
return NULL;
}
(*sp)++;
pos++;
} else {
*code = LDAP_SCHERR_UNEXPTOKEN;
- charray_free(res);
+ LDAP_VFREE(res);
return NULL;
}
parse_whsp(sp);
size++;
res1 = LDAP_REALLOC(res,size*sizeof(char *));
if ( !res1 ) {
- charray_free(res);
+ LDAP_VFREE(res);
*code = LDAP_SCHERR_OUTOFMEM;
return(NULL);
}
pos++;
} else {
*code = LDAP_SCHERR_UNEXPTOKEN;
- charray_free(res);
+ LDAP_VFREE(res);
return NULL;
}
parse_whsp(sp);
} else {
*code = LDAP_SCHERR_UNEXPTOKEN;
- charray_free(res);
+ LDAP_VFREE(res);
return NULL;
}
}
static void
free_syn(LDAP_SYNTAX * syn)
{
- ldap_memfree(syn->syn_oid);
- ldap_memfree(syn->syn_desc);
- ldap_memfree(syn);
+ LDAP_FREE(syn->syn_oid);
+ LDAP_FREE(syn->syn_desc);
+ LDAP_FREE(syn);
}
LDAP_SYNTAX *
static void
free_at(LDAP_ATTRIBUTE_TYPE * at)
{
- ldap_memfree(at->at_oid);
- charray_free(at->at_names);
- ldap_memfree(at->at_desc);
- ldap_memfree(at->at_sup_oid);
- ldap_memfree(at->at_equality_oid);
- ldap_memfree(at->at_ordering_oid);
- ldap_memfree(at->at_substr_oid);
- ldap_memfree(at->at_syntax_oid);
- ldap_memfree(at);
+ LDAP_FREE(at->at_oid);
+ LDAP_VFREE(at->at_names);
+ LDAP_FREE(at->at_desc);
+ LDAP_FREE(at->at_sup_oid);
+ LDAP_FREE(at->at_equality_oid);
+ LDAP_FREE(at->at_ordering_oid);
+ LDAP_FREE(at->at_substr_oid);
+ LDAP_FREE(at->at_syntax_oid);
+ LDAP_FREE(at);
}
LDAP_ATTRIBUTE_TYPE *
static void
free_oc(LDAP_OBJECT_CLASS * oc)
{
- ldap_memfree(oc->oc_oid);
- charray_free(oc->oc_names);
- ldap_memfree(oc->oc_desc);
- charray_free(oc->oc_sup_oids);
- charray_free(oc->oc_at_oids_must);
- charray_free(oc->oc_at_oids_may);
- ldap_memfree(oc);
+ LDAP_FREE(oc->oc_oid);
+ LDAP_VFREE(oc->oc_names);
+ LDAP_FREE(oc->oc_desc);
+ LDAP_VFREE(oc->oc_sup_oids);
+ LDAP_VFREE(oc->oc_at_oids_must);
+ LDAP_VFREE(oc->oc_at_oids_may);
+ LDAP_FREE(oc);
}
LDAP_OBJECT_CLASS *