[Fedora-directory-commits] ldapserver/ldap/servers/slapd/back-ldbm ancestorid.c, 1.5, 1.6 cache.c, 1.5, 1.6 dblayer.c, 1.29, 1.30 dbtest.c, 1.5, 1.6 id2entry.c, 1.6, 1.7 idl.c, 1.6, 1.7 import-merge.c, 1.9, 1.10 import-threads.c, 1.16, 1.17 import.c, 1.12, 1.13 index.c, 1.16, 1.17 instance.c, 1.7, 1.8 ldif2ldbm.c, 1.18, 1.19 monitor.c, 1.8, 1.9 nextid.c, 1.5, 1.6 perfctrs.c, 1.11, 1.12 seq.c, 1.5, 1.6 sort.c, 1.11, 1.12 vlv.c, 1.15, 1.16 vlv_srch.c, 1.8, 1.9
Noriko Hosoi
nhosoi at fedoraproject.org
Wed Oct 15 06:30:13 UTC 2008
- Previous message (by thread): [Fedora-directory-commits] ldapserver/ldap/servers/slapd mempool.c, NONE, 1.1 add.c, 1.12, 1.13 attrsyntax.c, 1.7, 1.8 ava.c, 1.7, 1.8 bind.c, 1.14, 1.15 ch_malloc.c, 1.9, 1.10 computed.c, 1.5, 1.6 connection.c, 1.19, 1.20 entry.c, 1.18, 1.19 filter.c, 1.10, 1.11 filtercmp.c, 1.6, 1.7 libglobs.c, 1.25, 1.26 main.c, 1.25, 1.26 operation.c, 1.6, 1.7 proto-slap.h, 1.36, 1.37 rwlock.c, 1.5, 1.6 slap.h, 1.35, 1.36 slapi2nspr.c, 1.5, 1.6
- Next message (by thread): [Fedora-directory-commits] ldapserver/ldap/servers/slapd/tools pwenc.c, 1.10, 1.11
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Author: nhosoi
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv25637/ldap/servers/slapd/back-ldbm
Modified Files:
ancestorid.c cache.c dblayer.c dbtest.c id2entry.c idl.c
import-merge.c import-threads.c import.c index.c instance.c
ldif2ldbm.c monitor.c nextid.c perfctrs.c seq.c sort.c vlv.c
vlv_srch.c
Log Message:
Resolves: #466702
Summary: Memory usage research: checking in the experimental code
See also: http://directory.fedoraproject.org/wiki/Memory_Usage_Research
Index: ancestorid.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/ancestorid.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ancestorid.c 10 Nov 2006 23:45:39 -0000 1.5
+++ ancestorid.c 15 Oct 2008 06:30:06 -0000 1.6
@@ -373,7 +373,7 @@
out:
/* Free the entry value */
- if (data.data != NULL) free(data.data);
+ slapi_ch_free(&(data.data));
/* Release the id2entry file */
if (db != NULL) {
Index: cache.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/cache.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- cache.c 10 Nov 2006 23:45:39 -0000 1.5
+++ cache.c 15 Oct 2008 06:30:06 -0000 1.6
@@ -423,7 +423,7 @@
#define CACHE_FULL(cache) \
(((cache)->c_cursize > (cache)->c_maxsize) || \
(((cache)->c_maxentries > 0) && \
- ((cache)->c_curentries > cache->c_maxentries)))
+ ((cache)->c_curentries > (cache)->c_maxentries)))
/* clear out the cache to make room for new entries
Index: dblayer.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/dblayer.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- dblayer.c 9 Oct 2008 17:40:14 -0000 1.29
+++ dblayer.c 15 Oct 2008 06:30:06 -0000 1.30
@@ -772,6 +772,11 @@
}
#endif
+void dblayer_free(void *ptr)
+{
+ slapi_ch_free(&ptr);
+}
+
static void dblayer_init_dbenv(DB_ENV *pEnv, dblayer_private *priv)
{
size_t mysize;
@@ -797,7 +802,7 @@
pEnv->set_tx_max(pEnv, priv->dblayer_tx_max);
#if 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR >= 3300
- pEnv->set_alloc(pEnv, malloc, realloc, free);
+ pEnv->set_alloc(pEnv, (void *)slapi_ch_malloc, (void *)slapi_ch_realloc, dblayer_free);
/*
* The log region is used to store filenames and so needs to be
@@ -2063,7 +2068,7 @@
}
#if 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR < 3300
- return_value = dbp->set_malloc(dbp, malloc);
+ return_value = dbp->set_malloc(dbp, (void *)slapi_ch_malloc);
if (0 != return_value) {
LDAPDebug(LDAP_DEBUG_ANY,
"dbp->set_malloc failed %d\n",
@@ -2762,7 +2767,7 @@
goto out;
#if 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR < 3300
- return_value = dbp->set_malloc(dbp, malloc);
+ return_value = dbp->set_malloc(dbp, (void *)slapi_ch_malloc);
if (0 != return_value) {
goto out;
}
@@ -3727,7 +3732,7 @@
/* find out which log files don't contain active txns */
DB_CHECKPOINT_LOCK(PR_TRUE, penv->dblayer_env_lock);
return_value = LOG_ARCHIVE(penv->dblayer_DB_ENV, &list,
- 0, malloc);
+ 0, (void *)slapi_ch_malloc);
DB_CHECKPOINT_UNLOCK(PR_TRUE, penv->dblayer_env_lock);
checkpoint_debug_message(debug_checkpointing,
"Got list of logfiles not needed %d %p\n",
@@ -3990,7 +3995,7 @@
env = priv->dblayer_env->dblayer_DB_ENV;
PR_ASSERT(NULL != env);
- return MEMP_STAT(env, gsp, fsp, 0, malloc);
+ return MEMP_STAT(env, gsp, fsp, 0, (void *)slapi_ch_malloc);
}
/* import wants this one */
@@ -4011,7 +4016,7 @@
}
PR_ASSERT(NULL != env);
- return MEMP_STAT(env, gsp, fsp, 0, malloc);
+ return MEMP_STAT(env, gsp, fsp, 0, (void *)slapi_ch_malloc);
}
/* Helper functions for recovery */
@@ -4954,7 +4959,7 @@
/* get the list of logfiles currently existing */
if (priv->dblayer_enable_transactions) {
return_value = LOG_ARCHIVE(priv->dblayer_env->dblayer_DB_ENV,
- &listA, DB_ARCH_LOG, malloc);
+ &listA, DB_ARCH_LOG, (void *)slapi_ch_malloc);
if ((return_value != 0) || (listA == NULL)) {
LDAPDebug(LDAP_DEBUG_ANY, "BAD: can't get list of logs\n",
0, 0, 0);
@@ -4990,9 +4995,7 @@
slapi_task_log_notice(task,
"ERROR: Instance dir is empty\n");
}
- if (listA) {
- free(listA);
- }
+ slapi_ch_free((void **)&listA);
dblayer_txn_abort(li,&txn);
return -1;
}
@@ -5005,9 +5008,7 @@
"ERROR: error copying directory (%s -> %s): err=%d",
inst_dirp, dest_dir, return_value);
}
- if (listA) {
- free(listA);
- }
+ slapi_ch_free((void **)&listA);
dblayer_txn_abort(li,&txn);
if (inst_dirp != inst_dir)
slapi_ch_free_string(&inst_dirp);
@@ -5019,11 +5020,11 @@
if (priv->dblayer_enable_transactions) {
/* now, get the list of logfiles that still exist */
return_value = LOG_ARCHIVE(priv->dblayer_env->dblayer_DB_ENV,
- &listB, DB_ARCH_LOG, malloc);
+ &listB, DB_ARCH_LOG, (void *)slapi_ch_malloc);
if ((return_value != 0) || (listB == NULL)) {
LDAPDebug(LDAP_DEBUG_ANY, "ERROR: can't get list of logs\n",
0, 0, 0);
- free(listA);
+ slapi_ch_free((void **)&listA);
dblayer_txn_abort(li,&txn);
return return_value;
}
@@ -5107,14 +5108,8 @@
slapi_ch_free((void **)&pathname2);
}
- if (listA) {
- free(listA);
- listA = NULL;
- }
- if (listB) {
- free(listB);
- listB = NULL;
- }
+ slapi_ch_free((void **)&listA);
+ slapi_ch_free((void **)&listB);
}
} while (!ok);
Index: dbtest.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/dbtest.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- dbtest.c 10 Nov 2006 23:45:39 -0000 1.5
+++ dbtest.c 15 Oct 2008 06:30:06 -0000 1.6
@@ -260,8 +260,8 @@
fprintf( outfp, "\tdata: %s\n", (char *)data.data );
}
}
- free( key.data );
- free( data.data );
+ slapi_ch_free( &(key.data) );
+ slapi_ch_free( &(data.data) );
}
dbc->c_close(dbc);
}
Index: id2entry.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/id2entry.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- id2entry.c 10 Nov 2006 23:45:39 -0000 1.6
+++ id2entry.c 15 Oct 2008 06:30:06 -0000 1.7
@@ -103,7 +103,7 @@
/* store it */
rc = db->put( db, db_txn, &key, &data, 0);
/* DBDB looks like we're freeing memory allocated by another DLL, which is bad */
- free( data.dptr );
+ slapi_ch_free( &(data.dptr) );
dblayer_release_id2entry( be, db );
@@ -210,19 +210,30 @@
}
do {
*err = db->get( db, db_txn, &key, &data, 0 );
- if ( 0 != *err &&
- DB_NOTFOUND != *err && DB_LOCK_DEADLOCK != *err )
+ if ( (0 != *err) &&
+ (DB_NOTFOUND != *err) && (DB_LOCK_DEADLOCK != *err) )
{
- LDAPDebug( LDAP_DEBUG_ANY, "id2entry error %d\n",
- *err, 0, 0 );
+ LDAPDebug( LDAP_DEBUG_ANY,
+ "id2entry: libdb returned error %d (%s)\n",
+ *err, dblayer_strerror( *err ), 0 );
}
}
- while ( DB_LOCK_DEADLOCK == *err && txn == NULL );
+ while ( (DB_LOCK_DEADLOCK == *err) && (txn == NULL) );
- if ( 0 != *err && DB_NOTFOUND != *err && DB_LOCK_DEADLOCK != *err )
+ if ( (0 != *err) && (DB_NOTFOUND != *err) && (DB_LOCK_DEADLOCK != *err) )
{
- LDAPDebug( LDAP_DEBUG_ANY, "id2entry get error %d\n",
- *err, 0, 0 );
+ if ( (ENOMEM == *err) && (data.dptr == NULL) )
+ {
+ /*
+ * Now we are setting slapi_ch_malloc and its friends to libdb
+ * by ENV->set_alloc in dblayer.c. As long as the functions are
+ * used by libdb, it won't reach here.
+ */
+ LDAPDebug( LDAP_DEBUG_ANY,
+ "malloc failed in libdb; terminating the server; OS error %d (%s)\n",
+ *err, slapd_system_strerror( *err ), 0 );
+ exit (1);
+ }
dblayer_release_id2entry( be, db );
return( NULL );
}
@@ -274,7 +285,7 @@
e = NULL;
}
- free( data.data );
+ slapi_ch_free( &(data.data) );
dblayer_release_id2entry( be, db );
Index: idl.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/idl.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- idl.c 1 Dec 2006 21:57:57 -0000 1.6
+++ idl.c 15 Oct 2008 06:30:07 -0000 1.7
@@ -141,7 +141,7 @@
PR_ASSERT(NULL != priv->idl_rwlock);
PR_DestroyRWLock(priv->idl_rwlock);
#endif
- free( a->ai_idl );
+ slapi_ch_free( (void **)&(a->ai_idl) );
}
return 0;
}
@@ -909,12 +909,8 @@
idl_check_indirect (idl, i, tmp, tmp2,
"idl_insert_key", "overflow", key, id);
- if ( k2.dptr != NULL ) {
- free( k2.dptr );
- }
- if ( k3.dptr != NULL ) {
- free( k3.dptr );
- }
+ slapi_ch_free( (void **)&(k2.dptr) );
+ slapi_ch_free( (void **)&(k3.dptr) );
idl_free( tmp );
idl_free( tmp2 );
idl_free( idl );
@@ -998,12 +994,8 @@
}
}
- if ( k2.dptr != NULL ) {
- free( k2.dptr );
- }
- if ( k3.dptr != NULL ) {
- free( k3.dptr );
- }
+ slapi_ch_free( (void **)&(k2.dptr) );
+ slapi_ch_free( (void **)&(k3.dptr) );
idl_free( idl );
idl_free( tmp );
idl_unlock_list(a->ai_idl,key);
@@ -1065,12 +1057,8 @@
break;
}
- if ( k2.dptr != NULL ) {
- free( k2.dptr );
- }
- if ( k3.dptr != NULL ) {
- free( k3.dptr );
- }
+ slapi_ch_free( (void **)&(k2.dptr) );
+ slapi_ch_free( (void **)&(k3.dptr) );
idl_free( tmp );
idl_free( idl );
idl_unlock_list(a->ai_idl,key);
@@ -1166,7 +1154,7 @@
/* Now store the continuation block */
ret = idl_store(be,db,&cont_key,this_cont_block,txn);
idl_free(this_cont_block);
- free(cont_key.data);
+ slapi_ch_free(&(cont_key.data));
if ( ret != 0 && ret != DB_LOCK_DEADLOCK )
{
LDAPDebug( LDAP_DEBUG_ANY, "idl_store_block(%s) 1 BAD %d %s\n",key->data, ret, dblayer_strerror( ret ));
@@ -1490,9 +1478,7 @@
}
LDAPDebug( LDAP_DEBUG_TRACE, "<= idl_delete_key(%s,%lu) %d idl_fetch_one(contkey)\n",
contkey.dptr, (u_long)id, rc );
- if ( contkey.dptr != NULL ) {
- free( contkey.dptr );
- }
+ slapi_ch_free( (void **)&(contkey.dptr) );
return( rc );
}
@@ -1572,9 +1558,7 @@
}
idl_free( idl );
idl_free( didl );
- if ( contkey.dptr != NULL ) {
- free( contkey.dptr );
- }
+ slapi_ch_free( (void **)&(contkey.dptr) );
idl_unlock_list(a->ai_idl,key);
if ( rc != 0 && rc != DB_LOCK_DEADLOCK )
{
Index: import-merge.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/import-merge.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- import-merge.c 8 Oct 2008 17:29:03 -0000 1.9
+++ import-merge.c 15 Oct 2008 06:30:07 -0000 1.10
@@ -100,12 +100,12 @@
thang->payload.idl = idl_fetch(be, db, key, NULL, NULL, &ret);
PR_ASSERT(NULL != thang->payload.idl);
} else {
- free(value.data);
- free(key->data);
+ slapi_ch_free(&(value.data));
+ slapi_ch_free(&(key->data));
key->flags = DB_DBT_MALLOC;
goto around; /* Just skip these */
}
- free(value.data);
+ slapi_ch_free(&(value.data));
} else {
if (DB_NOTFOUND == ret) {
/* This means that we're at the end of the file */
@@ -189,7 +189,7 @@
(current_entry->file_referenced_list)[fileno] = 1;
/* Because we merged the entries, we no longer need the
* key, so free it */
- free(key->data);
+ slapi_ch_free(&(key->data));
goto done;
} else {
/* VLV case, we can see exact keys, this is not a bug ! */
@@ -573,7 +573,7 @@
/* Write the vlv index */
ret = output_file->put(output_file, NULL, &key,
&(thang.payload.vlv_data),0);
- free(thang.payload.vlv_data.data);
+ slapi_ch_free(&(thang.payload.vlv_data.data));
thang.payload.vlv_data.data = NULL;
} else {
/* Write the IDL index */
@@ -583,7 +583,7 @@
idl_free(thang.payload.idl);
thang.payload.idl = NULL;
}
- free(key.data);
+ slapi_ch_free(&(key.data));
key.data = NULL;
if (0 != ret) {
/* Failed to write--- most obvious cause being out of
Index: import-threads.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/import-threads.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- import-threads.c 8 Oct 2008 17:29:03 -0000 1.16
+++ import-threads.c 15 Oct 2008 06:30:07 -0000 1.17
@@ -734,7 +734,7 @@
}
curr_entry++;
temp_id = id_stored_to_internal((char *)key.data);
- free(key.data);
+ slapi_ch_free(&(key.data));
/* call post-entry plugin */
plugin_call_entryfetch_plugins((char **) &data.dptr, &data.dsize);
@@ -750,7 +750,7 @@
inst->inst_name, (u_long)temp_id, 0);
continue;
}
- free(data.data);
+ slapi_ch_free(&(data.data));
/* generate uniqueid if necessary */
import_generate_uniqueid(job, e);
Index: import.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/import.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- import.c 8 Oct 2008 17:29:03 -0000 1.12
+++ import.c 15 Oct 2008 06:30:07 -0000 1.13
@@ -135,7 +135,7 @@
job->fifo.item[i].entry = NULL;
job->fifo.item[i].filename = NULL;
}
- free(job->fifo.item);
+ slapi_ch_free((void **)&job->fifo.item);
job->fifo.item = NULL;
}
@@ -277,7 +277,7 @@
info->ai = a;
if (NULL == info->name) {
/* Memory allocation error */
- free(info);
+ FREE(info);
return -1;
}
info->next = job->index_list;
@@ -505,15 +505,15 @@
inst->inst_cache_hits = current_cache_hits;
if (mpstat)
- free(mpstat);
+ slapi_ch_free((void **)&mpstat);
if (mpfstat) {
#if 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR + DB_VERSION_PATCH <= 3204
/* In DB 3.2.4 and earlier, we need to free each element */
DB_MPOOL_FSTAT **tfsp;
for (tfsp = mpfstat; *tfsp; tfsp++)
- free(*tfsp);
+ slapi_ch_free((void **)tfsp);
#endif
- free(mpfstat);
+ slapi_ch_free((void **)&mpfstat);
}
}
return cache_hit_ratio;
Index: index.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/index.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- index.c 27 Aug 2008 21:05:44 -0000 1.16
+++ index.c 15 Oct 2008 06:30:08 -0000 1.17
@@ -187,7 +187,7 @@
if (0 != ret) {
goto error;
}
- slapi_ch_free((void**)&bin->key.data );
+ slapi_ch_free( &(bin->key.data) );
idl_free(bin->value);
/* If we're already at allids, store an allids block to prevent needless accumulation of blocks */
if (old_idl && ALLIDS(old_idl)) {
@@ -262,13 +262,11 @@
idl_free(bin->value);
bin->value = NULL;
}
- if (bin->key.data) {
- free(bin->key.data);
- }
+ slapi_ch_free(&(bin->key.data));
}
- free(handle->bins);
+ slapi_ch_free((void **)&(handle->bins));
/* Now free the handle */
- free(handle);
+ slapi_ch_free((void **)&handle);
return 0;
}
@@ -334,7 +332,7 @@
retry:
if (!(bin->key).data) {
(bin->key).size = key->size;
- (bin->key).data = malloc(key->size);
+ (bin->key).data = slapi_ch_malloc(key->size);
if (NULL == bin->key.data) {
return -1;
}
@@ -1018,7 +1016,7 @@
/* Means that we never allocated a new key */
;
} else {
- free(saved_key);
+ slapi_ch_free(&saved_key);
}
}
return ret;
@@ -1248,7 +1246,7 @@
*err = dbc->c_get(dbc,&lowerkey,&data,DB_SET_RANGE); /* lowerkey, if allocated and needs freed */
DBT_FREE_PAYLOAD(data);
if (old_lower_key_data != lowerkey.data) {
- free(old_lower_key_data);
+ slapi_ch_free(&old_lower_key_data);
}
}
/* If the seek above fails due to DB_NOTFOUND, this means that there are no keys
@@ -2044,7 +2042,7 @@
for (bcnt = 0; b[bcnt] != NULL; bcnt++);
/* allocate return array as big as a */
- c = (Slapi_Value**)calloc(acnt+1, sizeof(Slapi_Value*));
+ c = (Slapi_Value**)slapi_ch_calloc(acnt+1, sizeof(Slapi_Value*));
if (acnt == 0) return c;
/* sort a */
Index: instance.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/instance.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- instance.c 15 Mar 2007 18:21:43 -0000 1.7
+++ instance.c 15 Oct 2008 06:30:08 -0000 1.8
@@ -60,7 +60,7 @@
inst = (ldbm_instance *) slapi_ch_calloc(1, sizeof(ldbm_instance));
/* Record the name of this instance. */
- inst->inst_name = strdup(name);
+ inst->inst_name = slapi_ch_strdup(name);
/* initialize the entry cache */
if (! cache_init(&(inst->inst_cache), DEFAULT_CACHE_SIZE,
Index: ldif2ldbm.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/ldif2ldbm.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- ldif2ldbm.c 9 Oct 2008 14:57:32 -0000 1.18
+++ ldif2ldbm.c 15 Oct 2008 06:30:08 -0000 1.19
@@ -463,7 +463,7 @@
key.flags = DB_DBT_MALLOC;
ret = dbc->c_get(dbc,&key,&data,DB_NEXT_NODUP);
if (NULL != data.data) {
- free(data.data);
+ slapi_ch_free(&(data.data));
data.data = NULL;
}
if (0 != ret) {
@@ -471,7 +471,7 @@
ldbm_nasty(sourcefile,62,ret);
}
if (NULL != key.data) {
- free(key.data);
+ slapi_ch_free(&(key.data));
key.data = NULL;
}
break;
@@ -521,7 +521,7 @@
}
}
if (NULL != key.data) {
- free(key.data);
+ slapi_ch_free(&(key.data));
key.data = NULL;
}
}
@@ -985,8 +985,8 @@
keepgoing = 0;
} else {
lastid = id_stored_to_internal((char *)key.data);
- free( key.data );
- free( data.data );
+ slapi_ch_free( &(key.data) );
+ slapi_ch_free( &(data.data) );
isfirst = 1;
}
}
@@ -1089,7 +1089,7 @@
/* back to internal format */
temp_id = id_stored_to_internal((char *)key.data);
- free(key.data);
+ slapi_ch_free(&(key.data));
}
/* call post-entry plugin */
@@ -1097,7 +1097,7 @@
ep = backentry_alloc();
ep->ep_entry = slapi_str2entry( data.data, str2entry_options );
- free(data.data);
+ slapi_ch_free(&(data.data));
if ( (ep->ep_entry) != NULL ) {
ep->ep_id = temp_id;
@@ -1176,7 +1176,7 @@
}
backentry_free( &ep );
- free( data.data );
+ slapi_ch_free( &(data.data) );
}
/* DB_NOTFOUND -> successful end */
if (return_value == DB_NOTFOUND)
@@ -1383,8 +1383,8 @@
isfirst = 0; /* neither a first nor a last */
} else if (rc == 0) {
lastid = id_stored_to_internal((char *)key.data);
- free(key.data);
- free(data.data);
+ slapi_ch_free(&(key.data));
+ slapi_ch_free(&(data.data));
isfirst = 1;
} else {
LDAPDebug(LDAP_DEBUG_ANY,
@@ -1560,7 +1560,7 @@
break;
}
temp_id = id_stored_to_internal((char *)key.data);
- free(key.data);
+ slapi_ch_free(&(key.data));
}
/* call post-entry plugin */
@@ -1568,7 +1568,7 @@
ep = backentry_alloc();
ep->ep_entry = slapi_str2entry( data.data, 0 );
- free(data.data);
+ slapi_ch_free(&(data.data));
if ( ep->ep_entry != NULL ) {
ep->ep_id = temp_id;
Index: monitor.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/monitor.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- monitor.c 8 Oct 2008 17:29:04 -0000 1.8
+++ monitor.c 15 Oct 2008 06:30:09 -0000 1.9
@@ -218,9 +218,9 @@
#if 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR + DB_VERSION_PATCH <= 3204
/* In DB 3.2.4 and earlier, we need to free each element */
for (i = 0; mpfstat[i]; i++)
- free(mpfstat[i]);
+ slapi_ch_free((void **)&mpfstat[i]);
#endif
- free(mpfstat);
+ slapi_ch_free((void **)&mpfstat);
*returncode = LDAP_SUCCESS;
return SLAPI_DSE_CALLBACK_OK;
@@ -275,16 +275,16 @@
sprintf(buf, "%u", mpstat->st_rw_evict);
MSET("dbCacheRWEvict");
- free(mpstat);
+ slapi_ch_free((void **)&mpstat);
if (mpfstat) {
#if 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR + DB_VERSION_PATCH <= 3204
/* In DB 3.2.4 and earlier, we need to free each element */
int i;
for (i = 0; mpfstat[i]; i++)
- free(mpfstat[i]);
+ slapi_ch_free((void **)&mpfstat[i]);
#endif
- free(mpfstat);
+ slapi_ch_free((void **)&mpfstat);
}
*returncode = LDAP_SUCCESS;
Index: nextid.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/nextid.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- nextid.c 10 Nov 2006 23:45:39 -0000 1.5
+++ nextid.c 15 Oct 2008 06:30:09 -0000 1.6
@@ -177,35 +177,26 @@
/*Get the last key*/
DBC *dbc = NULL;
- DBT key = {0}; /*For the nextid*/
+ DBT key = {0}; /*For the nextid*/
DBT Value = {0};
+
Value.flags = DB_DBT_MALLOC;
key.flags = DB_DBT_MALLOC;
return_value = id2entrydb->cursor(id2entrydb,NULL,&dbc,0);
if (0 == return_value) {
return_value = dbc->c_get(dbc,&key,&Value,DB_LAST);
- if (0 == return_value) {
+ if ( (0 == return_value) && (NULL != key.dptr) ) {
inst->inst_nextid = id_stored_to_internal(key.dptr) + 1;
+ } else {
+ inst->inst_nextid = 1; /* error case: set 1 */
}
- if (NULL != key.data) {
- free(key.data);
- }
- if (NULL != Value.data) {
- free(Value.data);
- }
+ slapi_ch_free(&(key.data));
+ slapi_ch_free(&(Value.data));
dbc->c_close(dbc);
+ } else {
+ inst->inst_nextid = 1; /* when there is no id2entry, start from id 1 */
}
- if ( (key.dptr == NULL) || (0 != return_value) ) {
- inst->inst_nextid = 1;
- /*close the cache*/
- dblayer_release_id2entry( be, id2entrydb );
-
- /* unlock */
- PR_Unlock( inst->inst_nextid_mutex );
- return;
- }
-
}
/*close the cache*/
@@ -213,6 +204,8 @@
/* unlock */
PR_Unlock( inst->inst_nextid_mutex );
+
+ return;
}
Index: perfctrs.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/perfctrs.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- perfctrs.c 9 Oct 2008 17:40:14 -0000 1.11
+++ perfctrs.c 15 Oct 2008 06:30:10 -0000 1.12
@@ -91,7 +91,7 @@
char *string = NULL;
string_length = strlen(a) + strlen(b) + 1;
- string = malloc(string_length);
+ string = slapi_ch_malloc(string_length);
if (NULL == string) {
return string;
}
@@ -188,7 +188,7 @@
/*
* We need the perfctrs_private area on all platforms.
*/
- priv = calloc(1,sizeof(perfctrs_private));
+ priv = (perfctrs_private *)slapi_ch_calloc(1,sizeof(perfctrs_private));
if (NULL == priv) {
return;
}
@@ -210,7 +210,7 @@
/*
* On other platforms, the performance counters reside in regular memory.
*/
- if ( NULL == ( priv->memory = calloc( 1, sizeof( performance_counters )))) {
+ if ( NULL == ( priv->memory = slapi_ch_calloc( 1, sizeof( performance_counters )))) {
return;
}
#endif
@@ -226,13 +226,13 @@
DB_LOG_STAT *logstat = NULL;
DB_LOCK_STAT *lockstat = NULL;
- MEMP_STAT(db_env, &mpstat, NULL, DB_STAT_CLEAR, malloc);
+ MEMP_STAT(db_env, &mpstat, NULL, DB_STAT_CLEAR, (void *)slapi_ch_malloc);
slapi_ch_free((void**)&mpstat);
- TXN_STAT(db_env, &txnstat, DB_STAT_CLEAR, malloc);
+ TXN_STAT(db_env, &txnstat, DB_STAT_CLEAR, (void *)slapi_ch_malloc);
slapi_ch_free((void**)&txnstat);
- LOG_STAT(db_env, &logstat, DB_STAT_CLEAR, malloc);
+ LOG_STAT(db_env, &logstat, DB_STAT_CLEAR, (void *)slapi_ch_malloc);
slapi_ch_free((void**)&logstat);
- LOCK_STAT(db_env, &lockstat, DB_STAT_CLEAR, malloc);
+ LOCK_STAT(db_env, &lockstat, DB_STAT_CLEAR, (void *)slapi_ch_malloc);
slapi_ch_free((void**)&lockstat);
#if defined(_WIN32)
if (NULL != (*priv)->memory) {
@@ -246,12 +246,11 @@
}
#else
if (NULL != (*priv)->memory) {
- free((*priv)->memory);
+ slapi_ch_free(&(*priv)->memory);
}
#endif
- free( (*priv) );
- (*priv) = NULL;
+ slapi_ch_free( (void **)priv );
}
/* Wait while checking for perfctr update requests */
@@ -299,31 +298,30 @@
if (dblayer_db_uses_logging(db_env))
{
DB_LOG_STAT *logstat = NULL;
- ret = LOG_STAT(db_env,&logstat,0,malloc);
+ ret = LOG_STAT(db_env,&logstat,0,(void *)slapi_ch_malloc);
if (0 == ret) {
perf->log_region_wait_rate = logstat->st_region_wait;
perf->log_write_rate = 1024*1024*logstat->st_w_mbytes + logstat->st_w_bytes;
perf->log_bytes_since_checkpoint = 1024*1024*logstat->st_wc_mbytes + logstat->st_wc_bytes;
}
- free(logstat);
+ slapi_ch_free((void **)&logstat);
}
if (dblayer_db_uses_transactions(db_env))
{
DB_TXN_STAT *txnstat = NULL;
- ret = TXN_STAT(db_env, &txnstat, 0, malloc);
+ ret = TXN_STAT(db_env, &txnstat, 0, (void *)slapi_ch_malloc);
if (0 == ret) {
perf->active_txns = txnstat->st_nactive;
perf->commit_rate = txnstat->st_ncommits;
perf->abort_rate = txnstat->st_naborts;
perf->txn_region_wait_rate = txnstat->st_region_wait;
}
- if (txnstat)
- free(txnstat);
+ slapi_ch_free((void **)&txnstat);
}
if (dblayer_db_uses_locking(db_env))
{
DB_LOCK_STAT *lockstat = NULL;
- ret = LOCK_STAT(db_env,&lockstat,0,malloc);
+ ret = LOCK_STAT(db_env,&lockstat,0,(void *)slapi_ch_malloc);
if (0 == ret) {
perf->lock_region_wait_rate = lockstat->st_region_wait;
perf->deadlock_rate = lockstat->st_ndeadlocks;
@@ -336,12 +334,12 @@
perf->current_lock_objects = lockstat->st_nobjects;
perf->max_lock_objects = lockstat->st_maxnobjects;
}
- free(lockstat);
+ slapi_ch_free((void **)&lockstat);
}
if (dblayer_db_uses_mpool(db_env))
{
DB_MPOOL_STAT *mpstat = NULL;
- ret = MEMP_STAT(db_env,&mpstat,NULL,0,malloc);
+ ret = MEMP_STAT(db_env,&mpstat,NULL,0,(void *)slapi_ch_malloc);
if (0 == ret) {
#define ONEG 1073741824
perf->cache_size_bytes = mpstat->st_gbytes * ONEG + mpstat->st_bytes;
@@ -362,7 +360,7 @@
perf->clean_pages = mpstat->st_page_clean;
perf->page_trickle_rate = mpstat->st_page_trickle;
perf->cache_region_wait_rate = mpstat->st_region_wait;
- free(mpstat);
+ slapi_ch_free((void **)&mpstat);
}
}
/* Place the stats in the shared memory region */
Index: seq.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/seq.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- seq.c 10 Nov 2006 23:45:39 -0000 1.5
+++ seq.c 15 Oct 2008 06:30:10 -0000 1.6
@@ -184,7 +184,7 @@
return_value = dbc->c_get(dbc,&key,&data,DB_SET);
if (0 == return_value)
{
- free(data.data);
+ slapi_ch_free(&(data.data));
return_value = dbc->c_get(dbc,&key,&data,DB_NEXT);
}
else
@@ -198,7 +198,7 @@
return_value = dbc->c_get(dbc,&key,&data,DB_SET);
if (0 == return_value )
{
- free(data.data);
+ slapi_ch_free(&(data.data));
return_value = dbc->c_get(dbc,&key,&data,DB_PREV);
}
else
@@ -216,7 +216,7 @@
return_value = dbc->c_get(dbc,&key,&data,DB_SET_RANGE);
if (0 == return_value || DB_NOTFOUND == return_value)
{
- free(data.data);
+ slapi_ch_free(&(data.data));
return_value = dbc->c_get(dbc,&key,&data,DB_PREV);
}
}
@@ -252,11 +252,11 @@
} else if ( err != 0 && err != DB_NOTFOUND ) {
ldbm_nasty("ldbm_back_seq database error", 1650, err);
}
- free( data.data );
+ slapi_ch_free( &(data.data) );
if ( key.data != little_buffer && key.data != &keystring ) {
- free( key.data );
+ slapi_ch_free( &(key.data) );
}
- free( big_buffer );
+ slapi_ch_free_string( &big_buffer );
}
/* null idlist means there were no matching keys */
Index: sort.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/sort.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- sort.c 18 Oct 2007 00:08:34 -0000 1.11
+++ sort.c 15 Oct 2008 06:30:10 -0000 1.12
@@ -395,7 +395,7 @@
}
/* normalize */
type = slapi_attr_syntax_normalize(rtype);
- free(rtype);
+ slapi_ch_free_string(&rtype);
/* Now look for the next tag. */
Index: vlv.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/vlv.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- vlv.c 2 Oct 2007 23:21:31 -0000 1.15
+++ vlv.c 15 Oct 2008 06:30:10 -0000 1.16
@@ -959,14 +959,14 @@
err= dbc->c_get(dbc,&key,&data,DB_SET_RANGE);
if(err==0)
{
- free(data.data);
+ slapi_ch_free(&(data.data));
err= dbc->c_get(dbc,&key,&data,DB_GET_RECNO);
if(err==0)
{
si= *((db_recno_t*)data.data);
/* Records are numbered from one. */
si--;
- free(data.data);
+ slapi_ch_free(&(data.data));
LDAPDebug( LDAP_DEBUG_TRACE, "<= vlv_build_candidate_list_byvalue: Found. Index=%lu\n",si,0,0);
}
else
@@ -1029,7 +1029,7 @@
err = dbc->c_get(dbc, &key, &data, DB_SET_RECNO);
while ((err == 0) && (recno <= stop+1)) {
if (key.data != &recno)
- free(key.data);
+ slapi_ch_free(&(key.data));
idl_append(idl, *(ID *)data.data);
if (++recno <= stop+1) {
err = dbc->c_get(dbc, &key, &data, DB_NEXT);
@@ -1955,7 +1955,7 @@
/* similar to what the console GUI does */
char *create_vlv_search_tag(const char* dn) {
- char *tmp2=strdup(dn);
+ char *tmp2=slapi_ch_strdup(dn);
replace_char(tmp2,',',' ');
replace_char(tmp2,'"','-');
Index: vlv_srch.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/vlv_srch.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- vlv_srch.c 20 Sep 2007 16:58:41 -0000 1.8
+++ vlv_srch.c 15 Oct 2008 06:30:11 -0000 1.9
@@ -673,8 +673,8 @@
err= dbc->c_get(dbc,&key,&data,DB_LAST);
if(err==0)
{
- free(key.data); key.data= NULL;
- free(data.data); data.data= NULL;
+ slapi_ch_free(&(key.data));
+ slapi_ch_free(&(data.data));
err= dbc->c_get(dbc,&key,&data,DB_GET_RECNO);
if(err==0)
{
@@ -682,7 +682,7 @@
p->vlv_indexlength_cached= 1;
p->vlv_indexlength= *((db_recno_t*)data.data);
PR_Unlock(p->vlv_indexlength_lock);
- free(data.data);
+ slapi_ch_free(&(data.data));
}
}
dbc->c_close(dbc);
- Previous message (by thread): [Fedora-directory-commits] ldapserver/ldap/servers/slapd mempool.c, NONE, 1.1 add.c, 1.12, 1.13 attrsyntax.c, 1.7, 1.8 ava.c, 1.7, 1.8 bind.c, 1.14, 1.15 ch_malloc.c, 1.9, 1.10 computed.c, 1.5, 1.6 connection.c, 1.19, 1.20 entry.c, 1.18, 1.19 filter.c, 1.10, 1.11 filtercmp.c, 1.6, 1.7 libglobs.c, 1.25, 1.26 main.c, 1.25, 1.26 operation.c, 1.6, 1.7 proto-slap.h, 1.36, 1.37 rwlock.c, 1.5, 1.6 slap.h, 1.35, 1.36 slapi2nspr.c, 1.5, 1.6
- Next message (by thread): [Fedora-directory-commits] ldapserver/ldap/servers/slapd/tools pwenc.c, 1.10, 1.11
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Fedora-directory-commits
mailing list