From bf364b7c7deabe95dea0cf62180cdbf36c7c2031 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Tue, 22 Nov 2005 23:51:50 +0000 Subject: More optimizations for msg parser etc. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@77 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/src/test-pjsip/msg.c | 16 +++++++++++----- pjsip/src/test-pjsip/test.c | 4 ++-- 2 files changed, 13 insertions(+), 7 deletions(-) (limited to 'pjsip/src/test-pjsip') diff --git a/pjsip/src/test-pjsip/msg.c b/pjsip/src/test-pjsip/msg.c index bfa253bd..1f6affdd 100644 --- a/pjsip/src/test-pjsip/msg.c +++ b/pjsip/src/test-pjsip/msg.c @@ -34,7 +34,7 @@ static pjsip_msg *create_msg1(pj_pool_t *pool); #define FLAG_PARSE_ONLY 4 #define FLAG_PRINT_ONLY 8 -static int flag = FLAG_PARSE_ONLY; +static int flag = 0; struct test_msg { @@ -105,6 +105,7 @@ static pj_timestamp detect_time, parse_time, print_time; static pj_status_t test_entry( pj_pool_t *pool, struct test_msg *entry ) { pjsip_msg *parsed_msg, *ref_msg; + static pjsip_msg *print_msg; pj_status_t status = PJ_SUCCESS; int len; pj_str_t str1, str2; @@ -114,15 +115,18 @@ static pj_status_t test_entry( pj_pool_t *pool, struct test_msg *entry ) pj_size_t msg_size; char msgbuf1[PJSIP_MAX_PKT_LEN]; char msgbuf2[PJSIP_MAX_PKT_LEN]; - enum { BUFLEN = 512 }; entry->len = pj_native_strlen(entry->msg); if (flag & FLAG_PARSE_ONLY) goto parse_msg; - if (flag & FLAG_PRINT_ONLY) + + if (flag & FLAG_PRINT_ONLY) { + if (print_msg == NULL) + print_msg = entry->creator(pool); goto print_msg; + } /* Detect message. */ detect_len = detect_len + entry->len; @@ -144,7 +148,7 @@ static pj_status_t test_entry( pj_pool_t *pool, struct test_msg *entry ) pj_sub_timestamp(&t2, &t1); pj_add_timestamp(&detect_time, &t2); - if (flag & FLAG_PARSE_ONLY) + if (flag & FLAG_DETECT_ONLY) return PJ_SUCCESS; /* Parse message. */ @@ -302,7 +306,9 @@ parse_msg: print_msg: print_len = print_len + entry->len; pj_get_timestamp(&t1); - len = pjsip_msg_print(parsed_msg, msgbuf1, PJSIP_MAX_PKT_LEN); + if (flag && FLAG_PRINT_ONLY) + ref_msg = print_msg; + len = pjsip_msg_print(ref_msg, msgbuf1, PJSIP_MAX_PKT_LEN); if (len < 1) { status = -150; goto on_return; diff --git a/pjsip/src/test-pjsip/test.c b/pjsip/src/test-pjsip/test.c index d598dd5d..b940ffa1 100644 --- a/pjsip/src/test-pjsip/test.c +++ b/pjsip/src/test-pjsip/test.c @@ -81,8 +81,8 @@ int test_main(void) PJ_LOG(3,("","")); - //DO_TEST(uri_test()); - DO_TEST(msg_test()); + DO_TEST(uri_test()); + //DO_TEST(msg_test()); on_return: -- cgit v1.2.3