[asterisk-commits] tilghman: branch tilghman/ast_str_opaque r161945 - in /team/tilghman/ast_str_...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Dec 8 19:33:03 CST 2008


Author: tilghman
Date: Mon Dec  8 19:32:59 2008
New Revision: 161945

URL: http://svn.digium.com/view/asterisk?view=rev&rev=161945
Log:
Most things converted, except xmldoc

Modified:
    team/tilghman/ast_str_opaque/apps/app_dumpchan.c
    team/tilghman/ast_str_opaque/apps/app_externalivr.c
    team/tilghman/ast_str_opaque/apps/app_followme.c
    team/tilghman/ast_str_opaque/apps/app_queue.c
    team/tilghman/ast_str_opaque/apps/app_voicemail.c
    team/tilghman/ast_str_opaque/channels/chan_sip.c
    team/tilghman/ast_str_opaque/channels/iax2-parser.c
    team/tilghman/ast_str_opaque/funcs/func_curl.c
    team/tilghman/ast_str_opaque/funcs/func_odbc.c
    team/tilghman/ast_str_opaque/funcs/func_realtime.c
    team/tilghman/ast_str_opaque/funcs/func_strings.c
    team/tilghman/ast_str_opaque/include/asterisk/app.h
    team/tilghman/ast_str_opaque/include/asterisk/cdr.h
    team/tilghman/ast_str_opaque/include/asterisk/strings.h
    team/tilghman/ast_str_opaque/include/asterisk/tcptls.h
    team/tilghman/ast_str_opaque/include/asterisk/threadstorage.h
    team/tilghman/ast_str_opaque/main/app.c
    team/tilghman/ast_str_opaque/main/asterisk.c
    team/tilghman/ast_str_opaque/main/cdr.c
    team/tilghman/ast_str_opaque/main/cli.c
    team/tilghman/ast_str_opaque/main/config.c
    team/tilghman/ast_str_opaque/main/http.c
    team/tilghman/ast_str_opaque/main/logger.c
    team/tilghman/ast_str_opaque/main/manager.c
    team/tilghman/ast_str_opaque/main/pbx.c
    team/tilghman/ast_str_opaque/main/strings.c
    team/tilghman/ast_str_opaque/main/tcptls.c
    team/tilghman/ast_str_opaque/main/translate.c
    team/tilghman/ast_str_opaque/res/res_agi.c
    team/tilghman/ast_str_opaque/res/res_clialiases.c
    team/tilghman/ast_str_opaque/utils/check_expr.c

Modified: team/tilghman/ast_str_opaque/apps/app_dumpchan.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/ast_str_opaque/apps/app_dumpchan.c?view=diff&rev=161945&r1=161944&r2=161945
==============================================================================
--- team/tilghman/ast_str_opaque/apps/app_dumpchan.c (original)
+++ team/tilghman/ast_str_opaque/apps/app_dumpchan.c Mon Dec  8 19:32:59 2008
@@ -35,6 +35,7 @@
 #include "asterisk/pbx.h"
 #include "asterisk/module.h"
 #include "asterisk/channel.h"
+#include "asterisk/app.h"
 
 /*** DOCUMENTATION
 	<application name="DumpChan" language="en_US">
@@ -148,7 +149,7 @@
 
 static int dumpchan_exec(struct ast_channel *chan, void *data)
 {
-	struct ast_str *vars = ast_str_alloca(BUFSIZ * 4); /* XXX very large! */
+	struct ast_str *vars = ast_str_thread_get(&global_app_buf, 16);
 	char info[1024];
 	int level = 0;
 	static char *line = "================================================================================";
@@ -156,10 +157,11 @@
 	if (!ast_strlen_zero(data))
 		level = atoi(data);
 
-	pbx_builtin_serialize_variables(chan, &vars);
-	serialize_showchan(chan, info, sizeof(info));
-	if (option_verbose >= level)
-		ast_verbose("\nDumping Info For Channel: %s:\n%s\nInfo:\n%s\nVariables:\n%s%s\n", chan->name, line, info, vars->str, line);
+	if (option_verbose >= level) {
+		serialize_showchan(chan, info, sizeof(info));
+		pbx_builtin_serialize_variables(chan, &vars);
+		ast_verbose("\nDumping Info For Channel: %s:\n%s\nInfo:\n%s\nVariables:\n%s%s\n", chan->name, line, info, ast_str_buffer(vars), line);
+	}
 
 	return 0;
 }

Modified: team/tilghman/ast_str_opaque/apps/app_externalivr.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/ast_str_opaque/apps/app_externalivr.c?view=diff&rev=161945&r1=161944&r2=161945
==============================================================================
--- team/tilghman/ast_str_opaque/apps/app_externalivr.c (original)
+++ team/tilghman/ast_str_opaque/apps/app_externalivr.c Mon Dec  8 19:32:59 2008
@@ -122,8 +122,8 @@
 		ast_str_append(&tmp, 0, ",%s", data);
 	}
 
-	fprintf(handle, "%s\n", tmp->str);
-	ast_debug(1, "sent '%s'\n", tmp->str);
+	fprintf(handle, "%s\n", ast_str_buffer(tmp));
+	ast_debug(1, "sent '%s'\n", ast_str_buffer(tmp));
 }
 
 static void *gen_alloc(struct ast_channel *chan, void *params)
@@ -276,7 +276,7 @@
 
 		ast_str_append(&newstring, 0, "%s=%s,", variable, value);
 		ast_channel_unlock(chan);
-		ast_copy_string(outbuf, newstring->str, outbuflen);
+		ast_copy_string(outbuf, ast_str_buffer(newstring), outbuflen);
 	}
 }
 
@@ -659,7 +659,8 @@
  				continue;
   
 			if (input[0] == 'P') {
- 				send_eivr_event(eivr_events, 'P', args->str, chan);
+				struct ast_str *tmp = (struct ast_str *) args;
+ 				send_eivr_event(eivr_events, 'P', ast_str_buffer(tmp), chan);
 			} else if ( input[0] == 'T' ) {
 				ast_chan_log(LOG_WARNING, chan, "Answering channel if needed and starting generator\n");
 				if (chan->_state != AST_STATE_UP) {

Modified: team/tilghman/ast_str_opaque/apps/app_followme.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/ast_str_opaque/apps/app_followme.c?view=diff&rev=161945&r1=161944&r2=161945
==============================================================================
--- team/tilghman/ast_str_opaque/apps/app_followme.c (original)
+++ team/tilghman/ast_str_opaque/apps/app_followme.c Mon Dec  8 19:32:59 2008
@@ -961,7 +961,7 @@
 		/* This one has to exist; it was part of the query */
 		ordstr = ast_variable_retrieve(cfg, catg, "ordinal");
 		ast_str_set(&str, 0, "%s", numstr);
-		if ((cur = create_followme_number(str->str, timeout, atoi(ordstr)))) {
+		if ((cur = create_followme_number(ast_str_buffer(str), timeout, atoi(ordstr)))) {
 			AST_LIST_INSERT_TAIL(&new->numbers, cur, entry);
 		}
 	}

Modified: team/tilghman/ast_str_opaque/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/ast_str_opaque/apps/app_queue.c?view=diff&rev=161945&r1=161944&r2=161945
==============================================================================
--- team/tilghman/ast_str_opaque/apps/app_queue.c (original)
+++ team/tilghman/ast_str_opaque/apps/app_queue.c Mon Dec  8 19:32:59 2008
@@ -2266,7 +2266,7 @@
 /*! \brief convert "\n" to "\nVariable: " ready for manager to use */
 static char *vars2manager(struct ast_channel *chan, char *vars, size_t len)
 {
-	struct ast_str *buf = ast_str_alloca(len + 1);
+	struct ast_str *buf = ast_str_thread_get(&global_app_buf, len + 1);
 	char *tmp;
 
 	if (pbx_builtin_serialize_variables(chan, &buf)) {
@@ -2274,7 +2274,7 @@
 
 		/* convert "\n" to "\nVariable: " */
 		strcpy(vars, "Variable: ");
-		tmp = buf->str;
+		tmp = ast_str_buffer(buf);
 
 		for (i = 0, j = 10; (i < len - 1) && (j < len - 1); i++, j++) {
 			vars[j] = tmp[i];
@@ -2583,12 +2583,12 @@
 	if (qe->parent->randomperiodicannounce) {
 		qe->last_periodic_announce_sound = ((unsigned long) ast_random()) % qe->parent->numperiodicannounce;
 	} else if (qe->last_periodic_announce_sound >= qe->parent->numperiodicannounce || 
-		ast_strlen_zero(qe->parent->sound_periodicannounce[qe->last_periodic_announce_sound]->str)) {
+		ast_str_strlen(qe->parent->sound_periodicannounce[qe->last_periodic_announce_sound]) == 0) {
 		qe->last_periodic_announce_sound = 0;
 	}
 	
 	/* play the announcement */
-	res = play_file(qe->chan, qe->parent->sound_periodicannounce[qe->last_periodic_announce_sound]->str);
+	res = play_file(qe->chan, ast_str_buffer(qe->parent->sound_periodicannounce[qe->last_periodic_announce_sound]));
 
 	if ((res > 0 && !valid_exit(qe, res)) || res < 0)
 		res = 0;
@@ -5716,7 +5716,7 @@
 		ast_str_append(&out, 0, ") in '%s' strategy (%ds holdtime), W:%d, C:%d, A:%d, SL:%2.1f%% within %ds",
 			int2strat(q->strategy), q->holdtime, q->weight,
 			q->callscompleted, q->callsabandoned,sl,q->servicelevel);
-		do_print(s, fd, out->str);
+		do_print(s, fd, ast_str_buffer(out));
 		if (!ao2_container_count(q->members))
 			do_print(s, fd, "   No Members");
 		else {
@@ -5741,7 +5741,7 @@
 						mem->calls, (long) (time(NULL) - mem->lastcall));
 				else
 					ast_str_append(&out, 0, " has taken no calls yet");
-				do_print(s, fd, out->str);
+				do_print(s, fd, ast_str_buffer(out));
 				ao2_ref(mem, -1);
 			}
 		}
@@ -5756,7 +5756,7 @@
 				ast_str_set(&out, 0, "      %d. %s (wait: %ld:%2.2ld, prio: %d)",
 					pos++, qe->chan->name, (long) (now - qe->start) / 60,
 					(long) (now - qe->start) % 60, qe->prio);
-				do_print(s, fd, out->str);
+				do_print(s, fd, ast_str_buffer(out));
 			}
 		}
 		do_print(s, fd, "");	/* blank line between entries */
@@ -5777,7 +5777,7 @@
 			ast_str_set(&out, 0, "No such queue: %s.", argv[2]);
 		else
 			ast_str_set(&out, 0, "No queues.");
-		do_print(s, fd, out->str);
+		do_print(s, fd, ast_str_buffer(out));
 	}
 	return CLI_SUCCESS;
 }

Modified: team/tilghman/ast_str_opaque/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/ast_str_opaque/apps/app_voicemail.c?view=diff&rev=161945&r1=161944&r2=161945
==============================================================================
--- team/tilghman/ast_str_opaque/apps/app_voicemail.c (original)
+++ team/tilghman/ast_str_opaque/apps/app_voicemail.c Mon Dec  8 19:32:59 2008
@@ -10191,12 +10191,12 @@
 	AST_LIST_UNLOCK(&zones);
 }
 
-static char *substitute_escapes(const char *value)
-{
-	char *current, *result;
+static const char *substitute_escapes(const char *value)
+{
+	char *current;
 
 	/* Add 16 for fudge factor */
-	struct ast_str *str = ast_str_create(strlen(value) + 16);
+	struct ast_str *str = ast_str_thread_get(&global_app_buf, strlen(value) + 16);
 
 	/* Substitute strings \r, \n, and \t into the appropriate characters */
 	for (current = (char *) value; *current; current++) {
@@ -10230,10 +10230,7 @@
 		}
 	}
 
-	result = ast_strdup(str->str);
-	ast_free(str);
-
-	return result;
+	return ast_str_buffer(str);
 }
 
 static int load_config(int reload)
@@ -10844,13 +10841,13 @@
 			emailsubject = ast_strdup(val);
 		}
 		if ((val = ast_variable_retrieve(cfg, "general", "emailbody"))) {
-			emailbody = substitute_escapes(val);
+			emailbody = ast_strdup(substitute_escapes(val));
 		}
 		if ((val = ast_variable_retrieve(cfg, "general", "pagersubject"))) {
 			pagersubject = ast_strdup(val);
 		}
 		if ((val = ast_variable_retrieve(cfg, "general", "pagerbody"))) {
-			pagerbody = substitute_escapes(val);
+			pagerbody = ast_strdup(substitute_escapes(val));
 		}
 		AST_LIST_UNLOCK(&users);
 		ast_config_destroy(cfg);

Modified: team/tilghman/ast_str_opaque/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/ast_str_opaque/channels/chan_sip.c?view=diff&rev=161945&r1=161944&r2=161945
==============================================================================
--- team/tilghman/ast_str_opaque/channels/chan_sip.c (original)
+++ team/tilghman/ast_str_opaque/channels/chan_sip.c Mon Dec  8 19:32:59 2008
@@ -2031,6 +2031,8 @@
 
 /*! \brief A per-thread temporary pvt structure */
 AST_THREADSTORAGE_CUSTOM(ts_temp_pvt, temp_pvt_init, temp_pvt_cleanup);
+AST_THREADSTORAGE(transmit_state_buffer);
+AST_THREADSTORAGE(mailbox_buffer);
 
 #ifdef LOW_MEMORY
 static void ts_ast_rtp_destroy(void *);
@@ -2261,7 +2263,7 @@
 static int expire_register(const void *data);
 static void *do_monitor(void *data);
 static int restart_monitor(void);
-static void peer_mailboxes_to_str(struct ast_str **mailbox_str, struct sip_peer *peer);
+static char *peer_mailboxes_to_str(struct ast_str **mailbox_str, struct sip_peer *peer);
 /* static int sip_addrcmp(char *name, struct sockaddr_in *sin);	Support for peer matching */
 static int sip_refer_allocate(struct sip_pvt *p);
 static void ast_quiet_chan(struct ast_channel *chan);
@@ -2707,7 +2709,7 @@
 		}
 
 		/* Read in headers one line at a time */
-		while (req.len < 4 || strncmp((char *)&req.data->str + req.len - 4, "\r\n\r\n", 4)) {
+		while (req.len < 4 || strncmp(ast_str_buffer(req.data) + req.len - 4, "\r\n\r\n", 4)) {
 			ast_mutex_lock(&ser->lock);
 			if (!fgets(buf, sizeof(buf), ser->f)) {
 				ast_mutex_unlock(&ser->lock);
@@ -2716,8 +2718,8 @@
 			ast_mutex_unlock(&ser->lock);
 			if (me->stop) 
 				 goto cleanup;
-			ast_str_append(&req.data, 0, "%s", buf);
-			req.len = req.data->used;
+			ast_str_append(&req.data, -1, "%s", buf);
+			req.len = ast_str_strlen(req.data);
 		}
 		copy_request(&reqcpy, &req);
 		parse_request(&reqcpy);
@@ -2733,8 +2735,8 @@
 				if (me->stop)
 					goto cleanup;
 				cl -= strlen(buf);
-				ast_str_append(&req.data, 0, "%s", buf);
-				req.len = req.data->used;
+				ast_str_append(&req.data, -1, "%s", buf);
+				req.len = ast_str_strlen(req.data);
 			}
 		}
 		/*! \todo XXX If there's no Content-Length or if the content-length and what
@@ -3163,7 +3165,7 @@
 	int res = 0;
 	const struct sockaddr_in *dst = sip_real_dst(p);
 
-	ast_debug(2, "Trying to put '%.10s' onto %s socket destined for %s:%d\n", data->str, get_transport_pvt(p), ast_inet_ntoa(dst->sin_addr), htons(dst->sin_port));
+	ast_debug(2, "Trying to put '%.10s' onto %s socket destined for %s:%d\n", ast_str_buffer(data), get_transport_pvt(p), ast_inet_ntoa(dst->sin_addr), htons(dst->sin_port));
 
 	if (sip_prepare_socket(p) < 0)
 		return XMIT_ERROR;
@@ -3172,10 +3174,10 @@
 		ast_mutex_lock(&p->socket.ser->lock);
 
 	if (p->socket.type & SIP_TRANSPORT_UDP) 
-		res = sendto(p->socket.fd, data->str, len, 0, (const struct sockaddr *)dst, sizeof(struct sockaddr_in));
+		res = sendto(p->socket.fd, ast_str_buffer(data), len, 0, (const struct sockaddr *)dst, sizeof(struct sockaddr_in));
 	else {
 		if (p->socket.ser->f) 
-			res = ast_tcptls_server_write(p->socket.ser, data->str, len);
+			res = ast_tcptls_server_write(p->socket.ser, ast_str_buffer(data), len);
 		else
 			ast_debug(2, "No p->socket.ser->f len=%d\n", len);
 	} 
@@ -3354,10 +3356,10 @@
 			ast_verbose("Retransmitting #%d (%s) to %s:%d:\n%s\n---\n",
 				pkt->retrans, sip_nat_mode(pkt->owner),
 				ast_inet_ntoa(dst->sin_addr),
-				ntohs(dst->sin_port), pkt->data->str);
-		}
-
-		append_history(pkt->owner, "ReTx", "%d %s", reschedule, pkt->data->str);
+				ntohs(dst->sin_port), ast_str_buffer(pkt->data));
+		}
+
+		append_history(pkt->owner, "ReTx", "%d %s", reschedule, ast_str_buffer(pkt->data));
 		xmitres = __sip_xmit(pkt->owner, pkt->data, pkt->packetlen);
 		sip_pvt_unlock(pkt->owner);
 		if (xmitres == XMIT_ERROR)
@@ -3472,7 +3474,7 @@
 		ast_free(pkt);
 		return AST_FAILURE;
 	}
-	ast_str_set(&pkt->data, 0, "%s%s", data->str, "\0");
+	ast_str_set(&pkt->data, 0, "%s", ast_str_buffer(data));
 	pkt->packetlen = len;
 	/* copy other parameters from the caller */
 	pkt->method = sipmethod;
@@ -3674,7 +3676,7 @@
 			return;
 		}
 		cur = p->packets;
-		method = (cur->method) ? cur->method : find_sip_method(cur->data->str);
+		method = (cur->method) ? cur->method : find_sip_method(ast_str_buffer(cur->data));
 		__sip_ack(p, cur->seqno, cur->is_resp, method);
 	}
 }
@@ -3687,7 +3689,7 @@
 
 	for (cur = p->packets; cur; cur = cur->next) {
 		if (cur->seqno == seqno && cur->is_resp == resp &&
-			(cur->is_resp || method_match(sipmethod, cur->data->str))) {
+			(cur->is_resp || method_match(sipmethod, ast_str_buffer(cur->data)))) {
 			/* this is our baby */
 			if (cur->retransid > -1) {
 				if (sipdebug)
@@ -3716,7 +3718,7 @@
 	if (!req->lines) {
 		/* Add extra empty return. add_header() reserves 4 bytes so cannot be truncated */
 		ast_str_append(&req->data, 0, "\r\n");
-		req->len = req->data->used;
+		req->len = ast_str_strlen(req->data);
 	}
 }
 
@@ -3732,12 +3734,12 @@
 		ast_verbose("\n<--- %sTransmitting (%s) to %s:%d --->\n%s\n<------------>\n",
 			reliable ? "Reliably " : "", sip_nat_mode(p),
 			ast_inet_ntoa(dst->sin_addr),
-			ntohs(dst->sin_port), req->data->str);
+			ntohs(dst->sin_port), ast_str_buffer(req->data));
 	}
 	if (p->do_history) {
 		struct sip_request tmp = { .rlPart1 = NULL, };
 		parse_copy(&tmp, req);
-		append_history(p, reliable ? "TxRespRel" : "TxResp", "%s / %s - %s", tmp.data->str, get_header(&tmp, "CSeq"), 
+		append_history(p, reliable ? "TxRespRel" : "TxResp", "%s / %s - %s", ast_str_buffer(tmp.data), get_header(&tmp, "CSeq"), 
 			(tmp.method == SIP_RESPONSE || tmp.method == SIP_UNKNOWN) ? tmp.rlPart2 : sip_methods[tmp.method].text);
 		ast_free(tmp.data);
 	}
@@ -3765,15 +3767,16 @@
 
 	add_blank(req);
 	if (sip_debug_test_pvt(p)) {
-		if (ast_test_flag(&p->flags[0], SIP_NAT_ROUTE))
-			ast_verbose("%sTransmitting (NAT) to %s:%d:\n%s\n---\n", reliable ? "Reliably " : "", ast_inet_ntoa(p->recv.sin_addr), ntohs(p->recv.sin_port), req->data->str);
-		else
-			ast_verbose("%sTransmitting (no NAT) to %s:%d:\n%s\n---\n", reliable ? "Reliably " : "", ast_inet_ntoa(p->sa.sin_addr), ntohs(p->sa.sin_port), req->data->str);
+		if (ast_test_flag(&p->flags[0], SIP_NAT_ROUTE)) {
+			ast_verbose("%sTransmitting (NAT) to %s:%d:\n%s\n---\n", reliable ? "Reliably " : "", ast_inet_ntoa(p->recv.sin_addr), ntohs(p->recv.sin_port), ast_str_buffer(req->data));
+		} else {
+			ast_verbose("%sTransmitting (no NAT) to %s:%d:\n%s\n---\n", reliable ? "Reliably " : "", ast_inet_ntoa(p->sa.sin_addr), ntohs(p->sa.sin_port), ast_str_buffer(req->data));
+		}
 	}
 	if (p->do_history) {
 		struct sip_request tmp = { .rlPart1 = NULL, };
 		parse_copy(&tmp, req);
-		append_history(p, reliable ? "TxReqRel" : "TxReq", "%s / %s - %s", tmp.data->str, get_header(&tmp, "CSeq"), sip_methods[tmp.method].text);
+		append_history(p, reliable ? "TxReqRel" : "TxReq", "%s / %s - %s", ast_str_buffer(tmp.data), get_header(&tmp, "CSeq"), sip_methods[tmp.method].text);
 		ast_free(tmp.data);
 	}
 	res = (reliable) ?
@@ -5504,7 +5507,7 @@
 		sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
 
 	/* Start the process if it's not already started */
-	if (!p->alreadygone && p->initreq.data && !ast_strlen_zero(p->initreq.data->str)) {
+	if (!p->alreadygone && p->initreq.data && ast_str_strlen(p->initreq.data)) {
 		if (needcancel) {	/* Outgoing call, not up */
 			if (ast_test_flag(&p->flags[0], SIP_OUTGOING)) {
 				/* stop retransmitting an INVITE that has not received a response */
@@ -7033,7 +7036,7 @@
 */
 static int parse_request(struct sip_request *req)
 {
-	char *c = req->data->str, **dst = req->header;
+	char *c = ast_str_buffer(req->data), **dst = req->header;
 	int i = 0, lim = SIP_MAX_HEADERS - 1;
 	unsigned int skipping_headers = 0;
 
@@ -7931,7 +7934,7 @@
 		/* Activate a re-invite */
 		ast_queue_frame(p->owner, &ast_null_frame);
 		/* Queue Manager Unhold event */
-		append_history(p, "Unhold", "%s", req->data->str);
+		append_history(p, "Unhold", "%s", ast_str_buffer(req->data));
 		if (sip_cfg.callevents)
 			manager_event(EVENT_FLAG_CALL, "Hold",
 				      "Status: Off\r\n"
@@ -7953,7 +7956,7 @@
 		/* Activate a re-invite */
 		ast_queue_frame(p->owner, &ast_null_frame);
 		/* Queue Manager Hold event */
-		append_history(p, "Hold", "%s", req->data->str);
+		append_history(p, "Hold", "%s", ast_str_buffer(req->data));
 		if (sip_cfg.callevents && !ast_test_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD)) {
 			manager_event(EVENT_FLAG_CALL, "Hold",
 				      "Status: On\r\n"
@@ -7996,8 +7999,8 @@
 		return -1;
 	}
 
-	ast_str_append(&req->data, 0, "%s: %s\r\n", var, value);
-	req->header[req->headers] = req->data->str + req->len;
+	ast_str_append(&req->data, -1, "%s: %s\r\n", var, value);
+	req->header[req->headers] = ast_str_buffer(req->data) + req->len;
 
 	if (sip_cfg.compactheaders)
 		var = find_alias(var, var);
@@ -8023,16 +8026,12 @@
 		ast_log(LOG_WARNING, "Out of SIP line space\n");
 		return -1;
 	}
-	if (!req->lines)
+	if (!req->lines) {
 		/* Add extra empty return */
-		req->len += ast_str_append(&req->data, 0, "\r\n");
-	if (req->len >= sizeof(req->data->str) - 4) {
-		ast_log(LOG_WARNING, "Out of space, can't add anymore\n");
-		return -1;
-	}
-	req->line[req->lines] = req->data->str + req->len;
-	ast_str_append(&req->data, 0, "%s", line);
-	req->len += strlen(req->line[req->lines]);
+		req->len += ast_str_append(&req->data, -1, "\r\n");
+	}
+	req->line[req->lines] = ast_str_buffer(req->data) + ast_str_strlen(req->data);
+	req->len += ast_str_append(&req->data, -1, "%s", line);
 	req->lines++;
 	return 0;	
 }
@@ -8096,7 +8095,7 @@
 
 			/* Find ;rport;  (empty request) */
 			rport = strstr(leftmost, ";rport");
-			if (rport && *(rport+6) == '=') 
+			if (rport && *(rport + 6) == '=') 
 				rport = NULL;		/* We already have a parameter to rport */
 
 			/* Check rport if NAT=yes or NAT=rfc3581 (which is the default setting)  */
@@ -8248,9 +8247,9 @@
 	resp->method = SIP_RESPONSE;
 	if (!(resp->data = ast_str_create(SIP_MIN_PACKET)))
 		return -1;
-	resp->header[0] = resp->data->str;
-	ast_str_set(&resp->data, 0, "SIP/2.0 %s\r\n", msg);
-	resp->len = strlen(resp->header[0]);
+	ast_str_set(&resp->data, -1, "SIP/2.0 %s\r\n", msg);
+	resp->header[0] = ast_str_buffer(resp->data);
+	resp->len = ast_str_strlen(resp->data);
 	resp->headers++;
 	return 0;
 }
@@ -8263,9 +8262,9 @@
 	if (!(req->data = ast_str_create(SIP_MIN_PACKET)))
 		return -1;
 	req->method = sipmethod;
-	req->header[0] = req->data->str;
-	ast_str_set(&req->data, 0, "%s %s SIP/2.0\r\n", sip_methods[sipmethod].text, recip);
-	req->len = strlen(req->header[0]);
+	ast_str_set(&req->data, -1, "%s %s SIP/2.0\r\n", sip_methods[sipmethod].text, recip);
+	req->header[0] = ast_str_buffer(req->data);
+	req->len = ast_str_strlen(req->data);
 	req->headers++;
 	return 0;
 }
@@ -8912,11 +8911,11 @@
 	ast_str_append(&a_modem, 0, "a=T38FaxMaxDatagram:%d\r\n", x);
 	if (p->t38.jointcapability != T38FAX_UDP_EC_NONE)
 		ast_str_append(&a_modem, 0, "a=T38FaxUdpEC:%s\r\n", (p->t38.jointcapability & T38FAX_UDP_EC_REDUNDANCY) ? "t38UDPRedundancy" : "t38UDPFEC");
-	len = m_modem->used + a_modem->used;
+	len = ast_str_strlen(m_modem) + ast_str_strlen(a_modem);
 	add_header(resp, "Content-Type", "application/sdp");
 	add_header_contentLength(resp, len);
-	add_line(resp, m_modem->str);
-	add_line(resp, a_modem->str);
+	add_line(resp, ast_str_buffer(m_modem));
+	add_line(resp, ast_str_buffer(a_modem));
 
 	/* Update lastrtprx when we send our SDP */
 	p->lastrtprx = p->lastrtptx = time(NULL);
@@ -8954,10 +8953,12 @@
 {
 	/* First, get our address */
 	ast_rtp_get_us(p->rtp, sin);
-	if (p->vrtp)
+	if (p->vrtp) {
 		ast_rtp_get_us(p->vrtp, vsin);
-	if (p->trtp)
+	}
+	if (p->trtp) {
 		ast_rtp_get_us(p->trtp, tsin);
+	}
 
 	/* Now, try to figure out where we want them to send data */
 	/* Is this a re-invite to move the media out, then use the original offer from caller  */
@@ -9007,12 +9008,12 @@
 	struct sockaddr_in tdest = { 0, };
 
 	/* SDP fields */
-	char *version = 	"v=0\r\n";		/* Protocol version */
-	char subject[256];				/* Subject of the session */
-	char owner[256];				/* Session owner/creator */
-	char connection[256];				/* Connection data */
-	char *session_time = "t=0 0\r\n"; 			/* Time the session is active */
-	char bandwidth[256] = "";			/* Max bitrate */
+	char *version = "v=0\r\n";                      /* Protocol version */
+	char subject[256];                              /* Subject of the session */
+	char owner[256];                                /* Session owner/creator */
+	char connection[256];                           /* Connection data */
+	char *session_time = "t=0 0\r\n";               /* Time the session is active */
+	char bandwidth[256] = "";                       /* Max bitrate */
 	char *hold;
 	struct ast_str *m_audio = ast_str_alloca(256);  /* Media declaration line for audio */
 	struct ast_str *m_video = ast_str_alloca(256);  /* Media declaration line for video */
@@ -9046,11 +9047,12 @@
 
 	/* Set RTP Session ID and version */
 	if (!p->sessionid) {
-		p->sessionid = (int)ast_random();
+		p->sessionid = (int) ast_random();
 		p->sessionversion = p->sessionid;
 	} else {
-		if (oldsdp == FALSE)
+		if (oldsdp == FALSE) {
 			p->sessionversion++;
+		}
 	}
 
 	capability = p->jointcapability;
@@ -9068,23 +9070,26 @@
 #endif
 
 	/* Check if we need audio */
-	if (capability & AST_FORMAT_AUDIO_MASK)
+	if (capability & AST_FORMAT_AUDIO_MASK) {
 		needaudio = TRUE;
+	}
 
 	/* Check if we need video in this call */
 	if ((capability & AST_FORMAT_VIDEO_MASK) && !p->novideo) {
 		if (p->vrtp) {
 			needvideo = TRUE;
 			ast_debug(2, "This call needs video offers!\n");
-		} else
+		} else {
 			ast_debug(2, "This call needs video offers, but there's no video support enabled!\n");
+		}
 	}
 
 	/* Get our media addresses */
 	get_our_media_address(p, needvideo, &sin, &vsin, &tsin, &dest, &vdest);
 		
-	if (debug) 
-		ast_verbose("Audio is at %s port %d\n", ast_inet_ntoa(p->ourip.sin_addr), ntohs(sin.sin_port));	
+	if (debug) {
+		ast_verbose("Audio is at %s port %d\n", ast_inet_ntoa(p->ourip.sin_addr), ntohs(sin.sin_port));
+	}
 
 	/* Ok, we need video. Let's add what we need for video and set codecs.
 	   Video is handled differently than audio since we can not transcode. */
@@ -9092,30 +9097,36 @@
 		ast_str_append(&m_video, 0, "m=video %d RTP/AVP", ntohs(vdest.sin_port));
 
 		/* Build max bitrate string */
-		if (p->maxcallbitrate)
+		if (p->maxcallbitrate) {
 			snprintf(bandwidth, sizeof(bandwidth), "b=CT:%d\r\n", p->maxcallbitrate);
-		if (debug) 
-			ast_verbose("Video is at %s port %d\n", ast_inet_ntoa(p->ourip.sin_addr), ntohs(vsin.sin_port));	
+		}
+		if (debug) {
+			ast_verbose("Video is at %s port %d\n", ast_inet_ntoa(p->ourip.sin_addr), ntohs(vsin.sin_port));
+		}
 	}
 
 	/* Check if we need text in this call */
 	if((capability & AST_FORMAT_TEXT_MASK) && !p->notext) {
-		if (sipdebug_text)
+		if (sipdebug_text) {
 			ast_verbose("We think we can do text\n");
+		}
 		if (p->trtp) {
-			if (sipdebug_text)
+			if (sipdebug_text) {
 				ast_verbose("And we have a text rtp object\n");
+			}
 			needtext = TRUE;
 			ast_debug(2, "This call needs text offers! \n");
-		} else
+		} else {
 			ast_debug(2, "This call needs text offers, but there's no text support enabled ! \n");
+		}
 	}
 		
 	/* Ok, we need text. Let's add what we need for text and set codecs.
 	   Text is handled differently than audio since we can not transcode. */
 	if (needtext) {
-		if (sipdebug_text)
+		if (sipdebug_text) {
 			ast_verbose("Lets set up the text sdp\n");
+		}
 		/* Determine text destination */
 		if (p->tredirip.sin_addr.s_addr) {
 			tdest.sin_addr = p->tredirip.sin_addr;
@@ -9126,9 +9137,9 @@
 		}
 		ast_str_append(&m_text, 0, "m=text %d RTP/AVP", ntohs(tdest.sin_port));
 
-		if (debug) /* XXX should I use tdest below ? */
+		if (debug) { /* XXX should I use tdest below ? */
 			ast_verbose("Text is at %s port %d\n", ast_inet_ntoa(p->ourip.sin_addr), ntohs(tsin.sin_port));	
-
+		}
 	}
 
 	/* Start building generic SDP headers */
@@ -9140,12 +9151,13 @@
 	snprintf(connection, sizeof(connection), "c=IN IP4 %s\r\n", ast_inet_ntoa(dest.sin_addr));
 	ast_str_append(&m_audio, 0, "m=audio %d RTP/AVP", ntohs(dest.sin_port));
 
-	if (ast_test_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD) == SIP_PAGE2_CALL_ONHOLD_ONEDIR)
+	if (ast_test_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD) == SIP_PAGE2_CALL_ONHOLD_ONEDIR) {
 		hold = "a=recvonly\r\n";
-	else if (ast_test_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD) == SIP_PAGE2_CALL_ONHOLD_INACTIVE)
+	} else if (ast_test_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD) == SIP_PAGE2_CALL_ONHOLD_INACTIVE) {
 		hold = "a=inactive\r\n";
-	else
+	} else {
 		hold = "a=sendrecv\r\n";
+	}
 
 	/* Now, start adding audio codecs. These are added in this order:
 		- First what was requested by the calling channel
@@ -9169,14 +9181,15 @@
 	for (x = 0; x < 32; x++) {
 		int codec;
 
-		if (!(codec = ast_codec_pref_index(&p->prefs, x)))
-			break; 
-
-		if (!(capability & codec))
+		if (!(codec = ast_codec_pref_index(&p->prefs, x))) {
+			break;
+		}
+		if (!(capability & codec)) {
 			continue;
-
-		if (alreadysent & codec)
+		}
+		if (alreadysent & codec) {
 			continue;
+		}
 
 		add_codec_to_sdp(p, codec, SDP_SAMPLE_RATE(codec),
 				 &m_audio, &a_audio,
@@ -9186,67 +9199,85 @@
 
 	/* Now send any other common audio and video codecs, and non-codec formats: */
 	for (x = 1; x <= (needtext ? AST_FORMAT_TEXT_MASK : (needvideo ? AST_FORMAT_VIDEO_MASK : AST_FORMAT_AUDIO_MASK)); x <<= 1) {
-		if (!(capability & x))	/* Codec not requested */
+		if (!(capability & x)) {  /* Codec not requested */
 			continue;
-
-		if (alreadysent & x)	/* Already added to SDP */
+		}
+
+		if (alreadysent & x) {    /* Already added to SDP */
 			continue;
-
-		if (x & AST_FORMAT_AUDIO_MASK)
+		}
+
+		if (x & AST_FORMAT_AUDIO_MASK) {
 			add_codec_to_sdp(p, x, SDP_SAMPLE_RATE(x),
 				 &m_audio, &a_audio, debug, &min_audio_packet_size);
-		else if (x & AST_FORMAT_VIDEO_MASK) 
+		} else if (x & AST_FORMAT_VIDEO_MASK) {
 			add_vcodec_to_sdp(p, x, 90000,
 				 &m_video, &a_video, debug, &min_video_packet_size);
-		else if (x & AST_FORMAT_TEXT_MASK)
+		} else if (x & AST_FORMAT_TEXT_MASK) {
 			add_tcodec_to_sdp(p, x, 1000,
 				 &m_text, &a_text, debug, &min_text_packet_size);
+		}
 	}
 
 	/* Now add DTMF RFC2833 telephony-event as a codec */
 	for (x = 1; x <= AST_RTP_MAX; x <<= 1) {
-		if (!(p->jointnoncodeccapability & x))
+		if (!(p->jointnoncodeccapability & x)) {
 			continue;
+		}
 
 		add_noncodec_to_sdp(p, x, 8000, &m_audio, &a_audio, debug);
 	}
 
 	ast_debug(3, "-- Done with adding codecs to SDP\n");
 
-	if (!p->owner || !ast_internal_timing_enabled(p->owner))
+	if (!p->owner || !ast_internal_timing_enabled(p->owner)) {
 		ast_str_append(&a_audio, 0, "a=silenceSupp:off - - - -\r\n");
-
-	if (min_audio_packet_size)
+	}
+
+	if (min_audio_packet_size) {
 		ast_str_append(&a_audio, 0, "a=ptime:%d\r\n", min_audio_packet_size);
+	}
 
  	/* XXX don't think you can have ptime for video */
-	if (min_video_packet_size)
+	if (min_video_packet_size) {
 		ast_str_append(&a_video, 0, "a=ptime:%d\r\n", min_video_packet_size);
+	}
 
  	/* XXX don't think you can have ptime for text */
- 	if (min_text_packet_size)
+ 	if (min_text_packet_size) {
  		ast_str_append(&a_text, 0, "a=ptime:%d\r\n", min_text_packet_size);
+	}
  
-	if (m_audio->len - m_audio->used < 2 || m_video->len - m_video->used < 2 ||
-			m_text->len - m_text->used < 2 || a_text->len - a_text->used < 2 ||
-			a_audio->len - a_audio->used < 2 || a_video->len - a_video->used < 2)
+	if (	ast_str_size(m_audio) - ast_str_strlen(m_audio) < 2 ||
+			ast_str_size(m_video) - ast_str_strlen(m_video) < 2 ||
+			ast_str_size(m_text) - ast_str_strlen(m_text) < 2 ||
+			ast_str_size(a_text) - ast_str_strlen(a_text) < 2 ||
+			ast_str_size(a_audio) - ast_str_strlen(a_audio) < 2 ||
+			ast_str_size(a_video) - ast_str_strlen(a_video) < 2) {
 		ast_log(LOG_WARNING, "SIP SDP may be truncated due to undersized buffer!!\n");
-
-	if (needaudio)
+	}
+
+	if (needaudio) {
  		ast_str_append(&m_audio, 0, "\r\n");
- 	if (needvideo)
+	}
+ 	if (needvideo) {
  		ast_str_append(&m_video, 0, "\r\n");
- 	if (needtext)
+	}
+ 	if (needtext) {
  		ast_str_append(&m_text, 0, "\r\n");
+	}
 
  	len = strlen(version) + strlen(subject) + strlen(owner) +
 		strlen(connection) + strlen(session_time);
-	if (needaudio)
-		len += m_audio->used + a_audio->used + strlen(hold);
- 	if (needvideo) /* only if video response is appropriate */
- 		len += m_video->used + a_video->used + strlen(bandwidth) + strlen(hold);
- 	if (needtext) /* only if text response is appropriate */
- 		len += m_text->used + a_text->used + strlen(hold);
+	if (needaudio) {
+		len += ast_str_strlen(m_audio) + ast_str_strlen(a_audio) + strlen(hold);
+	}
+ 	if (needvideo) { /* only if video response is appropriate */
+ 		len += ast_str_strlen(m_video) + ast_str_strlen(a_video) + strlen(bandwidth) + strlen(hold);
+	}
+ 	if (needtext) { /* only if text response is appropriate */
+ 		len += ast_str_strlen(m_text) + ast_str_strlen(a_text) + strlen(hold);
+	}
 
 	add_header(resp, "Content-Type", "application/sdp");
 	add_header_contentLength(resp, len);
@@ -9254,22 +9285,23 @@
 	add_line(resp, owner);
 	add_line(resp, subject);
 	add_line(resp, connection);
-	if (needvideo)	 	/* only if video response is appropriate */
+	if (needvideo) {	 	/* only if video response is appropriate */
 		add_line(resp, bandwidth);
+	}
 	add_line(resp, session_time);
 	if (needaudio) {
-		add_line(resp, m_audio->str);
-		add_line(resp, a_audio->str);
+		add_line(resp, ast_str_buffer(m_audio));
+		add_line(resp, ast_str_buffer(a_audio));
 		add_line(resp, hold);
 	}
 	if (needvideo) { /* only if video response is appropriate */
-		add_line(resp, m_video->str);
-		add_line(resp, a_video->str);
+		add_line(resp, ast_str_buffer(m_video));
+		add_line(resp, ast_str_buffer(a_video));
 		add_line(resp, hold);	/* Repeat hold for the video stream */
 	}
 	if (needtext) { /* only if text response is appropriate */
-		add_line(resp, m_text->str);
-		add_line(resp, a_text->str);
+		add_line(resp, ast_str_buffer(m_text));
+		add_line(resp, ast_str_buffer(a_text));
 		add_line(resp, hold);	/* Repeat hold for the text stream */
 	}
 
@@ -9319,14 +9351,13 @@
 	 * the place and so a memcpy is the only way to accurately copy the string
 	 */
 
-	if (!dst->data && !(dst->data = ast_str_create(src->data->used + 1)))
+	if (!dst->data && !(dst->data = ast_str_create(ast_str_strlen(src->data) + 1)))
 		return;
-	else if (dst->data->len < src->data->used + 1)
-		ast_str_make_space(&dst->data, src->data->used + 1);
-		
-	memcpy(dst->data->str, src->data->str, src->data->used + 1);
-	dst->data->used = src->data->used;
-	offset = ((void *)dst->data->str) - ((void *)src->data->str);
+	else if (ast_str_size(dst->data) < ast_str_strlen(src->data) + 1)
+		ast_str_make_space(&dst->data, ast_str_strlen(src->data) + 1);
+
+	ast_str_set(&dst->data, 0, "%s", ast_str_buffer(src->data));
+	offset = ((void *)ast_str_buffer(dst->data)) - ((void *)ast_str_buffer(src->data));
 	/* Now fix pointer arithmetic */
 	for (x = 0; x < src->headers; x++)
 		dst->header[x] += offset;
@@ -9675,7 +9706,7 @@
  	/* This is the request URI, which is the next hop of the call
  		which may or may not be the destination of the call
  	*/
-	ast_string_field_set(p, uri, invite->str);
+	ast_string_field_set(p, uri, ast_str_buffer(invite));
   
  	if (!ast_strlen_zero(p->todnid)) {
  		/*! \todo Need to add back the VXML URL here at some point, possibly use build_string for all this junk */
@@ -9958,8 +9989,8 @@
 /*! \brief Used in the SUBSCRIBE notification subsystem (RFC3265) */
 static int transmit_state_notify(struct sip_pvt *p, int state, int full, int timeout)
 {
-	struct ast_str *tmp = ast_str_alloca(4000);
-	char from[256], to[256];
+	struct ast_str *tmp = ast_str_thread_get(&transmit_state_buffer, 4000);
+	char from[256] = "", to[256] = "";
 	char *c, *mfrom, *mto;
 	struct sip_request req;
 	char hint[AST_MAX_EXTENSION];
@@ -9969,9 +10000,6 @@
 	char *pidfstate = "--";
 	char *pidfnote= "Ready";
 	
-	memset(from, 0, sizeof(from));
-	memset(to, 0, sizeof(to));
-
 	switch (state) {
 	case (AST_EXTENSION_RINGING | AST_EXTENSION_INUSE):
 		statestring = (global_notifyringing) ? "early" : "confirmed";
@@ -10161,8 +10189,8 @@
 		break;
 	}
 
-	add_header_contentLength(&req, tmp->used);
-	add_line(&req, tmp->str);
+	add_header_contentLength(&req, ast_str_strlen(tmp));
+	add_line(&req, ast_str_buffer(tmp));
 
 	p->pendinginvite = p->ocseq;	/* Remember that we have a pending NOTIFY in order not to confuse the NOTIFY subsystem */
 
@@ -10200,8 +10228,8 @@
 			add_header(&req, "Subscription-State", "terminated;reason=timeout");
 	}
 
-	add_header_contentLength(&req, out->used);
-	add_line(&req, out->str);
+	add_header_contentLength(&req, ast_str_strlen(out));
+	add_line(&req, ast_str_buffer(out));
 
 	if (!p->initreq.headers) 
 		initialize_initreq(p, &req);
@@ -11457,7 +11485,7 @@
 	if (res == AST_DYNSTR_BUILD_FAILED)
 		return AUTH_SECRET_FAILED; /*! XXX \todo need a better return code here */
 
-	c = buf->str;
+	c = ast_str_buffer(buf);
 
 	while(c && *(c = ast_skip_blanks(c)) ) { /* lookup for keys */
 		for (i = keys; i->key != NULL; i++) {
@@ -13948,7 +13976,7 @@
 }
 
 /*! \brief list peer mailboxes to CLI */
-static void peer_mailboxes_to_str(struct ast_str **mailbox_str, struct sip_peer *peer)
+static char *peer_mailboxes_to_str(struct ast_str **mailbox_str, struct sip_peer *peer)
 {
 	struct sip_mailbox *mailbox;
 
@@ -13959,6 +13987,7 @@
 			S_OR(mailbox->context, ""),
 			AST_LIST_NEXT(mailbox, entry) ? "," : "");
 	}
+	return ast_str_buffer(*mailbox_str);
 }
 
 /*! \brief Show one peer in detail (main function) */
@@ -13995,7 +14024,7 @@
 		}
 	}
 	if (peer && type==0 ) { /* Normal listing */
-		struct ast_str *mailbox_str = ast_str_alloca(512);
+		struct ast_str *mailbox_str = ast_str_thread_get(&mailbox_buffer, 16);
 		ast_cli(fd, "\n\n");
 		ast_cli(fd, "  * Name       : %s\n", peer->name);
 		if (realtimepeers) {	/* Realtime is enabled */
@@ -14024,8 +14053,7 @@
 		print_group(fd, peer->callgroup, 0);
 		ast_cli(fd, "  Pickupgroup  : ");
 		print_group(fd, peer->pickupgroup, 0);
-		peer_mailboxes_to_str(&mailbox_str, peer);
-		ast_cli(fd, "  Mailbox      : %s\n", mailbox_str->str);
+		ast_cli(fd, "  Mailbox      : %s\n", peer_mailboxes_to_str(&mailbox_str, peer));
 		ast_cli(fd, "  VM Extension : %s\n", peer->vmexten);
 		ast_cli(fd, "  LastMsgsSent : %d/%d\n", (peer->lastmsgssent & 0x7fff0000) >> 16, peer->lastmsgssent & 0xffff);
 		ast_cli(fd, "  Call limit   : %d\n", peer->call_limit);
@@ -14111,7 +14139,7 @@
 		peer = unref_peer(peer, "sip_show_peer: unref_peer: done with peer ptr");
 	} else  if (peer && type == 1) { /* manager listing */
 		char buffer[256];
-		struct ast_str *mailbox_str = ast_str_alloca(512);
+		struct ast_str *mailbox_str = ast_str_thread_get(&mailbox_buffer, 16);
 		astman_append(s, "Channeltype: SIP\r\n");
 		astman_append(s, "ObjectName: %s\r\n", peer->name);
 		astman_append(s, "ChanObjectType: peer\r\n");
@@ -14132,8 +14160,7 @@
 		astman_append(s, "%s\r\n", ast_print_group(buffer, sizeof(buffer), peer->callgroup));
 		astman_append(s, "Pickupgroup: ");
 		astman_append(s, "%s\r\n", ast_print_group(buffer, sizeof(buffer), peer->pickupgroup));
-		peer_mailboxes_to_str(&mailbox_str, peer);
-		astman_append(s, "VoiceMailbox: %s\r\n", mailbox_str->str);
+		astman_append(s, "VoiceMailbox: %s\r\n", peer_mailboxes_to_str(&mailbox_str, peer));
 		astman_append(s, "TransferMode: %s\r\n", transfermode2str(peer->allowtransfer));
 		astman_append(s, "LastMsgsSent: %d\r\n", peer->lastmsgssent);
 		astman_append(s, "Call-limit: %d\r\n", peer->call_limit);
@@ -14700,7 +14727,7 @@
 		arg->numchans++;
 	}
 	if (cur->subscribed != NONE && arg->subscriptions) {
-		struct ast_str *mailbox_str = ast_str_alloca(512);
+		struct ast_str *mailbox_str = ast_str_thread_get(&mailbox_buffer, 16);
 		if (cur->subscribed == MWI_NOTIFICATION && cur->relatedpeer)
 			peer_mailboxes_to_str(&mailbox_str, cur->relatedpeer);
 		ast_cli(arg->fd, FORMAT4, ast_inet_ntoa(dst->sin_addr),
@@ -14710,7 +14737,7 @@
 				cur->subscribed == MWI_NOTIFICATION ? "--" : cur->subscribeuri,
 				cur->subscribed == MWI_NOTIFICATION ? "<none>" : ast_extension_state2str(cur->laststate), 
 				subscription_type2str(cur->subscribed),
-				cur->subscribed == MWI_NOTIFICATION ? S_OR(mailbox_str->str, "<none>") : "<none>",
+				cur->subscribed == MWI_NOTIFICATION ? AS_OR(mailbox_str, "<none>") : "<none>",
 				cur->expiry
 			);
 		arg->numchans++;
@@ -15796,9 +15823,8 @@
 	} else  if (!strcasecmp(colname, "useragent")) {
 		ast_copy_string(buf, peer->useragent, len);
 	} else  if (!strcasecmp(colname, "mailbox")) {
-		struct ast_str *mailbox_str = ast_str_alloca(512);
-		peer_mailboxes_to_str(&mailbox_str, peer);
-		ast_copy_string(buf, mailbox_str->str, len);
+		struct ast_str *mailbox_str = ast_str_thread_get(&mailbox_buffer, 16);
+		ast_copy_string(buf, peer_mailboxes_to_str(&mailbox_str, peer), len);
 	} else  if (!strcasecmp(colname, "context")) {
 		ast_copy_string(buf, peer->context, len);
 	} else  if (!strcasecmp(colname, "expire")) {
@@ -18097,12 +18123,12 @@
 
 	ast_str_set(&str, 0, "%s@%s", extension, context);
 
-	ast_debug(2, "About to call Pickup(%s)\n", str->str);
+	ast_debug(2, "About to call Pickup(%s)\n", ast_str_buffer(str));
 

[... 1617 lines stripped ...]



More information about the asterisk-commits mailing list