[asterisk-commits] jamesgolovich: branch jamesgolovich/chan_sip-ast_str r100728 - /team/jamesgol...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Jan 28 17:49:12 CST 2008
Author: jamesgolovich
Date: Mon Jan 28 17:49:11 2008
New Revision: 100728
URL: http://svn.digium.com/view/asterisk?view=rev&rev=100728
Log:
Change size of memory allocated to 1024 since typical SIP packets are
smaller than this and we will grow the size of the ast_str if needed
Modified:
team/jamesgolovich/chan_sip-ast_str/channels/chan_sip.c
Modified: team/jamesgolovich/chan_sip-ast_str/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/jamesgolovich/chan_sip-ast_str/channels/chan_sip.c?view=diff&rev=100728&r1=100727&r2=100728
==============================================================================
--- team/jamesgolovich/chan_sip-ast_str/channels/chan_sip.c (original)
+++ team/jamesgolovich/chan_sip-ast_str/channels/chan_sip.c Mon Jan 28 17:49:11 2008
@@ -237,6 +237,7 @@
#define SIP_MAX_HEADERS 64 /*!< Max amount of SIP headers to read */
#define SIP_MAX_LINES 64 /*!< Max amount of lines in SIP attachment (like SDP) */
#define SIP_MAX_PACKET 4096 /*!< Also from RFC 3261 (2543), should sub headers tho */
+#define SIP_MIN_PACKET 1024 /*!< Initialize size of memory to allocate for packets */
#define INITIAL_CSEQ 101 /*!< our initial sip sequence number */
@@ -2165,11 +2166,14 @@
goto cleanup;
ast_mutex_init(req.socket.lock);
- if (!(req.data = ast_str_create(SIP_MAX_PACKET)))
+ if (!(req.data = ast_str_create(SIP_MIN_PACKET)))
+ goto cleanup;
+ if (!(reqcpy.data = ast_str_create(SIP_MIN_PACKET)))
goto cleanup;
for (;;) {
ast_str_reset(req.data);
+ ast_str_reset(reqcpy.data);
req.len = 0;
req.ignore = 0;
@@ -7053,7 +7057,7 @@
/* Initialize a response */
memset(resp, 0, sizeof(*resp));
resp->method = SIP_RESPONSE;
- if (!(resp->data = ast_str_create(SIP_MAX_PACKET)))
+ 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);
@@ -7067,7 +7071,7 @@
{
/* Initialize a request */
memset(req, 0, sizeof(*req));
- if (!(req->data = ast_str_create(SIP_MAX_PACKET)))
+ if (!(req->data = ast_str_create(SIP_MIN_PACKET)))
return -1;
req->method = sipmethod;
req->header[0] = req->data->str;
@@ -17809,7 +17813,7 @@
return 1;
}
readbuf[res] = '\0';
- if (!(req.data = ast_str_create(SIP_MAX_PACKET)))
+ if (!(req.data = ast_str_create(SIP_MIN_PACKET)))
return 1;
ast_str_set(&req.data, 0, "%s", readbuf);
if (res == sizeof(req.data)) {
More information about the asterisk-commits
mailing list