[svn-commits] mmichelson: branch mmichelson/npm_fixes r181247 - in /team/mmichelson/npm_fix...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Mar 11 09:58:12 CDT 2009


Author: mmichelson
Date: Wed Mar 11 09:58:08 2009
New Revision: 181247

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=181247
Log:
Resolve conflicts. Reset Automerge. Main screen turn on.


Modified:
    team/mmichelson/npm_fixes/   (props changed)
    team/mmichelson/npm_fixes/apps/app_confbridge.c
    team/mmichelson/npm_fixes/apps/app_queue.c
    team/mmichelson/npm_fixes/channels/chan_sip.c
    team/mmichelson/npm_fixes/channels/h323/ast_h323.cxx
    team/mmichelson/npm_fixes/doc/google-soc2009-ideas.txt
    team/mmichelson/npm_fixes/include/asterisk/astmm.h
    team/mmichelson/npm_fixes/include/asterisk/astobj2.h
    team/mmichelson/npm_fixes/include/asterisk/hashtab.h
    team/mmichelson/npm_fixes/include/asterisk/heap.h
    team/mmichelson/npm_fixes/include/asterisk/strings.h
    team/mmichelson/npm_fixes/include/asterisk/utils.h
    team/mmichelson/npm_fixes/main/astobj2.c
    team/mmichelson/npm_fixes/main/features.c
    team/mmichelson/npm_fixes/main/hashtab.c
    team/mmichelson/npm_fixes/main/heap.c
    team/mmichelson/npm_fixes/main/pbx.c
    team/mmichelson/npm_fixes/main/strings.c
    team/mmichelson/npm_fixes/pbx/pbx_config.c
    team/mmichelson/npm_fixes/utils/Makefile
    team/mmichelson/npm_fixes/utils/extconf.c

Propchange: team/mmichelson/npm_fixes/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/mmichelson/npm_fixes/
------------------------------------------------------------------------------
Binary property 'branch-1.4-blocked' - no diff available.

Propchange: team/mmichelson/npm_fixes/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/mmichelson/npm_fixes/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Mar 11 09:58:08 2009
@@ -1,1 +1,1 @@
-/trunk:1-180975
+/trunk:1-181246

Modified: team/mmichelson/npm_fixes/apps/app_confbridge.c
URL: http://svn.digium.com/svn-view/asterisk/team/mmichelson/npm_fixes/apps/app_confbridge.c?view=diff&rev=181247&r1=181246&r2=181247
==============================================================================
--- team/mmichelson/npm_fixes/apps/app_confbridge.c (original)
+++ team/mmichelson/npm_fixes/apps/app_confbridge.c Wed Mar 11 09:58:08 2009
@@ -271,11 +271,13 @@
 		}
 
 		/* Next play the audio file stating they are going to be placed into the conference */
-		ao2_unlock(conference_bridge);
-		ast_autoservice_start(conference_bridge_user->chan);
-		play_sound_file(conference_bridge, "conf-placeintoconf");
-		ast_autoservice_stop(conference_bridge_user->chan);
-		ao2_lock(conference_bridge);
+		if (!ast_test_flag(&conference_bridge_user->flags, OPTION_QUIET)) {
+			ao2_unlock(conference_bridge);
+			ast_autoservice_start(conference_bridge_user->chan);
+			play_sound_file(conference_bridge, "conf-placeintoconf");
+			ast_autoservice_stop(conference_bridge_user->chan);
+			ao2_lock(conference_bridge);
+		}
 
 		/* Finally iterate through and unmute them all */
 		AST_LIST_TRAVERSE(&conference_bridge->users_list, other_conference_bridge_user, list) {
@@ -505,11 +507,13 @@
 			}
 
 			/* Play back the audio prompt saying the leader has left the conference */
-			ao2_unlock(conference_bridge);
-			ast_autoservice_start(conference_bridge_user->chan);
-			play_sound_file(conference_bridge, "conf-leaderhasleft");
-			ast_autoservice_stop(conference_bridge_user->chan);
-			ao2_lock(conference_bridge);
+			if (!ast_test_flag(&conference_bridge_user->flags, OPTION_QUIET)) {
+				ao2_unlock(conference_bridge);
+				ast_autoservice_start(conference_bridge_user->chan);
+				play_sound_file(conference_bridge, "conf-leaderhasleft");
+				ast_autoservice_stop(conference_bridge_user->chan);
+				ao2_lock(conference_bridge);
+			}
 
 			/* Now on to starting MOH if needed */
 			AST_LIST_TRAVERSE(&conference_bridge->users_list, other_participant, list) {

Modified: team/mmichelson/npm_fixes/apps/app_queue.c
URL: http://svn.digium.com/svn-view/asterisk/team/mmichelson/npm_fixes/apps/app_queue.c?view=diff&rev=181247&r1=181246&r2=181247
==============================================================================
--- team/mmichelson/npm_fixes/apps/app_queue.c (original)
+++ team/mmichelson/npm_fixes/apps/app_queue.c Wed Mar 11 09:58:08 2009
@@ -1826,11 +1826,13 @@
 			ast_variables_destroy(queue_vars);
 		}
 		/* update the use_weight value if the queue's has gained or lost a weight */ 
-		if (!q->weight && prev_weight) {
-			ast_atomic_fetchadd_int(&use_weight, -1);
-		}
-		if (q->weight && !prev_weight) {
-			ast_atomic_fetchadd_int(&use_weight, +1);
+		if (q) {
+			if (!q->weight && prev_weight) {
+				ast_atomic_fetchadd_int(&use_weight, -1);
+			}
+			if (q->weight && !prev_weight) {
+				ast_atomic_fetchadd_int(&use_weight, +1);
+			}
 		}
 		/* Other cases will end up with the proper value for use_weight */
 		ao2_unlock(queues);

Modified: team/mmichelson/npm_fixes/channels/chan_sip.c
URL: http://svn.digium.com/svn-view/asterisk/team/mmichelson/npm_fixes/channels/chan_sip.c?view=diff&rev=181247&r1=181246&r2=181247
==============================================================================
--- team/mmichelson/npm_fixes/channels/chan_sip.c (original)
+++ team/mmichelson/npm_fixes/channels/chan_sip.c Wed Mar 11 09:58:08 2009
@@ -4200,7 +4200,7 @@
 		if (onoff) {
 			if (!ast_exists_extension(NULL, context, ext, 1, NULL)) {
 				ast_add_extension(context, 1, ext, 1, NULL, NULL, "Noop",
-					 ast_strdup(peer->name), ast_free, "SIP");
+					 ast_strdup(peer->name), ast_free_ptr, "SIP");
 			}
 		} else if (pbx_find_extension(NULL, NULL, &q, context, ext, 1, NULL, "", E_MATCH)) {
 			ast_context_remove_extension(context, ext, 1, NULL);
@@ -12389,7 +12389,6 @@
 		/* Go ahead and lock it (and its owner) before returning */
 		sip_pvt_lock(sip_pvt_ptr);
 		if (sip_cfg.pedanticsipchecking) {
-			const char *pvt_fromtag, *pvt_totag;
 			unsigned char frommismatch = 0, tomismatch = 0;
 
 			if (ast_strlen_zero(fromtag)) {
@@ -12405,31 +12404,34 @@
 					  sip_pvt_ptr->outgoing_call == TRUE ? "OUTGOING": "INCOMING", sip_pvt_ptr->callid);
 				return NULL;
 			}
-
-			if (sip_pvt_ptr->outgoing_call == TRUE) {
-				/* Outgoing call tags : from is "our", to is "their" */
-				pvt_fromtag = sip_pvt_ptr->tag ;
-				pvt_totag = sip_pvt_ptr->theirtag ;
-			} else {
-				/* Incoming call tags : from is "their", to is "our" */
-				pvt_fromtag = sip_pvt_ptr->theirtag ;
-				pvt_totag = sip_pvt_ptr->tag ;
-			}
-
-			frommismatch = !!strcmp(fromtag, pvt_fromtag);
-			tomismatch = !!strcmp(totag, pvt_totag);
+			/* RFC 3891
+			 * > 3.  User Agent Server Behavior: Receiving a Replaces Header
+			 * > The Replaces header contains information used to match an existing
+			 * > SIP dialog (call-id, to-tag, and from-tag).  Upon receiving an INVITE
+			 * > with a Replaces header, the User Agent (UA) attempts to match this
+			 * > information with a confirmed or early dialog.  The User Agent Server
+			 * > (UAS) matches the to-tag and from-tag parameters as if they were tags
+			 * > present in an incoming request.  In other words, the to-tag parameter
+			 * > is compared to the local tag, and the from-tag parameter is compared
+			 * > to the remote tag.
+			 *
+			 * Thus, the totag is always compared to the local tag, regardless if
+			 * this our call is an incoming or outgoing call.
+			 */
+			frommismatch = !!strcmp(fromtag, sip_pvt_ptr->theirtag);
+			tomismatch = !!strcmp(totag, sip_pvt_ptr->tag);
 
 			if (frommismatch || tomismatch) {
 				sip_pvt_unlock(sip_pvt_ptr);
 				if (frommismatch) {
 					ast_debug(4, "Matched %s call for callid=%s - pedantic from tag check fails; their tag is %s our tag is %s\n",
 						  sip_pvt_ptr->outgoing_call == TRUE ? "OUTGOING": "INCOMING", sip_pvt_ptr->callid, 
-						  fromtag, pvt_fromtag);
+						  fromtag, sip_pvt_ptr->theirtag);
 				}
 				if (tomismatch) {
 					ast_debug(4, "Matched %s call for callid=%s - pedantic to tag check fails; their tag is %s our tag is %s\n",
 						  sip_pvt_ptr->outgoing_call == TRUE ? "OUTGOING": "INCOMING", sip_pvt_ptr->callid, 
-						  totag, pvt_totag);
+						  totag, sip_pvt_ptr->tag);
 				}
 				return NULL;
 			}

Modified: team/mmichelson/npm_fixes/channels/h323/ast_h323.cxx
URL: http://svn.digium.com/svn-view/asterisk/team/mmichelson/npm_fixes/channels/h323/ast_h323.cxx?view=diff&rev=181247&r1=181246&r2=181247
==============================================================================
--- team/mmichelson/npm_fixes/channels/h323/ast_h323.cxx (original)
+++ team/mmichelson/npm_fixes/channels/h323/ast_h323.cxx Wed Mar 11 09:58:08 2009
@@ -140,7 +140,7 @@
 
 int PAsteriskLog::Buffer::sync()
 {
-	char *str = strdup(string);
+	char *str = ast_strdup(string);
 	char *s, *s1;
 	char c;
 
@@ -156,7 +156,7 @@
 		ast_verbose("%s", s);
 		*s1 = c;
 	}
-	free(str);
+	ast_free(str);
 
 	string = PString();
 	char *base = string.GetPointer(2000);
@@ -2141,7 +2141,7 @@
 		/* tell the H.323 stack */
 		SetExternalAddress(H323TransportAddress(localIpAddr, localPort), H323TransportAddress(localIpAddr, localPort + 1));
 		/* clean up allocated memory */
-		free(info);
+		ast_free(info);
 	}
 
 	/* Get the payload code	*/
@@ -2388,7 +2388,7 @@
 			endPoint->SetGateway();
 		}
 		if (prefix)
-			free(prefix);
+			ast_free(prefix);
 	}
 	return 0;
 }

Modified: team/mmichelson/npm_fixes/doc/google-soc2009-ideas.txt
URL: http://svn.digium.com/svn-view/asterisk/team/mmichelson/npm_fixes/doc/google-soc2009-ideas.txt?view=diff&rev=181247&r1=181246&r2=181247
==============================================================================
--- team/mmichelson/npm_fixes/doc/google-soc2009-ideas.txt (original)
+++ team/mmichelson/npm_fixes/doc/google-soc2009-ideas.txt Wed Mar 11 09:58:08 2009
@@ -21,15 +21,15 @@
 Contact:
 
     To get in contact with mentors or the Asterisk development community in
-	general, the best place is the asterisk-dev mailing list, hosted on 
-	http://lists.digium.com/.  Alternatively, many developers can be found in
-	the #asterisk-dev IRC channel on Freenode.  The most active time for this
-	channel on IRC is during US business hours.
+    general, the best place is the asterisk-dev mailing list, hosted on 
+    http://lists.digium.com/.  Alternatively, many developers can be found in
+    the #asterisk-dev IRC channel on Freenode.  The most active time for this
+    channel on IRC is during US business hours.
 
-	Feel free to get in contact with the development community ahead of time if
-	you are a student interested in applying for a project with Asterisk.  We
-	can help explain projects proposed here, or help come up with potential
-	alternative project proposals.
+    Feel free to get in contact with the development community ahead of time if
+    you are a student interested in applying for a project with Asterisk.  We
+    can help explain projects proposed here, or help come up with potential
+    alternative project proposals.
 
 --------------------------------------------------------------------------------
 --------------------------------------------------------------------------------

Modified: team/mmichelson/npm_fixes/include/asterisk/astmm.h
URL: http://svn.digium.com/svn-view/asterisk/team/mmichelson/npm_fixes/include/asterisk/astmm.h?view=diff&rev=181247&r1=181246&r2=181247
==============================================================================
--- team/mmichelson/npm_fixes/include/asterisk/astmm.h (original)
+++ team/mmichelson/npm_fixes/include/asterisk/astmm.h Wed Mar 11 09:58:08 2009
@@ -20,8 +20,15 @@
  * \brief Asterisk memory usage debugging
  */
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifndef _ASTERISK_ASTMM_H
 #define _ASTERISK_ASTMM_H
+
+#ifndef STANDALONE
 
 #define __AST_DEBUG_MALLOC
 
@@ -42,6 +49,7 @@
 #undef strndup
 #undef asprintf
 #undef vasprintf
+#undef free
 
 void *__ast_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func);
 void *__ast_calloc_cache(size_t nmemb, size_t size, const char *file, int lineno, const char *func);
@@ -61,30 +69,60 @@
 #define calloc(a,b) \
 	__ast_calloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
 
+#define ast_calloc(a,b) \
+	__ast_calloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+
 #define ast_calloc_cache(a,b) \
 	__ast_calloc_cache(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
 
 #define malloc(a) \
 	__ast_malloc(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
 
+#define ast_malloc(a) \
+	__ast_malloc(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+
 #define free(a) \
+	__ast_free(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+
+#define ast_free(a) \
 	__ast_free(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
 
 #define realloc(a,b) \
 	__ast_realloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
 
+#define ast_realloc(a,b) \
+	__ast_realloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+
 #define strdup(a) \
+	__ast_strdup(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+
+#define ast_strdup(a) \
 	__ast_strdup(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
 
 #define strndup(a,b) \
 	__ast_strndup(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
 
+#define ast_strndup(a,b) \
+	__ast_strndup(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+
 #define asprintf(a, b, c...) \
+	__ast_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, b, c)
+
+#define ast_asprintf(a, b, c...) \
 	__ast_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, b, c)
 
 #define vasprintf(a,b,c) \
 	__ast_vasprintf(a,b,c,__FILE__, __LINE__, __PRETTY_FUNCTION__)
 
+#define ast_vasprintf(a,b,c) \
+	__ast_vasprintf(a,b,c,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+
+#endif /* !STANDALONE */
+
 #else
 #error "NEVER INCLUDE astmm.h DIRECTLY!!"
 #endif /* _ASTERISK_ASTMM_H */
+
+#ifdef __cplusplus
+}
+#endif

Modified: team/mmichelson/npm_fixes/include/asterisk/astobj2.h
URL: http://svn.digium.com/svn-view/asterisk/team/mmichelson/npm_fixes/include/asterisk/astobj2.h?view=diff&rev=181247&r1=181246&r2=181247
==============================================================================
--- team/mmichelson/npm_fixes/include/asterisk/astobj2.h (original)
+++ team/mmichelson/npm_fixes/include/asterisk/astobj2.h Wed Mar 11 09:58:08 2009
@@ -18,6 +18,10 @@
 #define _ASTERISK_ASTOBJ2_H
 
 #include "asterisk/compat.h"
+
+#ifdef MALLOC_DEBUG
+#define REF_DEBUG
+#endif
 
 /*! \file
  * \ref AstObj2

Modified: team/mmichelson/npm_fixes/include/asterisk/hashtab.h
URL: http://svn.digium.com/svn-view/asterisk/team/mmichelson/npm_fixes/include/asterisk/hashtab.h?view=diff&rev=181247&r1=181246&r2=181247
==============================================================================
--- team/mmichelson/npm_fixes/include/asterisk/hashtab.h (original)
+++ team/mmichelson/npm_fixes/include/asterisk/hashtab.h Wed Mar 11 09:58:08 2009
@@ -291,7 +291,12 @@
  * \retval 1 on success
  * \retval 0 if there's a problem
 */
+#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
+int _ast_hashtab_insert_immediate(struct ast_hashtab *tab, const void *obj, const char *file, int lineno, const char *func);
+#define	ast_hashtab_insert_immediate(a,b)	_ast_hashtab_insert_immediate(a, b, __FILE__, __LINE__, __PRETTY_FUNCTION__)
+#else
 int ast_hashtab_insert_immediate(struct ast_hashtab *tab, const void *obj);
+#endif
 
 /*!
  * \brief Insert without checking, hashing or locking
@@ -303,7 +308,12 @@
  * \retval 1 on success
  * \retval 0 if there's a problem
 */
+#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
+int _ast_hashtab_insert_immediate_bucket(struct ast_hashtab *tab, const void *obj, unsigned int h, const char *file, int lineno, const char *func);
+#define	ast_hashtab_insert_immediate_bucket(a,b,c)	_ast_hashtab_insert_immediate_bucket(a, b, c, __FILE__, __LINE__, __PRETTY_FUNCTION__)
+#else
 int ast_hashtab_insert_immediate_bucket(struct ast_hashtab *tab, const void *obj, unsigned int h);
+#endif
 
 /*!
  * \brief Check and insert new object only if it is not there.
@@ -311,7 +321,12 @@
  * \retval 1 on success
  * \retval  0 if there's a problem, or it's already there.
 */
+#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
+int _ast_hashtab_insert_safe(struct ast_hashtab *tab, const void *obj, const char *file, int lineno, const char *func);
+#define	ast_hashtab_insert_safe(a,b)	_ast_hashtab_insert_safe(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+#else
 int ast_hashtab_insert_safe(struct ast_hashtab *tab, const void *obj);
+#endif
 
 /*!
  * \brief Lookup this object in the hash table.
@@ -344,10 +359,20 @@
 int ast_hashtab_capacity( struct ast_hashtab *tab);
 
 /*! \brief Return a copy of the hash table */
+#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
+struct ast_hashtab *_ast_hashtab_dup(struct ast_hashtab *tab, void *(*obj_dup_func)(const void *obj), const char *file, int lineno, const char *func);
+#define	ast_hashtab_dup(a,b)	_ast_hashtab_dup(a,b,__FILE__,__LINE__,__PRETTY_FUNCTION__)
+#else
 struct ast_hashtab *ast_hashtab_dup(struct ast_hashtab *tab, void *(*obj_dup_func)(const void *obj));
+#endif
 
 /*! \brief Gives an iterator to hastable */
+#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
+struct ast_hashtab_iter *_ast_hashtab_start_traversal(struct ast_hashtab *tab, const char *file, int lineno, const char *func);
+#define	ast_hashtab_start_traversal(a)	_ast_hashtab_start_traversal(a,__FILE__,__LINE__,__PRETTY_FUNCTION__)
+#else
 struct ast_hashtab_iter *ast_hashtab_start_traversal(struct ast_hashtab *tab);
+#endif
 
 /*! \brief end the traversal, free the iterator, unlock if necc. */
 void ast_hashtab_end_traversal(struct ast_hashtab_iter *it);
@@ -367,7 +392,12 @@
 /* ------------------ */
 
 /*! \brief Gives an iterator to hastable */
+#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
+struct ast_hashtab_iter *_ast_hashtab_start_write_traversal(struct ast_hashtab *tab, const char *file, int lineno, const char *func);
+#define	ast_hashtab_start_write_traversal(a)	_ast_hashtab_start_write_traversal(a,__FILE__,__LINE__,__PRETTY_FUNCTION__)
+#else
 struct ast_hashtab_iter *ast_hashtab_start_write_traversal(struct ast_hashtab *tab);
+#endif
 
 /*! \brief Looks up the object, removes the corresponding bucket */
 void *ast_hashtab_remove_object_via_lookup_nolock(struct ast_hashtab *tab, void *obj);

Modified: team/mmichelson/npm_fixes/include/asterisk/heap.h
URL: http://svn.digium.com/svn-view/asterisk/team/mmichelson/npm_fixes/include/asterisk/heap.h?view=diff&rev=181247&r1=181246&r2=181247
==============================================================================
--- team/mmichelson/npm_fixes/include/asterisk/heap.h (original)
+++ team/mmichelson/npm_fixes/include/asterisk/heap.h Wed Mar 11 09:58:08 2009
@@ -97,8 +97,14 @@
  * \return An instance of a max heap
  * \since 1.6.1
  */
+#ifdef MALLOC_DEBUG
+struct ast_heap *_ast_heap_create(unsigned int init_height, ast_heap_cmp_fn cmp_fn,
+		ssize_t index_offset, const char *file, int lineno, const char *func);
+#define	ast_heap_create(a,b,c)	_ast_heap_create(a,b,c,__FILE__,__LINE__,__PRETTY_FUNCTION__)
+#else
 struct ast_heap *ast_heap_create(unsigned int init_height, ast_heap_cmp_fn cmp_fn,
 		ssize_t index_offset);
+#endif
 
 /*!
  * \brief Destroy a max heap
@@ -120,7 +126,12 @@
  * \retval non-zero failure
  * \since 1.6.1
  */
+#ifdef MALLOC_DEBUG
+int _ast_heap_push(struct ast_heap *h, void *elm, const char *file, int lineno, const char *func);
+#define	ast_heap_push(a,b)	_ast_heap_push(a,b,__FILE__,__LINE__,__PRETTY_FUNCTION__)
+#else
 int ast_heap_push(struct ast_heap *h, void *elm);
+#endif
 
 /*!
  * \brief Pop the max element off of the heap

Modified: team/mmichelson/npm_fixes/include/asterisk/strings.h
URL: http://svn.digium.com/svn-view/asterisk/team/mmichelson/npm_fixes/include/asterisk/strings.h?view=diff&rev=181247&r1=181246&r2=181247
==============================================================================
--- team/mmichelson/npm_fixes/include/asterisk/strings.h (original)
+++ team/mmichelson/npm_fixes/include/asterisk/strings.h Wed Mar 11 09:58:08 2009
@@ -372,6 +372,26 @@
  * \note The result of this function is dynamically allocated memory, and must
  *       be free()'d after it is no longer needed.
  */
+#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
+#define	ast_str_create(a)	_ast_str_create(a,__FILE__,__LINE__,__PRETTY_FUNCTION__)
+AST_INLINE_API(
+struct ast_str * attribute_malloc _ast_str_create(size_t init_len,
+		const char *file, int lineno, const char *func),
+{
+	struct ast_str *buf;
+
+	buf = (struct ast_str *)__ast_calloc(1, sizeof(*buf) + init_len, file, lineno, func);
+	if (buf == NULL)
+		return NULL;
+
+	buf->__AST_STR_LEN = init_len;
+	buf->__AST_STR_USED = 0;
+	buf->__AST_STR_TS = DS_MALLOC;
+
+	return buf;
+}
+)
+#else
 AST_INLINE_API(
 struct ast_str * attribute_malloc ast_str_create(size_t init_len),
 {
@@ -388,6 +408,7 @@
 	return buf;
 }
 )
+#endif
 
 /*! \brief Reset the content of a dynamic string.
  * Useful before a series of ast_str_append.
@@ -665,8 +686,14 @@
  *       through calling one of the other functions or macros defined in this
  *       file.
  */
+#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
+int __attribute__((format(printf, 4, 0))) __ast_debug_str_helper(struct ast_str **buf, size_t max_len,
+							   int append, const char *fmt, va_list ap, const char *file, int lineno, const char *func);
+#define __ast_str_helper(a,b,c,d,e)	__ast_debug_str_helper(a,b,c,d,e,__FILE__,__LINE__,__PRETTY_FUNCTION__)
+#else
 int __attribute__((format(printf, 4, 0))) __ast_str_helper(struct ast_str **buf, size_t max_len,
 							   int append, const char *fmt, va_list ap);
+#endif
 char *__ast_str_helper2(struct ast_str **buf, size_t max_len,
 	const char *src, size_t maxsrc, int append, int escapecommas);
 

Modified: team/mmichelson/npm_fixes/include/asterisk/utils.h
URL: http://svn.digium.com/svn-view/asterisk/team/mmichelson/npm_fixes/include/asterisk/utils.h?view=diff&rev=181247&r1=181246&r2=181247
==============================================================================
--- team/mmichelson/npm_fixes/include/asterisk/utils.h (original)
+++ team/mmichelson/npm_fixes/include/asterisk/utils.h Wed Mar 11 09:58:08 2009
@@ -398,7 +398,6 @@
 
 long int ast_random(void);
 
-#define ast_free free
 
 /*! 
  * \brief free() wrapper
@@ -413,6 +412,7 @@
 	ast_free(ptr);
 }
 #else
+#define ast_free free
 #define ast_free_ptr ast_free
 #endif
 
@@ -597,19 +597,6 @@
 	return res;
 }
 )
-
-#else
-
-/* If astmm is in use, let it handle these.  Otherwise, it will report that
-   all allocations are coming from this header file */
-
-#define ast_malloc(a)		malloc(a)
-#define ast_calloc(a,b)		calloc(a,b)
-#define ast_realloc(a,b)	realloc(a,b)
-#define ast_strdup(a)		strdup(a)
-#define ast_strndup(a,b)	strndup(a,b)
-#define ast_asprintf(a,b,...)	asprintf(a,b,__VA_ARGS__)
-#define ast_vasprintf(a,b,c)	vasprintf(a,b,c)
 
 #endif /* AST_DEBUG_MALLOC */
 

Modified: team/mmichelson/npm_fixes/main/astobj2.c
URL: http://svn.digium.com/svn-view/asterisk/team/mmichelson/npm_fixes/main/astobj2.c?view=diff&rev=181247&r1=181246&r2=181247
==============================================================================
--- team/mmichelson/npm_fixes/main/astobj2.c (original)
+++ team/mmichelson/npm_fixes/main/astobj2.c Wed Mar 11 09:58:08 2009
@@ -138,7 +138,7 @@
 static void *__ao2_alloc(size_t data_size, ao2_destructor_fn destructor_fn);
 static struct ao2_container *__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 *__ao2_link(struct ao2_container *c, void *user_data);
+static struct bucket_list *__ao2_link(struct ao2_container *c, void *user_data, const char *file, int line, const char *func);
 static void *__ao2_callback(struct ao2_container *c,
 	const enum search_flags flags, void *cb_fn, void *arg, void *data, enum ao2_callback_type type,
 					 char *tag, char *file, int line, const char *funcname);
@@ -486,13 +486,13 @@
  * link an object to a container
  */
 
-static struct bucket_list *__ao2_link(struct ao2_container *c, void *user_data)
+static struct bucket_list *__ao2_link(struct ao2_container *c, void *user_data, const char *file, int line, const char *func)
 {
 	int i;
 	/* create a new list entry */
 	struct bucket_list *p;
 	struct astobj2 *obj = INTERNAL_OBJ(user_data);
-	
+
 	if (!obj)
 		return NULL;
 
@@ -518,8 +518,8 @@
 
 void *_ao2_link_debug(struct ao2_container *c, void *user_data, char *tag, char *file, int line, const char *funcname)
 {
-	struct bucket_list *p = __ao2_link(c, user_data);
-	
+	struct bucket_list *p = __ao2_link(c, user_data, file, line, funcname);
+
 	if (p) {
 		_ao2_ref_debug(user_data, +1, tag, file, line, funcname);
 		ao2_unlock(c);
@@ -529,8 +529,8 @@
 
 void *_ao2_link(struct ao2_container *c, void *user_data)
 {
-	struct bucket_list *p = __ao2_link(c, user_data);
-	
+	struct bucket_list *p = __ao2_link(c, user_data, __FILE__, __LINE__, __PRETTY_FUNCTION__);
+
 	if (p) {
 		_ao2_ref(user_data, +1);
 		ao2_unlock(c);

Modified: team/mmichelson/npm_fixes/main/features.c
URL: http://svn.digium.com/svn-view/asterisk/team/mmichelson/npm_fixes/main/features.c?view=diff&rev=181247&r1=181246&r2=181247
==============================================================================
--- team/mmichelson/npm_fixes/main/features.c (original)
+++ team/mmichelson/npm_fixes/main/features.c Wed Mar 11 09:58:08 2009
@@ -3544,7 +3544,7 @@
 	/* Add a parking extension into the context */
 	if (!oldparkinglot) {
 		if (!ast_strlen_zero(ast_parking_ext())) {
-			if (ast_add_extension2(con, 1, ast_parking_ext(), 1, NULL, NULL, parkcall, strdup(""), ast_free, registrar) == -1)
+			if (ast_add_extension2(con, 1, ast_parking_ext(), 1, NULL, NULL, parkcall, strdup(""), ast_free_ptr, registrar) == -1)
 				error = 1;
 		}
 	}

Modified: team/mmichelson/npm_fixes/main/hashtab.c
URL: http://svn.digium.com/svn-view/asterisk/team/mmichelson/npm_fixes/main/hashtab.c?view=diff&rev=181247&r1=181246&r2=181247
==============================================================================
--- team/mmichelson/npm_fixes/main/hashtab.c (original)
+++ team/mmichelson/npm_fixes/main/hashtab.c Wed Mar 11 09:58:08 2009
@@ -38,7 +38,13 @@
 #include "asterisk/linkedlists.h"
 #include "asterisk/hashtab.h"
 
+
+#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
+static void _ast_hashtab_resize(struct ast_hashtab *tab, const char *file, int lineno, const char *func);
+#define ast_hashtab_resize(a)	_ast_hashtab_resize(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+#else
 static void ast_hashtab_resize(struct ast_hashtab *tab);
+#endif
 static void *ast_hashtab_lookup_internal(struct ast_hashtab *tab, const void *obj, unsigned int h);
 
 /* some standard, default routines for general use */
@@ -264,7 +270,11 @@
 	return ht;
 }
 
+#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
+struct ast_hashtab *_ast_hashtab_dup(struct ast_hashtab *tab, void *(*obj_dup_func)(const void *obj), const char *file, int lineno, const char *func)
+#else
 struct ast_hashtab *ast_hashtab_dup(struct ast_hashtab *tab, void *(*obj_dup_func)(const void *obj))
+#endif
 {
 	struct ast_hashtab *ht;
 	unsigned int i;
@@ -272,7 +282,13 @@
 	if (!(ht = ast_calloc(1, sizeof(*ht))))
 		return NULL;
 
-	if (!(ht->array = ast_calloc(tab->hash_tab_size, sizeof(*(ht->array))))) {
+	if (!(ht->array =
+#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
+		__ast_calloc(tab->hash_tab_size, sizeof(*(ht->array)), file, lineno, func)
+#else
+		ast_calloc(tab->hash_tab_size, sizeof(*(ht->array)))
+#endif
+		)) {
 		free(ht);
 		return NULL;
 	}
@@ -295,7 +311,11 @@
 		while (b) {
 			void *newobj = (*obj_dup_func)(b->object);
 			if (newobj)
+#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
+				_ast_hashtab_insert_immediate_bucket(ht, newobj, i, file, lineno, func);
+#else
 				ast_hashtab_insert_immediate_bucket(ht, newobj, i);
+#endif
 			b = b->next;
 		}
 	}
@@ -402,7 +422,11 @@
 	}
 }
 
+#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
+int _ast_hashtab_insert_immediate(struct ast_hashtab *tab, const void *obj, const char *file, int lineno, const char *func)
+#else
 int ast_hashtab_insert_immediate(struct ast_hashtab *tab, const void *obj)
+#endif
 {
 	unsigned int h;
 	int res=0;
@@ -415,7 +439,11 @@
 
 	h = (*tab->hash)(obj) % tab->hash_tab_size;
 
-	res = ast_hashtab_insert_immediate_bucket(tab,obj,h);
+#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
+	res = _ast_hashtab_insert_immediate_bucket(tab, obj, h, file, lineno, func);
+#else
+	res = ast_hashtab_insert_immediate_bucket(tab, obj, h);
+#endif
 
 	if (tab->do_locking)
 		ast_rwlock_unlock(&tab->lock);
@@ -423,7 +451,11 @@
 	return res;
 }
 
+#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
+int _ast_hashtab_insert_immediate_bucket(struct ast_hashtab *tab, const void *obj, unsigned int h, const char *file, int lineno, const char *func)
+#else
 int ast_hashtab_insert_immediate_bucket(struct ast_hashtab *tab, const void *obj, unsigned int h)
+#endif
 {
 	int c;
 	struct ast_hashtab_bucket *b;
@@ -437,8 +469,13 @@
 	if (c + 1 > tab->largest_bucket_size)
 		tab->largest_bucket_size = c + 1;
 
-	if (!(b = ast_calloc(1, sizeof(*b))))
-		return 0;
+	if (!(b =
+#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
+			__ast_calloc(1, sizeof(*b), file, lineno, func)
+#else
+			ast_calloc(1, sizeof(*b))
+#endif
+		)) return 0;
 
 	b->object = obj;
 	b->next = tab->array[h];
@@ -456,7 +493,11 @@
 	return 1;
 }
 
+#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
+int _ast_hashtab_insert_safe(struct ast_hashtab *tab, const void *obj, const char *file, int lineno, const char *func)
+#else
 int ast_hashtab_insert_safe(struct ast_hashtab *tab, const void *obj)
+#endif
 {
 	/* check to see if the element is already there; insert only if
 	   it is not there. */
@@ -468,7 +509,11 @@
 		ast_rwlock_wrlock(&tab->lock);
 
 	if (!ast_hashtab_lookup_bucket(tab, obj, &bucket)) {
+#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
+		int ret2 = _ast_hashtab_insert_immediate_bucket(tab, obj, bucket, file, lineno, func);
+#else
 		int ret2 = ast_hashtab_insert_immediate_bucket(tab, obj, bucket);
+#endif
 
 		if (tab->do_locking)
 			ast_rwlock_unlock(&tab->lock);
@@ -587,7 +632,11 @@
 /* the insert operation calls this, and is wrlock'd when it does. */
 /* if you want to call it, you should set the wrlock yourself */
 
-static void ast_hashtab_resize( struct ast_hashtab *tab)
+#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
+static void _ast_hashtab_resize(struct ast_hashtab *tab, const char *file, int lineno, const char *func)
+#else
+static void ast_hashtab_resize(struct ast_hashtab *tab)
+#endif
 {
 	/* this function is called either internally, when the resize func returns 1, or
 	   externally by the user to force a resize of the hash table */
@@ -605,7 +654,13 @@
 		tab->array[i] = 0; /* erase old ptrs */
 	}
 	free(tab->array);
-	if (!(tab->array = ast_calloc(newsize, sizeof(*(tab->array)))))
+	if (!(tab->array =
+#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
+		__ast_calloc(newsize, sizeof(*(tab->array)), file, lineno, func)
+#else
+		ast_calloc(newsize, sizeof(*(tab->array)))
+#endif
+		))
 		return;
 
 	/* now sort the buckets into their rightful new slots */
@@ -631,12 +686,22 @@
 	}
 }
 
+#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
+struct ast_hashtab_iter *_ast_hashtab_start_traversal(struct ast_hashtab *tab, const char *file, int lineno, const char *func)
+#else
 struct ast_hashtab_iter *ast_hashtab_start_traversal(struct ast_hashtab *tab)
+#endif
 {
 	/* returns an iterator */
 	struct ast_hashtab_iter *it;
 
-	if (!(it = ast_calloc(1, sizeof(*it))))
+	if (!(it =
+#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
+			__ast_calloc(1, sizeof(*it), file, lineno, func)
+#else
+			ast_calloc(1, sizeof(*it))
+#endif
+		))
 		return NULL;
 
 	it->next = tab->tlist;
@@ -648,12 +713,22 @@
 }
 
 /* use this function to get a write lock */
+#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
+struct ast_hashtab_iter *_ast_hashtab_start_write_traversal(struct ast_hashtab *tab, const char *file, int lineno, const char *func)
+#else
 struct ast_hashtab_iter *ast_hashtab_start_write_traversal(struct ast_hashtab *tab)
+#endif
 {
 	/* returns an iterator */
 	struct ast_hashtab_iter *it;
 
-	if (!(it = ast_calloc(1, sizeof(*it))))
+	if (!(it =
+#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
+			__ast_calloc(1, sizeof(*it), file, lineno, func)
+#else
+			ast_calloc(1, sizeof(*it))
+#endif
+		))
 		return NULL;
 
 	it->next = tab->tlist;

Modified: team/mmichelson/npm_fixes/main/heap.c
URL: http://svn.digium.com/svn-view/asterisk/team/mmichelson/npm_fixes/main/heap.c?view=diff&rev=181247&r1=181246&r2=181247
==============================================================================
--- team/mmichelson/npm_fixes/main/heap.c (original)
+++ team/mmichelson/npm_fixes/main/heap.c Wed Mar 11 09:58:08 2009
@@ -107,8 +107,13 @@
 	return 0;
 }
 
+#ifdef MALLOC_DEBUG
+struct ast_heap *_ast_heap_create(unsigned int init_height, ast_heap_cmp_fn cmp_fn,
+		ssize_t index_offset, const char *file, int lineno, const char *func)
+#else
 struct ast_heap *ast_heap_create(unsigned int init_height, ast_heap_cmp_fn cmp_fn,
 		ssize_t index_offset)
+#endif
 {
 	struct ast_heap *h;
 
@@ -121,7 +126,13 @@
 		init_height = 8;
 	}
 
-	if (!(h = ast_calloc(1, sizeof(*h)))) {
+	if (!(h =
+#ifdef MALLOC_DEBUG
+			__ast_calloc(1, sizeof(*h), file, lineno, func)
+#else
+			ast_calloc(1, sizeof(*h))
+#endif
+		)) {
 		return NULL;
 	}
 
@@ -129,7 +140,13 @@
 	h->index_offset = index_offset;
 	h->avail_len = (1 << init_height) - 1;
 
-	if (!(h->heap = ast_calloc(1, h->avail_len * sizeof(void *)))) {
+	if (!(h->heap =
+#ifdef MALLOC_DEBUG
+			__ast_calloc(1, h->avail_len * sizeof(void *), file, lineno, func)
+#else
+			ast_calloc(1, h->avail_len * sizeof(void *))
+#endif
+		)) {
 		ast_free(h);
 		return NULL;
 	}
@@ -154,11 +171,21 @@
 /*!
  * \brief Add a row of additional storage for the heap.
  */
-static int grow_heap(struct ast_heap *h)
+static int grow_heap(struct ast_heap *h
+#ifdef MALLOC_DEBUG
+, const char *file, int lineno, const char *func
+#endif
+)
 {
 	h->avail_len = h->avail_len * 2 + 1;
 
-	if (!(h->heap = ast_realloc(h->heap, h->avail_len * sizeof(void *)))) {
+	if (!(h->heap =
+#ifdef MALLOC_DEBUG
+			__ast_realloc(h->heap, h->avail_len * sizeof(void *), file, lineno, func)
+#else
+			ast_realloc(h->heap, h->avail_len * sizeof(void *))
+#endif
+		)) {
 		h->cur_len = h->avail_len = 0;
 		return -1;
 	}
@@ -202,11 +229,19 @@
 	}
 }
 
+#ifdef MALLOC_DEBUG
+int _ast_heap_push(struct ast_heap *h, void *elm, const char *file, int lineno, const char *func)
+#else
 int ast_heap_push(struct ast_heap *h, void *elm)
+#endif
 {
 	int i;
 
-	if (h->cur_len == h->avail_len && grow_heap(h)) {
+	if (h->cur_len == h->avail_len && grow_heap(h
+#ifdef MALLOC_DEBUG
+		, file, lineno, func
+#endif
+		)) {
 		return -1;
 	}
 

Modified: team/mmichelson/npm_fixes/main/pbx.c
URL: http://svn.digium.com/svn-view/asterisk/team/mmichelson/npm_fixes/main/pbx.c?view=diff&rev=181247&r1=181246&r2=181247
==============================================================================
--- team/mmichelson/npm_fixes/main/pbx.c (original)
+++ team/mmichelson/npm_fixes/main/pbx.c Wed Mar 11 09:58:08 2009
@@ -76,13 +76,13 @@
  *
  * A new algorithm to do searching based on a 'compiled' pattern tree is introduced
  * here, and shows a fairly flat (constant) search time, even for over
- * 10000 patterns. 
+ * 10000 patterns.
  *
  * Also, using a hash table for context/priority name lookup can help prevent
- * the find_extension routines from absorbing exponential cpu cycles as the number 
- * of contexts/priorities grow. I've previously tested find_extension with red-black trees, 
- * which have O(log2(n)) speed. Right now, I'm using hash tables, which do 
- * searches (ideally) in O(1) time. While these techniques do not yield much 
+ * the find_extension routines from absorbing exponential cpu cycles as the number
+ * of contexts/priorities grow. I've previously tested find_extension with red-black trees,
+ * which have O(log2(n)) speed. Right now, I'm using hash tables, which do
+ * searches (ideally) in O(1) time. While these techniques do not yield much
  * speed in small dialplans, they are worth the trouble in large dialplans.
  *
  */
@@ -142,7 +142,7 @@
 			<parameter name="context">
 				<para>This is the dialplan context that this application will use when exiting
 				to a dialed extension.</para>
-			</parameter>	
+			</parameter>
 		</syntax>
 		<description>
 			<para>This application will play the given list of files <emphasis>(do not put extension)</emphasis>
@@ -773,7 +773,7 @@
 	int priority;			/*!< Priority */
 	const char *label;		/*!< Label */
 	struct ast_context *parent;	/*!< The context this extension belongs to  */
-	const char *app; 		/*!< Application to execute */
+	const char *app;		/*!< Application to execute */
 	struct ast_app *cached_app;     /*!< Cached location of application */
 	void *data;			/*!< Data to use (arguments) */
 	void (*datad)(void *);		/*!< Data destructor */
@@ -838,10 +838,10 @@
 
 /*! \brief ast_context: An extension context */
 struct ast_context {
-	ast_rwlock_t lock; 			/*!< A lock to prevent multiple threads from clobbering the context */
+	ast_rwlock_t lock;			/*!< A lock to prevent multiple threads from clobbering the context */
 	struct ast_exten *root;			/*!< The root of the list of extensions */
 	struct ast_hashtab *root_table;            /*!< For exact matches on the extensions in the pattern tree, and for traversals of the pattern_tree  */
- 	struct match_char *pattern_tree;        /*!< A tree to speed up extension pattern matching */
+	struct match_char *pattern_tree;        /*!< A tree to speed up extension pattern matching */
 	struct ast_context *next;		/*!< Link them together */
 	struct ast_include *includes;		/*!< Include other contexts */
 	struct ast_ignorepat *ignorepats;	/*!< Patterns for which to continue playing dialtone */
@@ -879,12 +879,12 @@
 /*! \brief Structure for dial plan hints
 
   \note Hints are pointers from an extension in the dialplan to one or
-  more devices (tech/name) 
+  more devices (tech/name)
 	- See \ref AstExtState
 */
 struct ast_hint {
 	struct ast_exten *exten;	/*!< Extension */
-	int laststate; 			/*!< Last known state */
+	int laststate;			/*!< Last known state */
 	AST_LIST_HEAD_NOLOCK(, ast_state_cb) callbacks; /*!< Callback list for this extension */
 	AST_RWLIST_ENTRY(ast_hint) list;/*!< Pointer to next hint in list */
 };
@@ -945,15 +945,15 @@
 void log_match_char_tree(struct match_char *node, char *prefix); /* for use anywhere */
 int pbx_builtin_setvar_multiple(struct ast_channel *, void *);
 static int pbx_builtin_importvar(struct ast_channel *, void *);
-static void set_ext_pri(struct ast_channel *c, const char *exten, int pri); 
-static void new_find_extension(const char *str, struct scoreboard *score, 
-		struct match_char *tree, int length, int spec, const char *callerid, 
+static void set_ext_pri(struct ast_channel *c, const char *exten, int pri);
+static void new_find_extension(const char *str, struct scoreboard *score,
+		struct match_char *tree, int length, int spec, const char *callerid,
 		const char *label, enum ext_match_t action);
 static struct match_char *already_in_tree(struct match_char *current, char *pat, int is_pattern);
-static struct match_char *add_exten_to_pattern_tree(struct ast_context *con, 
+static struct match_char *add_exten_to_pattern_tree(struct ast_context *con,
 		struct ast_exten *e1, int findonly);
-static struct match_char *add_pattern_node(struct ast_context *con, 
-		struct match_char *current, char *pattern, int is_pattern, 

[... 2010 lines stripped ...]



More information about the svn-commits mailing list