[asterisk-commits] russell: trunk r39272 - in /trunk: ./ channels/ include/asterisk/ pbx/ res/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Aug 7 23:32:05 MST 2006


Author: russell
Date: Tue Aug  8 01:32:04 2006
New Revision: 39272

URL: http://svn.digium.com/view/asterisk?rev=39272&view=rev
Log:
Merge team/russell/ast_verbose_threadstorage

- instead of defining a free() wrapper in a bunch of files, define it as
  ast_free() in utils.h and remove the copies from all the files.

- centralize and abstract the code used for doing thread storage. The code
  lives in threadstorage.h, with one function being implemented in utils.c.
  This new API includes generic thread storage as well as special functions
  for handling thread local dynamic length string buffers.

- update ast_inet_ntoa() to use the new threadstorage API
- update ast_state2str() to use the new threadstorage API
- update ast_cli() to use the new threadstorage API

- Modify manager_event() to use thread storage. Instead of using a buffer of
  4096 characters as the workspace for building the manager event, use a thread
  local dynamic string.  Now there is no length limitation on the length of the
  body of a manager event.

- Significantly simplify the handling of ast_verbose() ...
  - Instead of using a static char buffer and a lock to make sure only one
    thread can be using ast_verbose() at a time, use a thread local dynamic
    string as the workspace for preparing the verbose message. Instead of
    locking around the entire function, the only locking done now is when the
    message has been built and is being deliviered to the list of registered
    verbose message handlers.
  - This function was doing a strdup() on every message passed to it and
    keeping a queue of the last 200 messages in memory. This has been
    completely removed. The only place this was used was that if there were
    any messages in the verbose queue when a verbose handler was registered,
    all of the messages in the queue would be fed to it.  So, I just made sure
    that the console verbose handler and the network verbose handler (for
    remote asterisk consoles) were registered before any verbose messages.
    pbx_gtkconsole and pbx_kdeconsole will now lose a few verbose messages at
    startup, but I didn't feel the performance hit of this message queue was
    worth saving the initial verbose output for these very rarely used modules.
  - I have removed the last three arguments to the verbose handlers, leaving
    only the string itself because they aren't needed anymore. For example,
    ast_verbose had some logic for telling the verbose handler to add
    a newline if the buffer was completely full. Now that the buffer can grow
    as needed, this doesn't matter anymore.
  - remove unused function, ast_verbose_dmesg() which was to dispatch the
    message queue
  - Convert the list of verbose handlers to use the linked list macros.

- add missing newline characters to a few ast_verbose() calls

- convert the list of log channels to use the linked list macros in logger.c

- fix close_logger() to close all of the files it opened for logging

- update ast_log() to use a thread local dynamic string for its workspace
  for preparing log messages instead of a buffer of size BUFSIZ (8kB on my
  system) allocated on the stack.  The dynamic string in this case is limited
  to only growing to a maximum size of BUFSIZ.

Added:
    trunk/include/asterisk/threadstorage.h
      - copied unchanged from r39271, team/russell/ast_verbose_threadstorage/include/asterisk/threadstorage.h
Modified:
    trunk/asterisk.c
    trunk/channel.c
    trunk/channels/chan_iax2.c
    trunk/channels/chan_sip.c
    trunk/cli.c
    trunk/include/asterisk/compiler.h
    trunk/include/asterisk/logger.h
    trunk/include/asterisk/utils.h
    trunk/logger.c
    trunk/manager.c
    trunk/pbx/pbx_ael.c
    trunk/pbx/pbx_config.c
    trunk/res/res_agi.c
    trunk/res/res_features.c
    trunk/utils.c

Modified: trunk/asterisk.c
URL: http://svn.digium.com/view/asterisk/trunk/asterisk.c?rev=39272&r1=39271&r2=39272&view=diff
==============================================================================
--- trunk/asterisk.c (original)
+++ trunk/asterisk.c Tue Aug  8 01:32:04 2006
@@ -746,23 +746,9 @@
 	ast_network_puts(string);
 }
 
-static void network_verboser(const char *s, int pos, int replace, int complete)
-	/* ARGUSED */
-{
-	if (replace) {
-		char *t;
-		if ((t = alloca(strlen(s) + 2))) {
-			sprintf(t, "\r%s", s);
-			if (complete)
-				ast_network_puts_mutable(t);
-		} else {
-			ast_log(LOG_ERROR, "Out of memory\n");
-			ast_network_puts_mutable(s);
-		}
-	} else {
-		if (complete)
-			ast_network_puts_mutable(s);
-	}
+static void network_verboser(const char *s)
+{
+	ast_network_puts_mutable(s);
 }
 
 static pthread_t lthread;
@@ -1203,29 +1189,25 @@
 	return NULL;
 }
 
-static void console_verboser(const char *s, int pos, int replace, int complete)
+static void console_verboser(const char *s)
 {
 	char tmp[80];
 	const char *c = NULL;
-	/* Return to the beginning of the line */
-	if (!pos) {
-		fprintf(stdout, "\r");
-		if ((c = fix_header(tmp, sizeof(tmp), s, VERBOSE_PREFIX_4)) ||
-			(c = fix_header(tmp, sizeof(tmp), s, VERBOSE_PREFIX_3)) ||
-			(c = fix_header(tmp, sizeof(tmp), s, VERBOSE_PREFIX_2)) ||
-			(c = fix_header(tmp, sizeof(tmp), s, VERBOSE_PREFIX_1)))
-			fputs(tmp, stdout);
-	}
-	if (c)
-		fputs(c + pos,stdout);
-	else
-		fputs(s + pos,stdout);
+
+	if ((c = fix_header(tmp, sizeof(tmp), s, VERBOSE_PREFIX_4)) ||
+	    (c = fix_header(tmp, sizeof(tmp), s, VERBOSE_PREFIX_3)) ||
+	    (c = fix_header(tmp, sizeof(tmp), s, VERBOSE_PREFIX_2)) ||
+	    (c = fix_header(tmp, sizeof(tmp), s, VERBOSE_PREFIX_1))) {
+		fputs(tmp, stdout);
+		fputs(c, stdout);
+	} else
+		fputs(s, stdout);
+
 	fflush(stdout);
-	if (complete) {
-		/* Wake up a poll()ing console */
-		if (ast_opt_console && consolethread != AST_PTHREADT_NULL)
-			pthread_kill(consolethread, SIGURG);
-	}
+	
+	/* Wake up a poll()ing console */
+	if (ast_opt_console && consolethread != AST_PTHREADT_NULL)
+		pthread_kill(consolethread, SIGURG);
 }
 
 static int ast_all_zeros(char *s)
@@ -2427,6 +2409,14 @@
 		}
 	}
 
+	if (ast_opt_console || option_verbose || (ast_opt_remote && !ast_opt_exec)) {
+		ast_register_verbose(console_verboser);
+		WELCOME_MESSAGE;
+	}
+
+	if (ast_opt_console && !option_verbose) 
+		ast_verbose("[ Booting...\n");
+
 	if (ast_opt_always_fork && (ast_opt_remote || ast_opt_console)) {
 		ast_log(LOG_WARNING, "'alwaysfork' is not compatible with console or remote console mode; ignored\n");
 		ast_clear_flag(&ast_options, AST_OPT_FLAG_ALWAYS_FORK);
@@ -2443,7 +2433,7 @@
 	}
 
 	if (ast_opt_console && !option_verbose) 
-		ast_verbose("[ Reading Master Configuration ]");
+		ast_verbose("[ Reading Master Configuration ]\n");
 	ast_readconfig();
 
 	if (ast_opt_dump_core) {
@@ -2526,7 +2516,7 @@
 	fflush(stdout);
 
 	if (ast_opt_console && !option_verbose) 
-		ast_verbose("[ Initializing Custom Configuration Options ]");
+		ast_verbose("[ Initializing Custom Configuration Options ]\n");
 	/* custom config setup */
 	register_config_cli();
 	read_config_maps();
@@ -2548,8 +2538,6 @@
 				exit(0);
 			}
 			printf(term_quit());
-			ast_register_verbose(console_verboser);
-			WELCOME_MESSAGE;
 			ast_remotecontrol(NULL);
 			quit_handler(0, 0, 0, 0);
 			exit(0);
@@ -2597,15 +2585,6 @@
 	sigaddset(&sigs, SIGPIPE);
 	sigaddset(&sigs, SIGWINCH);
 	pthread_sigmask(SIG_BLOCK, &sigs, NULL);
-	if (ast_opt_console || option_verbose || ast_opt_remote)
-		ast_register_verbose(console_verboser);
-	/* Print a welcome message if desired */
-	if (option_verbose || ast_opt_console) {
-		WELCOME_MESSAGE;
-	}
-	if (ast_opt_console && !option_verbose) 
-		ast_verbose("[ Booting...");
-
 	signal(SIGURG, urg_handler);
 	signal(SIGINT, __quit_handler);
 	signal(SIGTERM, __quit_handler);

Modified: trunk/channel.c
URL: http://svn.digium.com/view/asterisk/trunk/channel.c?rev=39272&r1=39271&r2=39272&view=diff
==============================================================================
--- trunk/channel.c (original)
+++ trunk/channel.c Tue Aug  8 01:32:04 2006
@@ -66,6 +66,7 @@
 #include "asterisk/transcap.h"
 #include "asterisk/devicestate.h"
 #include "asterisk/sha1.h"
+#include "asterisk/threadstorage.h"
 #include "asterisk/slinfactory.h"
 
 struct channel_spy_trans {
@@ -99,8 +100,7 @@
 
 unsigned long global_fin = 0, global_fout = 0;
 
-static pthread_key_t state2str_buf_key;
-static pthread_once_t state2str_buf_once = PTHREAD_ONCE_INIT;
+AST_THREADSTORAGE(state2str_threadbuf, state2str_threadbuf_init);
 #define STATE2STR_BUFSIZE   32
 
 struct chanlist {
@@ -167,15 +167,6 @@
 	{ AST_CAUSE_INTERWORKING, "INTERWORKING", "Interworking, unspecified" },
 };
 
-#ifdef __AST_DEBUG_MALLOC
-static void FREE(void *ptr)
-{
-	free(ptr);
-}
-#else
-#define FREE free
-#endif
-
 struct ast_variable *ast_channeltype_list(void)
 {
 	struct chanlist *cl;
@@ -500,11 +491,6 @@
 	return -1;
 }
 
-static void state2str_buf_key_create(void)
-{
-	pthread_key_create(&state2str_buf_key, FREE);
-}
- 
 /*! \brief Gives the string form of a given channel state */
 char *ast_state2str(int state)
 {
@@ -532,12 +518,8 @@
 	case AST_STATE_PRERING:
 		return "Pre-ring";
 	default:
-		pthread_once(&state2str_buf_once, state2str_buf_key_create);
-		if (!(buf = pthread_getspecific(state2str_buf_key))) {
-			if (!(buf = ast_malloc(STATE2STR_BUFSIZE)))
-				return NULL;
-			pthread_setspecific(state2str_buf_key, buf);
-		}
+		if (!(buf = ast_threadstorage_get(&state2str_threadbuf, STATE2STR_BUFSIZE)))
+			return "Unknown";
 		snprintf(buf, STATE2STR_BUFSIZE, "Unknown (%d)", state);
 		return buf;
 	}

Modified: trunk/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_iax2.c?rev=39272&r1=39271&r2=39272&view=diff
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Tue Aug  8 01:32:04 2006
@@ -711,15 +711,6 @@
 static AST_LIST_HEAD_STATIC(dynamic_list, iax2_thread);
 
 static void *iax2_process_thread(void *data);
-
-#ifdef __AST_DEBUG_MALLOC
-static void FREE(void *ptr)
-{
-	free(ptr);
-}
-#else
-#define FREE free
-#endif
 
 static void signal_condition(ast_mutex_t *lock, ast_cond_t *cond)
 {
@@ -5472,7 +5463,7 @@
 			if (onoff) {
 				if (!ast_exists_extension(NULL, regcontext, ext, 1, NULL))
 					ast_add_extension(regcontext, 1, ext, 1, NULL, NULL,
-							  "Noop", ast_strdup(peer->name), FREE, "IAX2");
+							  "Noop", ast_strdup(peer->name), ast_free, "IAX2");
 			} else
 				ast_context_remove_extension(regcontext, ext, 1, NULL);
 		}

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?rev=39272&r1=39271&r2=39272&view=diff
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Tue Aug  8 01:32:04 2006
@@ -1538,15 +1538,6 @@
 	set_udptl_peer: sip_set_udptl_peer,
 };
 
-#ifdef __AST_DEBUG_MALLOC
-static void FREE(void *ptr)
-{
-	free(ptr);
-}
-#else
-#define FREE free
-#endif
-
 /*! \brief Convert transfer status to string */
 static char *referstatus2str(enum referstatus rstatus)
 {
@@ -2253,7 +2244,7 @@
 		}
 		if (onoff)
 			ast_add_extension(context, 1, ext, 1, NULL, NULL, "Noop",
-				 ast_strdup(peer->name), FREE, "SIP");
+				 ast_strdup(peer->name), ast_free, "SIP");
 		else
 			ast_context_remove_extension(context, ext, 1, NULL);
 	}

Modified: trunk/cli.c
URL: http://svn.digium.com/view/asterisk/trunk/cli.c?rev=39272&r1=39271&r2=39272&view=diff
==============================================================================
--- trunk/cli.c (original)
+++ trunk/cli.c Tue Aug  8 01:32:04 2006
@@ -48,62 +48,29 @@
 #include "asterisk/app.h"
 #include "asterisk/lock.h"
 #include "editline/readline/readline.h"
+#include "asterisk/threadstorage.h"
 
 extern unsigned long global_fin, global_fout;
 
-static pthread_key_t ast_cli_buf_key;
-static pthread_once_t ast_cli_buf_once = PTHREAD_ONCE_INIT;
+AST_THREADSTORAGE(ast_cli_buf, ast_cli_buf_init);
 
 /*! \brief Initial buffer size for resulting strings in ast_cli() */
 #define AST_CLI_MAXSTRLEN   256
 
-#ifdef __AST_DEBUG_MALLOC
-static void FREE(void *ptr)
-{
-	free(ptr);
-}
-#else
-#define FREE free
-#endif
-
-static void ast_cli_buf_key_create(void)
-{
-	pthread_key_create(&ast_cli_buf_key, FREE);
-}
-
 void ast_cli(int fd, char *fmt, ...)
 {
-	struct {
-		size_t len;
-		char str[0];
-	} *buf;
 	int res;
+	struct ast_dynamic_str *buf;
 	va_list ap;
 
-	pthread_once(&ast_cli_buf_once, ast_cli_buf_key_create);
-	if (!(buf = pthread_getspecific(ast_cli_buf_key))) {
-		if (!(buf = ast_malloc(AST_CLI_MAXSTRLEN + sizeof(*buf))))
-			return;
-		buf->len = AST_CLI_MAXSTRLEN;
-		pthread_setspecific(ast_cli_buf_key, buf);
-	}
+	if (!(buf = ast_dynamic_str_thread_get(&ast_cli_buf, AST_CLI_MAXSTRLEN)))
+		return;
 
 	va_start(ap, fmt);
-	res = vsnprintf(buf->str, buf->len, fmt, ap);
-	while (res >= buf->len) {
-		if (!(buf = ast_realloc(buf, (buf->len * 2) + sizeof(*buf)))) {
-			va_end(ap);
-			return;
-		}
-		buf->len *= 2;
-		pthread_setspecific(ast_cli_buf_key, buf);
-		va_end(ap);
-		va_start(ap, fmt);
-		res = vsnprintf(buf->str, buf->len, fmt, ap);
-	}
+	res = ast_dynamic_str_thread_set_va(&buf, 0, &ast_cli_buf, fmt, ap);
 	va_end(ap);
 
-	if (res > 0)
+	if (res != AST_DYNSTR_BUILD_FAILED)
 		ast_carefulwrite(fd, buf->str, strlen(buf->str), 100);
 }
 

Modified: trunk/include/asterisk/compiler.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/compiler.h?rev=39272&r1=39271&r2=39272&view=diff
==============================================================================
--- trunk/include/asterisk/compiler.h (original)
+++ trunk/include/asterisk/compiler.h Tue Aug  8 01:32:04 2006
@@ -33,5 +33,6 @@
 #endif
 
 #define attribute_const __attribute__((const))
+#define attribute_unused __attribute__((unused))
 
 #endif /* _ASTERISK_COMPILER_H */

Modified: trunk/include/asterisk/logger.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/logger.h?rev=39272&r1=39271&r2=39272&view=diff
==============================================================================
--- trunk/include/asterisk/logger.h (original)
+++ trunk/include/asterisk/logger.h Tue Aug  8 01:32:04 2006
@@ -77,9 +77,9 @@
 void ast_verbose(const char *fmt, ...)
 	__attribute__ ((format (printf, 1, 2)));
 
-int ast_register_verbose(void (*verboser)(const char *string, int opos, int replacelast, int complete));
-int ast_unregister_verbose(void (*verboser)(const char *string, int opos, int replacelast, int complete));
-int ast_verbose_dmesg(void (*verboser)(const char *string, int opos, int replacelast, int complete));
+int ast_register_verbose(void (*verboser)(const char *string));
+int ast_unregister_verbose(void (*verboser)(const char *string));
+
 void ast_console_puts(const char *string);
 
 void ast_console_puts_mutable(const char *string);

Modified: trunk/include/asterisk/utils.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/utils.h?rev=39272&r1=39271&r2=39272&view=diff
==============================================================================
--- trunk/include/asterisk/utils.h (original)
+++ trunk/include/asterisk/utils.h Tue Aug  8 01:32:04 2006
@@ -35,6 +35,7 @@
 #include "asterisk/time.h"
 #include "asterisk/strings.h"
 #include "asterisk/logger.h"
+#include "asterisk/compiler.h"
 
 /*! \note
  \verbatim
@@ -272,6 +273,22 @@
 long int ast_random(void);
 #endif
 
+/*! 
+ * \brief free() wrapper
+ *
+ * ast_free should be used when a function pointer for free() needs to be passed
+ * as the argument to a function. Otherwise, astmm will cause seg faults.
+ */
+#ifdef __AST_DEBUG_MALLOC
+static void ast_free(void *ptr) attribute_unused;
+static void ast_free(void *ptr)
+{
+	free(ptr);
+}
+#else
+#define ast_free free
+#endif
+
 #ifndef __AST_DEBUG_MALLOC
 
 /*!

Modified: trunk/logger.c
URL: http://svn.digium.com/view/asterisk/trunk/logger.c?rev=39272&r1=39271&r2=39272&view=diff
==============================================================================
--- trunk/logger.c (original)
+++ trunk/logger.c Tue Aug  8 01:32:04 2006
@@ -68,8 +68,7 @@
 #include "asterisk/cli.h"
 #include "asterisk/utils.h"
 #include "asterisk/manager.h"
-
-#define MAX_MSG_QUEUE 200
+#include "asterisk/threadstorage.h"
 
 #if defined(__linux__) && !defined(__NR_gettid)
 #include <asm/unistd.h>
@@ -84,8 +83,6 @@
 
 static char dateformat[256] = "%b %e %T";		/* Original Asterisk Format */
 
-AST_MUTEX_DEFINE_STATIC(msglist_lock);
-AST_MUTEX_DEFINE_STATIC(loglock);
 static int filesize_reload_needed = 0;
 static int global_logmask = -1;
 
@@ -93,11 +90,6 @@
 	unsigned int queue_log:1;
 	unsigned int event_log:1;
 } logfiles = { 1, 1 };
-
-static struct msglist {
-	char *msg;
-	struct msglist *next;
-} *list = NULL, *last = NULL;
 
 static char hostname[MAXHOSTNAMELEN];
 
@@ -114,12 +106,10 @@
 	enum logtypes type;		/* Type of log channel */
 	FILE *fileptr;			/* logfile logging file pointer */
 	char filename[256];		/* Filename */
-	struct logchannel *next;	/* Next channel in chain */
+	AST_LIST_ENTRY(logchannel) list;
 };
 
-static struct logchannel *logchannels = NULL;
-
-static int msgcnt = 0;
+static AST_LIST_HEAD_STATIC(logchannels, logchannel);
 
 static FILE *eventlog = NULL;
 static FILE *qlog = NULL;
@@ -143,6 +133,12 @@
 	COLOR_GREEN,
 	COLOR_BRGREEN
 };
+
+AST_THREADSTORAGE(verbose_buf, verbose_buf_init);
+#define VERBOSE_BUF_INIT_SIZE   128
+
+AST_THREADSTORAGE(log_buf, log_buf_init);
+#define LOG_BUF_INIT_SIZE       128
 
 static int make_components(char *s, int lineno)
 {
@@ -287,21 +283,16 @@
 
 static void init_logger_chain(void)
 {
-	struct logchannel *chan, *cur;
+	struct logchannel *chan;
 	struct ast_config *cfg;
 	struct ast_variable *var;
 	char *s;
 
 	/* delete our list of log channels */
-	ast_mutex_lock(&loglock);
-	chan = logchannels;
-	while (chan) {
-		cur = chan->next;
+	AST_LIST_LOCK(&logchannels);
+	while ((chan = AST_LIST_REMOVE_HEAD(&logchannels, list)))
 		free(chan);
-		chan = cur;
-	}
-	logchannels = NULL;
-	ast_mutex_unlock(&loglock);
+	AST_LIST_UNLOCK(&logchannels);
 	
 	global_logmask = 0;
 	/* close syslog */
@@ -316,16 +307,16 @@
 			return;
 		chan->type = LOGTYPE_CONSOLE;
 		chan->logmask = 28; /*warning,notice,error */
-		chan->next = logchannels;
-		logchannels = chan;
+		AST_LIST_LOCK(&logchannels);
+		AST_LIST_INSERT_HEAD(&logchannels, chan, list);
+		AST_LIST_UNLOCK(&logchannels);
 		global_logmask |= chan->logmask;
 		return;
 	}
 	
-	ast_mutex_lock(&loglock);
 	if ((s = ast_variable_retrieve(cfg, "general", "appendhostname"))) {
-		if(ast_true(s)) {
-			if(gethostname(hostname, sizeof(hostname)-1)) {
+		if (ast_true(s)) {
+			if (gethostname(hostname, sizeof(hostname) - 1)) {
 				ast_copy_string(hostname, "unknown", sizeof(hostname));
 				ast_log(LOG_WARNING, "What box has no hostname???\n");
 			}
@@ -333,36 +324,32 @@
 			hostname[0] = '\0';
 	} else
 		hostname[0] = '\0';
-	if ((s = ast_variable_retrieve(cfg, "general", "dateformat"))) {
+	if ((s = ast_variable_retrieve(cfg, "general", "dateformat")))
 		ast_copy_string(dateformat, s, sizeof(dateformat));
-	} else
+	else
 		ast_copy_string(dateformat, "%b %e %T", sizeof(dateformat));
-	if ((s = ast_variable_retrieve(cfg, "general", "queue_log"))) {
+	if ((s = ast_variable_retrieve(cfg, "general", "queue_log")))
 		logfiles.queue_log = ast_true(s);
-	}
-	if ((s = ast_variable_retrieve(cfg, "general", "event_log"))) {
+	if ((s = ast_variable_retrieve(cfg, "general", "event_log")))
 		logfiles.event_log = ast_true(s);
-	}
-
+
+	AST_LIST_LOCK(&logchannels);
 	var = ast_variable_browse(cfg, "logfiles");
-	while(var) {
-		chan = make_logchannel(var->name, var->value, var->lineno);
-		if (chan) {
-			chan->next = logchannels;
-			logchannels = chan;
-			global_logmask |= chan->logmask;
-		}
-		var = var->next;
-	}
+	for (; var; var = var->next) {
+		if (!(chan = make_logchannel(var->name, var->value, var->lineno)))
+			continue;
+		AST_LIST_INSERT_HEAD(&logchannels, chan, list);
+		global_logmask |= chan->logmask;
+	}
+	AST_LIST_UNLOCK(&logchannels);
 
 	ast_config_destroy(cfg);
-	ast_mutex_unlock(&loglock);
 }
 
 void ast_queue_log(const char *queuename, const char *callid, const char *agent, const char *event, const char *fmt, ...)
 {
 	va_list ap;
-	ast_mutex_lock(&loglock);
+	AST_LIST_LOCK(&logchannels);
 	if (qlog) {
 		va_start(ap, fmt);
 		fprintf(qlog, "%ld|%s|%s|%s|%s|", (long)time(NULL), callid, queuename, agent, event);
@@ -371,7 +358,7 @@
 		va_end(ap);
 		fflush(qlog);
 	}
-	ast_mutex_unlock(&loglock);
+	AST_LIST_UNLOCK(&logchannels);
 }
 
 int reload_logger(int rotate)
@@ -383,8 +370,8 @@
 	FILE *myf;
 	int x, res = 0;
 
-	ast_mutex_lock(&msglist_lock);	/* to avoid deadlock */
-	ast_mutex_lock(&loglock);
+	AST_LIST_LOCK(&logchannels);
+
 	if (eventlog) 
 		fclose(eventlog);
 	else 
@@ -399,8 +386,7 @@
 
 	mkdir((char *)ast_config_AST_LOG_DIR, 0755);
 
-	f = logchannels;
-	while(f) {
+	AST_LIST_TRAVERSE(&logchannels, f, list) {
 		if (f->disabled) {
 			f->disabled = 0;	/* Re-enable logging at reload */
 			manager_event(EVENT_FLAG_SYSTEM, "LogChannel", "Channel: %s\r\nEnabled: Yes\r\n", f->filename);
@@ -408,17 +394,16 @@
 		if (f->fileptr && (f->fileptr != stdout) && (f->fileptr != stderr)) {
 			fclose(f->fileptr);	/* Close file */
 			f->fileptr = NULL;
-			if(rotate) {
+			if (rotate) {
 				ast_copy_string(old, f->filename, sizeof(old));
 	
-				for(x=0;;x++) {
+				for (x = 0; ; x++) {
 					snprintf(new, sizeof(new), "%s.%d", f->filename, x);
 					myf = fopen((char *)new, "r");
-					if (myf) {
+					if (myf)
 						fclose(myf);
-					} else {
+					else
 						break;
-					}
 				}
 	    
 				/* do it */
@@ -426,7 +411,6 @@
 					fprintf(stderr, "Unable to rename file '%s' to '%s'\n", old, new);
 			}
 		}
-		f = f->next;
 	}
 
 	filesize_reload_needed = 0;
@@ -489,8 +473,8 @@
 			res = -1;
 		}
 	}
-	ast_mutex_unlock(&loglock);
-	ast_mutex_unlock(&msglist_lock);
+
+	AST_LIST_UNLOCK(&logchannels);
 
 	return res;
 }
@@ -519,14 +503,12 @@
 #define FORMATL	"%-35.35s %-8.8s %-9.9s "
 	struct logchannel *chan;
 
-	ast_mutex_lock(&loglock);
-
-	chan = logchannels;
 	ast_cli(fd,FORMATL, "Channel", "Type", "Status");
 	ast_cli(fd, "Configuration\n");
 	ast_cli(fd,FORMATL, "-------", "----", "------");
 	ast_cli(fd, "-------------\n");
-	while (chan) {
+	AST_LIST_LOCK(&logchannels);
+	AST_LIST_TRAVERSE(&logchannels, chan, list) {
 		ast_cli(fd, FORMATL, chan->filename, chan->type==LOGTYPE_CONSOLE ? "Console" : (chan->type==LOGTYPE_SYSLOG ? "Syslog" : "File"),
 			chan->disabled ? "Disabled" : "Enabled");
 		ast_cli(fd, " - ");
@@ -545,20 +527,19 @@
 		if (chan->logmask & (1 << __LOG_EVENT)) 
 			ast_cli(fd, "Event ");
 		ast_cli(fd, "\n");
-		chan = chan->next;
-	}
+	}
+	AST_LIST_UNLOCK(&logchannels);
 	ast_cli(fd, "\n");
-
-	ast_mutex_unlock(&loglock);
  		
 	return RESULT_SUCCESS;
 }
 
-static struct verb {
-	void (*verboser)(const char *string, int opos, int replacelast, int complete);
-	struct verb *next;
-} *verboser = NULL;
-
+struct verb {
+	void (*verboser)(const char *string);
+	AST_LIST_ENTRY(verb) list;
+};
+
+static AST_LIST_HEAD_STATIC(verbosers, verb);
 
 static char logger_reload_help[] =
 "Usage: logger reload\n"
@@ -637,21 +618,31 @@
 
 void close_logger(void)
 {
-	struct msglist *m, *tmp;
-
-	ast_mutex_lock(&msglist_lock);
-	m = list;
-	while(m) {
-		if (m->msg) {
-			free(m->msg);
-		}
-		tmp = m->next;
-		free(m);
-		m = tmp;
-	}
-	list = last = NULL;
-	msgcnt = 0;
-	ast_mutex_unlock(&msglist_lock);
+	struct logchannel *f;
+
+	AST_LIST_LOCK(&logchannels);
+
+	if (eventlog) {
+		fclose(eventlog);
+		eventlog = NULL;
+	}
+
+	if (qlog) {
+		fclose(qlog);
+		qlog = NULL;
+	}
+
+	AST_LIST_TRAVERSE(&logchannels, f, list) {
+		if (f->fileptr && (f->fileptr != stdout) && (f->fileptr != stderr)) {
+			fclose(f->fileptr);
+			f->fileptr = NULL;
+		}
+	}
+
+	closelog(); /* syslog */
+
+	AST_LIST_UNLOCK(&logchannels);
+
 	return;
 }
 
@@ -681,28 +672,30 @@
 	syslog(syslog_level_map[level], "%s", buf);
 }
 
-/*
- * send log messages to syslog and/or the console
+/*!
+ * \brief send log messages to syslog and/or the console
  */
 void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...)
 {
 	struct logchannel *chan;
-	char buf[BUFSIZ];
+	struct ast_dynamic_str *buf;
 	time_t t;
 	struct tm tm;
 	char date[256];
 
 	va_list ap;
-	
+
+	if (!(buf = ast_dynamic_str_thread_get(&log_buf, LOG_BUF_INIT_SIZE)))
+		return;
+
 	/* don't display LOG_DEBUG messages unless option_verbose _or_ option_debug
 	   are non-zero; LOG_DEBUG messages can still be displayed if option_debug
 	   is zero, if option_verbose is non-zero (this allows for 'level zero'
 	   LOG_DEBUG messages to be displayed, if the logmask on any channel
 	   allows it)
 	*/
-	if (!option_verbose && !option_debug && (level == __LOG_DEBUG)) {
+	if (!option_verbose && !option_debug && (level == __LOG_DEBUG))
 		return;
-	}
 
 	/* Ignore anything that never gets logged anywhere */
 	if (!(global_logmask & (1 << level)))
@@ -712,13 +705,12 @@
 	if ((level == __LOG_DEBUG) && !ast_strlen_zero(debug_filename) && strcasecmp(debug_filename, file))
 		return;
 
-	/* begin critical section */
-	ast_mutex_lock(&loglock);
-
 	time(&t);
 	localtime_r(&t, &tm);
 	strftime(date, sizeof(date), dateformat, &tm);
 
+	AST_LIST_LOCK(&logchannels);
+
 	if (logfiles.event_log && level == __LOG_EVENT) {
 		va_start(ap, fmt);
 
@@ -727,13 +719,14 @@
 		fflush(eventlog);
 
 		va_end(ap);
-		ast_mutex_unlock(&loglock);
+		AST_LIST_UNLOCK(&logchannels);
 		return;
 	}
 
-	if (logchannels) {
-		chan = logchannels;
-		while(chan && !chan->disabled) {
+	if (!AST_LIST_EMPTY(&logchannels)) {
+		AST_LIST_TRAVERSE(&logchannels, chan, list) {
+			if (chan->disabled)
+				break;
 			/* Check syslog channels */
 			if (chan->type == LOGTYPE_SYSLOG && (chan->logmask & (1 << level))) {
 				va_start(ap, fmt);
@@ -745,28 +738,33 @@
 				char tmp1[80], tmp2[80], tmp3[80], tmp4[80];
 
 				if (level != __LOG_VERBOSE) {
+					int res;
 					sprintf(linestr, "%d", line);
-					snprintf(buf, sizeof(buf), "[%s] %s[%ld]: %s:%s %s: ",
+					ast_dynamic_str_thread_set(&buf, BUFSIZ, &log_buf,
+						"[%s] %s[%ld]: %s:%s %s: ",
 						date,
 						term_color(tmp1, levels[level], colors[level], 0, sizeof(tmp1)),
 						(long)GETTID(),
 						term_color(tmp2, file, COLOR_BRWHITE, 0, sizeof(tmp2)),
 						term_color(tmp3, linestr, COLOR_BRWHITE, 0, sizeof(tmp3)),
 						term_color(tmp4, function, COLOR_BRWHITE, 0, sizeof(tmp4)));
+
+					ast_console_puts_mutable(buf->str);
 					
-					ast_console_puts_mutable(buf);
 					va_start(ap, fmt);
-					vsnprintf(buf, sizeof(buf), fmt, ap);
+					res = ast_dynamic_str_thread_set_va(&buf, BUFSIZ, &log_buf, fmt, ap);
 					va_end(ap);
-					ast_console_puts_mutable(buf);
+					if (res != AST_DYNSTR_BUILD_FAILED)
+						ast_console_puts_mutable(buf->str);
 				}
 			/* File channels */
 			} else if ((chan->logmask & (1 << level)) && (chan->fileptr)) {
 				int res;
-				snprintf(buf, sizeof(buf), "[%s] %s[%ld] %s: ", date,
-					levels[level], (long)GETTID(), file);
-				res = fprintf(chan->fileptr, buf);
-				if (res <= 0 && buf[0] != '\0') {	/* Error, no characters printed */
+				ast_dynamic_str_thread_set(&buf, BUFSIZ, &log_buf, 
+					"[%s] %s[%ld] %s: ",
+					date, levels[level], (long)GETTID(), file);
+				res = fprintf(chan->fileptr, "%s", buf->str);
+				if (res <= 0 && !ast_strlen_zero(buf->str)) {	/* Error, no characters printed */
 					fprintf(stderr,"**** Asterisk Logging Error: ***********\n");
 					if (errno == ENOMEM || errno == ENOSPC) {
 						fprintf(stderr, "Asterisk logging error: Out of disk space, can't log to log file %s\n", chan->filename);
@@ -775,16 +773,18 @@
 					manager_event(EVENT_FLAG_SYSTEM, "LogChannel", "Channel: %s\r\nEnabled: No\r\nReason: %d - %s\r\n", chan->filename, errno, strerror(errno));
 					chan->disabled = 1;	
 				} else {
+					int res;
 					/* No error message, continue printing */
 					va_start(ap, fmt);
-					vsnprintf(buf, sizeof(buf), fmt, ap);
+					res = ast_dynamic_str_thread_set_va(&buf, BUFSIZ, &log_buf, fmt, ap);
 					va_end(ap);
-					term_strip(buf, buf, sizeof(buf));
-					fputs(buf, chan->fileptr);
-					fflush(chan->fileptr);
+					if (res != AST_DYNSTR_BUILD_FAILED) {
+						term_strip(buf->str, buf->str, buf->len);
+						fputs(buf->str, chan->fileptr);
+						fflush(chan->fileptr);
+					}
 				}
 			}
-			chan = chan->next;
 		}
 	} else {
 		/* 
@@ -792,15 +792,17 @@
 		 * so just log to stdout 
 		*/
 		if (level != __LOG_VERBOSE) {
+			int res;
 			va_start(ap, fmt);
-			vsnprintf(buf, sizeof(buf), fmt, ap);
+			res = ast_dynamic_str_thread_set_va(&buf, BUFSIZ, &log_buf, fmt, ap);
 			va_end(ap);
-			fputs(buf, stdout);
-		}
-	}
-
-	ast_mutex_unlock(&loglock);
-	/* end critical section */
+			if (res != AST_DYNSTR_BUILD_FAILED)
+				fputs(buf->str, stdout);
+		}
+	}
+
+	AST_LIST_UNLOCK(&logchannels);
+
 	if (filesize_reload_needed) {
 		reload_logger(1);
 		ast_log(LOG_EVENT,"Rotated Logs Per SIGXFSZ (Exceeded file size limit)\n");
@@ -840,17 +842,10 @@
 
 void ast_verbose(const char *fmt, ...)
 {
-	static char stuff[4096];
-	static int len = 0;
-	static int replacelast = 0;
-
-	int complete;
-	int olen;
-	struct msglist *m;
 	struct verb *v;
-	
+	struct ast_dynamic_str *buf;
+	int res;
 	va_list ap;
-	va_start(ap, fmt);
 
 	if (ast_opt_timestamp) {
 		time_t t;
@@ -866,128 +861,54 @@
 		fmt = datefmt;
 	}
 
-	/* this lock is also protecting against multiple threads
-	   being in this function at the same time, so it must be
-	   held before any of the static variables are accessed
-	*/
-	ast_mutex_lock(&msglist_lock);
-
-	/* there is a potential security problem here: if formatting
-	   the current date using 'dateformat' results in a string
-	   containing '%', then the vsnprintf() call below will
-	   probably try to access random memory
-	*/
-	vsnprintf(stuff + len, sizeof(stuff) - len, fmt, ap);
+	if (!(buf = ast_dynamic_str_thread_get(&verbose_buf, VERBOSE_BUF_INIT_SIZE)))
+		return;
+
+	va_start(ap, fmt);
+	res = ast_dynamic_str_thread_set_va(&buf, 0, &verbose_buf, fmt, ap);
 	va_end(ap);
 
-	olen = len;
-	len = strlen(stuff);
-
-	complete = (stuff[len - 1] == '\n') ? 1 : 0;
-
-	/* If we filled up the stuff completely, then log it even without the '\n' */
-	if (len >= sizeof(stuff) - 1) {
-		complete = 1;
-		len = 0;
-	}
-
-	if (complete) {
-		if (msgcnt < MAX_MSG_QUEUE) {
-			/* Allocate new structure */
-			if ((m = ast_malloc(sizeof(*m))))
-				msgcnt++;
-		} else {
-			/* Recycle the oldest entry */
-			m = list;
-			list = list->next;
-			free(m->msg);
-		}
-		if (m) {
-			if ((m->msg = ast_strdup(stuff))) {
-				if (last)
-					last->next = m;
-				else
-					list = m;
-				m->next = NULL;
-				last = m;
-			} else {
-				msgcnt--;
-				free(m);
-			}
-		}
-	}
-
-	for (v = verboser; v; v = v->next)
-		v->verboser(stuff, olen, replacelast, complete);
-
-	ast_log(LOG_VERBOSE, "%s", stuff);
-
-	if (len) {
-		if (!complete)
-			replacelast = 1;
-		else 
-			replacelast = len = 0;
-	}
-
-	ast_mutex_unlock(&msglist_lock);
-}
-
-int ast_verbose_dmesg(void (*v)(const char *string, int opos, int replacelast, int complete))
-{
-	struct msglist *m;
-	ast_mutex_lock(&msglist_lock);
-	m = list;
-	while(m) {
-		/* Send all the existing entries that we have queued (i.e. they're likely to have missed) */
-		v(m->msg, 0, 0, 1);
-		m = m->next;
-	}
-	ast_mutex_unlock(&msglist_lock);
+	if (res == AST_DYNSTR_BUILD_FAILED)
+		return;
+
+	AST_LIST_LOCK(&verbosers);
+	AST_LIST_TRAVERSE(&verbosers, v, list)
+		v->verboser(buf->str);
+	AST_LIST_UNLOCK(&verbosers);
+
+	ast_log(LOG_VERBOSE, "%s", buf->str);
+}
+
+int ast_register_verbose(void (*v)(const char *string)) 
+{
+	struct verb *verb;
+
+	if (!(verb = ast_malloc(sizeof(*verb))))
+		return -1;
+
+	verb->verboser = v;
+
+	AST_LIST_LOCK(&verbosers);
+	AST_LIST_INSERT_HEAD(&verbosers, verb, list);
+	AST_LIST_UNLOCK(&verbosers);
+	
 	return 0;
 }
 
-int ast_register_verbose(void (*v)(const char *string, int opos, int replacelast, int complete)) 
-{
-	struct msglist *m;
-	struct verb *tmp;
-	/* XXX Should be more flexible here, taking > 1 verboser XXX */
-	if ((tmp = ast_malloc(sizeof(*tmp)))) {
-		tmp->verboser = v;
-		ast_mutex_lock(&msglist_lock);
-		tmp->next = verboser;
-		verboser = tmp;
-		m = list;
-		while(m) {
-			/* Send all the existing entries that we have queued (i.e. they're likely to have missed) */
-			v(m->msg, 0, 0, 1);
-			m = m->next;
-		}
-		ast_mutex_unlock(&msglist_lock);
-		return 0;
-	}
-	return -1;
-}
-
-int ast_unregister_verbose(void (*v)(const char *string, int opos, int replacelast, int complete))
-{
-	int res = -1;
-	struct verb *tmp, *tmpl=NULL;
-	ast_mutex_lock(&msglist_lock);
-	tmp = verboser;
-	while(tmp) {
-		if (tmp->verboser == v)	{
-			if (tmpl)
-				tmpl->next = tmp->next;
-			else
-				verboser = tmp->next;
-			free(tmp);
+int ast_unregister_verbose(void (*v)(const char *string))
+{
+	struct verb *cur;
+
+	AST_LIST_LOCK(&verbosers);
+	AST_LIST_TRAVERSE_SAFE_BEGIN(&verbosers, cur, list) {
+		if (cur->verboser == v) {
+			AST_LIST_REMOVE_CURRENT(&verbosers, list);
+			free(cur);
 			break;
 		}
-		tmpl = tmp;
-		tmp = tmp->next;
-	}
-	if (tmp)
-		res = 0;
-	ast_mutex_unlock(&msglist_lock);
-	return res;
-}
+	}
+	AST_LIST_TRAVERSE_SAFE_END
+	AST_LIST_UNLOCK(&verbosers);
+	
+	return cur ? 0 : -1;
+}

Modified: trunk/manager.c
URL: http://svn.digium.com/view/asterisk/trunk/manager.c?rev=39272&r1=39271&r2=39272&view=diff
==============================================================================
--- trunk/manager.c (original)
+++ trunk/manager.c Tue Aug  8 01:32:04 2006
@@ -66,6 +66,7 @@
 #include "asterisk/acl.h"
 #include "asterisk/utils.h"
 #include "asterisk/http.h"
+#include "asterisk/threadstorage.h"
 
 struct fast_originate_helper {
 	char tech[AST_MAX_MANHEADER_LEN];
@@ -103,6 +104,9 @@
 static int block_sockets = 0;
 static int num_sessions = 0;
 struct eventqent *master_eventq = NULL;
+
+AST_THREADSTORAGE(manager_event_buf, manager_event_buf_init);
+#define MANAGER_EVENT_BUF_INITSIZE   256
 
 static struct permalias {
 	int num;
@@ -2113,33 +2117,37 @@
 {
 	struct mansession *s;
 	char auth[80];
-	char tmp[4096] = "";
-	char *tmp_next = tmp;
-	size_t tmp_left = sizeof(tmp) - 2;
 	va_list ap;
 	struct timeval now;
+	struct ast_dynamic_str *buf;
 
 	/* Abort if there aren't any manager sessions */
 	if (!num_sessions)
 		return 0;
 
-	ast_build_string(&tmp_next, &tmp_left, "Event: %s\r\nPrivilege: %s\r\n",
+	if (!(buf = ast_dynamic_str_thread_get(&manager_event_buf, MANAGER_EVENT_BUF_INITSIZE)))
+		return -1;
+
+	ast_dynamic_str_thread_set(&buf, 0, &manager_event_buf,
+			"Event: %s\r\nPrivilege: %s\r\n",
 			 event, authority_to_str(category, auth, sizeof(auth)));
+
 	if (timestampevents) {
 		now = ast_tvnow();
-		ast_build_string(&tmp_next, &tmp_left, "Timestamp: %ld.%06lu\r\n",
+		ast_dynamic_str_thread_append(&buf, 0, &manager_event_buf,
+				"Timestamp: %ld.%06lu\r\n",
 				 now.tv_sec, (unsigned long) now.tv_usec);
 	}
+
 	va_start(ap, fmt);
-	ast_build_string_va(&tmp_next, &tmp_left, fmt, ap);
+	ast_dynamic_str_thread_append_va(&buf, 0, &manager_event_buf, fmt, ap);
 	va_end(ap);
-	*tmp_next++ = '\r';
-	*tmp_next++ = '\n';
-	*tmp_next = '\0';
+	
+	ast_dynamic_str_thread_append(&buf, 0, &manager_event_buf, "\r\n");	
 	
 	ast_mutex_lock(&sessionlock);
 	/* Append even to master list and wake up any sleeping sessions */
-	append_event(tmp, category);
+	append_event(buf->str, category);
 	for (s = sessions; s; s = s->next) {
 		ast_mutex_lock(&s->__lock);
 		if (s->waiting_thread != AST_PTHREADT_NULL)

Modified: trunk/pbx/pbx_ael.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx/pbx_ael.c?rev=39272&r1=39271&r2=39272&view=diff
==============================================================================
--- trunk/pbx/pbx_ael.c (original)
+++ trunk/pbx/pbx_ael.c Tue Aug  8 01:32:04 2006
@@ -50,16 +50,6 @@
 static char expr_output[2096];
 
 /* these functions are in ../ast_expr2.fl */
-
-	
-#ifdef __AST_DEBUG_MALLOC
-static void FREE(void *ptr)
-{
-	free(ptr);
-}
-#else
-#define FREE free
-#endif
 
 #define DEBUG_READ   (1 << 0)
 #define DEBUG_TOKENS (1 << 1)
@@ -3403,7 +3393,7 @@
 		
 		if (exten->hints) {
 			if (ast_add_extension2(exten->context, 0 /*no replace*/, exten->name, PRIORITY_HINT, NULL, exten->cidmatch, 
-								  exten->hints, NULL, FREE, registrar)) {
+								  exten->hints, NULL, ast_free, registrar)) {
 				ast_log(LOG_WARNING, "Unable to add step at priority 'hint' of extension '%s'\n",
 						exten->name);
 			}
@@ -3483,7 +3473,7 @@
 				label = 0;
 			
 			if (ast_add_extension2(exten->context, 0 /*no replace*/, exten->name, pr->priority_num, (label?label:NULL), exten->cidmatch, 
-								  app, strdup(appargs), FREE, registrar)) {
+								  app, strdup(appargs), ast_free, registrar)) {
 				ast_log(LOG_WARNING, "Unable to add step at priority '%d' of extension '%s'\n", pr->priority_num, 
 						exten->name);
 			}

Modified: trunk/pbx/pbx_config.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx/pbx_config.c?rev=39272&r1=39271&r2=39272&view=diff
==============================================================================
--- trunk/pbx/pbx_config.c (original)
+++ trunk/pbx/pbx_config.c Tue Aug  8 01:32:04 2006
@@ -41,15 +41,6 @@
 #include "asterisk/logger.h"
 #include "asterisk/cli.h"
 #include "asterisk/callerid.h"
-
-#ifdef __AST_DEBUG_MALLOC
-static void FREE(void *ptr)
-{
-	free(ptr);
-}
-#else
-#define FREE free
-#endif
 
 static char *config = "extensions.conf";
 static char *registrar = "pbx_config";
@@ -1458,7 +1449,7 @@
 						lastpri = ipri;
 						if (!ast_opt_dont_warn && !strcmp(realext, "_."))
 							ast_log(LOG_WARNING, "The use of '_.' for an extension is strongly discouraged and can have unexpected behavior.  Please use '_X.' instead at line %d\n", v->lineno);
-						if (ast_add_extension2(con, 0, realext, ipri, label, cidmatch, appl, strdup(data), FREE, registrar)) {
+						if (ast_add_extension2(con, 0, realext, ipri, label, cidmatch, appl, strdup(data), ast_free, registrar)) {
 							ast_log(LOG_WARNING, "Unable to register extension at line %d\n", v->lineno);
 						}
 					}

Modified: trunk/res/res_agi.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_agi.c?rev=39272&r1=39271&r2=39272&view=diff
==============================================================================
--- trunk/res/res_agi.c (original)
+++ trunk/res/res_agi.c Tue Aug  8 01:32:04 2006
@@ -130,7 +130,7 @@
 		ast_log(LOG_ERROR, "Out of memory\n");
 	} else {
 		if (agidebug)
-			ast_verbose("AGI Tx >> %s", stuff);
+			ast_verbose("AGI Tx >> %s\n", stuff);
 		ast_carefulwrite(fd, stuff, strlen(stuff), 100);
 		free(stuff);
 	}

Modified: trunk/res/res_features.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_features.c?rev=39272&r1=39271&r2=39272&view=diff
==============================================================================
--- trunk/res/res_features.c (original)
+++ trunk/res/res_features.c Tue Aug  8 01:32:04 2006
@@ -59,15 +59,6 @@
 #include "asterisk/devicestate.h"
 #include "asterisk/monitor.h"
 
-#ifdef __AST_DEBUG_MALLOC
-static void FREE(void *ptr)
-{
-	free(ptr);
-}
-#else
-#define FREE free
-#endif
-
 #define DEFAULT_PARK_TIME 45000
 #define DEFAULT_TRANSFER_DIGIT_TIMEOUT 3000
 #define DEFAULT_FEATURE_DIGIT_TIMEOUT 500
@@ -427,7 +418,7 @@
 	if (!con)	/* Still no context? Bad */
 		ast_log(LOG_ERROR, "Parking context '%s' does not exist and unable to create\n", parking_con);
 	else {		/* Add extension to context */
-		if (!ast_add_extension2(con, 1, pu->parkingexten, 1, NULL, NULL, parkedcall, strdup(pu->parkingexten), FREE, registrar))
+		if (!ast_add_extension2(con, 1, pu->parkingexten, 1, NULL, NULL, parkedcall, strdup(pu->parkingexten), ast_free, registrar))
 			notify_metermaids(pu->parkingexten, parking_con);

[... 115 lines stripped ...]


More information about the asterisk-commits mailing list