[Fedora-directory-commits] ldapserver/ldap/servers/plugins/replication cl5_api.c, 1.22, 1.23 repl5_agmt.c, 1.13, 1.14 repl_controls.c, 1.9, 1.10 repl_objset.c, 1.5, 1.6 replutil.c, 1.11, 1.12 urp.c, 1.6, 1.7
Noriko Hosoi
nhosoi at fedoraproject.org
Wed Oct 15 06:30:01 UTC 2008
Author: nhosoi
Update of /cvs/dirsec/ldapserver/ldap/servers/plugins/replication
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv25637/ldap/servers/plugins/replication
Modified Files:
cl5_api.c repl5_agmt.c repl_controls.c repl_objset.c
replutil.c urp.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: cl5_api.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/cl5_api.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- cl5_api.c 8 Oct 2008 17:29:02 -0000 1.22
+++ cl5_api.c 15 Oct 2008 06:29:58 -0000 1.23
@@ -1008,7 +1008,7 @@
}
/* copy db log files */
- rc = LOG_ARCHIVE(s_cl5Desc.dbEnv, &list, DB_ARCH_LOG, malloc);
+ rc = LOG_ARCHIVE(s_cl5Desc.dbEnv, &list, DB_ARCH_LOG, (void *)slapi_ch_malloc);
if (rc != 0)
{
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
@@ -1037,7 +1037,7 @@
logFile ++;
}
- free(list);
+ slapi_ch_free((void **)&list);
}
/* now, copy the version file */
@@ -2535,7 +2535,7 @@
}
/* allocate data buffer */
- (*data) = (char *) slapi_ch_malloc (size);
+ (*data) = slapi_ch_malloc (size);
if ((*data) == NULL)
{
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
@@ -3029,7 +3029,7 @@
bv->bv_len = length;
if (bv->bv_len > 0) {
- bv->bv_val = (char*)slapi_ch_malloc (bv->bv_len);
+ bv->bv_val = slapi_ch_malloc (bv->bv_len);
memcpy (bv->bv_val, *buff, bv->bv_len);
*buff += bv->bv_len;
}
@@ -3216,7 +3216,7 @@
char filename[MAXPATHLEN + 1];
/* find out which log files don't contain active txns */
- rc = LOG_ARCHIVE(s_cl5Desc.dbEnv, &list, 0, malloc);
+ rc = LOG_ARCHIVE(s_cl5Desc.dbEnv, &list, 0, (void *)slapi_ch_malloc);
if (0 == rc && NULL != list)
{
/* zap 'em ! */
@@ -3982,6 +3982,16 @@
s_cl5Desc.dbConfig.fileMode = FILE_CREATE_MODE;
}
+/*
+ * a wrapper for slapi_ch_free; it's declared to set slapi_ch_free in BDB
+ * dbEnv->set_alloc(dbEnv, (void *)slapi_ch_malloc, (void *)slapi_ch_realloc, _cl5_api_free);
+ *
+ */
+void _cl5_api_free(void *ptr)
+{
+ slapi_ch_free(&ptr);
+}
+
#define ONEG 1073741824 /* one giga bytes */
static void _cl5InitDBEnv(DB_ENV *dbEnv)
{
@@ -4011,7 +4021,7 @@
dbEnv->set_errcall(dbEnv, _cl5DBLogPrint);
}
#if 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR >= 3300
- dbEnv->set_alloc(dbEnv, malloc, realloc, free);
+ dbEnv->set_alloc(dbEnv, (void *)slapi_ch_malloc, (void *)slapi_ch_realloc, _cl5_api_free);
#endif
}
@@ -4393,7 +4403,7 @@
{
case 0: pos = data.data;
rc = _cl5ReadBervals (&vals, &pos, data.size);
- free (data.data);
+ slapi_ch_free (&(data.data));
if (rc != CL5_SUCCESS)
return rc;
@@ -4473,7 +4483,7 @@
#endif
rc = file->db->put(file->db, txnid, &key, &data, DEFAULT_DB_OP_FLAGS);
- slapi_ch_free ((void**)&data.data);
+ slapi_ch_free (&(data.data));
if ( rc == 0 )
{
#if 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR < 4100
@@ -4748,7 +4758,7 @@
switch (rc)
{
case 0: file->entryCount = *(int*)data.data;
- free (data.data);
+ slapi_ch_free (&(data.data));
/* delete the entry. the entry is re-added when file
is successfully closed */
@@ -4765,7 +4775,7 @@
#elif 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR >= 3300
rc = file->db->stat(file->db, (void*)&stats, 0);
#else
- rc = file->db->stat(file->db, (void*)&stats, malloc, 0);
+ rc = file->db->stat(file->db, (void*)&stats, (void *)slapi_ch_malloc, 0);
#endif
if (rc != 0)
{
@@ -4784,7 +4794,7 @@
"_cl5GetEntryCount: %d changes for replica %s\n",
file->entryCount, file->replName);
- free (stats);
+ slapi_ch_free ((void **)&stats);
return CL5_SUCCESS;
default: slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
@@ -4950,7 +4960,7 @@
}
/* allocate buffer */
- buff = (char*)slapi_ch_malloc (len);
+ buff = slapi_ch_malloc (len);
start = buff;
if (buff == NULL)
{
@@ -5315,7 +5325,7 @@
rc = CL5_SUCCESS;
done:
if (data->data)
- slapi_ch_free ((void**)&data->data);
+ slapi_ch_free (&(data->data));
slapi_ch_free((void**) &data);
if (file_obj)
@@ -5353,15 +5363,15 @@
/* skip service entries */
if (cl5HelperEntry ((char*)key.data, NULL))
{
- free (key.data);
- free (data.data);
+ slapi_ch_free (&(key.data));
+ slapi_ch_free (&(data.data));
continue;
}
/* format entry */
- free (key.data);
+ slapi_ch_free (&(key.data));
rc = cl5DBData2Entry (data.data, data.size, entry);
- free (data.data);
+ slapi_ch_free (&(data.data));
if (rc != 0)
{
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl,
@@ -5397,8 +5407,8 @@
/* successfully retrieved next entry but it was out of range */
if (rc == CL5_SUCCESS)
{
- free (key.data);
- free (data.data);
+ slapi_ch_free (&(key.data));
+ slapi_ch_free (&(data.data));
rc = CL5_NOTFOUND;
goto done;
}
@@ -5429,15 +5439,15 @@
{
if (cl5HelperEntry ((char*)key.data, NULL))
{
- free (key.data);
- free (data.data);
+ slapi_ch_free (&(key.data));
+ slapi_ch_free (&(data.data));
continue;
}
- free (key.data);
+ slapi_ch_free (&(key.data));
/* format entry */
rc = cl5DBData2Entry (data.data, data.size, entry);
- free (data.data);
+ slapi_ch_free (&(data.data));
if (rc != 0)
{
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl,
@@ -5558,8 +5568,7 @@
if (obj)
object_release (obj);
- if (data.data)
- free (data.data);
+ slapi_ch_free (&(data.data));
return rc;
}
@@ -6341,7 +6350,7 @@
}
#if 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR < 3300
- rc = db->set_malloc(db, malloc);
+ rc = db->set_malloc(db, (void *)slapi_ch_malloc);
if (0 != rc) {
goto out;
}
Index: repl5_agmt.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/repl5_agmt.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- repl5_agmt.c 8 Oct 2008 17:29:02 -0000 1.13
+++ repl5_agmt.c 15 Oct 2008 06:29:58 -0000 1.14
@@ -977,12 +977,12 @@
if (NULL != sval)
{
const char *val = slapi_value_get_string(sval);
- ra->binddn = strdup(val);
+ ra->binddn = slapi_ch_strdup(val);
}
}
/* If no BindDN set, set to zero-length string */
if (ra->binddn == NULL) {
- ra->binddn = strdup("");
+ ra->binddn = slapi_ch_strdup("");
}
PR_Unlock(ra->lock);
prot_notify_agmt_changed(ra->protocol, ra->long_name);
Index: repl_controls.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/repl_controls.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- repl_controls.c 18 Oct 2007 00:08:31 -0000 1.9
+++ repl_controls.c 15 Oct 2008 06:29:58 -0000 1.10
@@ -254,7 +254,7 @@
goto loser;
}
slapi_mods_add_modbvps(&modrdn_smods, op, type, embvals);
- free( type );
+ slapi_ch_free_string( &type );
ber_bvecfree( embvals );
}
got_modrdn_mods = PR_TRUE;
@@ -364,7 +364,7 @@
to end up in the entry. We need to remove the old ones.
*/
}
- free( type );
+ slapi_ch_free_string( &type );
ber_bvecfree( embvals );
}
}
Index: repl_objset.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/repl_objset.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- repl_objset.c 10 Nov 2006 23:45:17 -0000 1.5
+++ repl_objset.c 15 Oct 2008 06:29:58 -0000 1.6
@@ -95,7 +95,7 @@
p->lock = PR_NewLock();
if (NULL == p->lock)
{
- free(p); p = NULL;
+ slapi_ch_free((void **)&p);
}
p->objects = llistNew();
p->destructor = destructor;
@@ -196,7 +196,7 @@
/* Free the linked list */
llistDestroy(&(*o)->objects, (*o)->destructor);
PR_DestroyLock((*o)->lock);
- free(*o); *o = NULL;
+ slapi_ch_free((void **)o);
}
}
@@ -270,9 +270,9 @@
llistRemove(o->objects, co->key);
/* Destroy the object */
o->destructor(&(co->data));
- free(co->key);
+ slapi_ch_free((void **)&(co->key));
/* Deallocate the container */
- free(co);
+ slapi_ch_free((void **)&co);
}
static Repl_Objset_object *
@@ -287,9 +287,9 @@
ro = llistRemoveCurrentAndGetNext (o->objects, &iterator);
o->destructor(&(co->data));
- free(co->key);
+ slapi_ch_free((void **)&(co->key));
/* Deallocate the container */
- free(co);
+ slapi_ch_free((void **)&co);
return ro;
}
Index: replutil.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/replutil.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- replutil.c 18 Oct 2007 00:08:31 -0000 1.11
+++ replutil.c 15 Oct 2008 06:29:58 -0000 1.12
@@ -170,7 +170,7 @@
}
puts( p );
fflush( stdout );
- free( p );
+ slapi_ch_free_string( &p );
return;
}
@@ -198,8 +198,8 @@
int return_value = -1;
int bytes_to_write = 0;
- /* malloc the buffer */
- buffer = (char*) malloc(64*1024);
+ /* allocate the buffer */
+ buffer = slapi_ch_malloc(64*1024);
if (NULL == buffer)
{
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "copy file: memory allocation failed\n");
@@ -250,10 +250,7 @@
{
close(dest_fd);
}
- if (NULL != buffer)
- {
- free(buffer);
- }
+ slapi_ch_free_string(&buffer);
return return_value;
#endif
}
@@ -263,7 +260,7 @@
age_str2time (const char *age)
{
char *maxage;
- char unit;
+ char unit;
time_t ageval;
if (age == NULL || age[0] == '\0' || strcmp (age, "0") == 0)
@@ -272,14 +269,11 @@
}
maxage = slapi_ch_strdup ( age );
- unit = maxage[ strlen( maxage ) - 1 ];
- maxage[ strlen( maxage ) - 1 ] = '\0';
- ageval = strntoul( maxage, strlen( maxage ), 10 );
- if ( maxage)
- {
- slapi_ch_free ( (void **) &maxage );
- }
- switch ( unit )
+ unit = maxage[ strlen( maxage ) - 1 ];
+ maxage[ strlen( maxage ) - 1 ] = '\0';
+ ageval = strntoul( maxage, strlen( maxage ), 10 );
+ slapi_ch_free_string(&maxage);
+ switch ( unit )
{
case 's':
break;
@@ -297,10 +291,10 @@
break;
default:
slapi_log_error( SLAPI_LOG_PLUGIN, repl_plugin_name,
- "age_str2time: unknown unit \"%c\" "
+ "age_str2time: unknown unit \"%c\" "
"for maxiumum changelog age\n", unit );
ageval = -1;
- }
+ }
return ageval;
}
@@ -394,7 +388,7 @@
addlenstr( l, buf );
- free( buf );
+ slapi_ch_free_string( &buf );
}
addlenstr( l, "-\n" );
}
@@ -635,7 +629,7 @@
control = (LDAPControl*)slapi_ch_malloc (sizeof (LDAPControl));
control->ldctl_oid = slapi_ch_strdup ("2.16.840.1.113730.3.4.14");
- control->ldctl_value.bv_val = strdup(be_name);
+ control->ldctl_value.bv_val = slapi_ch_strdup(be_name);
control->ldctl_value.bv_len = strlen (be_name);
control->ldctl_iscritical = 1;
}
Index: urp.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/urp.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- urp.c 10 Nov 2006 23:45:17 -0000 1.6
+++ urp.c 15 Oct 2008 06:29:59 -0000 1.7
@@ -343,7 +343,7 @@
* Remember to turn this entry back to tombstone in post op.
* We'll just borrow an obsolete pblock type here.
*/
- slapi_pblock_set (pb, SLAPI_URP_TOMBSTONE_UNIQUEID, strdup(op_uniqueid));
+ slapi_pblock_set (pb, SLAPI_URP_TOMBSTONE_UNIQUEID, slapi_ch_strdup(op_uniqueid));
rc= slapi_setbit_int(rc,SLAPI_RTN_BIT_FETCH_TARGET_ENTRY);
rc = 0;
}
More information about the Fedora-directory-commits
mailing list