Make LDAP_MEMORY_DEBUG a bitmask. #define LDAP_MEMORY_DEBUG_ASSERT. ITS#4990.

This commit is contained in:
Hallvard Furuseth 2007-07-24 20:53:23 +00:00
parent ea497ca60e
commit 973a2b41b7
4 changed files with 15 additions and 21 deletions

View file

@ -204,11 +204,8 @@ ber_free_buf( BerElement *ber )
void
ber_free( BerElement *ber, int freebuf )
{
#ifdef LDAP_MEMORY_DEBUG
assert( ber != NULL );
#endif
if( ber == NULL ) {
LDAP_MEMORY_DEBUG_ASSERT( ber != NULL );
return;
}

View file

@ -47,6 +47,11 @@ LBER_V (BER_ERRNO_FN) ber_int_errno_fn;
#ifdef LDAP_MEMORY_DEBUG
LBER_V (long) ber_int_meminuse;
#endif
#if defined(LDAP_MEMORY_DEBUG) && ((LDAP_MEMORY_DEBUG +0) & 2)
# define LDAP_MEMORY_DEBUG_ASSERT assert
#else
# define LDAP_MEMORY_DEBUG_ASSERT(expr) ((void) 0)
#endif
struct lber_options {
short lbo_valid;

View file

@ -28,9 +28,11 @@
/*
* LDAP_MEMORY_DEBUG should only be enabled for the purposes of
* debugging memory management within OpenLDAP libraries and slapd.
* It should only be enabled by an experienced developer as it
* causes the inclusion of numerous assert()'s, many of which may
* be triggered by a prefectly valid program.
*
* It should only be enabled by an experienced developer as it causes
* the inclusion of numerous assert()'s, many of which may be triggered
* by a prefectly valid program. If LDAP_MEMORY_DEBUG & 2 is true,
* that includes asserts known to break both slapd and current clients.
*
* The code behind this macro is subject to change as needed to
* support this testing.
@ -192,11 +194,8 @@ ber_memalloc_x( ber_len_t s, void *ctx )
{
void *new;
#ifdef LDAP_MEMORY_DEBUG
assert( s != 0 );
#endif
if( s == 0 ) {
LDAP_MEMORY_DEBUG_ASSERT( s != 0 );
return NULL;
}
@ -248,11 +247,8 @@ ber_memcalloc_x( ber_len_t n, ber_len_t s, void *ctx )
{
void *new;
#ifdef LDAP_MEMORY_DEBUG
assert( n != 0 && s != 0);
#endif
if( n == 0 || s == 0 ) {
LDAP_MEMORY_DEBUG_ASSERT( n != 0 && s != 0);
return NULL;
}

View file

@ -246,9 +246,7 @@ int ldap_pvt_get_controls(
void
ldap_control_free( LDAPControl *c )
{
#ifdef LDAP_MEMORY_DEBUG
assert( c != NULL );
#endif
LDAP_MEMORY_DEBUG_ASSERT( c != NULL );
if ( c != NULL ) {
if( c->ldctl_oid != NULL) {
@ -269,9 +267,7 @@ ldap_control_free( LDAPControl *c )
void
ldap_controls_free( LDAPControl **controls )
{
#ifdef LDAP_MEMORY_DEBUG
assert( controls != NULL );
#endif
LDAP_MEMORY_DEBUG_ASSERT( controls != NULL );
if ( controls != NULL ) {
int i;