summaryrefslogtreecommitdiffstats
path: root/ldap/servers/slapd/main.c
diff options
context:
space:
mode:
authorNoriko Hosoi <nhosoi@redhat.com>2008-10-15 06:30:11 +0000
committerNoriko Hosoi <nhosoi@redhat.com>2008-10-15 06:30:11 +0000
commit91d5d9d04a1a0137a6d16089c46f21771b62b3e2 (patch)
tree5668b30e432c29eac8a4dfbf8eebff02af603c35 /ldap/servers/slapd/main.c
parentf7bc5b0691f58138eeb7783af9743de4410b46c4 (diff)
downloadds-91d5d9d04a1a0137a6d16089c46f21771b62b3e2.tar.gz
ds-91d5d9d04a1a0137a6d16089c46f21771b62b3e2.tar.xz
ds-91d5d9d04a1a0137a6d16089c46f21771b62b3e2.zip
Resolves: #466702
Summary: Memory usage research: checking in the experimental code See also: http://directory.fedoraproject.org/wiki/Memory_Usage_Research
Diffstat (limited to 'ldap/servers/slapd/main.c')
-rw-r--r--ldap/servers/slapd/main.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c
index 61ead86f..3a328cd8 100644
--- a/ldap/servers/slapd/main.c
+++ b/ldap/servers/slapd/main.c
@@ -225,7 +225,7 @@ chown_dir_files(char *name, struct passwd *pw, PRBool strip_fn)
char *log=NULL, *ptr=NULL;
int rc=0;
- log=strdup(name);
+ log=slapi_ch_strdup(name);
if(strip_fn)
{
if((ptr=strrchr(log,'/'))==NULL)
@@ -250,7 +250,7 @@ chown_dir_files(char *name, struct passwd *pw, PRBool strip_fn)
}
PR_CloseDir( dir );
}
- free(log);
+ slapi_ch_free_string(&log);
}
/* Changes the owner of the files in the logs and
@@ -621,6 +621,12 @@ write_start_pid_file()
}
#endif /* WIN32 */
+#ifdef MEMPOOL_EXPERIMENTAL
+void _free_wrapper(void *ptr)
+{
+ slapi_ch_free(&ptr);
+}
+#endif
int
main( int argc, char **argv)
@@ -635,6 +641,19 @@ main( int argc, char **argv)
_main();
#endif
#endif
+#ifdef MEMPOOL_EXPERIMENTAL
+ /* to use LDAP C SDK lber functions seemlessly with slapi_ch_malloc funcs,
+ * setting the slapi_ch_malloc funcs to lber option here. */
+ {
+ struct ldap_memalloc_fns memalloc_fns;
+
+ memalloc_fns.ldapmem_malloc = (LDAP_MALLOC_CALLBACK *)slapi_ch_malloc;
+ memalloc_fns.ldapmem_calloc = (LDAP_CALLOC_CALLBACK *)slapi_ch_calloc;
+ memalloc_fns.ldapmem_realloc = (LDAP_REALLOC_CALLBACK *)slapi_ch_realloc;
+ memalloc_fns.ldapmem_free = (LDAP_FREE_CALLBACK *)_free_wrapper;
+ ldap_set_option( 0x1, LDAP_OPT_MEMALLOC_FN_PTRS, &memalloc_fns );
+ }
+#endif
/*
* Initialize NSPR very early. NSPR supports implicit initialization,
* but it is not bulletproof -- so it is better to be explicit.