[asterisk-commits] rizzo: branch rizzo/astobj2 r47319 -
/team/rizzo/astobj2/main/astobj2.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Wed Nov 8 07:35:12 MST 2006
Author: rizzo
Date: Wed Nov 8 08:35:11 2006
New Revision: 47319
URL: http://svn.digium.com/view/asterisk?rev=47319&view=rev
Log:
add a counter of the total number of objects,
for debugging purposes.
Modified:
team/rizzo/astobj2/main/astobj2.c
Modified: team/rizzo/astobj2/main/astobj2.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/main/astobj2.c?rev=47319&r1=47318&r2=47319&view=diff
==============================================================================
--- team/rizzo/astobj2/main/astobj2.c (original)
+++ team/rizzo/astobj2/main/astobj2.c Wed Nov 8 08:35:11 2006
@@ -51,6 +51,8 @@
void *user_data[0];
};
+volatile int astobj2_total_objects;
+
/*
* From a pointer _p to a user-defined object,
* return the pointer to the astobj2 structure
@@ -115,6 +117,7 @@
*/
bzero(obj, sizeof(struct astobj2 *) + sizeof(void *) );
free(obj);
+ ast_atomic_fetchadd_int(&astobj2_total_objects, -1);
}
return ret;
@@ -141,6 +144,7 @@
ast_mutex_init(&obj->priv_data.lock);
obj->priv_data.ref_counter = 1;
obj->priv_data.destructor_fn = destructor_fn; /* can be NULL */
+ ast_atomic_fetchadd_int(&astobj2_total_objects, 1);
/* return a pointer to the user data */
return EXTERNAL_OBJ(obj);
@@ -496,6 +500,8 @@
lim = atoi(argv[2]);
ast_cli(fd, "called astobj_test\n");
+ ast_verbose("at the beginning have %d objects\n",
+ astobj2_total_objects);
/*
* allocate a container with no default callback, and no hash function.
* No hash means everything goes in the same bucket.
@@ -536,6 +542,8 @@
ast_cli(fd, "destroy container\n");
astobj2_ref(c1, -1); /* destroy container */
+ ast_verbose("at the end have %d objects\n",
+ astobj2_total_objects);
return 0;
}
More information about the asterisk-commits
mailing list