#ifndef _AC_STDLIB_H
#define _AC_STDLIB_H
+#if defined( HAVE_CSRIMALLOC )
+#include <stdio.h>
+#define MALLOC_TRACE
+#include <libmalloc.h>
+#endif
+
#include <stdlib.h>
/* Ignore malloc.h if we have STDC_HEADERS */
e->e_ndn = ndn;
e->e_private = NULL;
- dn = NULL;
-
Debug( LDAP_DEBUG_ARGS, " do_add: ndn (%s)\n", e->e_ndn, 0, 0 );
/* get the attrs */
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
+#define CH_FREE 1
+
#include "portable.h"
#include <stdio.h>
#include "slap.h"
+#ifndef CSRIMALLOC
+
void *
ch_malloc(
ber_len_t size
{
ber_memfree( ptr );
}
+
+#endif
static unsigned char *ecur; /* pointer to end of currently used ebuf */
static int emaxsize;/* max size of ebuf */
+int entry_destroy(void)
+{
+ free( *ebuf );
+ ebuf = NULL;
+ ecur = NULL;
+ emaxsize = 0;
+ return 0;
+}
+
Entry *
str2entry( char *s )
{
rc = backend_destroy();
+ entry_destroy();
+
ldap_pvt_thread_destroy();
/* should destory the above mutex */
int tls_port = 0;
#endif
+#ifdef CSRIMALLOC
+ FILE *leakfile;
+ if( ( leakfile = fopen( "slapd.leak", "w" )) == NULL ) {
+ leakfile = stderr;
+ }
+#endif
+
g_argc = argc;
g_argv = argv;
#endif
#endif /* HAVE_WINSOCK */
+#ifdef CSRIMALLOC
+ mal_leaktrace(1);
+#endif
+
if ( slap_startup( NULL ) != 0 ) {
rc = 1;
SERVICE_EXIT( ERROR_SERVICE_SPECIFIC_ERROR, 20 );
shutdown:
/* remember an error during shutdown */
rc |= slap_shutdown( NULL );
+
destroy:
/* remember an error during destroy */
rc |= slap_destroy();
closelog();
slapd_daemon_destroy();
+#ifdef CSRIMALLOC
+ mal_dumpleaktrace( leakfile );
+#endif
+
MAIN_RETURN(rc);
}
* ch_malloc.c
*/
+#ifdef CSRIMALLOC
+#define ch_malloc malloc
+#define ch_realloc realloc
+#define ch_calloc calloc
+#define ch_strdup strdup
+#define ch_free free
+
+#else
void * ch_malloc LDAP_P(( ber_len_t size ));
void * ch_realloc LDAP_P(( void *block, ber_len_t size ));
void * ch_calloc LDAP_P(( ber_len_t nelem, ber_len_t size ));
char * ch_strdup LDAP_P(( const char *string ));
void ch_free LDAP_P(( void * ));
+
+#ifndef CH_FREE
+#undef free
#define free ch_free
+#endif
+#endif
/*
* charray.c
* entry.c
*/
+int entry_destroy LDAP_P((void));
+
Entry * str2entry LDAP_P(( char *s ));
char * entry2str LDAP_P(( Entry *e, int *len ));
void entry_free LDAP_P(( Entry *e ));