mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-11-03 20:38:59 +00:00 
			
		
		
		
	Ensure that astobj2 memory allocations are properly accounted for when MALLOC_DEBUG is used
This commit ensures that all astobj2 allocated objects are properly accounted for in MALLOC_DEBUG mode by passing down the file/function/line information from the module/function that actually called the astobj2 allocation function. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@192059 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
		@@ -135,7 +135,6 @@ enum ao2_callback_type {
 | 
			
		||||
/* the underlying functions common to debug and non-debug versions */
 | 
			
		||||
 | 
			
		||||
static int internal_ao2_ref(void *user_data, const int delta);
 | 
			
		||||
static void *internal_ao2_alloc(size_t data_size, ao2_destructor_fn destructor_fn);
 | 
			
		||||
static struct ao2_container *internal_ao2_container_alloc(struct ao2_container *c, const uint n_buckets, ao2_hash_fn *hash_fn,
 | 
			
		||||
							  ao2_callback_fn *cmp_fn);
 | 
			
		||||
static struct bucket_list *internal_ao2_link(struct ao2_container *c, void *user_data, const char *file, int line, const char *func);
 | 
			
		||||
@@ -303,7 +302,7 @@ static int internal_ao2_ref(void *user_data, const int delta)
 | 
			
		||||
 * We always alloc at least the size of a void *,
 | 
			
		||||
 * for debugging purposes.
 | 
			
		||||
 */
 | 
			
		||||
static void *internal_ao2_alloc(size_t data_size, ao2_destructor_fn destructor_fn)
 | 
			
		||||
static void *internal_ao2_alloc(size_t data_size, ao2_destructor_fn destructor_fn, char *file, int line, const char *funcname)
 | 
			
		||||
{
 | 
			
		||||
	/* allocation */
 | 
			
		||||
	struct astobj2 *obj;
 | 
			
		||||
@@ -311,7 +310,11 @@ static void *internal_ao2_alloc(size_t data_size, ao2_destructor_fn destructor_f
 | 
			
		||||
	if (data_size < sizeof(void *))
 | 
			
		||||
		data_size = sizeof(void *);
 | 
			
		||||
 | 
			
		||||
#if defined(__AST_DEBUG_MALLOC)
 | 
			
		||||
	obj = __ast_calloc(1, sizeof(*obj) + data_size, file, line, funcname);
 | 
			
		||||
#else
 | 
			
		||||
	obj = ast_calloc(1, sizeof(*obj) + data_size);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	if (obj == NULL)
 | 
			
		||||
		return NULL;
 | 
			
		||||
@@ -338,7 +341,7 @@ void *__ao2_alloc_debug(size_t data_size, ao2_destructor_fn destructor_fn, char
 | 
			
		||||
	void *obj;
 | 
			
		||||
	FILE *refo = fopen(REF_FILE,"a");
 | 
			
		||||
 | 
			
		||||
	obj = internal_ao2_alloc(data_size, destructor_fn);
 | 
			
		||||
	obj = internal_ao2_alloc(data_size, destructor_fn, file, line, funcname);
 | 
			
		||||
 | 
			
		||||
	if (obj == NULL)
 | 
			
		||||
		return NULL;
 | 
			
		||||
@@ -354,7 +357,7 @@ void *__ao2_alloc_debug(size_t data_size, ao2_destructor_fn destructor_fn, char
 | 
			
		||||
 | 
			
		||||
void *__ao2_alloc(size_t data_size, ao2_destructor_fn destructor_fn)
 | 
			
		||||
{
 | 
			
		||||
	return internal_ao2_alloc(data_size, destructor_fn);
 | 
			
		||||
	return internal_ao2_alloc(data_size, destructor_fn, NULL, 0, NULL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user