sip_parser.c:pj_cis_match:
  151|  20.0k|{
  152|  20.0k|    return PJ_CIS_ISSET(cis, c);
  ------------------
  |  |   90|  20.0k|#define PJ_CIS_ISSET(cis,c) ((cis)->cis_buf[(int)c] & (1 << (cis)->cis_id))
  ------------------
  153|  20.0k|}
sip_parser.c:pj_scan_is_eof:
  253|   222k|{
  254|   222k|    return scanner->curptr >= scanner->end;
  255|   222k|}
sip_parser.c:pj_scan_get_col:
  541|  39.1k|{
  542|  39.1k|    return (int)(scanner->curptr - scanner->start_line);
  543|  39.1k|}
scanner.c:pj_scan_is_eof:
  253|   610k|{
  254|   610k|    return scanner->curptr >= scanner->end;
  255|   610k|}
scanner.c:pj_cis_match:
  151|  4.63M|{
  152|  4.63M|    return PJ_CIS_ISSET(cis, c);
  ------------------
  |  |   90|  4.63M|#define PJ_CIS_ISSET(cis,c) ((cis)->cis_buf[(int)c] & (1 << (cis)->cis_id))
  ------------------
  153|  4.63M|}
string.c:pj_cis_match:
  151|  14.5k|{
  152|  14.5k|    return PJ_CIS_ISSET(cis, c);
  ------------------
  |  |   90|  14.5k|#define PJ_CIS_ISSET(cis,c) ((cis)->cis_buf[(int)c] & (1 << (cis)->cis_id))
  ------------------
  153|  14.5k|}

pj_cis_add_range:
   51|     36|{
   52|       |    /* Can not set zero. This is the requirement of the parser. */
   53|     36|    pj_assert(cstart > 0);
  ------------------
  |  |   65|     36|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (53:5): [True: 0, False: 36]
  |  Branch (53:5): [True: 36, False: 0]
  ------------------
   54|       |
   55|    780|    while (cstart != cend) {
  ------------------
  |  Branch (55:12): [True: 744, False: 36]
  ------------------
   56|    744|        PJ_CIS_SET(cis, cstart);
  ------------------
  |  |   72|    744|#define PJ_CIS_SET(cis,c)   ((cis)->cis_buf[(int)(c)] |= (1 << (cis)->cis_id))
  ------------------
   57|    744|        ++cstart;
   58|    744|    }
   59|     36|}
pj_cis_add_alpha:
   62|     12|{
   63|     12|    pj_cis_add_range( cis, 'a', 'z'+1);
   64|     12|    pj_cis_add_range( cis, 'A', 'Z'+1);
   65|     12|}
pj_cis_add_num:
   68|     12|{
   69|     12|    pj_cis_add_range( cis, '0', '9'+1);
   70|     12|}
pj_cis_add_str:
   73|     46|{
   74|    580|    while (*str) {
  ------------------
  |  Branch (74:12): [True: 534, False: 46]
  ------------------
   75|    534|        PJ_CIS_SET(cis, *str);
  ------------------
  |  |   72|    534|#define PJ_CIS_SET(cis,c)   ((cis)->cis_buf[(int)(c)] |= (1 << (cis)->cis_id))
  ------------------
   76|    534|        ++str;
   77|    534|    }
   78|     46|}
pj_cis_add_cis:
   81|      2|{
   82|      2|    int i;
   83|    514|    for (i=0; i<256; ++i) {
  ------------------
  |  Branch (83:15): [True: 512, False: 2]
  ------------------
   84|    512|        if (PJ_CIS_ISSET(rhs, i))
  ------------------
  |  |   90|    512|#define PJ_CIS_ISSET(cis,c) ((cis)->cis_buf[(int)c] & (1 << (cis)->cis_id))
  |  |  ------------------
  |  |  |  Branch (90:29): [True: 158, False: 354]
  |  |  ------------------
  ------------------
   85|    158|            PJ_CIS_SET(cis, i);
  ------------------
  |  |   72|    158|#define PJ_CIS_SET(cis,c)   ((cis)->cis_buf[(int)(c)] |= (1 << (cis)->cis_id))
  ------------------
   86|    512|    }
   87|      2|}
pj_cis_del_str:
   98|     12|{
   99|     24|    while (*str) {
  ------------------
  |  Branch (99:12): [True: 12, False: 12]
  ------------------
  100|     12|        PJ_CIS_CLR(cis, *str);
  ------------------
  |  |   81|     12|#define PJ_CIS_CLR(cis,c)   ((cis)->cis_buf[(int)c] &= ~(1 << (cis)->cis_id))
  ------------------
  101|     12|        ++str;
  102|     12|    }
  103|     12|}
pj_cis_invert:
  106|      8|{
  107|      8|    unsigned i;
  108|       |    /* Can not set zero. This is the requirement of the parser. */
  109|  2.04k|    for (i=1; i<256; ++i) {
  ------------------
  |  Branch (109:15): [True: 2.04k, False: 8]
  ------------------
  110|  2.04k|        if (PJ_CIS_ISSET(cis,i))
  ------------------
  |  |   90|  2.04k|#define PJ_CIS_ISSET(cis,c) ((cis)->cis_buf[(int)c] & (1 << (cis)->cis_id))
  |  |  ------------------
  |  |  |  Branch (90:29): [True: 26, False: 2.01k]
  |  |  ------------------
  ------------------
  111|     26|            PJ_CIS_CLR(cis,i);
  ------------------
  |  |   81|     26|#define PJ_CIS_CLR(cis,c)   ((cis)->cis_buf[(int)c] &= ~(1 << (cis)->cis_id))
  ------------------
  112|  2.01k|        else
  113|  2.01k|            PJ_CIS_SET(cis,i);
  ------------------
  |  |   72|  2.01k|#define PJ_CIS_SET(cis,c)   ((cis)->cis_buf[(int)(c)] |= (1 << (cis)->cis_id))
  ------------------
  114|  2.04k|    }
  115|      8|}
pj_scan_init:
  120|  17.0k|{
  121|  17.0k|    PJ_CHECK_STACK();
  122|       |
  123|  17.0k|    scanner->begin = scanner->curptr = bufstart;
  124|  17.0k|    scanner->end = bufstart + buflen;
  125|  17.0k|    scanner->line = 1;
  126|  17.0k|    scanner->start_line = scanner->begin;
  127|  17.0k|    scanner->callback = callback;
  128|  17.0k|    scanner->skip_ws = options;
  129|       |
  130|  17.0k|    if (scanner->skip_ws) 
  ------------------
  |  Branch (130:9): [True: 11.0k, False: 6.06k]
  ------------------
  131|  11.0k|        pj_scan_skip_whitespace(scanner);
  132|  17.0k|}
pj_scan_fini:
  136|  11.8k|{
  137|  11.8k|    PJ_CHECK_STACK();
  138|  11.8k|    PJ_UNUSED_ARG(scanner);
  ------------------
  |  | 1537|  11.8k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  139|  11.8k|}
pj_scan_skip_whitespace:
  142|   131k|{
  143|   131k|    register char *s = scanner->curptr;
  144|       |
  145|   157k|    while (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_SPACE(*s)) {
  ------------------
  |  |   33|   315k|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 156k, False: 838]
  |  |  ------------------
  ------------------
                  while (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_SPACE(*s)) {
  ------------------
  |  |   30|   156k|#define PJ_SCAN_IS_SPACE(c)             ((c)==' ' || (c)=='\t')
  |  |  ------------------
  |  |  |  Branch (30:42): [True: 22.4k, False: 134k]
  |  |  |  Branch (30:54): [True: 3.88k, False: 130k]
  |  |  ------------------
  ------------------
  146|  26.3k|        ++s;
  147|  26.3k|    }
  148|       |
  149|   131k|    if (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_NEWLINE(*s) &&
  ------------------
  |  |   33|   262k|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 130k, False: 838]
  |  |  ------------------
  ------------------
                  if (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_NEWLINE(*s) &&
  ------------------
  |  |   31|   261k|#define PJ_SCAN_IS_NEWLINE(c)           ((c)=='\r' || (c)=='\n')
  |  |  ------------------
  |  |  |  Branch (31:42): [True: 12.4k, False: 118k]
  |  |  |  Branch (31:55): [True: 29.7k, False: 88.3k]
  |  |  ------------------
  ------------------
  150|  42.1k|        (scanner->skip_ws & PJ_SCAN_AUTOSKIP_NEWLINE))
  ------------------
  |  Branch (150:9): [True: 0, False: 42.1k]
  ------------------
  151|      0|    {
  152|      0|        for (; PJ_SCAN_CHECK_EOF(s); ) {
  ------------------
  |  |   33|      0|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  153|      0|            if (*s == '\r') {
  ------------------
  |  Branch (153:17): [True: 0, False: 0]
  ------------------
  154|      0|                ++s;
  155|      0|                if (!PJ_SCAN_CHECK_EOF(s)) break;
  ------------------
  |  |   33|      0|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  ------------------
  |  Branch (155:21): [True: 0, False: 0]
  ------------------
  156|      0|                if (*s == '\n') ++s;
  ------------------
  |  Branch (156:21): [True: 0, False: 0]
  ------------------
  157|      0|                ++scanner->line;
  158|      0|                scanner->curptr = scanner->start_line = s;
  159|      0|            } else if (*s == '\n') {
  ------------------
  |  Branch (159:24): [True: 0, False: 0]
  ------------------
  160|      0|                ++s;
  161|      0|                ++scanner->line;
  162|      0|                scanner->curptr = scanner->start_line = s;
  163|      0|            } else if (PJ_SCAN_IS_SPACE(*s)) {
  ------------------
  |  |   30|      0|#define PJ_SCAN_IS_SPACE(c)             ((c)==' ' || (c)=='\t')
  |  |  ------------------
  |  |  |  Branch (30:42): [True: 0, False: 0]
  |  |  |  Branch (30:54): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  164|      0|                do {
  165|      0|                    ++s;
  166|      0|                } while (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_SPACE(*s));
  ------------------
  |  |   33|      0|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 0, False: 0]
  |  |  ------------------
  ------------------
                              } while (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_SPACE(*s));
  ------------------
  |  |   30|      0|#define PJ_SCAN_IS_SPACE(c)             ((c)==' ' || (c)=='\t')
  |  |  ------------------
  |  |  |  Branch (30:42): [True: 0, False: 0]
  |  |  |  Branch (30:54): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  167|      0|            } else {
  168|      0|                break;
  169|      0|            }
  170|      0|        }
  171|      0|    }
  172|       |
  173|   131k|    if (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_NEWLINE(*s) &&
  ------------------
  |  |   33|   262k|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 130k, False: 838]
  |  |  ------------------
  ------------------
                  if (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_NEWLINE(*s) &&
  ------------------
  |  |   31|   261k|#define PJ_SCAN_IS_NEWLINE(c)           ((c)=='\r' || (c)=='\n')
  |  |  ------------------
  |  |  |  Branch (31:42): [True: 12.4k, False: 118k]
  |  |  |  Branch (31:55): [True: 29.7k, False: 88.3k]
  |  |  ------------------
  ------------------
  174|  42.1k|        (scanner->skip_ws & PJ_SCAN_AUTOSKIP_WS_HEADER)==
  ------------------
  |  Branch (174:9): [True: 41.3k, False: 835]
  ------------------
  175|  42.1k|         PJ_SCAN_AUTOSKIP_WS_HEADER)
  176|  41.3k|    {
  177|       |        /* Check for header continuation. */
  178|  41.3k|        scanner->curptr = s;
  179|       |
  180|  41.3k|        if (*s == '\r') {
  ------------------
  |  Branch (180:13): [True: 12.1k, False: 29.1k]
  ------------------
  181|  12.1k|            ++s;
  182|  12.1k|        }
  183|  41.3k|        if (PJ_SCAN_CHECK_EOF(s) && *s == '\n') {
  ------------------
  |  |   33|  82.6k|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 41.2k, False: 24]
  |  |  ------------------
  ------------------
  |  Branch (183:37): [True: 29.2k, False: 12.0k]
  ------------------
  184|  29.2k|            ++s;
  185|  29.2k|        }
  186|  41.3k|        scanner->start_line = s;
  187|       |
  188|  41.3k|        if (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_SPACE(*s)) {
  ------------------
  |  |   33|  82.6k|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 38.0k, False: 3.26k]
  |  |  ------------------
  ------------------
                      if (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_SPACE(*s)) {
  ------------------
  |  |   30|  38.0k|#define PJ_SCAN_IS_SPACE(c)             ((c)==' ' || (c)=='\t')
  |  |  ------------------
  |  |  |  Branch (30:42): [True: 996, False: 37.0k]
  |  |  |  Branch (30:54): [True: 636, False: 36.4k]
  |  |  ------------------
  ------------------
  189|  1.63k|            register char *t = s;
  190|  3.29k|            do {
  191|  3.29k|                ++t;
  192|  3.29k|            } while (PJ_SCAN_CHECK_EOF(t) && PJ_SCAN_IS_SPACE(*t));
  ------------------
  |  |   33|  6.58k|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 3.26k, False: 25]
  |  |  ------------------
  ------------------
                          } while (PJ_SCAN_CHECK_EOF(t) && PJ_SCAN_IS_SPACE(*t));
  ------------------
  |  |   30|  3.26k|#define PJ_SCAN_IS_SPACE(c)             ((c)==' ' || (c)=='\t')
  |  |  ------------------
  |  |  |  Branch (30:42): [True: 1.35k, False: 1.90k]
  |  |  |  Branch (30:54): [True: 302, False: 1.60k]
  |  |  ------------------
  ------------------
  193|       |
  194|  1.63k|            ++scanner->line;
  195|  1.63k|            scanner->curptr = t;
  196|  1.63k|        }
  197|  90.0k|    } else {
  198|  90.0k|        scanner->curptr = s;
  199|  90.0k|    }
  200|   131k|}
pj_scan_skip_line:
  203|  43.6k|{
  204|  43.6k|    char *s;
  205|       |
  206|  43.6k|    if (pj_scan_is_eof(scanner)) {
  ------------------
  |  Branch (206:9): [True: 0, False: 43.6k]
  ------------------
  207|      0|        return;
  208|      0|    }
  209|       |
  210|  43.6k|    s = pj_memchr(scanner->curptr, '\n', scanner->end - scanner->curptr);
  211|  43.6k|    if (!s) {
  ------------------
  |  Branch (211:9): [True: 866, False: 42.8k]
  ------------------
  212|    866|        scanner->curptr = scanner->end;
  213|  42.8k|    } else {
  214|  42.8k|        scanner->curptr = scanner->start_line = s+1;
  215|  42.8k|        scanner->line++;
  216|  42.8k|   }
  217|  43.6k|}
pj_scan_peek:
  221|  53.7k|{
  222|  53.7k|    register char *s = scanner->curptr;
  223|       |
  224|  53.7k|    if (s >= scanner->end) {
  ------------------
  |  Branch (224:9): [True: 206, False: 53.5k]
  ------------------
  225|    206|        pj_scan_syntax_err(scanner);
  226|    206|        return -1;
  227|    206|    }
  228|       |
  229|  2.00M|    while (PJ_SCAN_CHECK_EOF(s) && pj_cis_match(spec, *s))
  ------------------
  |  |   33|  4.00M|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 1.99M, False: 6.31k]
  |  |  ------------------
  ------------------
  |  Branch (229:36): [True: 1.95M, False: 47.2k]
  ------------------
  230|  1.95M|        ++s;
  231|       |
  232|  53.5k|    pj_strset3(out, scanner->curptr, s);
  233|  53.5k|    return *s;
  234|  53.7k|}
pj_scan_get:
  273|   248k|{
  274|   248k|    register char *s = scanner->curptr;
  275|       |
  276|   248k|    pj_assert(pj_cis_match(spec,0)==0);
  ------------------
  |  |   65|   248k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (276:5): [True: 0, False: 248k]
  |  Branch (276:5): [True: 248k, False: 0]
  ------------------
  277|       |
  278|   248k|    if (pj_scan_is_eof(scanner) || !pj_cis_match(spec, *s)) {
  ------------------
  |  Branch (278:9): [True: 840, False: 247k]
  |  Branch (278:36): [True: 19.9k, False: 227k]
  ------------------
  279|  20.8k|        pj_scan_syntax_err(scanner);
  280|  20.8k|        return;
  281|  20.8k|    }
  282|       |
  283|  2.13M|    do {
  284|  2.13M|        ++s;
  285|  2.13M|    } while (PJ_SCAN_CHECK_EOF(s) && pj_cis_match(spec, *s));
  ------------------
  |  |   33|  4.27M|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 2.13M, False: 2.69k]
  |  |  ------------------
  ------------------
  |  Branch (285:38): [True: 1.91M, False: 225k]
  ------------------
  286|       |
  287|   227k|    pj_strset3(out, scanner->curptr, s);
  288|       |
  289|   227k|    scanner->curptr = s;
  290|       |
  291|   227k|    if (!pj_scan_is_eof(scanner) &&
  ------------------
  |  Branch (291:9): [True: 225k, False: 2.69k]
  ------------------
  292|   225k|        PJ_SCAN_IS_PROBABLY_SPACE(*s) && scanner->skip_ws)
  ------------------
  |  |   32|   452k|#define PJ_SCAN_IS_PROBABLY_SPACE(c)    ((c) <= 32)
  |  |  ------------------
  |  |  |  Branch (32:41): [True: 53.7k, False: 171k]
  |  |  ------------------
  ------------------
  |  Branch (292:42): [True: 48.4k, False: 5.26k]
  ------------------
  293|  48.4k|    {
  294|  48.4k|        pj_scan_skip_whitespace(scanner);    
  295|  48.4k|    }
  296|   227k|}
pj_scan_get_quote:
  358|  2.92k|{
  359|  2.92k|    char beg = (char)begin_quote;
  360|  2.92k|    char end = (char)end_quote;
  361|  2.92k|    pj_scan_get_quotes(scanner, &beg, &end, 1, out);
  362|  2.92k|}
pj_scan_get_quotes:
  367|  2.92k|{
  368|  2.92k|    register char *s = scanner->curptr;
  369|  2.92k|    int qpair = -1;
  370|  2.92k|    int i;
  371|       |
  372|  2.92k|    pj_assert(qsize > 0);
  ------------------
  |  |   65|  2.92k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (372:5): [True: 0, False: 2.92k]
  |  Branch (372:5): [True: 2.92k, False: 0]
  ------------------
  373|       |
  374|       |    /* Check and eat the begin_quote. */
  375|  2.92k|    for (i = 0; i < qsize; ++i) {
  ------------------
  |  Branch (375:17): [True: 2.92k, False: 0]
  ------------------
  376|  2.92k|        if (*s == begin_quote[i]) {
  ------------------
  |  Branch (376:13): [True: 2.92k, False: 0]
  ------------------
  377|  2.92k|            qpair = i;
  378|  2.92k|            break;
  379|  2.92k|        }
  380|  2.92k|    }
  381|  2.92k|    if (qpair == -1) {
  ------------------
  |  Branch (381:9): [True: 0, False: 2.92k]
  ------------------
  382|      0|        pj_scan_syntax_err(scanner);
  383|      0|        return;
  384|      0|    }
  385|  2.92k|    ++s;
  386|       |
  387|       |    /* Loop until end_quote is found. 
  388|       |     */
  389|  3.16k|    do {
  390|       |        /* loop until end_quote is found. */
  391|   130k|        while (PJ_SCAN_CHECK_EOF(s) && *s != '\n' && *s != end_quote[qpair]) {
  ------------------
  |  |   33|   260k|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 130k, False: 72]
  |  |  ------------------
  ------------------
  |  Branch (391:40): [True: 129k, False: 229]
  |  Branch (391:54): [True: 126k, False: 2.86k]
  ------------------
  392|   126k|            ++s;
  393|   126k|        }
  394|       |
  395|       |        /* check that no backslash character precedes the end_quote. */
  396|  3.16k|        if (*s == end_quote[qpair]) {
  ------------------
  |  Branch (396:13): [True: 2.86k, False: 301]
  ------------------
  397|  2.86k|            if (*(s-1) == '\\') {
  ------------------
  |  Branch (397:17): [True: 445, False: 2.41k]
  ------------------
  398|    445|                char *q = s-2;
  399|    445|                char *r = s-2;
  400|       |
  401|  1.78k|                while (r != scanner->begin && *r == '\\') {
  ------------------
  |  Branch (401:24): [True: 1.76k, False: 14]
  |  Branch (401:47): [True: 1.33k, False: 431]
  ------------------
  402|  1.33k|                    --r;
  403|  1.33k|                }
  404|       |                /* break from main loop if we have odd number of backslashes */
  405|    445|                if (((unsigned)(q-r) & 0x01) == 1) {
  ------------------
  |  Branch (405:21): [True: 207, False: 238]
  ------------------
  406|    207|                    break;
  407|    207|                }
  408|    238|                ++s;
  409|  2.41k|            } else {
  410|       |                /* end_quote is not preceeded by backslash. break now. */
  411|  2.41k|                break;
  412|  2.41k|            }
  413|  2.86k|        } else {
  414|       |            /* loop ended by non-end_quote character. break now. */
  415|    301|            break;
  416|    301|        }
  417|  3.16k|    } while (1);
  ------------------
  |  Branch (417:14): [True: 238, Folded]
  ------------------
  418|       |
  419|       |    /* Check and eat the end quote. */
  420|  2.92k|    if (*s != end_quote[qpair]) {
  ------------------
  |  Branch (420:9): [True: 301, False: 2.62k]
  ------------------
  421|    301|        pj_scan_syntax_err(scanner);
  422|    301|        return;
  423|    301|    }
  424|  2.62k|    ++s;
  425|       |
  426|  2.62k|    pj_strset3(out, scanner->curptr, s);
  427|       |
  428|  2.62k|    scanner->curptr = s;
  429|       |
  430|  2.62k|    if (!pj_scan_is_eof(scanner) &&
  ------------------
  |  Branch (430:9): [True: 2.59k, False: 30]
  ------------------
  431|  2.59k|        PJ_SCAN_IS_PROBABLY_SPACE(*s) && scanner->skip_ws)
  ------------------
  |  |   32|  5.22k|#define PJ_SCAN_IS_PROBABLY_SPACE(c)    ((c) <= 32)
  |  |  ------------------
  |  |  |  Branch (32:41): [True: 440, False: 2.15k]
  |  |  ------------------
  ------------------
  |  Branch (431:42): [True: 231, False: 209]
  ------------------
  432|    231|    {
  433|    231|        pj_scan_skip_whitespace(scanner);
  434|    231|    }
  435|  2.62k|}
pj_scan_get_n:
  440|  11.1k|{
  441|  11.1k|    if (scanner->curptr + N > scanner->end) {
  ------------------
  |  Branch (441:9): [True: 198, False: 10.9k]
  ------------------
  442|    198|        pj_scan_syntax_err(scanner);
  443|    198|        return;
  444|    198|    }
  445|       |
  446|  10.9k|    pj_strset(out, scanner->curptr, N);
  447|       |    
  448|  10.9k|    scanner->curptr += N;
  449|       |
  450|  10.9k|    if (!pj_scan_is_eof(scanner) &&
  ------------------
  |  Branch (450:9): [True: 10.6k, False: 274]
  ------------------
  451|  10.6k|        PJ_SCAN_IS_PROBABLY_SPACE(*scanner->curptr) && scanner->skip_ws)
  ------------------
  |  |   32|  21.5k|#define PJ_SCAN_IS_PROBABLY_SPACE(c)    ((c) <= 32)
  |  |  ------------------
  |  |  |  Branch (32:41): [True: 1.87k, False: 8.75k]
  |  |  ------------------
  ------------------
  |  Branch (451:56): [True: 1.87k, False: 0]
  ------------------
  452|  1.87k|    {
  453|  1.87k|        pj_scan_skip_whitespace(scanner);
  454|  1.87k|    }
  455|  10.9k|}
pj_scan_get_char:
  459|   216k|{
  460|   216k|    register char *s = scanner->curptr;
  461|   216k|    int chr;
  462|       |
  463|   216k|    if (s >= scanner->end || !*s) {
  ------------------
  |  Branch (463:9): [True: 340, False: 216k]
  |  Branch (463:30): [True: 2.03k, False: 214k]
  ------------------
  464|  2.37k|        pj_scan_syntax_err(scanner);
  465|  2.37k|        return 0;
  466|  2.37k|    }
  467|       |
  468|   214k|    chr = *s;
  469|       |
  470|   214k|    ++s;
  471|   214k|    scanner->curptr = s;
  472|   214k|    if (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_PROBABLY_SPACE(*s) &&
  ------------------
  |  |   33|   429k|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 212k, False: 2.06k]
  |  |  ------------------
  ------------------
                  if (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_PROBABLY_SPACE(*s) &&
  ------------------
  |  |   32|   426k|#define PJ_SCAN_IS_PROBABLY_SPACE(c)    ((c) <= 32)
  |  |  ------------------
  |  |  |  Branch (32:41): [True: 26.8k, False: 185k]
  |  |  ------------------
  ------------------
  473|  26.8k|        scanner->skip_ws)
  ------------------
  |  Branch (473:9): [True: 26.1k, False: 730]
  ------------------
  474|  26.1k|    {
  475|  26.1k|        pj_scan_skip_whitespace(scanner);
  476|  26.1k|    }
  477|   214k|    return chr;
  478|   216k|}
pj_scan_get_newline:
  482|  39.3k|{
  483|  39.3k|    if (pj_scan_is_eof(scanner) || !PJ_SCAN_IS_NEWLINE(*scanner->curptr)) {
  ------------------
  |  |   31|  39.3k|#define PJ_SCAN_IS_NEWLINE(c)           ((c)=='\r' || (c)=='\n')
  |  |  ------------------
  |  |  |  Branch (31:42): [True: 12.5k, False: 26.8k]
  |  |  |  Branch (31:55): [True: 21.7k, False: 5.06k]
  |  |  ------------------
  ------------------
  |  Branch (483:9): [True: 10, False: 39.3k]
  ------------------
  484|  5.07k|        pj_scan_syntax_err(scanner);
  485|  5.07k|        return;
  486|  5.07k|    }
  487|       |
  488|       |    /* We have checked scanner->curptr validity above */
  489|  34.2k|    if (*scanner->curptr == '\r') {
  ------------------
  |  Branch (489:9): [True: 12.5k, False: 21.7k]
  ------------------
  490|  12.5k|        ++scanner->curptr;
  491|  12.5k|    }
  492|  34.2k|    if (!pj_scan_is_eof(scanner) && *scanner->curptr == '\n') {
  ------------------
  |  Branch (492:9): [True: 34.2k, False: 24]
  |  Branch (492:37): [True: 21.8k, False: 12.4k]
  ------------------
  493|  21.8k|        ++scanner->curptr;
  494|  21.8k|    }
  495|       |
  496|  34.2k|    ++scanner->line;
  497|  34.2k|    scanner->start_line = scanner->curptr;
  498|       |
  499|       |    /**
  500|       |     * This probably is a bug, see PROTOS test #2480.
  501|       |     * This would cause scanner to incorrectly eat two new lines, e.g.
  502|       |     * when parsing:
  503|       |     *   
  504|       |     *  Content-Length: 120\r\n
  505|       |     *  \r\n
  506|       |     *  <space><space><space>...
  507|       |     *
  508|       |     * When pj_scan_get_newline() is called to parse the first newline
  509|       |     * in the Content-Length header, it will eat the second newline
  510|       |     * too because it thinks that it's a header continuation.
  511|       |     *
  512|       |     * if (PJ_SCAN_IS_PROBABLY_SPACE(*scanner->curptr) && scanner->skip_ws) {
  513|       |     *    pj_scan_skip_whitespace(scanner);
  514|       |     * }
  515|       |     */
  516|  34.2k|}
pj_scan_get_until_ch:
  547|  3.22k|{
  548|  3.22k|    register char *s = scanner->curptr;
  549|       |
  550|  3.22k|    if (s >= scanner->end) {
  ------------------
  |  Branch (550:9): [True: 4, False: 3.21k]
  ------------------
  551|      4|        pj_scan_syntax_err(scanner);
  552|      4|        return;
  553|      4|    }
  554|       |
  555|   207k|    while (PJ_SCAN_CHECK_EOF(s) && *s != until_char) {
  ------------------
  |  |   33|   414k|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 207k, False: 209]
  |  |  ------------------
  ------------------
  |  Branch (555:36): [True: 204k, False: 3.00k]
  ------------------
  556|   204k|        ++s;
  557|   204k|    }
  558|       |
  559|  3.21k|    pj_strset3(out, scanner->curptr, s);
  560|       |
  561|  3.21k|    scanner->curptr = s;
  562|       |
  563|  3.21k|    if (!pj_scan_is_eof(scanner) && PJ_SCAN_IS_PROBABLY_SPACE(*s) &&
  ------------------
  |  |   32|  6.22k|#define PJ_SCAN_IS_PROBABLY_SPACE(c)    ((c) <= 32)
  |  |  ------------------
  |  |  |  Branch (32:41): [True: 0, False: 3.00k]
  |  |  ------------------
  ------------------
  |  Branch (563:9): [True: 3.00k, False: 209]
  ------------------
  564|      0|        scanner->skip_ws)
  ------------------
  |  Branch (564:9): [True: 0, False: 0]
  ------------------
  565|      0|    {
  566|      0|        pj_scan_skip_whitespace(scanner);
  567|      0|    }
  568|  3.21k|}
scanner.c:pj_scan_syntax_err:
   45|  28.9k|{
   46|  28.9k|    (*scanner->callback)(scanner);
   47|  28.9k|}

pj_cis_buf_init:
   26|      4|{
   27|      4|    pj_bzero(cis_buf->cis_buf, sizeof(cis_buf->cis_buf));
   28|      4|    cis_buf->use_mask = 0;
   29|      4|}
pj_cis_init:
   32|     64|{
   33|     64|    unsigned i;
   34|       |
   35|     64|    cis->cis_buf = cis_buf->cis_buf;
   36|       |
   37|    616|    for (i=0; i<PJ_CIS_MAX_INDEX; ++i) {
  ------------------
  |  |   44|    616|#define PJ_CIS_MAX_INDEX   (sizeof(pj_cis_elem_t) << 3)
  ------------------
  |  Branch (37:15): [True: 616, False: 0]
  ------------------
   38|    616|        if ((cis_buf->use_mask & (1 << i)) == 0) {
  ------------------
  |  Branch (38:13): [True: 64, False: 552]
  ------------------
   39|     64|            cis->cis_id = i;
   40|     64|            cis_buf->use_mask |= (1 << i);
   41|     64|            return PJ_SUCCESS;
   42|     64|        }
   43|    616|    }
   44|       |
   45|      0|    cis->cis_id = PJ_CIS_MAX_INDEX;
  ------------------
  |  |   44|      0|#define PJ_CIS_MAX_INDEX   (sizeof(pj_cis_elem_t) << 3)
  ------------------
   46|      0|    return PJ_ETOOMANY;
  ------------------
  |  |  423|      0|#define PJ_ETOOMANY         (PJ_ERRNO_START_STATUS + 10)/* 70010 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   47|     64|}
pj_cis_dup:
   50|     36|{
   51|     36|    pj_status_t status;
   52|     36|    unsigned i;
   53|       |
   54|       |    /* Warning: typecasting here! */
   55|     36|    status = pj_cis_init((pj_cis_buf_t*)existing->cis_buf, new_cis);
   56|     36|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (56:9): [True: 0, False: 36]
  ------------------
   57|      0|        return status;
   58|       |
   59|  9.25k|    for (i=0; i<256; ++i) {
  ------------------
  |  Branch (59:15): [True: 9.21k, False: 36]
  ------------------
   60|  9.21k|        if (PJ_CIS_ISSET(existing, i))
  ------------------
  |  |   90|  9.21k|#define PJ_CIS_ISSET(cis,c) ((cis)->cis_buf[(int)c] & (1 << (cis)->cis_id))
  |  |  ------------------
  |  |  |  Branch (90:29): [True: 2.46k, False: 6.75k]
  |  |  ------------------
  ------------------
   61|  2.46k|            PJ_CIS_SET(new_cis, i);
  ------------------
  |  |   72|  2.46k|#define PJ_CIS_SET(cis,c)   ((cis)->cis_buf[(int)(c)] |= (1 << (cis)->cis_id))
  ------------------
   62|  6.75k|        else
   63|  6.75k|            PJ_CIS_CLR(new_cis, i);
  ------------------
  |  |   81|  6.75k|#define PJ_CIS_CLR(cis,c)   ((cis)->cis_buf[(int)c] &= ~(1 << (cis)->cis_id))
  ------------------
   64|  9.21k|    }
   65|       |
   66|     36|    return PJ_SUCCESS;
   67|     36|}

pj_str_unescape:
   25|  28.5k|{
   26|  28.5k|    char *src = src_str->ptr;
   27|  28.5k|    char *end = src + src_str->slen;
   28|  28.5k|    pj_str_t dst_str;
   29|  28.5k|    char *dst;
   30|       |    
   31|  28.5k|    if (pj_strchr(src_str, '%')==NULL)
  ------------------
  |  Branch (31:9): [True: 26.3k, False: 2.20k]
  ------------------
   32|  26.3k|        return *src_str;
   33|       |
   34|  2.20k|    dst = dst_str.ptr = (char*) pj_pool_alloc(pool, src_str->slen);
   35|       |
   36|   242k|    while (src != end) {
  ------------------
  |  Branch (36:12): [True: 240k, False: 2.20k]
  ------------------
   37|   240k|        if (*src == '%' && src < end-2 && pj_isxdigit(*(src+1)) && 
  ------------------
  |  Branch (37:13): [True: 57.4k, False: 183k]
  |  Branch (37:28): [True: 56.4k, False: 1.04k]
  |  Branch (37:43): [True: 11.4k, False: 44.9k]
  ------------------
   38|  11.4k|            pj_isxdigit(*(src+2))) 
  ------------------
  |  Branch (38:13): [True: 2.89k, False: 8.58k]
  ------------------
   39|  2.89k|        {
   40|  2.89k|            *dst = (pj_uint8_t) ((pj_hex_digit_to_val(*(src+1)) << 4) + 
   41|  2.89k|                                 pj_hex_digit_to_val(*(src+2)));
   42|  2.89k|            ++dst;
   43|  2.89k|            src += 3;
   44|   237k|        } else {
   45|   237k|            *dst++ = *src++;
   46|   237k|        }
   47|   240k|    }
   48|  2.20k|    dst_str.slen = dst - dst_str.ptr;
   49|  2.20k|    return dst_str;
   50|  28.5k|}
pj_strncpy2_escape:
   75|  2.17k|{
   76|  2.17k|    const char *src = src_str->ptr;
   77|  2.17k|    const char *src_end = src + src_str->slen;
   78|  2.17k|    char *dst = dst_str;
   79|  2.17k|    char *dst_end = dst + max;
   80|       |
   81|  2.17k|    if (max < src_str->slen)
  ------------------
  |  Branch (81:9): [True: 20, False: 2.15k]
  ------------------
   82|     20|        return -1;
   83|       |
   84|  16.7k|    while (src != src_end && dst != dst_end) {
  ------------------
  |  Branch (84:12): [True: 14.6k, False: 2.13k]
  |  Branch (84:30): [True: 14.5k, False: 8]
  ------------------
   85|  14.5k|        if (pj_cis_match(unres, *src)) {
  ------------------
  |  Branch (85:13): [True: 12.7k, False: 1.82k]
  ------------------
   86|  12.7k|            *dst++ = *src++;
   87|  12.7k|        } else {
   88|  1.82k|            if (dst < dst_end-2) {
  ------------------
  |  Branch (88:17): [True: 1.81k, False: 11]
  ------------------
   89|  1.81k|                *dst++ = '%';
   90|  1.81k|                pj_val_to_hex_digit(*src, dst);
   91|  1.81k|                dst+=2;
   92|  1.81k|                ++src;
   93|  1.81k|            } else {
   94|     11|                break;
   95|     11|            }
   96|  1.82k|        }
   97|  14.5k|    }
   98|       |
   99|  2.15k|    return src==src_end ? dst-dst_str : -1;
  ------------------
  |  Branch (99:12): [True: 2.13k, False: 19]
  ------------------
  100|  2.17k|}

sip_parser.c:pj_tolower:
  118|    430|PJ_INLINE(int) pj_tolower(unsigned char c) { return tolower(c); }
  ------------------
  |  Branch (118:53): [True: 0, False: 0]
  |  Branch (118:53): [True: 0, False: 0]
  |  Branch (118:53): [Folded, False: 430]
  ------------------
sip_multipart.c:pj_isspace:
   83|  58.4k|PJ_INLINE(int) pj_isspace(unsigned char c) { return isspace(c); }
string.c:pj_isxdigit:
  134|  67.9k|PJ_INLINE(int) pj_isxdigit(unsigned char c){ return isxdigit(c); }
string.c:pj_hex_digit_to_val:
  160|  5.79k|{
  161|  5.79k|    if (c <= '9')
  ------------------
  |  Branch (161:9): [True: 1.67k, False: 4.11k]
  ------------------
  162|  1.67k|        return (c-'0') & 0x0F;
  163|  4.11k|    else if (c <= 'F')
  ------------------
  |  Branch (163:14): [True: 3.22k, False: 892]
  ------------------
  164|  3.22k|        return  (c-'A'+10) & 0x0F;
  165|    892|    else
  166|    892|        return (c-'a'+10) & 0x0F;
  167|  5.79k|}
string.c:pj_val_to_hex_digit:
  149|  1.81k|{
  150|  1.81k|    *p++ = pj_hex_digits[ (value & 0xF0) >> 4 ];
  ------------------
  |  |  140|  1.81k|#define pj_hex_digits   "0123456789abcdef"
  ------------------
  151|  1.81k|    *p   = pj_hex_digits[ (value & 0x0F) ];
  ------------------
  |  |  140|  1.81k|#define pj_hex_digits   "0123456789abcdef"
  ------------------
  152|  1.81k|}
string.c:pj_isdigit:
   74|  11.5k|PJ_INLINE(int) pj_isdigit(unsigned char c) { return isdigit(c); }
string.c:pj_isspace:
   83|  24.8k|PJ_INLINE(int) pj_isspace(unsigned char c) { return isspace(c); }
hash.c:pj_tolower:
  118|   362k|PJ_INLINE(int) pj_tolower(unsigned char c) { return tolower(c); }
  ------------------
  |  Branch (118:53): [True: 0, False: 0]
  |  Branch (118:53): [True: 0, False: 0]
  |  Branch (118:53): [Folded, False: 362k]
  ------------------

fuzz-sip-dialog.c:pj_list_init:
   88|  5.42k|{
   89|  5.42k|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|  5.42k|}
fuzz-sip-dialog.c:pj_list_push_back:
  125|     27|{
  126|     27|    pj_list_insert_before(list, node);
  127|     27|}
sip_msg.c:pj_list_init:
   88|   120k|{
   89|   120k|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|   120k|}
sip_parser.c:pj_list_push_back:
  125|  1.14k|{
  126|  1.14k|    pj_list_insert_before(list, node);
  127|  1.14k|}
sip_uri.c:pj_list_init:
   88|  33.8k|{
   89|  33.8k|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|  33.8k|}
sip_endpoint.c:pj_list_init:
   88|      8|{
   89|      8|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|      8|}
sip_transport.c:pj_list_init:
   88|    489|{
   89|    489|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|    489|}
sip_transport.c:pj_list_empty:
  102|     44|{
  103|     44|    return ((pj_list*)node)->next == node;
  104|     44|}
sip_transport.c:pj_list_push_back:
  125|     74|{
  126|     74|    pj_list_insert_before(list, node);
  127|     74|}
sip_transport_loop.c:pj_list_empty:
  102|  4.33k|{
  103|  4.33k|    return ((pj_list*)node)->next == node;
  104|  4.33k|}
sip_transport_loop.c:pj_list_init:
   88|      8|{
   89|      8|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|      8|}
sip_dialog.c:pj_list_push_back:
  125|    220|{
  126|    220|    pj_list_insert_before(list, node);
  127|    220|}
sip_dialog.c:pj_list_init:
   88|  18.7k|{
   89|  18.7k|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|  18.7k|}
sip_dialog.c:pj_list_empty:
  102|     97|{
  103|     97|    return ((pj_list*)node)->next == node;
  104|     97|}
sip_ua_layer.c:pj_list_push_back:
  125|    898|{
  126|    898|    pj_list_insert_before(list, node);
  127|    898|}
sip_ua_layer.c:pj_list_init:
   88|    451|{
   89|    451|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|    451|}
sip_ua_layer.c:pj_list_empty:
  102|    898|{
  103|    898|    return ((pj_list*)node)->next == node;
  104|    898|}
sip_multipart.c:pj_list_init:
   88|  11.5k|{
   89|  11.5k|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|  11.5k|}
sip_multipart.c:pj_list_push_back:
  125|  11.5k|{
  126|  11.5k|    pj_list_insert_before(list, node);
  127|  11.5k|}
sip_tel_uri.c:pj_list_init:
   88|  1.43k|{
   89|  1.43k|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|  1.43k|}
sip_util.c:pj_list_push_back:
  125|    566|{
  126|    566|    pj_list_insert_before(list, node);
  127|    566|}
sip_auth_client.c:pj_list_init:
   88|  6.16k|{
   89|  6.16k|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|  6.16k|}
ioqueue_select.c:pj_list_init:
   88|      6|{
   89|      6|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|      6|}
ioqueue_select.c:pj_list_push_back:
  125|    128|{
  126|    128|    pj_list_insert_before(list, node);
  127|    128|}
list.c:pj_list_init:
   88|  47.7k|{
   89|  47.7k|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|  47.7k|}
lock.c:pj_list_init:
   88|  12.6k|{
   89|  12.6k|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|  12.6k|}
lock.c:pj_list_push_back:
  125|  12.6k|{
  126|  12.6k|    pj_list_insert_before(list, node);
  127|  12.6k|}
pool.c:pj_list_init:
   88|    111|{
   89|    111|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|    111|}
pool_caching.c:pj_list_init:
   88|     34|{
   89|     34|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|     34|}
pool_caching.c:pj_list_empty:
  102|  18.4k|{
  103|  18.4k|    return ((pj_list*)node)->next == node;
  104|  18.4k|}

pj_list_insert_after:
   29|   168k|{
   30|   168k|    ((pj_list*)node)->prev = pos;
   31|   168k|    ((pj_list*)node)->next = ((pj_list*)pos)->next;
   32|   168k|    ((pj_list*) ((pj_list*)pos)->next) ->prev = node;
   33|   168k|    ((pj_list*)pos)->next = node;
   34|   168k|}
pj_list_insert_before:
   38|   140k|{
   39|   140k|    pj_list_insert_after(((pj_list*)pos)->prev, node);
   40|   140k|}
pj_list_insert_nodes_after:
   44|  32.0k|{
   45|  32.0k|    pj_list *lst_last = (pj_list *) ((pj_list*)lst)->prev;
   46|  32.0k|    pj_list *pos_next = (pj_list *) ((pj_list*)pos)->next;
   47|       |
   48|  32.0k|    pj_link_node(pos, lst);
   49|  32.0k|    pj_link_node(lst_last, pos_next);
   50|  32.0k|}
pj_list_insert_nodes_before:
   53|  32.0k|{
   54|  32.0k|    pj_list_insert_nodes_after(((pj_list*)pos)->prev, lst);
   55|  32.0k|}
pj_list_erase:
   93|  47.7k|{
   94|  47.7k|    pj_link_node( ((pj_list*)node)->prev, ((pj_list*)node)->next);
   95|       |
   96|       |    /* It'll be safer to init the next/prev fields to itself, to
   97|       |     * prevent multiple erase() from corrupting the list. See
   98|       |     * ticket #520 for one sample bug.
   99|       |     */
  100|  47.7k|    pj_list_init(node);
  101|  47.7k|}
pj_list_find_node:
  105|     20|{
  106|     20|    pj_list *p = (pj_list *) ((pj_list*)list)->next;
  107|     60|    while (p != list && p != node)
  ------------------
  |  Branch (107:12): [True: 40, False: 20]
  |  Branch (107:25): [True: 40, False: 0]
  ------------------
  108|     40|        p = (pj_list *) p->next;
  109|       |
  110|     20|    return p==node ? p : NULL;
  ------------------
  |  Branch (110:12): [True: 0, False: 20]
  ------------------
  111|     20|}
pj_list_search:
  116|     20|{
  117|     20|    pj_list *p = (pj_list *) ((pj_list*)list)->next;
  118|     60|    while (p != list && (*comp)(value, p) != 0)
  ------------------
  |  Branch (118:12): [True: 40, False: 20]
  |  Branch (118:25): [True: 40, False: 0]
  ------------------
  119|     40|        p = (pj_list *) p->next;
  120|       |
  121|     20|    return p==list ? NULL : p;
  ------------------
  |  Branch (121:12): [True: 20, False: 0]
  ------------------
  122|     20|}
list.c:pj_link_node:
   23|   111k|{
   24|   111k|    ((pj_list*)prev)->next = next;
   25|   111k|    ((pj_list*)next)->prev = prev;
   26|   111k|}

os_timestamp_common.c:pj_set_timestamp32:
 1423|  8.94k|{
 1424|  8.94k|    t->u32.hi = hi;
 1425|  8.94k|    t->u32.lo = lo;
 1426|  8.94k|}

sip_uri.c:pj_pool_zalloc:
  552|  7.27k|{
  553|  7.27k|    return pj_pool_calloc(pool, 1, size);
  554|  7.27k|}
sip_endpoint.c:pj_pool_zalloc:
  552|      2|{
  553|      2|    return pj_pool_calloc(pool, 1, size);
  554|      2|}
sip_resolve.c:pj_pool_zalloc:
  552|      2|{
  553|      2|    return pj_pool_calloc(pool, 1, size);
  554|      2|}
sip_transport.c:pj_pool_zalloc:
  552|    485|{
  553|    485|    return pj_pool_calloc(pool, 1, size);
  554|    485|}
sip_transport_loop.c:pj_pool_zalloc:
  552|      2|{
  553|      2|    return pj_pool_calloc(pool, 1, size);
  554|      2|}
sip_transaction.c:pj_pool_zalloc:
  552|    281|{
  553|    281|    return pj_pool_calloc(pool, 1, size);
  554|    281|}
sip_dialog.c:pj_pool_zalloc:
  552|  5.99k|{
  553|  5.99k|    return pj_pool_calloc(pool, 1, size);
  554|  5.99k|}
sip_multipart.c:pj_pool_zalloc:
  552|  23.0k|{
  553|  23.0k|    return pj_pool_calloc(pool, 1, size);
  554|  23.0k|}
sip_tel_uri.c:pj_pool_zalloc:
  552|  1.43k|{
  553|  1.43k|    return pj_pool_calloc(pool, 1, size);
  554|  1.43k|}
sip_util.c:pj_pool_zalloc:
  552|    566|{
  553|    566|    return pj_pool_calloc(pool, 1, size);
  554|    566|}
os_core_unix.c:pj_pool_zalloc:
  552|  6.80k|{
  553|  6.80k|    return pj_pool_calloc(pool, 1, size);
  554|  6.80k|}
ioqueue_select.c:pj_pool_zalloc:
  552|      2|{
  553|      2|    return pj_pool_calloc(pool, 1, size);
  554|      2|}
lock.c:pj_pool_zalloc:
  552|  19.3k|{
  553|  19.3k|    return pj_pool_calloc(pool, 1, size);
  554|  19.3k|}
timer.c:pj_pool_zalloc:
  552|      2|{
  553|      2|    return pj_pool_calloc(pool, 1, size);
  554|      2|}

pj_pool_get_capacity:
   28|  72.7k|{
   29|  72.7k|    return pool->capacity;
   30|  72.7k|}
pj_pool_alloc_from_block:
   45|   381k|{
   46|   381k|    unsigned char *ptr;
   47|       |
   48|   381k|    pj_assert(PJ_IS_POWER_OF_TWO(alignment));
  ------------------
  |  |   65|   381k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (48:5): [True: 0, False: 381k]
  |  Branch (48:5): [True: 0, False: 0]
  |  Branch (48:5): [True: 381k, False: 0]
  |  Branch (48:5): [True: 381k, False: 0]
  ------------------
   49|       |    // Size should be already aligned.
   50|       |    // this code was moved up to pj_pool_aligned_alloc. 
   51|       |    // ...and then removed there
   52|       |    //
   53|       |    ///* The operation below is valid for size==0. 
   54|       |    // * When size==0, the function will return the pointer to the pool
   55|       |    // * memory address, but no memory will be allocated.
   56|       |    // */
   57|       |    //if (size & (alignment -1)) {
   58|       |    //    size = (size + alignment) & ~(alignment -1);
   59|       |    //}
   60|   381k|    ptr = PJ_POOL_ALIGN_PTR(block->cur, alignment);
  ------------------
  |  |   23|   381k|#define PJ_POOL_ALIGN_PTR(PTR,ALIGNMENT)    (PTR + (-(pj_ssize_t)(PTR) & (ALIGNMENT-1)))
  ------------------
   61|   381k|    if (block->cur <= ptr && /* check pointer overflow */
  ------------------
  |  Branch (61:9): [True: 381k, False: 0]
  ------------------
   62|   381k|        block->end - ptr >= (pj_ssize_t)size) /* check available size */
  ------------------
  |  Branch (62:9): [True: 345k, False: 36.2k]
  ------------------
   63|   345k|    {
   64|       |    //if (ptr + size <= block->end &&
   65|       |    //    /* here we check pointer overflow */
   66|       |    //    block->cur <= ptr && ptr <= ptr + size) {
   67|   345k|        block->cur = ptr + size;
   68|   345k|        return ptr;
   69|   345k|    }
   70|  36.2k|    return NULL;
   71|   381k|}
pj_pool_alloc:
   74|   345k|{
   75|   345k|    return pj_pool_aligned_alloc(pool, 0, size);
   76|   345k|}
pj_pool_aligned_alloc:
   80|   345k|{
   81|   345k|    void *ptr;
   82|       |
   83|   345k|    PJ_ASSERT_RETURN(!alignment || PJ_IS_POWER_OF_TWO(alignment), NULL);
  ------------------
  |  |   97|   345k|            do { \
  |  |   98|   345k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 0, False: 0]
  |  |  |  Branch (98:23): [True: 0, False: 0]
  |  |  |  Branch (98:23): [True: 345k, False: 0]
  |  |  ------------------
  |  |   99|   345k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 345k]
  |  |  ------------------
  ------------------
  |  Branch (83:5): [True: 0, False: 0]
  |  Branch (83:5): [True: 0, False: 0]
  |  Branch (83:5): [True: 0, False: 0]
  |  Branch (83:5): [True: 0, False: 0]
  |  Branch (83:5): [True: 0, False: 0]
  |  Branch (83:5): [True: 0, False: 0]
  ------------------
   84|       |
   85|   345k|    if (!alignment)
  ------------------
  |  Branch (85:9): [True: 345k, False: 0]
  ------------------
   86|   345k|        alignment = pool->alignment;
   87|       |
   88|       |#if 0
   89|       |    //Rounding up is the compiler's job, not the allocator's.
   90|       |
   91|       |    /* The operation below is valid for size==0. 
   92|       |     * When size==0, the function will return the pointer to the pool
   93|       |     * memory address, but no memory will be allocated.
   94|       |     */
   95|       |    if (size & (alignment -1)) {
   96|       |        size = (size + alignment) & ~(alignment -1);
   97|       |    }
   98|       |    pj_assert(PJ_IS_ALIGNED(size, alignment));
   99|       |#endif
  100|       |
  101|   345k|    ptr = pj_pool_alloc_from_block(pool->block_list.next, 
  102|   345k|                                   alignment, size);
  103|   345k|    if (!ptr)
  ------------------
  |  Branch (103:9): [True: 13.3k, False: 332k]
  ------------------
  104|  13.3k|        ptr = pj_pool_allocate_find(pool, alignment, size);
  105|   345k|    return ptr;
  106|   345k|}
pj_pool_calloc:
  110|  65.2k|{
  111|  65.2k|    void *buf = pj_pool_alloc( pool, size*count);
  112|  65.2k|    if (buf)
  ------------------
  |  Branch (112:9): [True: 65.2k, False: 0]
  ------------------
  113|  65.2k|        pj_bzero(buf, size * count);
  114|  65.2k|    return buf;
  115|  65.2k|}
pj_pool_create:
  127|  18.4k|{
  128|  18.4k|    return pj_pool_aligned_create(f, name, initial_size, increment_size, 0, callback);
  129|  18.4k|}
pj_pool_aligned_create:
  137|  18.4k|{
  138|  18.4k|    return (*f->create_pool)(f, name, initial_size, increment_size, alignment, callback);
  139|  18.4k|}
pj_pool_release:
  142|  18.4k|{
  143|       |#if PJ_POOL_RELEASE_WIPE_DATA
  144|       |    pj_pool_block *b;
  145|       |
  146|       |    b = pool->block_list.next;
  147|       |    while (b != &pool->block_list) {
  148|       |        volatile unsigned char *p = b->buf;
  149|       |        while (p < b->end) *p++ = 0;
  150|       |        b = b->next;
  151|       |    }
  152|       |#endif
  153|       |
  154|  18.4k|    if (pool->factory->release_pool)
  ------------------
  |  Branch (154:9): [True: 18.4k, False: 0]
  ------------------
  155|  18.4k|        (*pool->factory->release_pool)(pool->factory, pool);
  156|  18.4k|}

fuzz-sip-dialog.c:pj_bzero:
  820|  1.03k|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|  1.03k|    memset(dst, 0, size);
  825|  1.03k|#endif
  826|  1.03k|}
fuzz-sip-dialog.c:pj_memcpy:
  853|  21.3k|{
  854|  21.3k|    return memcpy(dst, src, size);
  855|  21.3k|}
sip_msg.c:pj_memcmp:
  881|  19.2k|{
  882|  19.2k|    return memcmp(buf1, buf2, size);
  883|  19.2k|}
sip_msg.c:pj_memcpy:
  853|    195|{
  854|    195|    return memcpy(dst, src, size);
  855|    195|}
sip_msg.c:pj_strset2:
  133|     80|{
  134|     80|    str->ptr = src;
  135|     80|    str->slen = src ? (pj_ssize_t)strlen(src) : 0;
  ------------------
  |  Branch (135:17): [True: 80, False: 0]
  ------------------
  136|     80|    return str;
  137|     80|}
sip_msg.c:pj_bzero:
  820|  54.5k|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|  54.5k|    memset(dst, 0, size);
  825|  54.5k|#endif
  826|  54.5k|}
sip_parser.c:pj_memcpy:
  853|  1.23k|{
  854|  1.23k|    return memcpy(dst, src, size);
  855|  1.23k|}
sip_parser.c:pj_memchr:
  896|  2.91k|{
  897|  2.91k|    return (void*)memchr((void*)buf, c, size);
  898|  2.91k|}
sip_parser.c:pj_bzero:
  820|  5.20k|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|  5.20k|    memset(dst, 0, size);
  825|  5.20k|#endif
  826|  5.20k|}
sip_parser.c:pj_memcmp:
  881|  56.5k|{
  882|  56.5k|    return memcmp(buf1, buf2, size);
  883|  56.5k|}
sip_parser.c:pj_memmove:
  867|    102|{
  868|    102|    return memmove(dst, src, size);
  869|    102|}
sip_uri.c:pj_memcpy:
  853|  3.15k|{
  854|  3.15k|    return memcpy(dst, src, size);
  855|  3.15k|}
sip_uri.c:pj_memchr:
  896|    869|{
  897|    869|    return (void*)memchr((void*)buf, c, size);
  898|    869|}
sip_uri.c:pj_bzero:
  820|  12.6k|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|  12.6k|    memset(dst, 0, size);
  825|  12.6k|#endif
  826|  12.6k|}
sip_endpoint.c:pj_cstr:
  101|      2|{
  102|      2|    str->ptr = (char*)s;
  103|      2|    str->slen = s ? (pj_ssize_t)strlen(s) : 0;
  ------------------
  |  Branch (103:17): [True: 2, False: 0]
  ------------------
  104|      2|    return str;
  105|      2|}
sip_transport.c:pj_memcpy:
  853|    491|{
  854|    491|    return memcpy(dst, src, size);
  855|    491|}
sip_transport.c:pj_bzero:
  820|      2|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|      2|    memset(dst, 0, size);
  825|      2|#endif
  826|      2|}
sip_transaction.c:pj_memcpy:
  853|  1.69k|{
  854|  1.69k|    return memcpy(dst, src, size);
  855|  1.69k|}
sip_dialog.c:pj_bzero:
  820|  5.28k|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|  5.28k|    memset(dst, 0, size);
  825|  5.28k|#endif
  826|  5.28k|}
sip_dialog.c:pj_memcpy:
  853|     59|{
  854|     59|    return memcpy(dst, src, size);
  855|     59|}
sip_multipart.c:pj_memcpy:
  853|    655|{
  854|    655|    return memcpy(dst, src, size);
  855|    655|}
sip_multipart.c:pj_strset:
  117|    651|{
  118|    651|    str->ptr = ptr;
  119|    651|    str->slen = (pj_ssize_t)length;
  120|    651|    return str;
  121|    651|}
sip_tel_uri.c:pj_memcpy:
  853|    118|{
  854|    118|    return memcpy(dst, src, size);
  855|    118|}
sip_util.c:pj_memcpy:
  853|    189|{
  854|    189|    return memcpy(dst, src, size);
  855|    189|}
sip_auth_client.c:pj_bzero:
  820|  5.99k|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|  5.99k|    memset(dst, 0, size);
  825|  5.99k|#endif
  826|  5.99k|}
scanner.c:pj_bzero:
  820|      4|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|      4|    memset(dst, 0, size);
  825|      4|#endif
  826|      4|}
scanner.c:pj_memchr:
  896|  43.6k|{
  897|  43.6k|    return (void*)memchr((void*)buf, c, size);
  898|  43.6k|}
scanner.c:pj_strset3:
  149|   287k|{
  150|   287k|    str->ptr = begin;
  151|   287k|    str->slen = (pj_ssize_t)(end-begin);
  152|   287k|    return str;
  153|   287k|}
scanner.c:pj_strset:
  117|  10.9k|{
  118|  10.9k|    str->ptr = ptr;
  119|  10.9k|    str->slen = (pj_ssize_t)length;
  120|  10.9k|    return str;
  121|  10.9k|}
string.c:pj_strchr:
  481|  28.5k|{
  482|  28.5k|    if (str->slen == 0)
  ------------------
  |  Branch (482:9): [True: 0, False: 28.5k]
  ------------------
  483|      0|        return NULL;
  484|  28.5k|    return (char*) memchr((char*)str->ptr, chr, str->slen);
  485|  28.5k|}
string.c:pj_memcpy:
  853|  38.5k|{
  854|  38.5k|    return memcpy(dst, src, size);
  855|  38.5k|}
string.c:pj_memcmp:
  881|  22.0k|{
  882|  22.0k|    return memcmp(buf1, buf2, size);
  883|  22.0k|}
os_core_unix.c:pj_bzero:
  820|      2|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|      2|    memset(dst, 0, size);
  825|      2|#endif
  826|      2|}
os_core_unix.c:pj_strlen:
  282|      2|{
  283|      2|    return str->slen;
  284|      2|}
ioqueue_select.c:pj_bzero:
  820|    451|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|    451|    memset(dst, 0, size);
  825|    451|#endif
  826|    451|}
hash.c:pj_memcmp:
  881|     42|{
  882|     42|    return memcmp(buf1, buf2, size);
  883|     42|}
hash.c:pj_memcpy:
  853|    562|{
  854|    562|    return memcpy(dst, src, size);
  855|    562|}
lock.c:pj_memcpy:
  853|  6.48k|{
  854|  6.48k|    return memcpy(dst, src, size);
  855|  6.48k|}
pool.c:pj_bzero:
  820|  65.3k|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|  65.3k|    memset(dst, 0, size);
  825|  65.3k|#endif
  826|  65.3k|}
pool_caching.c:pj_bzero:
  820|      2|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|      2|    memset(dst, 0, size);
  825|      2|#endif
  826|      2|}
pool_caching.c:pj_memcpy:
  853|      2|{
  854|      2|    return memcpy(dst, src, size);
  855|      2|}
timer.c:pj_bzero:
  820|    302|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|    302|    memset(dst, 0, size);
  825|    302|#endif
  826|    302|}
timer.c:pj_memcpy:
  853|    302|{
  854|    302|    return memcpy(dst, src, size);
  855|    302|}

pj_str:
   24|  23.9k|{
   25|  23.9k|    pj_str_t dst;
   26|  23.9k|    dst.ptr = str;
   27|  23.9k|    dst.slen = str ? pj_ansi_strlen(str) : 0;
  ------------------
  |  |   69|  23.9k|#define pj_ansi_strlen          strlen
  ------------------
  |  Branch (27:16): [True: 23.9k, False: 0]
  ------------------
   28|  23.9k|    return dst;
   29|  23.9k|}
pj_strdup:
   34|  60.2k|{
   35|  60.2k|    pj_assert(src->slen >= 0);
  ------------------
  |  |   65|  60.2k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (35:5): [True: 0, False: 60.2k]
  |  Branch (35:5): [True: 60.2k, False: 0]
  ------------------
   36|       |
   37|       |    /* Without this, destination will be corrupted */
   38|  60.2k|    if (dst == src)
  ------------------
  |  Branch (38:9): [True: 0, False: 60.2k]
  ------------------
   39|      0|        return dst;
   40|       |
   41|  60.2k|    if (src->slen > 0) {
  ------------------
  |  Branch (41:9): [True: 30.9k, False: 29.2k]
  ------------------
   42|  30.9k|        dst->ptr = (char*)pj_pool_alloc(pool, src->slen);
   43|  30.9k|        pj_memcpy(dst->ptr, src->ptr, src->slen);
   44|  30.9k|    }
   45|  60.2k|    dst->slen = (src->slen < 0)? 0: src->slen;
  ------------------
  |  Branch (45:17): [True: 0, False: 60.2k]
  ------------------
   46|  60.2k|    return dst;
   47|  60.2k|}
pj_strdup_with_null:
   52|  6.27k|{
   53|  6.27k|    pj_ssize_t src_slen = src->slen;
   54|       |
   55|  6.27k|    pj_assert(src->slen >= 0);
  ------------------
  |  |   65|  6.27k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (55:5): [True: 0, False: 6.27k]
  |  Branch (55:5): [True: 6.27k, False: 0]
  ------------------
   56|       |
   57|       |    /* Check if the source's length is invalid */
   58|  6.27k|    if (src_slen < 0)
  ------------------
  |  Branch (58:9): [True: 0, False: 6.27k]
  ------------------
   59|      0|        src_slen = 0;
   60|       |
   61|  6.27k|    dst->ptr = (char*)pj_pool_alloc(pool, src_slen+1);
   62|  6.27k|    if (src_slen) {
  ------------------
  |  Branch (62:9): [True: 6.27k, False: 0]
  ------------------
   63|  6.27k|        pj_memcpy(dst->ptr, src->ptr, src_slen);
   64|  6.27k|    }
   65|  6.27k|    dst->slen = src_slen;
   66|  6.27k|    dst->ptr[dst->slen] = '\0';
   67|  6.27k|    return dst;
   68|  6.27k|}
pj_strcpy:
  112|    445|{
  113|    445|    pj_assert(src->slen >= 0);
  ------------------
  |  |   65|    445|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (113:5): [True: 0, False: 445]
  |  Branch (113:5): [True: 445, False: 0]
  ------------------
  114|       |
  115|    445|    dst->slen = (src->slen < 0)? 0: src->slen;
  ------------------
  |  Branch (115:17): [True: 0, False: 445]
  ------------------
  116|    445|    if (src->slen > 0)
  ------------------
  |  Branch (116:9): [True: 445, False: 0]
  ------------------
  117|    445|        pj_memcpy(dst->ptr, src->ptr, src->slen);
  118|    445|    return dst;
  119|    445|}
pj_strcmp:
  162|    953|{
  163|    953|    pj_assert(str1->slen >= 0);
  ------------------
  |  |   65|    953|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (163:5): [True: 0, False: 953]
  |  Branch (163:5): [True: 953, False: 0]
  ------------------
  164|    953|    pj_assert(str2->slen >= 0);
  ------------------
  |  |   65|    953|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (164:5): [True: 0, False: 953]
  |  Branch (164:5): [True: 953, False: 0]
  ------------------
  165|       |
  166|    953|    if (str1->slen <= 0) {
  ------------------
  |  Branch (166:9): [True: 0, False: 953]
  ------------------
  167|      0|        return str2->slen<=0 ? 0 : -1;
  ------------------
  |  Branch (167:16): [True: 0, False: 0]
  ------------------
  168|    953|    } else if (str2->slen <= 0) {
  ------------------
  |  Branch (168:16): [True: 0, False: 953]
  ------------------
  169|      0|        return 1;
  170|    953|    } else {
  171|    953|        pj_size_t min = (str1->slen < str2->slen)? str1->slen : str2->slen;
  ------------------
  |  Branch (171:25): [True: 420, False: 533]
  ------------------
  172|    953|        int res = pj_memcmp(str1->ptr, str2->ptr, min);
  173|    953|        if (res == 0) {
  ------------------
  |  Branch (173:13): [True: 181, False: 772]
  ------------------
  174|    181|            return (str1->slen < str2->slen) ? -1 :
  ------------------
  |  Branch (174:20): [True: 3, False: 178]
  ------------------
  175|    181|                    (str1->slen == str2->slen ? 0 : 1);
  ------------------
  |  Branch (175:22): [True: 150, False: 28]
  ------------------
  176|    772|        } else {
  177|    772|            return res;
  178|    772|        }
  179|    953|    }
  180|    953|}
pj_stricmp:
  236|   124k|{
  237|   124k|    pj_assert(str1->slen >= 0);
  ------------------
  |  |   65|   124k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (237:5): [True: 0, False: 124k]
  |  Branch (237:5): [True: 124k, False: 0]
  ------------------
  238|   124k|    pj_assert(str2->slen >= 0);
  ------------------
  |  |   65|   124k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (238:5): [True: 0, False: 124k]
  |  Branch (238:5): [True: 124k, False: 0]
  ------------------
  239|       |
  240|   124k|    if (str1->slen <= 0) {
  ------------------
  |  Branch (240:9): [True: 199, False: 123k]
  ------------------
  241|    199|        return str2->slen<=0 ? 0 : -1;
  ------------------
  |  Branch (241:16): [True: 0, False: 199]
  ------------------
  242|   123k|    } else if (str2->slen <= 0) {
  ------------------
  |  Branch (242:16): [True: 0, False: 123k]
  ------------------
  243|      0|        return 1;
  244|   123k|    } else {
  245|   123k|        pj_size_t min = (str1->slen < str2->slen)? str1->slen : str2->slen;
  ------------------
  |  Branch (245:25): [True: 28.4k, False: 95.4k]
  ------------------
  246|   123k|        int res = pj_ansi_strnicmp(str1->ptr, str2->ptr, min);
  ------------------
  |  |   96|   123k|#define pj_ansi_strnicmp        strncasecmp
  ------------------
  247|   123k|        if (res == 0) {
  ------------------
  |  Branch (247:13): [True: 65.2k, False: 58.6k]
  ------------------
  248|  65.2k|            return (str1->slen < str2->slen) ? -1 :
  ------------------
  |  Branch (248:20): [True: 2.66k, False: 62.6k]
  ------------------
  249|  65.2k|                    (str1->slen == str2->slen ? 0 : 1);
  ------------------
  |  Branch (249:22): [True: 62.3k, False: 233]
  ------------------
  250|  65.2k|        } else {
  251|  58.6k|            return res;
  252|  58.6k|        }
  253|   123k|    }
  254|   124k|}
pj_stricmp2:
  328|  13.4k|{
  329|  13.4k|    pj_str_t copy2;
  330|       |
  331|  13.4k|    if (str2) {
  ------------------
  |  Branch (331:9): [True: 13.4k, False: 0]
  ------------------
  332|  13.4k|        copy2.ptr = (char*)str2;
  333|  13.4k|        copy2.slen = pj_ansi_strlen(str2);
  ------------------
  |  |   69|  13.4k|#define pj_ansi_strlen          strlen
  ------------------
  334|  13.4k|    } else {
  335|      0|        copy2.ptr = NULL;
  336|      0|        copy2.slen = 0;
  337|      0|    }
  338|       |
  339|  13.4k|    return pj_stricmp(str1, &copy2);
  340|  13.4k|}
pj_strnicmp:
  344|    281|{
  345|    281|    pj_str_t copy1, copy2;
  346|       |
  347|    281|    if (len < (unsigned)str1->slen && str1->slen > 0) {
  ------------------
  |  Branch (347:9): [True: 74, False: 207]
  |  Branch (347:39): [True: 74, False: 0]
  ------------------
  348|     74|        copy1.ptr = str1->ptr;
  349|     74|        copy1.slen = len;
  350|     74|        str1 = &copy1;
  351|     74|    }
  352|       |
  353|    281|    if (len < (unsigned)str2->slen && str2->slen > 0) {
  ------------------
  |  Branch (353:9): [True: 0, False: 281]
  |  Branch (353:39): [True: 0, False: 0]
  ------------------
  354|      0|        copy2.ptr = str2->ptr;
  355|      0|        copy2.slen = len;
  356|      0|        str2 = &copy2;
  357|      0|    }
  358|       |
  359|    281|    return pj_stricmp(str1, str2);
  360|    281|}
pj_strcat:
  378|    445|{
  379|    445|    pj_assert(src->slen >= 0);
  ------------------
  |  |   65|    445|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (379:5): [True: 0, False: 445]
  |  Branch (379:5): [True: 445, False: 0]
  ------------------
  380|    445|    pj_assert(dst->slen >= 0);
  ------------------
  |  |   65|    445|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (380:5): [True: 0, False: 445]
  |  Branch (380:5): [True: 445, False: 0]
  ------------------
  381|       |
  382|    445|    if (src->slen > 0 && dst->slen >= 0) {
  ------------------
  |  Branch (382:9): [True: 445, False: 0]
  |  Branch (382:26): [True: 445, False: 0]
  ------------------
  383|    445|        pj_memcpy(dst->ptr + dst->slen, src->ptr, src->slen);
  384|    445|        dst->slen += src->slen;
  385|    445|    }
  386|    445|}
pj_strcat2:
  389|    445|{
  390|    445|    pj_size_t len = str? pj_ansi_strlen(str) : 0;
  ------------------
  |  |   69|    445|#define pj_ansi_strlen          strlen
  ------------------
  |  Branch (390:21): [True: 445, False: 0]
  ------------------
  391|       |
  392|    445|    pj_assert(dst->slen >= 0);
  ------------------
  |  |   65|    445|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (392:5): [True: 0, False: 445]
  |  Branch (392:5): [True: 445, False: 0]
  ------------------
  393|       |
  394|    445|    if (len && dst->slen >= 0) {
  ------------------
  |  Branch (394:9): [True: 445, False: 0]
  |  Branch (394:16): [True: 445, False: 0]
  ------------------
  395|    445|        pj_memcpy(dst->ptr + dst->slen, str, len);
  396|    445|        dst->slen += len;
  397|    445|    }
  398|    445|}
pj_strtrim:
  401|  1.76k|{
  402|  1.76k|    pj_strltrim(str);
  403|  1.76k|    pj_strrtrim(str);
  404|  1.76k|    return str;
  405|  1.76k|}

pj_register_strerror:
  122|      2|{
  123|      2|    unsigned i;
  124|       |
  125|       |    /* Check arguments. */
  126|      2|    PJ_ASSERT_RETURN(start && space && f, PJ_EINVAL);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      8|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 2, False: 0]
  |  |  |  Branch (98:23): [True: 2, False: 0]
  |  |  |  Branch (98:23): [True: 2, False: 0]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (126:5): [True: 0, False: 0]
  |  Branch (126:5): [True: 0, False: 0]
  |  Branch (126:5): [True: 0, False: 0]
  |  Branch (126:5): [True: 0, False: 0]
  |  Branch (126:5): [True: 0, False: 0]
  |  Branch (126:5): [True: 0, False: 0]
  ------------------
  127|       |
  128|       |    /* Check if there aren't too many handlers registered. */
  129|      2|    PJ_ASSERT_RETURN(err_msg_hnd_cnt < PJ_ARRAY_SIZE(err_msg_hnd),
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (129:5): [True: 0, False: 0]
  |  Branch (129:5): [True: 0, False: 0]
  ------------------
  130|      2|                     PJ_ETOOMANY);
  131|       |
  132|       |    /* Start error must be greater than PJ_ERRNO_START_USER */
  133|      2|    PJ_ASSERT_RETURN(start >= PJ_ERRNO_START_USER, PJ_EEXISTS);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (133:5): [True: 0, False: 0]
  |  Branch (133:5): [True: 0, False: 0]
  ------------------
  134|       |
  135|       |    /* Check that no existing handler has covered the specified range. */
  136|      2|    for (i=0; i<err_msg_hnd_cnt; ++i) {
  ------------------
  |  Branch (136:15): [True: 0, False: 2]
  ------------------
  137|      0|        if (IN_RANGE(start, err_msg_hnd[i].begin, err_msg_hnd[i].end) ||
  ------------------
  |  |  116|      0|#define IN_RANGE(val,start,end)     ((val)>=(start) && (val)<(end))
  |  |  ------------------
  |  |  |  Branch (116:38): [True: 0, False: 0]
  |  |  |  Branch (116:56): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  138|      0|            IN_RANGE(start+space-1, err_msg_hnd[i].begin, err_msg_hnd[i].end))
  ------------------
  |  |  116|      0|#define IN_RANGE(val,start,end)     ((val)>=(start) && (val)<(end))
  |  |  ------------------
  |  |  |  Branch (116:38): [True: 0, False: 0]
  |  |  |  Branch (116:56): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  139|      0|        {
  140|      0|            if (err_msg_hnd[i].begin == start && 
  ------------------
  |  Branch (140:17): [True: 0, False: 0]
  ------------------
  141|      0|                err_msg_hnd[i].end == (start+space) &&
  ------------------
  |  Branch (141:17): [True: 0, False: 0]
  ------------------
  142|      0|                err_msg_hnd[i].strerror == f)
  ------------------
  |  Branch (142:17): [True: 0, False: 0]
  ------------------
  143|      0|            {
  144|       |                /* The same range and handler has already been registered */
  145|      0|                return PJ_SUCCESS;
  146|      0|            }
  147|       |
  148|      0|            return PJ_EEXISTS;
  ------------------
  |  |  448|      0|#define PJ_EEXISTS          (PJ_ERRNO_START_STATUS + 15)/* 70015 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  149|      0|        }
  150|      0|    }
  151|       |
  152|       |    /* Register the handler. */
  153|      2|    err_msg_hnd[err_msg_hnd_cnt].begin = start;
  154|      2|    err_msg_hnd[err_msg_hnd_cnt].end = start + space;
  155|      2|    err_msg_hnd[err_msg_hnd_cnt].strerror = f;
  156|       |
  157|      2|    ++err_msg_hnd_cnt;
  158|       |
  159|      2|    return PJ_SUCCESS;
  160|      2|}

pj_throw_exception_:
   41|  52.0k|{
   42|  52.0k|    struct pj_exception_state_t *handler;
   43|       |
   44|  52.0k|    handler = (struct pj_exception_state_t*) 
   45|  52.0k|              pj_thread_local_get(thread_local_id);
   46|  52.0k|    if (handler == NULL) {
  ------------------
  |  Branch (46:9): [True: 0, False: 52.0k]
  ------------------
   47|      0|        PJ_LOG(1,("except.c", "!!!FATAL: unhandled exception %s!\n", 
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  432|      0|    #define pj_log_wrapper_1(arg)       pj_log_1 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
   48|      0|                   pj_exception_id_name(exception_id)));
   49|      0|        pj_assert(handler != NULL);
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (49:9): [True: 0, False: 0]
  |  Branch (49:9): [True: 0, False: 0]
  ------------------
   50|       |        /* This will crash the system! */
   51|      0|    }
   52|  52.0k|    pj_pop_exception_handler_(handler);
   53|  52.0k|    pj_longjmp(handler->state, exception_id);
  ------------------
  |  |   34|  52.0k|#    define pj_longjmp(buf,d)   longjmp(buf,d)
  ------------------
   54|  52.0k|}
pj_push_exception_handler_:
   75|  57.7k|{
   76|  57.7k|    struct pj_exception_state_t *parent_handler = NULL;
   77|       |
   78|  57.7k|    if (thread_local_id == -1) {
  ------------------
  |  Branch (78:9): [True: 1, False: 57.7k]
  ------------------
   79|      1|        pj_thread_local_alloc(&thread_local_id);
   80|      1|        pj_assert(thread_local_id != -1);
  ------------------
  |  |   65|      1|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (80:9): [True: 0, False: 1]
  |  Branch (80:9): [True: 1, False: 0]
  ------------------
   81|      1|        pj_atexit(&exception_cleanup);
   82|      1|    }
   83|  57.7k|    parent_handler = (struct pj_exception_state_t *)
   84|  57.7k|                      pj_thread_local_get(thread_local_id);
   85|  57.7k|    rec->prev = parent_handler;
   86|  57.7k|    pj_thread_local_set(thread_local_id, rec);
   87|  57.7k|}
pj_pop_exception_handler_:
   90|  69.4k|{
   91|  69.4k|    struct pj_exception_state_t *handler;
   92|       |
   93|  69.4k|    handler = (struct pj_exception_state_t *)
   94|  69.4k|              pj_thread_local_get(thread_local_id);
   95|  69.4k|    if (handler && handler==rec) {
  ------------------
  |  Branch (95:9): [True: 69.4k, False: 8]
  |  Branch (95:20): [True: 60.8k, False: 8.56k]
  ------------------
   96|  60.8k|        pj_thread_local_set(thread_local_id, handler->prev);
   97|  60.8k|    }
   98|  69.4k|}
pj_exception_id_alloc:
  104|      6|{
  105|      6|    unsigned i;
  106|       |
  107|      6|    pj_enter_critical_section();
  108|       |
  109|       |    /*
  110|       |     * Start from 1 (not 0)!!!
  111|       |     * Exception 0 is reserved for normal path of setjmp()!!!
  112|       |     */
  113|     12|    for (i=1; i<PJ_MAX_EXCEPTION_ID; ++i) {
  ------------------
  |  |  947|     12|#   define PJ_MAX_EXCEPTION_ID      16
  ------------------
  |  Branch (113:15): [True: 12, False: 0]
  ------------------
  114|     12|        if (exception_id_names[i] == NULL) {
  ------------------
  |  Branch (114:13): [True: 6, False: 6]
  ------------------
  115|      6|            exception_id_names[i] = name;
  116|      6|            *id = i;
  117|      6|            pj_leave_critical_section();
  118|      6|            return PJ_SUCCESS;
  119|      6|        }
  120|     12|    }
  121|       |
  122|      0|    pj_leave_critical_section();
  123|      0|    return PJ_ETOOMANY;
  ------------------
  |  |  423|      0|#define PJ_ETOOMANY         (PJ_ERRNO_START_STATUS + 10)/* 70010 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  124|      6|}

pj_create_unique_string:
   35|  1.08k|{
   36|  1.08k|    str->ptr = (char*)pj_pool_alloc(pool, PJ_GUID_STRING_LENGTH);
   37|  1.08k|    pj_generate_unique_string(str);
   38|  1.08k|}

pj_generate_unique_string:
   52|  1.08k|{
   53|  1.08k|    char *p, *end;
   54|       |
   55|  1.08k|    PJ_CHECK_STACK();
   56|       |
   57|  1.08k|    if (guid_chars[0] == '\0') {
  ------------------
  |  Branch (57:9): [True: 2, False: 1.08k]
  ------------------
   58|      2|        pj_enter_critical_section();
   59|      2|        if (guid_chars[0] == '\0') {
  ------------------
  |  Branch (59:13): [True: 2, False: 0]
  ------------------
   60|      2|            init_guid_chars();
   61|      2|        }
   62|      2|        pj_leave_critical_section();
   63|      2|    }
   64|       |
   65|       |    /* This would only work if PJ_GUID_STRING_LENGTH is multiple of 2 bytes */
   66|  1.08k|    pj_assert(PJ_GUID_STRING_LENGTH % 2 == 0);
  ------------------
  |  |   65|  1.08k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (66:5): [True: 0, Folded]
  |  Branch (66:5): [True: 1.08k, Folded]
  ------------------
   67|       |
   68|  9.80k|    for (p=str->ptr, end=p+PJ_GUID_STRING_LENGTH; p<end; ) {
  ------------------
  |  Branch (68:51): [True: 8.71k, False: 1.08k]
  ------------------
   69|  8.71k|        pj_uint32_t rand_val = pj_rand();
   70|  8.71k|        pj_uint32_t rand_idx = RAND_MAX;
   71|       |
   72|  43.5k|        for ( ; rand_idx>0 && p<end; rand_idx>>=8, rand_val>>=8, p++) {
  ------------------
  |  Branch (72:17): [True: 34.8k, False: 8.71k]
  |  Branch (72:31): [True: 34.8k, False: 0]
  ------------------
   73|  34.8k|            *p = guid_chars[(rand_val & 0xFF) & 63];
   74|  34.8k|        }
   75|  8.71k|    }
   76|       |
   77|  1.08k|    str->slen = PJ_GUID_STRING_LENGTH;
   78|  1.08k|    return str;
   79|  1.08k|}
guid_simple.c:init_guid_chars:
   35|      2|{
   36|      2|    char *p = guid_chars;
   37|      2|    unsigned i;
   38|       |
   39|     22|    for (i=0; i<10; ++i)
  ------------------
  |  Branch (39:15): [True: 20, False: 2]
  ------------------
   40|     20|        *p++ = '0'+i;
   41|       |
   42|     54|    for (i=0; i<26; ++i) {
  ------------------
  |  Branch (42:15): [True: 52, False: 2]
  ------------------
   43|     52|        *p++ = 'a'+i;
   44|     52|        *p++ = 'A'+i;
   45|     52|    }
   46|       |
   47|      2|    *p++ = '-';
   48|      2|    *p++ = '.';
   49|      2|}

pj_hash_calc:
   54|  62.0k|{
   55|  62.0k|    PJ_CHECK_STACK();
   56|       |
   57|  62.0k|    if (keylen==PJ_HASH_KEY_STRING) {
  ------------------
  |  |   45|  62.0k|#define PJ_HASH_KEY_STRING      ((unsigned)-1)
  ------------------
  |  Branch (57:9): [True: 0, False: 62.0k]
  ------------------
   58|      0|        const pj_uint8_t *p = (const pj_uint8_t*)key;
   59|      0|        for ( ; *p; ++p ) {
  ------------------
  |  Branch (59:17): [True: 0, False: 0]
  ------------------
   60|      0|            hash = (hash * PJ_HASH_MULTIPLIER) + *p;
  ------------------
  |  |   30|      0|#define PJ_HASH_MULTIPLIER      33
  ------------------
   61|      0|        }
   62|  62.0k|    } else {
   63|  62.0k|        const pj_uint8_t *p = (const pj_uint8_t*)key,
   64|  62.0k|                              *end = p + keylen;
   65|   182k|        for ( ; p!=end; ++p) {
  ------------------
  |  Branch (65:17): [True: 120k, False: 62.0k]
  ------------------
   66|   120k|            hash = (hash * PJ_HASH_MULTIPLIER) + *p;
  ------------------
  |  |   30|   120k|#define PJ_HASH_MULTIPLIER      33
  ------------------
   67|   120k|        }
   68|  62.0k|    }
   69|  62.0k|    return hash;
   70|  62.0k|}
pj_hash_calc_tolower:
   75|  34.7k|{
   76|  34.7k|    long i;
   77|       |
   78|   306k|    for (i=0; i<key->slen; ++i) {
  ------------------
  |  Branch (78:15): [True: 271k, False: 34.7k]
  ------------------
   79|   271k|        int lower = pj_tolower(key->ptr[i]);
   80|   271k|        if (result)
  ------------------
  |  Branch (80:13): [True: 47.7k, False: 224k]
  ------------------
   81|  47.7k|            result[i] = (char)lower;
   82|       |
   83|   271k|        hval = hval * PJ_HASH_MULTIPLIER + lower;
  ------------------
  |  |   30|   271k|#define PJ_HASH_MULTIPLIER      33
  ------------------
   84|   271k|    }
   85|       |
   86|  34.7k|    return hval;
   87|  34.7k|}
pj_hash_create:
   91|      8|{
   92|      8|    pj_hash_table_t *h;
   93|      8|    unsigned table_size;
   94|       |    
   95|       |    /* Check that PJ_HASH_ENTRY_BUF_SIZE is correct. */
   96|      8|    PJ_ASSERT_RETURN(sizeof(pj_hash_entry)<=PJ_HASH_ENTRY_BUF_SIZE, NULL);
  ------------------
  |  |   97|      8|            do { \
  |  |   98|      8|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [Folded, False: 8]
  |  |  ------------------
  |  |   99|      8|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 8]
  |  |  ------------------
  ------------------
  |  Branch (96:5): [True: 0, Folded]
  |  Branch (96:5): [True: 0, Folded]
  ------------------
   97|       |
   98|      8|    h = PJ_POOL_ALLOC_T(pool, pj_hash_table_t);
  ------------------
  |  |  569|      8|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
   99|      8|    h->count = 0;
  100|       |
  101|      8|    PJ_LOG( 6, ("hashtbl", "hash table %p created from pool %s", h, pj_pool_getobjname(pool)));
  ------------------
  |  |  106|      8|#define PJ_LOG(level,arg)       do { \
  |  |  107|      8|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|     16|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 8]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|      8|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 8]
  |  |  ------------------
  ------------------
  102|       |
  103|       |    /* size must be 2^n - 1.
  104|       |       round-up the size to this rule, except when size is 2^n, then size
  105|       |       will be round-down to 2^n-1.
  106|       |     */
  107|      8|    table_size = 8;
  108|     44|    do {
  109|     44|        table_size <<= 1;    
  110|     44|    } while (table_size < size);
  ------------------
  |  Branch (110:14): [True: 36, False: 8]
  ------------------
  111|      8|    table_size -= 1;
  112|       |    
  113|      8|    h->rows = table_size;
  114|      8|    h->table = (pj_hash_entry**)
  115|      8|               pj_pool_calloc(pool, table_size+1, sizeof(pj_hash_entry*));
  116|      8|    return h;
  117|      8|}
pj_hash_get:
  214|     44|{
  215|     44|    pj_hash_entry *entry;
  216|     44|    entry = *find_entry( NULL, ht, key, keylen, NULL, hval, NULL, PJ_FALSE);
  217|     44|    return entry ? entry->value : NULL;
  ------------------
  |  Branch (217:12): [True: 42, False: 2]
  ------------------
  218|     44|}
pj_hash_get_lower:
  223|    898|{
  224|    898|    pj_hash_entry *entry;
  225|    898|    entry = *find_entry( NULL, ht, key, keylen, NULL, hval, NULL, PJ_TRUE);
  226|    898|    return entry ? entry->value : NULL;
  ------------------
  |  Branch (226:12): [True: 449, False: 449]
  ------------------
  227|    898|}
pj_hash_set_lower:
  263|  1.57k|{
  264|       |    hash_set(pool, ht, key, keylen, hval, value, NULL, PJ_TRUE);
  265|  1.57k|}
pj_hash_set_np:
  271|      2|{
  272|       |    hash_set(NULL, ht, key, keylen, hval, value, (void *)entry_buf, PJ_FALSE);
  273|      2|}
pj_hash_set_np_lower:
  280|    449|{
  281|       |    hash_set(NULL, ht, key, keylen, hval, value, (void *)entry_buf, PJ_TRUE);
  282|    449|}
hash.c:find_entry:
  123|  2.96k|{
  124|  2.96k|    pj_uint32_t hash;
  125|  2.96k|    pj_hash_entry **p_entry, *entry;
  126|       |
  127|  2.96k|    if (hval && *hval != 0) {
  ------------------
  |  Branch (127:9): [True: 2.64k, False: 323]
  |  Branch (127:17): [True: 2.64k, False: 2]
  ------------------
  128|  2.64k|        hash = *hval;
  129|  2.64k|        if (keylen==PJ_HASH_KEY_STRING) {
  ------------------
  |  |   45|  2.64k|#define PJ_HASH_KEY_STRING      ((unsigned)-1)
  ------------------
  |  Branch (129:13): [True: 0, False: 2.64k]
  ------------------
  130|      0|            keylen = (unsigned)pj_ansi_strlen((const char*)key);
  ------------------
  |  |   69|      0|#define pj_ansi_strlen          strlen
  ------------------
  131|      0|        }
  132|  2.64k|    } else {
  133|       |        /* This slightly differs with pj_hash_calc() because we need 
  134|       |         * to get the keylen when keylen is PJ_HASH_KEY_STRING.
  135|       |         */
  136|    325|        hash=0;
  137|    325|        if (keylen==PJ_HASH_KEY_STRING) {
  ------------------
  |  |   45|    325|#define PJ_HASH_KEY_STRING      ((unsigned)-1)
  ------------------
  |  Branch (137:13): [True: 0, False: 325]
  ------------------
  138|      0|            const pj_uint8_t *p = (const pj_uint8_t*)key;
  139|      0|            for ( ; *p; ++p ) {
  ------------------
  |  Branch (139:21): [True: 0, False: 0]
  ------------------
  140|      0|                if (lower)
  ------------------
  |  Branch (140:21): [True: 0, False: 0]
  ------------------
  141|      0|                    hash = hash * PJ_HASH_MULTIPLIER + pj_tolower(*p);
  ------------------
  |  |   30|      0|#define PJ_HASH_MULTIPLIER      33
  ------------------
  142|      0|                else 
  143|      0|                    hash = hash * PJ_HASH_MULTIPLIER + *p;
  ------------------
  |  |   30|      0|#define PJ_HASH_MULTIPLIER      33
  ------------------
  144|      0|            }
  145|      0|            keylen = (unsigned)(p - (const unsigned char*)key);
  146|    325|        } else {
  147|    325|            const pj_uint8_t *p = (const pj_uint8_t*)key,
  148|    325|                                  *end = p + keylen;
  149|  91.5k|            for ( ; p!=end; ++p) {
  ------------------
  |  Branch (149:21): [True: 91.2k, False: 325]
  ------------------
  150|  91.2k|                if (lower)
  ------------------
  |  Branch (150:21): [True: 90.1k, False: 1.05k]
  ------------------
  151|  90.1k|                    hash = hash * PJ_HASH_MULTIPLIER + pj_tolower(*p);
  ------------------
  |  |   30|  90.1k|#define PJ_HASH_MULTIPLIER      33
  ------------------
  152|  1.05k|                else
  153|  1.05k|                    hash = hash * PJ_HASH_MULTIPLIER + *p;
  ------------------
  |  |   30|  1.05k|#define PJ_HASH_MULTIPLIER      33
  ------------------
  154|  91.2k|            }
  155|    325|        }
  156|       |
  157|       |        /* Report back the computed hash. */
  158|    325|        if (hval)
  ------------------
  |  Branch (158:13): [True: 2, False: 323]
  ------------------
  159|      2|            *hval = hash;
  160|    325|    }
  161|       |
  162|       |    /* scan the linked list */
  163|  2.96k|    for (p_entry = &ht->table[hash & ht->rows], entry=*p_entry; 
  164|  2.96k|         entry; 
  ------------------
  |  Branch (164:10): [True: 1.50k, False: 1.46k]
  ------------------
  165|  2.96k|         p_entry = &entry->next, entry = *p_entry)
  166|  1.50k|    {
  167|  1.50k|        if (entry->hash==hash && entry->keylen==keylen &&
  ------------------
  |  Branch (167:13): [True: 1.50k, False: 0]
  |  Branch (167:34): [True: 1.50k, False: 0]
  ------------------
  168|  1.50k|            ((lower && pj_ansi_strnicmp((const char*)entry->key,
  ------------------
  |  |   96|  1.46k|#define pj_ansi_strnicmp        strncasecmp
  ------------------
  |  Branch (168:15): [True: 1.46k, False: 42]
  |  Branch (168:24): [True: 1.46k, False: 0]
  ------------------
  169|  1.46k|                                        (const char*)key, keylen)==0) ||
  170|     42|             (!lower && pj_memcmp(entry->key, key, keylen)==0)))
  ------------------
  |  Branch (170:15): [True: 42, False: 0]
  |  Branch (170:25): [True: 42, False: 0]
  ------------------
  171|  1.50k|        {
  172|  1.50k|            break;
  173|  1.50k|        }
  174|  1.50k|    }
  175|       |
  176|  2.96k|    if (entry || val==NULL)
  ------------------
  |  Branch (176:9): [True: 1.50k, False: 1.46k]
  |  Branch (176:18): [True: 451, False: 1.01k]
  ------------------
  177|  1.95k|        return p_entry;
  178|       |
  179|       |    /* Entry not found, create a new one. 
  180|       |     * If entry_buf is specified, use it. Otherwise allocate from pool.
  181|       |     */
  182|  1.01k|    if (entry_buf) {
  ------------------
  |  Branch (182:9): [True: 451, False: 562]
  ------------------
  183|    451|        entry = (pj_hash_entry*)entry_buf;
  184|    562|    } else {
  185|       |        /* Pool must be specified! */
  186|    562|        PJ_ASSERT_RETURN(pool != NULL, NULL);
  ------------------
  |  |   97|    562|            do { \
  |  |   98|    562|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 562]
  |  |  ------------------
  |  |   99|    562|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 562]
  |  |  ------------------
  ------------------
  |  Branch (186:9): [True: 0, False: 0]
  |  Branch (186:9): [True: 0, False: 0]
  ------------------
  187|       |
  188|    562|        entry = PJ_POOL_ALLOC_T(pool, pj_hash_entry);
  ------------------
  |  |  569|    562|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
  189|    562|        PJ_LOG(6, ("hashtbl", 
  ------------------
  |  |  106|    562|#define PJ_LOG(level,arg)       do { \
  |  |  107|    562|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  1.12k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 562]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|    562|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 562]
  |  |  ------------------
  ------------------
  190|    562|                   "%p: New p_entry %p created, pool used=%lu, cap=%lu", 
  191|    562|                   ht, entry,  (unsigned long)pj_pool_get_used_size(pool),
  192|    562|                   (unsigned long)pj_pool_get_capacity(pool)));
  193|    562|    }
  194|  1.01k|    entry->next = NULL;
  195|  1.01k|    entry->hash = hash;
  196|  1.01k|    if (pool) {
  ------------------
  |  Branch (196:9): [True: 562, False: 451]
  ------------------
  197|    562|        entry->key = pj_pool_alloc(pool, keylen);
  198|    562|        pj_memcpy(entry->key, key, keylen);
  199|    562|    } else {
  200|    451|        entry->key = (void*)key;
  201|    451|    }
  202|  1.01k|    entry->keylen = keylen;
  203|  1.01k|    entry->value = val;
  204|  1.01k|    *p_entry = entry;
  205|       |    
  206|  1.01k|    ++ht->count;
  207|       |    
  208|  1.01k|    return p_entry;
  209|  1.01k|}
hash.c:hash_set:
  232|  2.02k|{
  233|  2.02k|    pj_hash_entry **p_entry;
  234|       |
  235|  2.02k|    p_entry = find_entry( pool, ht, key, keylen, value, &hval, entry_buf,
  236|  2.02k|                          lower);
  237|  2.02k|    if (*p_entry) {
  ------------------
  |  Branch (237:9): [True: 2.02k, False: 0]
  ------------------
  238|  2.02k|        if (value == NULL) {
  ------------------
  |  Branch (238:13): [True: 1.01k, False: 1.01k]
  ------------------
  239|       |            /* delete entry */
  240|  1.01k|            PJ_LOG(6, ("hashtbl", "%p: p_entry %p deleted", ht, *p_entry));
  ------------------
  |  |  106|  1.01k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  1.01k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  2.02k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 1.01k]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  1.01k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 1.01k]
  |  |  ------------------
  ------------------
  241|  1.01k|            *p_entry = (*p_entry)->next;
  242|  1.01k|            --ht->count;
  243|       |            
  244|  1.01k|        } else {
  245|       |            /* overwrite */
  246|  1.01k|            (*p_entry)->value = value;
  247|  1.01k|            PJ_LOG(6, ("hashtbl", "%p: p_entry %p value set to %p", ht, 
  ------------------
  |  |  106|  1.01k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  1.01k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  2.02k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 1.01k]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  1.01k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 1.01k]
  |  |  ------------------
  ------------------
  248|  1.01k|                       *p_entry, value));
  249|  1.01k|        }
  250|  2.02k|    }
  251|  2.02k|}

pj_ioqueue_cfg_default:
   40|      2|{
   41|      2|    pj_bzero(cfg, sizeof(*cfg));
   42|      2|    cfg->epoll_flags = PJ_IOQUEUE_DEFAULT_EPOLL_FLAGS;
  ------------------
  |  |  810|      2|#   define PJ_IOQUEUE_DEFAULT_EPOLL_FLAGS PJ_IOQUEUE_EPOLL_AUTO
  ------------------
   43|      2|    cfg->default_concurrency = PJ_IOQUEUE_DEFAULT_ALLOW_CONCURRENCY;
  ------------------
  |  |  775|      2|#   define PJ_IOQUEUE_DEFAULT_ALLOW_CONCURRENCY   1
  ------------------
   44|      2|}
pj_ioqueue_set_lock:
   68|      2|{
   69|      2|    PJ_ASSERT_RETURN(ioqueue && lock, PJ_EINVAL);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      4|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 2, False: 0]
  |  |  |  Branch (98:23): [True: 2, False: 0]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (69:5): [True: 0, False: 0]
  |  Branch (69:5): [True: 0, False: 0]
  |  Branch (69:5): [True: 0, False: 0]
  |  Branch (69:5): [True: 0, False: 0]
  ------------------
   70|       |
   71|      2|    if (ioqueue->auto_delete_lock && ioqueue->lock) {
  ------------------
  |  Branch (71:9): [True: 0, False: 2]
  |  Branch (71:38): [True: 0, False: 0]
  ------------------
   72|      0|        pj_lock_destroy(ioqueue->lock);
   73|      0|    }
   74|       |
   75|      2|    ioqueue->lock = lock;
   76|      2|    ioqueue->auto_delete_lock = auto_delete;
   77|       |
   78|      2|    return PJ_SUCCESS;
   79|      2|}
pj_ioqueue_op_key_init:
 1444|    449|{
 1445|    449|    pj_bzero(op_key, size);
 1446|    449|}
ioqueue_select.c:ioqueue_init:
   47|      2|{
   48|       |    ioqueue->lock = NULL;
   49|      2|    ioqueue->auto_delete_lock = 0;
   50|      2|}

pj_ioqueue_create:
  196|      2|{
  197|       |    return pj_ioqueue_create2(pool, max_fd, NULL, p_ioqueue);
  198|      2|}
pj_ioqueue_create2:
  210|      2|{
  211|      2|    pj_ioqueue_t *ioqueue;
  212|      2|    pj_lock_t *lock;
  213|      2|    pj_size_t i;
  214|      2|    pj_status_t rc;
  215|       |
  216|       |    /* Check that arguments are valid. */
  217|      2|    PJ_ASSERT_RETURN(pool != NULL && p_ioqueue != NULL && 
  ------------------
  |  |   97|      2|            do { \
  |  |   98|     12|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 2, False: 0]
  |  |  |  Branch (98:23): [True: 2, False: 0]
  |  |  |  Branch (98:23): [True: 2, False: 0]
  |  |  |  Branch (98:23): [True: 2, False: 0]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (217:5): [True: 0, False: 0]
  |  Branch (217:5): [True: 0, False: 0]
  |  Branch (217:5): [True: 0, False: 0]
  |  Branch (217:5): [True: 0, False: 0]
  |  Branch (217:5): [True: 0, False: 0]
  |  Branch (217:5): [True: 0, False: 0]
  |  Branch (217:5): [True: 0, False: 0]
  |  Branch (217:5): [True: 0, False: 0]
  ------------------
  218|      2|                     max_fd > 0 && max_fd <= PJ_IOQUEUE_MAX_HANDLES, 
  219|      2|                     PJ_EINVAL);
  220|       |
  221|       |    /* Check that size of pj_ioqueue_op_key_t is sufficient */
  222|      2|    PJ_ASSERT_RETURN(sizeof(pj_ioqueue_op_key_t)-sizeof(void*) >=
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [Folded, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (222:5): [True: 0, Folded]
  |  Branch (222:5): [True: 0, Folded]
  ------------------
  223|      2|                     sizeof(union operation_key), PJ_EBUG);
  224|       |
  225|       |    /* Create and init common ioqueue stuffs */
  226|      2|    ioqueue = PJ_POOL_ZALLOC_T(pool, pj_ioqueue_t);
  ------------------
  |  |  583|      2|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  227|      2|    ioqueue_init(ioqueue);
  228|       |
  229|      2|    if (cfg)
  ------------------
  |  Branch (229:9): [True: 0, False: 2]
  ------------------
  230|      0|        pj_memcpy(&ioqueue->cfg, cfg, sizeof(*cfg));
  231|      2|    else
  232|      2|        pj_ioqueue_cfg_default(&ioqueue->cfg);
  233|      2|    ioqueue->max = (unsigned)max_fd;
  234|      2|    ioqueue->count = 0;
  235|      2|    PJ_FD_ZERO(&ioqueue->rfdset);
  236|      2|    PJ_FD_ZERO(&ioqueue->wfdset);
  237|      2|#if PJ_HAS_TCP
  238|      2|    PJ_FD_ZERO(&ioqueue->xfdset);
  239|      2|#endif
  240|      2|    pj_list_init(&ioqueue->active_list);
  241|       |
  242|      2|    rescan_fdset(ioqueue);
  243|       |
  244|      2|#if PJ_IOQUEUE_HAS_SAFE_UNREG
  245|       |    /* When safe unregistration is used (the default), we pre-create
  246|       |     * all keys and put them in the free list.
  247|       |     */
  248|       |
  249|       |    /* Mutex to protect key's reference counter 
  250|       |     * We don't want to use key's mutex or ioqueue's mutex because
  251|       |     * that would create deadlock situation in some cases.
  252|       |     */
  253|      2|    rc = pj_mutex_create_simple(pool, NULL, &ioqueue->ref_cnt_mutex);
  254|      2|    if (rc != PJ_SUCCESS)
  ------------------
  |  Branch (254:9): [True: 0, False: 2]
  ------------------
  255|      0|        return rc;
  256|       |
  257|       |
  258|       |    /* Init key list */
  259|      2|    pj_list_init(&ioqueue->free_list);
  260|      2|    pj_list_init(&ioqueue->closing_list);
  261|       |
  262|       |
  263|       |    /* Pre-create all keys according to max_fd */
  264|    130|    for (i=0; i<max_fd; ++i) {
  ------------------
  |  Branch (264:15): [True: 128, False: 2]
  ------------------
  265|    128|        pj_ioqueue_key_t *key;
  266|       |
  267|    128|        key = PJ_POOL_ALLOC_T(pool, pj_ioqueue_key_t);
  ------------------
  |  |  569|    128|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
  268|    128|        key->ref_count = 0;
  269|    128|        rc = pj_lock_create_recursive_mutex(pool, NULL, &key->lock);
  270|    128|        if (rc != PJ_SUCCESS) {
  ------------------
  |  Branch (270:13): [True: 0, False: 128]
  ------------------
  271|      0|            key = ioqueue->free_list.next;
  272|      0|            while (key != &ioqueue->free_list) {
  ------------------
  |  Branch (272:20): [True: 0, False: 0]
  ------------------
  273|      0|                pj_lock_destroy(key->lock);
  274|      0|                key = key->next;
  275|      0|            }
  276|      0|            pj_mutex_destroy(ioqueue->ref_cnt_mutex);
  277|      0|            return rc;
  278|      0|        }
  279|       |
  280|    128|        pj_list_push_back(&ioqueue->free_list, key);
  281|    128|    }
  282|      2|#endif
  283|       |
  284|       |    /* Create and init ioqueue mutex */
  285|      2|    rc = pj_lock_create_simple_mutex(pool, "ioq%p", &lock);
  286|      2|    if (rc != PJ_SUCCESS)
  ------------------
  |  Branch (286:9): [True: 0, False: 2]
  ------------------
  287|      0|        return rc;
  288|       |
  289|      2|    rc = pj_ioqueue_set_lock(ioqueue, lock, PJ_TRUE);
  290|      2|    if (rc != PJ_SUCCESS)
  ------------------
  |  Branch (290:9): [True: 0, False: 2]
  ------------------
  291|      0|        return rc;
  292|       |
  293|      2|    PJ_LOG(4, ("pjlib", "select() I/O Queue created (%p)", ioqueue));
  ------------------
  |  |  106|      2|#define PJ_LOG(level,arg)       do { \
  |  |  107|      2|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      4|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 2, Folded]
  |  |  |  Branch (107:70): [True: 2, False: 0]
  |  |  ------------------
  |  |  108|      2|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      2|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      2|                                    } \
  |  |  110|      2|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 2]
  |  |  ------------------
  ------------------
  294|       |
  295|      2|    *p_ioqueue = ioqueue;
  296|      2|    return PJ_SUCCESS;
  297|      2|}
pj_ioqueue_poll:
  933|  5.68k|{
  934|  5.68k|    pj_fd_set_t rfdset, wfdset, xfdset;
  935|  5.68k|    int nfds;
  936|  5.68k|    int i, count, event_cnt, processed_cnt;
  937|  5.68k|    pj_ioqueue_key_t *h;
  938|  5.68k|    enum { MAX_EVENTS = PJ_IOQUEUE_MAX_CAND_EVENTS };
  939|  5.68k|    struct event
  940|  5.68k|    {
  941|  5.68k|        pj_ioqueue_key_t        *key;
  942|  5.68k|        enum ioqueue_event_type  event_type;
  943|  5.68k|    } event[MAX_EVENTS];
  944|       |
  945|  5.68k|    PJ_ASSERT_RETURN(ioqueue, -PJ_EINVAL);
  ------------------
  |  |   97|  5.68k|            do { \
  |  |   98|  5.68k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 5.68k]
  |  |  ------------------
  |  |   99|  5.68k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 5.68k]
  |  |  ------------------
  ------------------
  |  Branch (945:5): [True: 0, False: 0]
  |  Branch (945:5): [True: 0, False: 0]
  ------------------
  946|       |
  947|       |#if defined(PJ_HAS_SSL_SOCK) && PJ_HAS_SSL_SOCK != 0 && \
  948|       |    (PJ_SSL_SOCK_IMP == PJ_SSL_SOCK_IMP_APPLE)
  949|       |    /* Call SSL Network framework event poll */
  950|       |    ssl_network_event_poll();
  951|       |#endif
  952|       |
  953|       |    /* Lock ioqueue before making fd_set copies */
  954|  5.68k|    pj_lock_acquire(ioqueue->lock);
  955|       |
  956|       |    /* We will only do select() when there are sockets to be polled.
  957|       |     * Otherwise select() will return error.
  958|       |     */
  959|  5.68k|    if (PJ_FD_COUNT(&ioqueue->rfdset)==0 &&
  ------------------
  |  Branch (959:9): [True: 5.68k, False: 0]
  ------------------
  960|  5.68k|        PJ_FD_COUNT(&ioqueue->wfdset)==0 
  ------------------
  |  Branch (960:9): [True: 5.68k, False: 0]
  ------------------
  961|  5.68k|#if defined(PJ_HAS_TCP) && PJ_HAS_TCP!=0
  962|  5.68k|        && PJ_FD_COUNT(&ioqueue->xfdset)==0
  ------------------
  |  Branch (962:12): [True: 5.68k, False: 0]
  ------------------
  963|  5.68k|#endif
  964|  5.68k|        )
  965|  5.68k|    {
  966|  5.68k|#if PJ_IOQUEUE_HAS_SAFE_UNREG
  967|  5.68k|        scan_closing_keys(ioqueue);
  968|  5.68k|#endif
  969|  5.68k|        pj_lock_release(ioqueue->lock);
  970|  5.68k|        TRACE__((THIS_FILE, "     poll: no fd is set"));
  971|  5.68k|        if (timeout)
  ------------------
  |  Branch (971:13): [True: 5.68k, False: 0]
  ------------------
  972|  5.68k|            pj_thread_sleep(PJ_TIME_VAL_MSEC(*timeout));
  ------------------
  |  |  477|  5.68k|#define PJ_TIME_VAL_MSEC(t)     ((t).sec * 1000 + (t).msec)
  ------------------
  973|  5.68k|        return 0;
  974|  5.68k|    }
  975|       |
  976|       |    /* Copy ioqueue's pj_fd_set_t to local variables. */
  977|      0|    pj_memcpy(&rfdset, &ioqueue->rfdset, sizeof(pj_fd_set_t));
  978|      0|    pj_memcpy(&wfdset, &ioqueue->wfdset, sizeof(pj_fd_set_t));
  979|      0|#if PJ_HAS_TCP
  980|      0|    pj_memcpy(&xfdset, &ioqueue->xfdset, sizeof(pj_fd_set_t));
  981|       |#else
  982|       |    PJ_FD_ZERO(&xfdset);
  983|       |#endif
  984|       |
  985|       |#if VALIDATE_FD_SET
  986|       |    validate_sets(ioqueue, &rfdset, &wfdset, &xfdset);
  987|       |#endif
  988|       |
  989|      0|    nfds = ioqueue->nfds;
  990|       |
  991|       |    /* Unlock ioqueue before select(). */
  992|      0|    pj_lock_release(ioqueue->lock);
  993|       |
  994|       |#if defined(PJ_WIN32_WINPHONE8) && PJ_WIN32_WINPHONE8
  995|       |    count = 0;
  996|       |    __try {
  997|       |#endif
  998|       |
  999|      0|    count = pj_sock_select(nfds+1, &rfdset, &wfdset, &xfdset, 
 1000|      0|                           timeout);
 1001|       |
 1002|       |#if defined(PJ_WIN32_WINPHONE8) && PJ_WIN32_WINPHONE8
 1003|       |    /* Ignore Invalid Handle Exception raised by select().*/
 1004|       |    }
 1005|       |    __except (GetExceptionCode() == STATUS_INVALID_HANDLE ?
 1006|       |              EXCEPTION_CONTINUE_EXECUTION : EXCEPTION_CONTINUE_SEARCH) {
 1007|       |    }
 1008|       |#endif    
 1009|       |    
 1010|      0|    if (count == 0)
  ------------------
  |  Branch (1010:9): [True: 0, False: 0]
  ------------------
 1011|      0|        return 0;
 1012|      0|    else if (count < 0)
  ------------------
  |  Branch (1012:14): [True: 0, False: 0]
  ------------------
 1013|      0|        return -pj_get_netos_error();
 1014|       |
 1015|       |    /* Scan descriptor sets for event and add the events in the event
 1016|       |     * array to be processed later in this function. We do this so that
 1017|       |     * events can be processed in parallel without holding ioqueue lock.
 1018|       |     */
 1019|      0|    pj_lock_acquire(ioqueue->lock);
 1020|       |
 1021|      0|    event_cnt = 0;
 1022|       |
 1023|       |    /* Scan for writable sockets first to handle piggy-back data
 1024|       |     * coming with accept().
 1025|       |     */
 1026|      0|    for (h = ioqueue->active_list.next;
 1027|      0|         h != &ioqueue->active_list && event_cnt < MAX_EVENTS;
  ------------------
  |  Branch (1027:10): [True: 0, False: 0]
  |  Branch (1027:40): [True: 0, False: 0]
  ------------------
 1028|      0|         h = h->next)
 1029|      0|    {
 1030|      0|        if (h->fd == PJ_INVALID_SOCKET)
  ------------------
  |  |  492|      0|#define PJ_INVALID_SOCKET   (-1)
  ------------------
  |  Branch (1030:13): [True: 0, False: 0]
  ------------------
 1031|      0|            continue;
 1032|       |
 1033|      0|        if ( (key_has_pending_write(h) || key_has_pending_connect(h))
  ------------------
  |  Branch (1033:15): [True: 0, False: 0]
  |  Branch (1033:43): [True: 0, False: 0]
  ------------------
 1034|      0|             && PJ_FD_ISSET(h->fd, &wfdset) && !IS_CLOSING(h))
  ------------------
  |  |  200|      0|#define IS_CLOSING(key) (key->closing)
  ------------------
  |  Branch (1034:17): [True: 0, False: 0]
  |  Branch (1034:48): [True: 0, False: 0]
  ------------------
 1035|      0|        {
 1036|      0|#if PJ_IOQUEUE_HAS_SAFE_UNREG
 1037|      0|            increment_counter(h);
 1038|      0|#endif
 1039|      0|            event[event_cnt].key = h;
 1040|      0|            event[event_cnt].event_type = WRITEABLE_EVENT;
 1041|      0|            ++event_cnt;
 1042|      0|        }
 1043|       |
 1044|       |        /* Scan for readable socket. */
 1045|      0|        if ((key_has_pending_read(h) || key_has_pending_accept(h))
  ------------------
  |  Branch (1045:14): [True: 0, False: 0]
  |  Branch (1045:41): [True: 0, False: 0]
  ------------------
 1046|      0|            && PJ_FD_ISSET(h->fd, &rfdset) && !IS_CLOSING(h) &&
  ------------------
  |  |  200|      0|#define IS_CLOSING(key) (key->closing)
  ------------------
  |  Branch (1046:16): [True: 0, False: 0]
  |  Branch (1046:47): [True: 0, False: 0]
  ------------------
 1047|      0|            event_cnt < MAX_EVENTS)
  ------------------
  |  Branch (1047:13): [True: 0, False: 0]
  ------------------
 1048|      0|        {
 1049|      0|#if PJ_IOQUEUE_HAS_SAFE_UNREG
 1050|      0|            increment_counter(h);
 1051|      0|#endif
 1052|      0|            event[event_cnt].key = h;
 1053|      0|            event[event_cnt].event_type = READABLE_EVENT;
 1054|      0|            ++event_cnt;
 1055|      0|        }
 1056|       |
 1057|      0|#if PJ_HAS_TCP
 1058|      0|        if (key_has_pending_connect(h) && PJ_FD_ISSET(h->fd, &xfdset) &&
  ------------------
  |  Branch (1058:13): [True: 0, False: 0]
  |  Branch (1058:43): [True: 0, False: 0]
  ------------------
 1059|      0|            !IS_CLOSING(h) && event_cnt < MAX_EVENTS)
  ------------------
  |  |  200|      0|#define IS_CLOSING(key) (key->closing)
  ------------------
  |  Branch (1059:13): [True: 0, False: 0]
  |  Branch (1059:31): [True: 0, False: 0]
  ------------------
 1060|      0|        {
 1061|      0|#if PJ_IOQUEUE_HAS_SAFE_UNREG
 1062|      0|            increment_counter(h);
 1063|      0|#endif
 1064|      0|            event[event_cnt].key = h;
 1065|      0|            event[event_cnt].event_type = EXCEPTION_EVENT;
 1066|      0|            ++event_cnt;
 1067|      0|        }
 1068|      0|#endif
 1069|      0|    }
 1070|       |
 1071|      0|    for (i=0; i<event_cnt; ++i) {
  ------------------
  |  Branch (1071:15): [True: 0, False: 0]
  ------------------
 1072|      0|        if (event[i].key->grp_lock)
  ------------------
  |  Branch (1072:13): [True: 0, False: 0]
  ------------------
 1073|      0|            pj_grp_lock_add_ref_dbg(event[i].key->grp_lock, "ioqueue", 0);
  ------------------
  |  |  351|      0|#define pj_grp_lock_add_ref_dbg(grp_lock, x, y) pj_grp_lock_add_ref(grp_lock)
  ------------------
 1074|      0|    }
 1075|       |
 1076|      0|    PJ_RACE_ME(5);
 1077|       |
 1078|      0|    pj_lock_release(ioqueue->lock);
 1079|       |
 1080|      0|    PJ_RACE_ME(5);
 1081|       |
 1082|      0|    processed_cnt = 0;
 1083|       |
 1084|       |    /* Now process all events. The dispatch functions will take care
 1085|       |     * of locking in each of the key
 1086|       |     */
 1087|      0|    for (i=0; i<event_cnt; ++i) {
  ------------------
  |  Branch (1087:15): [True: 0, False: 0]
  ------------------
 1088|       |
 1089|       |        /* Just do not exceed PJ_IOQUEUE_MAX_EVENTS_IN_SINGLE_POLL */
 1090|      0|        if (processed_cnt < PJ_IOQUEUE_MAX_EVENTS_IN_SINGLE_POLL) {
  ------------------
  |  |  301|      0|#   define PJ_IOQUEUE_MAX_EVENTS_IN_SINGLE_POLL     (16)
  ------------------
  |  Branch (1090:13): [True: 0, False: 0]
  ------------------
 1091|      0|            switch (event[i].event_type) {
  ------------------
  |  Branch (1091:21): [True: 0, False: 0]
  ------------------
 1092|      0|            case READABLE_EVENT:
  ------------------
  |  Branch (1092:13): [True: 0, False: 0]
  ------------------
 1093|      0|                if (ioqueue_dispatch_read_event(ioqueue, event[i].key))
  ------------------
  |  Branch (1093:21): [True: 0, False: 0]
  ------------------
 1094|      0|                    ++processed_cnt;
 1095|      0|                break;
 1096|      0|            case WRITEABLE_EVENT:
  ------------------
  |  Branch (1096:13): [True: 0, False: 0]
  ------------------
 1097|      0|                if (ioqueue_dispatch_write_event(ioqueue, event[i].key))
  ------------------
  |  Branch (1097:21): [True: 0, False: 0]
  ------------------
 1098|      0|                    ++processed_cnt;
 1099|      0|                break;
 1100|      0|            case EXCEPTION_EVENT:
  ------------------
  |  Branch (1100:13): [True: 0, False: 0]
  ------------------
 1101|      0|                if (ioqueue_dispatch_exception_event(ioqueue, event[i].key))
  ------------------
  |  Branch (1101:21): [True: 0, False: 0]
  ------------------
 1102|      0|                    ++processed_cnt;
 1103|      0|                break;
 1104|      0|            case NO_EVENT:
  ------------------
  |  Branch (1104:13): [True: 0, False: 0]
  ------------------
 1105|      0|                pj_assert(!"Invalid event!");
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (1105:17): [Folded, False: 0]
  |  Branch (1105:17): [Folded, False: 0]
  ------------------
 1106|      0|                break;
 1107|      0|            }
 1108|      0|        }
 1109|       |
 1110|      0|#if PJ_IOQUEUE_HAS_SAFE_UNREG
 1111|      0|        decrement_counter(event[i].key);
 1112|      0|#endif
 1113|       |
 1114|      0|        if (event[i].key->grp_lock)
  ------------------
  |  Branch (1114:13): [True: 0, False: 0]
  ------------------
 1115|      0|            pj_grp_lock_dec_ref_dbg(event[i].key->grp_lock,
  ------------------
  |  |  382|      0|#define pj_grp_lock_dec_ref_dbg(grp_lock, x, y) pj_grp_lock_dec_ref(grp_lock)
  ------------------
 1116|      0|                                    "ioqueue", 0);
 1117|      0|    }
 1118|       |
 1119|      0|    TRACE__((THIS_FILE, "     poll: count=%d events=%d processed=%d",
 1120|      0|             count, event_cnt, processed_cnt));
 1121|       |
 1122|      0|    return processed_cnt;
 1123|      0|}
ioqueue_select.c:rescan_fdset:
  182|      2|{
  183|       |    ioqueue->nfds = FD_SETSIZE-1;
  184|      2|}
ioqueue_select.c:scan_closing_keys:
  702|  5.68k|{
  703|  5.68k|    pj_time_val now;
  704|  5.68k|    pj_ioqueue_key_t *h;
  705|       |
  706|  5.68k|    pj_gettickcount(&now);
  707|  5.68k|    h = ioqueue->closing_list.next;
  708|  5.68k|    while (h != &ioqueue->closing_list) {
  ------------------
  |  Branch (708:12): [True: 0, False: 5.68k]
  ------------------
  709|      0|        pj_ioqueue_key_t *next = h->next;
  710|       |
  711|      0|        pj_assert(h->closing != 0);
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (711:9): [True: 0, False: 0]
  |  Branch (711:9): [True: 0, False: 0]
  ------------------
  712|       |
  713|      0|        if (PJ_TIME_VAL_GTE(now, h->free_time)) {
  ------------------
  |  |  508|      0|#define PJ_TIME_VAL_GTE(t1, t2) (PJ_TIME_VAL_GT(t1,t2) || \
  |  |  ------------------
  |  |  |  |  497|      0|#define PJ_TIME_VAL_GT(t1, t2)  ((t1).sec>(t2).sec || \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (497:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  498|      0|                                ((t1).sec==(t2).sec && (t1).msec>(t2).msec))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (498:34): [True: 0, False: 0]
  |  |  |  |  |  Branch (498:56): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  509|      0|                                 PJ_TIME_VAL_EQ(t1,t2))
  |  |  ------------------
  |  |  |  |  487|      0|#define PJ_TIME_VAL_EQ(t1, t2)  ((t1).sec==(t2).sec && (t1).msec==(t2).msec)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (487:34): [True: 0, False: 0]
  |  |  |  |  |  Branch (487:56): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  714|      0|            pj_list_erase(h);
  715|       |            // Don't set grp_lock to NULL otherwise the other thread
  716|       |            // will crash. Just leave it as dangling pointer, but this
  717|       |            // should be safe
  718|       |            //h->grp_lock = NULL;
  719|      0|            pj_list_push_back(&ioqueue->free_list, h);
  720|      0|        }
  721|      0|        h = next;
  722|      0|    }
  723|  5.68k|}

pj_lock_create_simple_mutex:
   87|      4|{
   88|      4|    return create_mutex_lock(pool, name, PJ_MUTEX_SIMPLE, lock);
   89|      4|}
pj_lock_create_recursive_mutex:
   94|  6.48k|{
   95|  6.48k|    return create_mutex_lock(pool, name, PJ_MUTEX_RECURSE, lock);
   96|  6.48k|}
pj_lock_create_null_mutex:
  120|    449|{
  121|    449|    PJ_UNUSED_ARG(name);
  ------------------
  |  | 1537|    449|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  122|    449|    PJ_UNUSED_ARG(pool);
  ------------------
  |  | 1537|    449|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  123|       |
  124|    449|    PJ_ASSERT_RETURN(lock, PJ_EINVAL);
  ------------------
  |  |   97|    449|            do { \
  |  |   98|    449|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 449]
  |  |  ------------------
  |  |   99|    449|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 449]
  |  |  ------------------
  ------------------
  |  Branch (124:5): [True: 0, False: 0]
  |  Branch (124:5): [True: 0, False: 0]
  ------------------
  125|       |
  126|    449|    *lock = &null_lock_template;
  127|    449|    return PJ_SUCCESS;
  128|    449|}
pj_lock_acquire:
  177|  70.0k|{
  178|  70.0k|    PJ_ASSERT_RETURN(lock != NULL, PJ_EINVAL);
  ------------------
  |  |   97|  70.0k|            do { \
  |  |   98|  70.0k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 70.0k]
  |  |  ------------------
  |  |   99|  70.0k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 70.0k]
  |  |  ------------------
  ------------------
  |  Branch (178:5): [True: 0, False: 0]
  |  Branch (178:5): [True: 0, False: 0]
  ------------------
  179|  70.0k|    return (*lock->acquire)(lock->lock_object);
  180|  70.0k|}
pj_lock_release:
  189|  70.0k|{
  190|  70.0k|    PJ_ASSERT_RETURN(lock != NULL, PJ_EINVAL);
  ------------------
  |  |   97|  70.0k|            do { \
  |  |   98|  70.0k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 70.0k]
  |  |  ------------------
  |  |   99|  70.0k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 70.0k]
  |  |  ------------------
  ------------------
  |  Branch (190:5): [True: 0, False: 0]
  |  Branch (190:5): [True: 0, False: 0]
  ------------------
  191|  70.0k|    return (*lock->release)(lock->lock_object);
  192|  70.0k|}
pj_lock_destroy:
  195|  6.79k|{
  196|  6.79k|    PJ_ASSERT_RETURN(lock != NULL, PJ_EINVAL);
  ------------------
  |  |   97|  6.79k|            do { \
  |  |   98|  6.79k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 6.79k]
  |  |  ------------------
  |  |   99|  6.79k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 6.79k]
  |  |  ------------------
  ------------------
  |  Branch (196:5): [True: 0, False: 0]
  |  Branch (196:5): [True: 0, False: 0]
  ------------------
  197|  6.79k|    return (*lock->destroy)(lock->lock_object);
  198|  6.79k|}
pj_grp_lock_create:
  413|  6.34k|{
  414|  6.34k|    pj_grp_lock_t *glock;
  415|  6.34k|    grp_lock_item *own_lock;
  416|  6.34k|    pj_status_t status;
  417|       |
  418|  6.34k|    PJ_ASSERT_RETURN(pool && p_grp_lock, PJ_EINVAL);
  ------------------
  |  |   97|  6.34k|            do { \
  |  |   98|  12.6k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 6.34k, False: 0]
  |  |  |  Branch (98:23): [True: 6.34k, False: 0]
  |  |  ------------------
  |  |   99|  6.34k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 6.34k]
  |  |  ------------------
  ------------------
  |  Branch (418:5): [True: 0, False: 0]
  |  Branch (418:5): [True: 0, False: 0]
  |  Branch (418:5): [True: 0, False: 0]
  |  Branch (418:5): [True: 0, False: 0]
  ------------------
  419|       |
  420|  6.34k|    PJ_UNUSED_ARG(cfg);
  ------------------
  |  | 1537|  6.34k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  421|       |
  422|  6.34k|    pool = pj_pool_create(pool->factory, "glck%p", 512, 512, NULL);
  423|  6.34k|    if (!pool)
  ------------------
  |  Branch (423:9): [True: 0, False: 6.34k]
  ------------------
  424|      0|        return PJ_ENOMEM;
  ------------------
  |  |  408|      0|#define PJ_ENOMEM           (PJ_ERRNO_START_STATUS + 7) /* 70007 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  425|       |
  426|  6.34k|    glock = PJ_POOL_ZALLOC_T(pool, pj_grp_lock_t);
  ------------------
  |  |  583|  6.34k|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  427|  6.34k|    glock->base.lock_object = glock;
  428|  6.34k|    glock->base.acquire = &grp_lock_acquire;
  429|  6.34k|    glock->base.tryacquire = &grp_lock_tryacquire;
  430|  6.34k|    glock->base.release = &grp_lock_release;
  431|  6.34k|    glock->base.destroy = &grp_lock_destroy;
  432|       |
  433|  6.34k|    glock->pool = pool;
  434|  6.34k|    pj_list_init(&glock->lock_list);
  435|  6.34k|    pj_list_init(&glock->destroy_list);
  436|       |#if PJ_GRP_LOCK_DEBUG
  437|       |    pj_list_init(&glock->ref_list);
  438|       |    pj_list_init(&glock->ref_free_list);
  439|       |#endif
  440|       |
  441|  6.34k|    status = pj_atomic_create(pool, 0, &glock->ref_cnt);
  442|  6.34k|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (442:9): [True: 0, False: 6.34k]
  ------------------
  443|      0|        goto on_error;
  444|       |
  445|  6.34k|    status = pj_lock_create_recursive_mutex(pool, pool->obj_name,
  446|  6.34k|                                            &glock->own_lock);
  447|  6.34k|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (447:9): [True: 0, False: 6.34k]
  ------------------
  448|      0|        goto on_error;
  449|       |
  450|  6.34k|    own_lock = PJ_POOL_ZALLOC_T(pool, grp_lock_item);
  ------------------
  |  |  583|  6.34k|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  451|  6.34k|    own_lock->lock = glock->own_lock;
  452|  6.34k|    pj_list_push_back(&glock->lock_list, own_lock);
  453|       |
  454|  6.34k|    *p_grp_lock = glock;
  455|  6.34k|    return PJ_SUCCESS;
  456|       |
  457|      0|on_error:
  458|      0|    grp_lock_destroy(glock);
  459|      0|    return status;
  460|  6.34k|}
pj_grp_lock_acquire:
  485|  6.68k|{
  486|  6.68k|    return grp_lock_acquire(grp_lock);
  487|  6.68k|}
pj_grp_lock_release:
  495|  6.68k|{
  496|  6.68k|    return grp_lock_release(grp_lock);
  497|  6.68k|}
pj_grp_lock_add_handler:
  527|  6.27k|{
  528|  6.27k|    return grp_lock_add_handler(glock, pool, comp, destroy, PJ_TRUE);
  529|  6.27k|}
pj_grp_lock_add_ref:
  648|  28.0k|{
  649|  28.0k|    return grp_lock_add_ref(glock);
  650|  28.0k|}
pj_grp_lock_dec_ref:
  653|  28.0k|{
  654|  28.0k|    return grp_lock_dec_ref(glock);
  655|  28.0k|}
pj_grp_lock_chain_lock:
  666|    347|{
  667|    347|    grp_lock_item *lck, *new_lck;
  668|    347|    int i;
  669|       |
  670|    347|    grp_lock_acquire(glock);
  671|       |
  672|    694|    for (i=0; i<glock->owner_cnt; ++i)
  ------------------
  |  Branch (672:15): [True: 347, False: 347]
  ------------------
  673|    347|        pj_lock_acquire(lock);
  674|       |
  675|    347|    lck = glock->lock_list.next;
  676|    347|    while (lck != &glock->lock_list) {
  ------------------
  |  Branch (676:12): [True: 347, False: 0]
  ------------------
  677|    347|        if (lck->prio >= pos)
  ------------------
  |  Branch (677:13): [True: 347, False: 0]
  ------------------
  678|    347|            break;
  679|      0|        lck = lck->next;
  680|      0|    }
  681|       |
  682|    347|    new_lck = PJ_POOL_ZALLOC_T(glock->pool, grp_lock_item);
  ------------------
  |  |  583|    347|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  683|    347|    new_lck->prio = pos;
  684|    347|    new_lck->lock = lock;
  685|    347|    pj_list_insert_before(lck, new_lck);
  686|       |
  687|       |    /* this will also release the new lock */
  688|    347|    grp_lock_release(glock);
  689|    347|    return PJ_SUCCESS;
  690|    347|}
pj_grp_lock_unchain_lock:
  694|    347|{
  695|    347|    grp_lock_item *lck;
  696|       |
  697|    347|    grp_lock_acquire(glock);
  698|       |
  699|    347|    lck = glock->lock_list.next;
  700|    347|    while (lck != &glock->lock_list) {
  ------------------
  |  Branch (700:12): [True: 347, False: 0]
  ------------------
  701|    347|        if (lck->lock == lock)
  ------------------
  |  Branch (701:13): [True: 347, False: 0]
  ------------------
  702|    347|            break;
  703|      0|        lck = lck->next;
  704|      0|    }
  705|       |
  706|    347|    if (lck != &glock->lock_list) {
  ------------------
  |  Branch (706:9): [True: 347, False: 0]
  ------------------
  707|    347|        int i;
  708|       |
  709|    347|        pj_list_erase(lck);
  710|    975|        for (i=0; i<glock->owner_cnt; ++i)
  ------------------
  |  Branch (710:19): [True: 628, False: 347]
  ------------------
  711|    628|            pj_lock_release(lck->lock);
  712|    347|    }
  713|       |
  714|    347|    grp_lock_release(glock);
  715|    347|    return PJ_SUCCESS;
  716|    347|}
lock.c:create_mutex_lock:
   62|  6.48k|{
   63|  6.48k|    pj_lock_t *p_lock;
   64|  6.48k|    pj_mutex_t *mutex;
   65|  6.48k|    pj_status_t rc;
   66|       |
   67|  6.48k|    PJ_ASSERT_RETURN(pool && lock, PJ_EINVAL);
  ------------------
  |  |   97|  6.48k|            do { \
  |  |   98|  12.9k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 6.48k, False: 0]
  |  |  |  Branch (98:23): [True: 6.48k, False: 0]
  |  |  ------------------
  |  |   99|  6.48k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 6.48k]
  |  |  ------------------
  ------------------
  |  Branch (67:5): [True: 0, False: 0]
  |  Branch (67:5): [True: 0, False: 0]
  |  Branch (67:5): [True: 0, False: 0]
  |  Branch (67:5): [True: 0, False: 0]
  ------------------
   68|       |
   69|  6.48k|    p_lock = PJ_POOL_ALLOC_T(pool, pj_lock_t);
  ------------------
  |  |  569|  6.48k|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
   70|  6.48k|    if (!p_lock)
  ------------------
  |  Branch (70:9): [True: 0, False: 6.48k]
  ------------------
   71|      0|        return PJ_ENOMEM;
  ------------------
  |  |  408|      0|#define PJ_ENOMEM           (PJ_ERRNO_START_STATUS + 7) /* 70007 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   72|       |
   73|  6.48k|    pj_memcpy(p_lock, &mutex_lock_template, sizeof(pj_lock_t));
   74|  6.48k|    rc = pj_mutex_create(pool, name, type, &mutex);
   75|  6.48k|    if (rc != PJ_SUCCESS)
  ------------------
  |  Branch (75:9): [True: 0, False: 6.48k]
  ------------------
   76|      0|        return rc;
   77|       |
   78|  6.48k|    p_lock->lock_object = mutex;
   79|  6.48k|    *lock = p_lock;
   80|  6.48k|    return PJ_SUCCESS;
   81|  6.48k|}
lock.c:null_op:
  103|    449|{
  104|    449|    PJ_UNUSED_ARG(arg);
  ------------------
  |  | 1537|    449|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  105|    449|    return PJ_SUCCESS;
  106|    449|}
lock.c:grp_lock_acquire:
  289|  16.3k|{
  290|  16.3k|    pj_grp_lock_t *glock = (pj_grp_lock_t*)p;
  291|  16.3k|    grp_lock_item *lck;
  292|       |
  293|  16.3k|    pj_assert(pj_atomic_get(glock->ref_cnt) > 0);
  ------------------
  |  |   65|  16.3k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (293:5): [True: 0, False: 16.3k]
  |  Branch (293:5): [True: 16.3k, False: 0]
  ------------------
  294|       |
  295|  16.3k|    lck = glock->lock_list.next;
  296|  35.1k|    while (lck != &glock->lock_list) {
  ------------------
  |  Branch (296:12): [True: 18.7k, False: 16.3k]
  ------------------
  297|  18.7k|        pj_lock_acquire(lck->lock);
  298|  18.7k|        lck = lck->next;
  299|  18.7k|    }
  300|  16.3k|    grp_lock_set_owner_thread(glock);
  301|  16.3k|    pj_grp_lock_add_ref(glock);
  302|  16.3k|    return PJ_SUCCESS;
  303|  16.3k|}
lock.c:grp_lock_set_owner_thread:
  260|  16.3k|{
  261|  16.3k|    if (!glock->owner) {
  ------------------
  |  Branch (261:9): [True: 9.19k, False: 7.19k]
  ------------------
  262|  9.19k|#if PJ_HAS_THREADS
  263|  9.19k|        glock->owner = pj_thread_this();
  264|       |#else
  265|       |        glock->owner = (pj_thread_t *) -1;
  266|       |#endif
  267|  9.19k|        glock->owner_cnt = 1;
  268|  9.19k|    } else {
  269|  7.19k|#if PJ_HAS_THREADS
  270|  7.19k|        pj_assert(glock->owner == pj_thread_this());
  ------------------
  |  |   65|  7.19k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (270:9): [True: 0, False: 7.19k]
  |  Branch (270:9): [True: 7.19k, False: 0]
  ------------------
  271|  7.19k|#endif
  272|  7.19k|        glock->owner_cnt++;
  273|  7.19k|    }
  274|  16.3k|}
lock.c:grp_lock_release:
  331|  16.3k|{
  332|  16.3k|    pj_grp_lock_t *glock = (pj_grp_lock_t*)p;
  333|  16.3k|    grp_lock_item *lck;
  334|       |
  335|  16.3k|    grp_lock_unset_owner_thread(glock);
  336|       |
  337|  16.3k|    lck = glock->lock_list.prev;
  338|  34.8k|    while (lck != &glock->lock_list) {
  ------------------
  |  Branch (338:12): [True: 18.4k, False: 16.3k]
  ------------------
  339|  18.4k|        pj_lock_release(lck->lock);
  340|  18.4k|        lck = lck->prev;
  341|  18.4k|    }
  342|  16.3k|    return pj_grp_lock_dec_ref(glock);
  343|  16.3k|}
lock.c:grp_lock_unset_owner_thread:
  277|  16.3k|{
  278|  16.3k|#if PJ_HAS_THREADS
  279|  16.3k|    pj_assert(glock->owner == pj_thread_this());
  ------------------
  |  |   65|  16.3k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (279:5): [True: 0, False: 16.3k]
  |  Branch (279:5): [True: 16.3k, False: 0]
  ------------------
  280|  16.3k|#endif
  281|  16.3k|    pj_assert(glock->owner_cnt > 0);
  ------------------
  |  |   65|  16.3k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (281:5): [True: 0, False: 16.3k]
  |  Branch (281:5): [True: 16.3k, False: 0]
  ------------------
  282|  16.3k|    if (--glock->owner_cnt <= 0) {
  ------------------
  |  Branch (282:9): [True: 9.19k, False: 7.19k]
  ------------------
  283|       |        glock->owner = NULL;
  284|  9.19k|        glock->owner_cnt = 0;
  285|  9.19k|    }
  286|  16.3k|}
lock.c:grp_lock_destroy:
  371|  6.34k|{
  372|  6.34k|    pj_grp_lock_t *glock = (pj_grp_lock_t*)p;
  373|  6.34k|    pj_pool_t *pool = glock->pool;
  374|  6.34k|    grp_lock_item *lck;
  375|  6.34k|    grp_destroy_callback *cb;
  376|       |
  377|  6.34k|    if (!glock->pool) {
  ------------------
  |  Branch (377:9): [True: 0, False: 6.34k]
  ------------------
  378|       |        /* already destroyed?! */
  379|      0|        return PJ_EINVAL;
  ------------------
  |  |  393|      0|#define PJ_EINVAL           (PJ_ERRNO_START_STATUS + 4) /* 70004 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  380|      0|    }
  381|       |
  382|       |    /* Release all chained locks */
  383|  6.34k|    lck = glock->lock_list.next;
  384|  12.6k|    while (lck != &glock->lock_list) {
  ------------------
  |  Branch (384:12): [True: 6.34k, False: 6.34k]
  ------------------
  385|  6.34k|        if (lck->lock != glock->own_lock) {
  ------------------
  |  Branch (385:13): [True: 0, False: 6.34k]
  ------------------
  386|      0|            int i;
  387|      0|            for (i=0; i<glock->owner_cnt; ++i)
  ------------------
  |  Branch (387:23): [True: 0, False: 0]
  ------------------
  388|      0|                pj_lock_release(lck->lock);
  389|      0|        }
  390|  6.34k|        lck = lck->next;
  391|  6.34k|    }
  392|       |
  393|       |    /* Call callbacks */
  394|  6.34k|    cb = glock->destroy_list.next;
  395|  12.6k|    while (cb != &glock->destroy_list) {
  ------------------
  |  Branch (395:12): [True: 6.27k, False: 6.34k]
  ------------------
  396|  6.27k|        grp_destroy_callback *next = cb->next;
  397|  6.27k|        cb->handler(cb->comp);
  398|  6.27k|        cb = next;
  399|  6.27k|    }
  400|       |
  401|  6.34k|    pj_lock_destroy(glock->own_lock);
  402|  6.34k|    pj_atomic_destroy(glock->ref_cnt);
  403|  6.34k|    glock->pool = NULL;
  404|  6.34k|    pj_pool_release(pool);
  405|       |
  406|  6.34k|    return PJ_SUCCESS;
  407|  6.34k|}
lock.c:grp_lock_add_handler:
  350|  6.27k|{
  351|  6.27k|    grp_destroy_callback *cb;
  352|       |
  353|  6.27k|    if (acquire_lock)
  ------------------
  |  Branch (353:9): [True: 6.27k, False: 0]
  ------------------
  354|  6.27k|        grp_lock_acquire(glock);
  355|       |
  356|  6.27k|    if (pool == NULL)
  ------------------
  |  Branch (356:9): [True: 0, False: 6.27k]
  ------------------
  357|      0|        pool = glock->pool;
  358|       |
  359|  6.27k|    cb = PJ_POOL_ZALLOC_T(pool, grp_destroy_callback);
  ------------------
  |  |  583|  6.27k|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  360|  6.27k|    cb->comp = comp;
  361|  6.27k|    cb->handler = destroy;
  362|  6.27k|    pj_list_push_back(&glock->destroy_list, cb);
  363|       |
  364|  6.27k|    if (acquire_lock)
  ------------------
  |  Branch (364:9): [True: 6.27k, False: 0]
  ------------------
  365|  6.27k|        grp_lock_release(glock);
  366|       |
  367|  6.27k|    return PJ_SUCCESS;
  368|  6.27k|}
lock.c:grp_lock_add_ref:
  554|  28.0k|{
  555|  28.0k|    pj_atomic_inc(glock->ref_cnt);
  556|  28.0k|    return PJ_SUCCESS;
  557|  28.0k|}
lock.c:grp_lock_dec_ref:
  560|  28.0k|{
  561|  28.0k|    int cnt; /* for debugging */
  562|  28.0k|    if ((cnt=pj_atomic_dec_and_get(glock->ref_cnt)) == 0) {
  ------------------
  |  Branch (562:9): [True: 6.34k, False: 21.7k]
  ------------------
  563|  6.34k|        grp_lock_destroy(glock);
  564|  6.34k|        return PJ_EGONE;
  ------------------
  |  |  489|  6.34k|#define PJ_EGONE            (PJ_ERRNO_START_STATUS + 23)/* 70023 */
  |  |  ------------------
  |  |  |  |  521|  6.34k|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|  6.34k|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|  6.34k|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  565|  6.34k|    }
  566|  21.7k|    pj_assert(cnt > 0);
  ------------------
  |  |   65|  21.7k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (566:5): [True: 0, False: 21.7k]
  |  Branch (566:5): [True: 21.7k, False: 0]
  ------------------
  567|  21.7k|    return PJ_SUCCESS;
  568|  21.7k|}

pj_log_set_indent:
  104|  6.85k|{
  105|  6.85k|    if (indent < 0) indent = 0;
  ------------------
  |  Branch (105:9): [True: 0, False: 6.85k]
  ------------------
  106|  6.85k|    pj_thread_local_set(thread_indent_tls_id, (void*)(pj_ssize_t)indent);
  107|  6.85k|}
pj_log_get_indent:
  128|     18|{
  129|     18|    int indent = log_get_raw_indent();
  130|     18|    return indent > LOG_MAX_INDENT ? LOG_MAX_INDENT : indent;
  ------------------
  |  |   84|     18|#define LOG_MAX_INDENT          80
  ------------------
                  return indent > LOG_MAX_INDENT ? LOG_MAX_INDENT : indent;
  ------------------
  |  |   84|      0|#define LOG_MAX_INDENT          80
  ------------------
  |  Branch (130:12): [True: 0, False: 18]
  ------------------
  131|     18|}
pj_log_add_indent:
  134|  6.85k|{
  135|  6.85k|    pj_log_set_indent(log_get_raw_indent() + indent);
  136|  6.85k|}
pj_log_push_indent:
  139|  3.42k|{
  140|  3.42k|    pj_log_add_indent(PJ_LOG_INDENT_SIZE);
  ------------------
  |  |  460|  3.42k|#   define PJ_LOG_INDENT_SIZE        1
  ------------------
  141|  3.42k|}
pj_log_pop_indent:
  144|  3.42k|{
  145|  3.42k|    pj_log_add_indent(-PJ_LOG_INDENT_SIZE);
  ------------------
  |  |  460|  3.42k|#   define PJ_LOG_INDENT_SIZE        1
  ------------------
  146|  3.42k|}
pj_log_init:
  149|      2|{
  150|      2|#if PJ_HAS_THREADS
  151|      2|    if (thread_suspended_tls_id == -1) {
  ------------------
  |  Branch (151:9): [True: 2, False: 0]
  ------------------
  152|      2|        pj_status_t status;
  153|      2|        status = pj_thread_local_alloc(&thread_suspended_tls_id);
  154|      2|        if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (154:13): [True: 0, False: 2]
  ------------------
  155|      0|            thread_suspended_tls_id = -1;
  156|      0|            return status;
  157|      0|        }
  158|       |
  159|      2|#  if PJ_LOG_ENABLE_INDENT
  160|      2|        status = pj_thread_local_alloc(&thread_indent_tls_id);
  161|      2|        if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (161:13): [True: 0, False: 2]
  ------------------
  162|      0|            pj_thread_local_free(thread_suspended_tls_id);
  163|      0|            thread_suspended_tls_id = -1;
  164|      0|            thread_indent_tls_id = -1;
  165|      0|            return status;
  166|      0|        }
  167|      2|#  endif
  168|      2|        pj_atexit(&logging_shutdown);
  169|      2|    }
  170|      2|#endif
  171|      2|    g_last_thread = NULL;
  172|       |
  173|       |    /* Normalize log decor, e.g: unset thread flags when threading is
  174|       |     * disabled.
  175|       |     */
  176|      2|    pj_log_set_decor(pj_log_get_decor());
  177|       |
  178|      2|    return PJ_SUCCESS;
  179|      2|}
pj_log_set_decor:
  182|      2|{
  183|      2|    log_decor = decor;
  184|       |
  185|       |#if !PJ_HAS_THREADS
  186|       |    /* Unset thread related flags */
  187|       |    if (log_decor & PJ_LOG_HAS_THREAD_ID) {
  188|       |       log_decor &= ~(PJ_LOG_HAS_THREAD_ID);
  189|       |    }
  190|       |    if (log_decor & PJ_LOG_HAS_THREAD_SWC) {
  191|       |       log_decor &= ~(PJ_LOG_HAS_THREAD_SWC);
  192|       |    }
  193|       |#endif
  194|      2|}
pj_log_get_decor:
  197|     20|{
  198|     20|    return log_decor;
  199|     20|}
pj_log_set_level:
  252|      2|{
  253|      2|    pj_log_max_level = level;
  254|      2|}
pj_log_get_level:
  258|  22.9k|{
  259|  22.9k|    return pj_log_max_level;
  260|  22.9k|}
pj_log:
  340|     18|{
  341|     18|    pj_time_val now;
  342|     18|    pj_parsed_time ptime;
  343|     18|    char *pre;
  344|     18|#if PJ_LOG_USE_STACK_BUFFER
  345|     18|    char log_buffer[PJ_LOG_MAX_SIZE];
  346|     18|#endif
  347|     18|    int saved_level, len, print_len;
  348|       |
  349|     18|    PJ_CHECK_STACK();
  350|       |
  351|     18|    if (level > pj_log_max_level)
  ------------------
  |  Branch (351:9): [True: 0, False: 18]
  ------------------
  352|      0|        return;
  353|       |
  354|     18|    if (is_logging_suspended())
  ------------------
  |  Branch (354:9): [True: 0, False: 18]
  ------------------
  355|      0|        return;
  356|       |
  357|       |    /* Temporarily disable logging for this thread. Some of PJLIB APIs that
  358|       |     * this function calls below will recursively call the logging function 
  359|       |     * back, hence it will cause infinite recursive calls if we allow that.
  360|       |     */
  361|     18|    suspend_logging(&saved_level);
  362|       |
  363|       |    /* Get current date/time. */
  364|     18|    pj_gettimeofday(&now);
  365|     18|    pj_time_decode(&now, &ptime);
  366|       |
  367|     18|    pre = log_buffer;
  368|     18|    if (log_decor & PJ_LOG_HAS_LEVEL_TEXT) {
  ------------------
  |  Branch (368:9): [True: 0, False: 18]
  ------------------
  369|      0|        static const char *ltexts[] = { "FATAL:", "ERROR:", " WARN:", 
  370|      0|                              " INFO:", "DEBUG:", "TRACE:", "DETRC:"};
  371|      0|        pj_ansi_strxcpy(pre, ltexts[level], PJ_LOG_MAX_SIZE);
  ------------------
  |  |  429|      0|#  define PJ_LOG_MAX_SIZE           4000
  ------------------
  372|      0|        pre += 6;
  373|      0|    }
  374|     18|    if (log_decor & PJ_LOG_HAS_DAY_NAME) {
  ------------------
  |  Branch (374:9): [True: 0, False: 18]
  ------------------
  375|      0|        static const char *wdays[] = { "Sun", "Mon", "Tue", "Wed",
  376|      0|                                       "Thu", "Fri", "Sat"};
  377|      0|        pj_ansi_strxcpy(pre, wdays[ptime.wday], PJ_LOG_MAX_SIZE-6);
  ------------------
  |  |  429|      0|#  define PJ_LOG_MAX_SIZE           4000
  ------------------
  378|      0|        pre += 3;
  379|      0|    }
  380|     18|    if (log_decor & PJ_LOG_HAS_YEAR) {
  ------------------
  |  Branch (380:9): [True: 0, False: 18]
  ------------------
  381|      0|        if (pre!=log_buffer) *pre++ = ' ';
  ------------------
  |  Branch (381:13): [True: 0, False: 0]
  ------------------
  382|      0|        pre += pj_utoa(ptime.year, pre);
  383|      0|    }
  384|     18|    if (log_decor & PJ_LOG_HAS_MONTH) {
  ------------------
  |  Branch (384:9): [True: 0, False: 18]
  ------------------
  385|      0|        *pre++ = '-';
  386|      0|        pre += pj_utoa_pad(ptime.mon+1, pre, 2, '0');
  387|      0|    }
  388|     18|    if (log_decor & PJ_LOG_HAS_DAY_OF_MON) {
  ------------------
  |  Branch (388:9): [True: 0, False: 18]
  ------------------
  389|      0|        *pre++ = '-';
  390|      0|        pre += pj_utoa_pad(ptime.day, pre, 2, '0');
  391|      0|    }
  392|     18|    if (log_decor & PJ_LOG_HAS_TIME) {
  ------------------
  |  Branch (392:9): [True: 18, False: 0]
  ------------------
  393|     18|        if (pre!=log_buffer) *pre++ = ' ';
  ------------------
  |  Branch (393:13): [True: 0, False: 18]
  ------------------
  394|     18|        pre += pj_utoa_pad(ptime.hour, pre, 2, '0');
  395|     18|        *pre++ = ':';
  396|     18|        pre += pj_utoa_pad(ptime.min, pre, 2, '0');
  397|     18|        *pre++ = ':';
  398|     18|        pre += pj_utoa_pad(ptime.sec, pre, 2, '0');
  399|     18|    }
  400|     18|    if (log_decor & PJ_LOG_HAS_MICRO_SEC) {
  ------------------
  |  Branch (400:9): [True: 18, False: 0]
  ------------------
  401|     18|        *pre++ = '.';
  402|     18|        pre += pj_utoa_pad(ptime.msec, pre, 3, '0');
  403|     18|    }
  404|     18|    if (log_decor & PJ_LOG_HAS_SENDER) {
  ------------------
  |  Branch (404:9): [True: 18, False: 0]
  ------------------
  405|     18|        enum { SENDER_WIDTH = PJ_LOG_SENDER_WIDTH };
  406|     18|        pj_size_t sender_len = strlen(sender);
  407|     18|        if (pre!=log_buffer) *pre++ = ' ';
  ------------------
  |  Branch (407:13): [True: 18, False: 0]
  ------------------
  408|     18|        if (sender_len <= SENDER_WIDTH) {
  ------------------
  |  Branch (408:13): [True: 18, False: 0]
  ------------------
  409|    178|            while (sender_len < SENDER_WIDTH)
  ------------------
  |  Branch (409:20): [True: 160, False: 18]
  ------------------
  410|    160|                *pre++ = ' ', ++sender_len;
  411|    254|            while (*sender)
  ------------------
  |  Branch (411:20): [True: 236, False: 18]
  ------------------
  412|    236|                *pre++ = *sender++;
  413|     18|        } else {
  414|      0|            int i;
  415|      0|            for (i=0; i<SENDER_WIDTH; ++i)
  ------------------
  |  Branch (415:23): [True: 0, False: 0]
  ------------------
  416|      0|                *pre++ = *sender++;
  417|      0|        }
  418|     18|    }
  419|     18|    if (log_decor & PJ_LOG_HAS_THREAD_ID) {
  ------------------
  |  Branch (419:9): [True: 0, False: 18]
  ------------------
  420|      0|        enum { THREAD_WIDTH = PJ_LOG_THREAD_WIDTH };
  421|      0|        const char *thread_name = pj_thread_get_name(pj_thread_this());
  422|      0|        pj_size_t thread_len = strlen(thread_name);
  423|      0|        *pre++ = ' ';
  424|      0|        if (thread_len <= THREAD_WIDTH) {
  ------------------
  |  Branch (424:13): [True: 0, False: 0]
  ------------------
  425|      0|            while (thread_len < THREAD_WIDTH)
  ------------------
  |  Branch (425:20): [True: 0, False: 0]
  ------------------
  426|      0|                *pre++ = ' ', ++thread_len;
  427|      0|            while (*thread_name)
  ------------------
  |  Branch (427:20): [True: 0, False: 0]
  ------------------
  428|      0|                *pre++ = *thread_name++;
  429|      0|        } else {
  430|      0|            int i;
  431|      0|            for (i=0; i<THREAD_WIDTH; ++i)
  ------------------
  |  Branch (431:23): [True: 0, False: 0]
  ------------------
  432|      0|                *pre++ = *thread_name++;
  433|      0|        }
  434|      0|    }
  435|       |
  436|     18|    if (log_decor != 0 && log_decor != PJ_LOG_HAS_NEWLINE)
  ------------------
  |  Branch (436:9): [True: 18, False: 0]
  |  Branch (436:27): [True: 18, False: 0]
  ------------------
  437|     18|        *pre++ = ' ';
  438|       |
  439|     18|    if (log_decor & PJ_LOG_HAS_THREAD_SWC) {
  ------------------
  |  Branch (439:9): [True: 18, False: 0]
  ------------------
  440|     18|        void *current_thread = (void*)pj_thread_this();
  441|     18|        if (current_thread != g_last_thread) {
  ------------------
  |  Branch (441:13): [True: 2, False: 16]
  ------------------
  442|      2|            *pre++ = '!';
  443|      2|            g_last_thread = current_thread;
  444|     16|        } else {
  445|     16|            *pre++ = ' ';
  446|     16|        }
  447|     18|    } else if (log_decor & PJ_LOG_HAS_SPACE) {
  ------------------
  |  Branch (447:16): [True: 0, False: 0]
  ------------------
  448|      0|        *pre++ = ' ';
  449|      0|    }
  450|       |
  451|     18|#if PJ_LOG_ENABLE_INDENT
  452|     18|    if (log_decor & PJ_LOG_HAS_INDENT) {
  ------------------
  |  Branch (452:9): [True: 18, False: 0]
  ------------------
  453|     18|        int indent = pj_log_get_indent();
  454|     18|        if (indent > 0) {
  ------------------
  |  Branch (454:13): [True: 0, False: 18]
  ------------------
  455|      0|            pj_memset(pre, PJ_LOG_INDENT_CHAR, indent);
  ------------------
  |  |  469|      0|#   define PJ_LOG_INDENT_CHAR       '.'
  ------------------
  456|      0|            pre += indent;
  457|      0|        }
  458|     18|    }
  459|     18|#endif
  460|       |
  461|     18|    len = (int)(pre - log_buffer);
  462|       |
  463|       |    /* Print the whole message to the string log_buffer. */
  464|     18|    print_len = pj_ansi_vsnprintf(pre, sizeof(log_buffer)-len, format, 
  ------------------
  |  |  122|     18|#define pj_ansi_vsnprintf       vsnprintf
  ------------------
  465|     18|                                  marker);
  466|     18|    if (print_len < 0) {
  ------------------
  |  Branch (466:9): [True: 0, False: 18]
  ------------------
  467|      0|        level = 1;
  468|      0|        print_len = pj_ansi_snprintf(pre, sizeof(log_buffer)-len, 
  ------------------
  |  |  114|      0|#define pj_ansi_snprintf        snprintf
  ------------------
  469|      0|                                     "<logging error: msg too long>");
  470|      0|    }
  471|     18|    if (print_len < 0 || print_len >= (int)(sizeof(log_buffer)-len)) {
  ------------------
  |  Branch (471:9): [True: 0, False: 18]
  |  Branch (471:26): [True: 0, False: 18]
  ------------------
  472|      0|        print_len = sizeof(log_buffer) - len - 1;
  473|      0|    }
  474|     18|    len = len + print_len;
  475|     18|    if (len >= 0 && len < (int)sizeof(log_buffer)-2) {
  ------------------
  |  Branch (475:9): [True: 18, False: 0]
  |  Branch (475:21): [True: 18, False: 0]
  ------------------
  476|     18|        if (log_decor & PJ_LOG_HAS_CR) {
  ------------------
  |  Branch (476:13): [True: 0, False: 18]
  ------------------
  477|      0|            log_buffer[len++] = '\r';
  478|      0|        }
  479|     18|        if (log_decor & PJ_LOG_HAS_NEWLINE) {
  ------------------
  |  Branch (479:13): [True: 18, False: 0]
  ------------------
  480|     18|            log_buffer[len++] = '\n';
  481|     18|        }
  482|     18|        log_buffer[len] = '\0';
  483|     18|    } else {
  484|      0|        len = sizeof(log_buffer)-1;
  485|      0|        if (log_decor & PJ_LOG_HAS_CR) {
  ------------------
  |  Branch (485:13): [True: 0, False: 0]
  ------------------
  486|      0|            log_buffer[sizeof(log_buffer)-3] = '\r';
  487|      0|        }
  488|      0|        if (log_decor & PJ_LOG_HAS_NEWLINE) {
  ------------------
  |  Branch (488:13): [True: 0, False: 0]
  ------------------
  489|      0|            log_buffer[sizeof(log_buffer)-2] = '\n';
  490|      0|        }
  491|      0|        log_buffer[sizeof(log_buffer)-1] = '\0';
  492|      0|    }
  493|       |
  494|       |    /* It should be safe to resume logging at this point. Application can
  495|       |     * recursively call the logging function inside the callback.
  496|       |     */
  497|     18|    resume_logging(&saved_level);
  498|       |
  499|     18|    if (log_writer)
  ------------------
  |  Branch (499:9): [True: 18, False: 0]
  ------------------
  500|     18|        (*log_writer)(level, log_buffer, len);
  501|     18|}
pj_log_4:
  548|     14|{
  549|     14|    va_list arg;
  550|     14|    va_start(arg, format);
  551|     14|    pj_log(obj, 4, format, arg);
  552|       |    va_end(arg);
  553|     14|}
pj_log_5:
  559|      4|{
  560|      4|    va_list arg;
  561|      4|    va_start(arg, format);
  562|      4|    pj_log(obj, 5, format, arg);
  563|       |    va_end(arg);
  564|      4|}
log.c:log_get_raw_indent:
  110|  6.87k|{
  111|  6.87k|    return (long)(pj_ssize_t)pj_thread_local_get(thread_indent_tls_id);
  112|  6.87k|}
log.c:is_logging_suspended:
  323|     18|{
  324|     18|#if PJ_HAS_THREADS
  325|     18|    if (thread_suspended_tls_id != -1) 
  ------------------
  |  Branch (325:9): [True: 18, False: 0]
  ------------------
  326|     18|    {
  327|     18|        pj_ssize_t *ils;
  328|     18|        ils = (pj_ssize_t *)pj_thread_local_get(thread_suspended_tls_id);
  329|     18|        return (ils? (*ils == PJ_TRUE): PJ_FALSE);
  ------------------
  |  Branch (329:17): [True: 16, False: 2]
  ------------------
  330|     18|    }
  331|      0|    else
  332|      0|#endif
  333|      0|    {
  334|      0|        return pj_log_max_level == 0;
  335|      0|    }
  336|     18|}
log.c:suspend_logging:
  280|     18|{
  281|       |    /* Save the level regardless, just in case PJLIB is shutdown
  282|       |     * between suspend and resume.
  283|       |     */
  284|     18|    *saved_level = pj_log_max_level;
  285|       |
  286|     18|#if PJ_HAS_THREADS
  287|     18|    if (thread_suspended_tls_id != -1) 
  ------------------
  |  Branch (287:9): [True: 18, False: 0]
  ------------------
  288|     18|    {
  289|     18|        static pj_ssize_t suspend_log = PJ_TRUE;
  290|     18|        pj_thread_local_set(thread_suspended_tls_id, 
  291|     18|                            (void*)&suspend_log);
  292|     18|    } 
  293|      0|    else
  294|      0|#endif
  295|      0|    {
  296|      0|        pj_log_max_level = 0;
  297|      0|    }
  298|     18|}
log.c:resume_logging:
  302|     18|{
  303|     18|#if PJ_HAS_THREADS
  304|     18|    if (thread_suspended_tls_id != -1) 
  ------------------
  |  Branch (304:9): [True: 18, False: 0]
  ------------------
  305|     18|    {
  306|     18|        static pj_ssize_t suspend_log = PJ_FALSE;
  307|     18|        pj_thread_local_set(thread_suspended_tls_id, 
  308|     18|                            (void*)&suspend_log);
  309|     18|    }
  310|      0|    else
  311|      0|#endif
  312|      0|    {
  313|       |        /* Only revert the level if application doesn't change the
  314|       |         * logging level between suspend and resume.
  315|       |         */
  316|      0|        if (pj_log_max_level==0 && *saved_level)
  ------------------
  |  Branch (316:13): [True: 0, False: 0]
  |  Branch (316:36): [True: 0, False: 0]
  ------------------
  317|      0|            pj_log_max_level = *saved_level;
  318|      0|    }
  319|     18|}

pj_log_write:
   43|     18|{
   44|     18|    PJ_CHECK_STACK();
   45|     18|    PJ_UNUSED_ARG(len);
  ------------------
  |  | 1537|     18|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
   46|       |
   47|       |    /* Copy to terminal/file. */
   48|     18|    if (pj_log_get_decor() & PJ_LOG_HAS_COLOR) {
  ------------------
  |  Branch (48:9): [True: 0, False: 18]
  ------------------
   49|      0|        term_set_color(level);
   50|      0|        printf("%s", buffer);
   51|      0|        term_restore_color();
   52|     18|    } else {
   53|     18|        printf("%s", buffer);
   54|     18|    }
   55|     18|}

pj_init:
  202|      2|{
  203|      2|    char dummy_guid[PJ_GUID_MAX_LENGTH];
  204|      2|    pj_str_t guid;
  205|      2|    pj_status_t rc;
  206|       |
  207|       |    /* Check if PJLIB have been initialized */
  208|      2|    if (initialized) {
  ------------------
  |  Branch (208:9): [True: 0, False: 2]
  ------------------
  209|      0|        ++initialized;
  210|      0|        return PJ_SUCCESS;
  211|      0|    }
  212|       |
  213|       |    /* Init logging */
  214|      2|    pj_log_init();
  215|       |
  216|      2|#if PJ_HAS_THREADS
  217|       |    /* Init this thread's TLS. */
  218|      2|    if ((rc=pj_thread_init()) != 0) {
  ------------------
  |  Branch (218:9): [True: 0, False: 2]
  ------------------
  219|      0|        return rc;
  220|      0|    }
  221|       |
  222|       |    /* Critical section. */
  223|      2|    if ((rc=init_mutex(&critical_section, "critsec", PJ_MUTEX_RECURSE)) != 0)
  ------------------
  |  Branch (223:9): [True: 0, False: 2]
  ------------------
  224|      0|        return rc;
  225|       |
  226|      2|#endif
  227|       |
  228|       |    /* Initialize exception ID for the pool.
  229|       |     * Must do so after critical section is configured.
  230|       |     */
  231|      2|    rc = pj_exception_id_alloc("PJLIB/No memory", &PJ_NO_MEMORY_EXCEPTION);
  232|      2|    if (rc != PJ_SUCCESS)
  ------------------
  |  Branch (232:9): [True: 0, False: 2]
  ------------------
  233|      0|        return rc;
  234|       |
  235|       |    /* Init random seed. */
  236|       |    /* Or probably not. Let application in charge of this */
  237|       |    /* pj_srand( clock() ); */
  238|       |
  239|       |    /* Startup GUID. */
  240|      2|    guid.ptr = dummy_guid;
  241|      2|    pj_generate_unique_string( &guid );
  242|       |
  243|       |    /* Startup timestamp */
  244|      2|#if defined(PJ_HAS_HIGH_RES_TIMER) && PJ_HAS_HIGH_RES_TIMER != 0
  245|      2|    {
  246|      2|        pj_timestamp dummy_ts;
  247|      2|        if ((rc=pj_get_timestamp(&dummy_ts)) != 0) {
  ------------------
  |  Branch (247:13): [True: 0, False: 2]
  ------------------
  248|      0|            return rc;
  249|      0|        }
  250|      2|    }
  251|      2|#endif
  252|       |
  253|       |    /* Flag PJLIB as initialized */
  254|      2|    ++initialized;
  255|      2|    pj_assert(initialized == 1);
  ------------------
  |  |   65|      2|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (255:5): [True: 0, False: 2]
  |  Branch (255:5): [True: 2, False: 0]
  ------------------
  256|       |
  257|      2|    PJ_LOG(4,(THIS_FILE, "pjlib %s for POSIX initialized",
  ------------------
  |  |  106|      2|#define PJ_LOG(level,arg)       do { \
  |  |  107|      2|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      4|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 2, Folded]
  |  |  |  Branch (107:70): [True: 2, False: 0]
  |  |  ------------------
  |  |  108|      2|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      2|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      2|                                    } \
  |  |  110|      2|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 2]
  |  |  ------------------
  ------------------
  258|      2|              PJ_VERSION));
  259|       |
  260|      2|    return PJ_SUCCESS;
  261|      2|}
pj_atexit:
  267|      5|{
  268|      5|    if (atexit_count >= PJ_ARRAY_SIZE(atexit_func))
  ------------------
  |  |  315|      5|#define PJ_ARRAY_SIZE(a)    (sizeof(a)/sizeof(a[0]))
  ------------------
  |  Branch (268:9): [True: 0, False: 5]
  ------------------
  269|      0|        return PJ_ETOOMANY;
  ------------------
  |  |  423|      0|#define PJ_ETOOMANY         (PJ_ERRNO_START_STATUS + 10)/* 70010 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  270|       |
  271|      5|    atexit_func[atexit_count++] = func;
  272|      5|    return PJ_SUCCESS;
  273|      5|}
pj_thread_register:
  608|      2|{
  609|      2|#if PJ_HAS_THREADS
  610|      2|    char stack_ptr;
  611|      2|    pj_status_t rc;
  612|      2|    pj_thread_t *thread = (pj_thread_t *)desc;
  613|      2|    pj_str_t thread_name = pj_str((char*)cstr_thread_name);
  614|       |
  615|       |    /* Size sanity check. */
  616|      2|    if (sizeof(pj_thread_desc) < sizeof(pj_thread_t)) {
  ------------------
  |  Branch (616:9): [Folded, False: 2]
  ------------------
  617|      0|        pj_assert(!"Not enough pj_thread_desc size!");
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (617:9): [Folded, False: 0]
  |  Branch (617:9): [Folded, False: 0]
  ------------------
  618|      0|        return PJ_EBUG;
  ------------------
  |  |  413|      0|#define PJ_EBUG             (PJ_ERRNO_START_STATUS + 8) /* 70008 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  619|      0|    }
  620|       |
  621|       |    /* Warn if this thread has been registered before */
  622|      2|    if (pj_thread_local_get (thread_tls_id) != 0) {
  ------------------
  |  Branch (622:9): [True: 0, False: 2]
  ------------------
  623|       |        // 2006-02-26 bennylp:
  624|       |        //  This wouldn't work in all cases!.
  625|       |        //  If thread is created by external module (e.g. sound thread),
  626|       |        //  thread may be reused while the pool used for the thread descriptor
  627|       |        //  has been deleted by application.
  628|       |        //*thread_ptr = (pj_thread_t*)pj_thread_local_get (thread_tls_id);
  629|       |        //return PJ_SUCCESS;
  630|      0|        PJ_LOG(4,(THIS_FILE, "Info: possibly re-registering existing "
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  631|      0|                             "thread"));
  632|      0|    }
  633|       |
  634|       |    /* On the other hand, also warn if the thread descriptor buffer seem to
  635|       |     * have been used to register other threads.
  636|       |     */
  637|      2|    pj_assert(thread->signature1 != SIGNATURE1 ||
  ------------------
  |  |   65|      2|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (637:5): [True: 2, False: 0]
  |  Branch (637:5): [True: 0, False: 0]
  |  Branch (637:5): [True: 0, False: 0]
  |  Branch (637:5): [True: 2, False: 0]
  |  Branch (637:5): [True: 0, False: 0]
  |  Branch (637:5): [True: 0, False: 0]
  ------------------
  638|      2|              thread->signature2 != SIGNATURE2 ||
  639|      2|              (thread->thread == pthread_self()));
  640|       |
  641|       |    /* Initialize and set the thread entry. */
  642|      2|    pj_bzero(desc, sizeof(struct pj_thread_t));
  643|      2|    thread->thread = pthread_self();
  644|      2|    thread->signature1 = SIGNATURE1;
  ------------------
  |  |   70|      2|#define SIGNATURE1  0xDEAFBEEF
  ------------------
  645|      2|    thread->signature2 = SIGNATURE2;
  ------------------
  |  |   71|      2|#define SIGNATURE2  0xDEADC0DE
  ------------------
  646|       |
  647|      2|    if(cstr_thread_name && pj_strlen(&thread_name) < sizeof(thread->obj_name)-1)
  ------------------
  |  Branch (647:8): [True: 2, False: 0]
  |  Branch (647:28): [True: 2, False: 0]
  ------------------
  648|      2|        pj_ansi_snprintf(thread->obj_name, sizeof(thread->obj_name),
  ------------------
  |  |  114|      2|#define pj_ansi_snprintf        snprintf
  ------------------
  649|      2|                         cstr_thread_name, thread->thread);
  650|      0|    else
  651|      0|        pj_ansi_snprintf(thread->obj_name, sizeof(thread->obj_name),
  ------------------
  |  |  114|      0|#define pj_ansi_snprintf        snprintf
  ------------------
  652|      0|                         "thr%p", (void*)thread->thread);
  653|       |
  654|      2|    rc = pj_thread_local_set(thread_tls_id, thread);
  655|      2|    if (rc != PJ_SUCCESS) {
  ------------------
  |  Branch (655:9): [True: 0, False: 2]
  ------------------
  656|      0|        pj_bzero(desc, sizeof(struct pj_thread_t));
  657|      0|        return rc;
  658|      0|    }
  659|       |
  660|       |#if defined(PJ_OS_HAS_CHECK_STACK) && PJ_OS_HAS_CHECK_STACK!=0
  661|       |    thread->stk_start = &stack_ptr;
  662|       |    thread->stk_size = 0xFFFFFFFFUL;
  663|       |    thread->stk_max_usage = 0;
  664|       |#else
  665|      2|    PJ_UNUSED_ARG(stack_ptr);
  ------------------
  |  | 1537|      2|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  666|      2|#endif
  667|       |
  668|      2|    *ptr_thread = thread;
  669|      2|    return PJ_SUCCESS;
  670|       |#else
  671|       |    pj_thread_t *thread = (pj_thread_t*)desc;
  672|       |    *ptr_thread = thread;
  673|       |    return PJ_SUCCESS;
  674|       |#endif
  675|      2|}
pj_thread_init:
  681|      2|{
  682|      2|#if PJ_HAS_THREADS
  683|      2|    pj_status_t rc;
  684|      2|    pj_thread_t *dummy;
  685|       |
  686|      2|    rc = pj_thread_local_alloc(&thread_tls_id );
  687|      2|    if (rc != PJ_SUCCESS) {
  ------------------
  |  Branch (687:9): [True: 0, False: 2]
  ------------------
  688|      0|        return rc;
  689|      0|    }
  690|      2|    return pj_thread_register("thr%p", main_thread_desc, &dummy);
  691|       |#else
  692|       |    PJ_LOG(2,(THIS_FILE, "Thread init error. Threading is not enabled!"));
  693|       |    return PJ_EINVALIDOP;
  694|       |#endif
  695|      2|}
pj_thread_create:
  863|      2|{
  864|      2|#if PJ_HAS_THREADS
  865|      2|    pj_status_t status;
  866|      2|    pj_thread_t *rec;
  867|      2|    void *stack_addr = NULL;
  868|      2|    int rc;
  869|       |
  870|      2|    PJ_CHECK_STACK();
  871|      2|    PJ_ASSERT_RETURN(pool && proc && ptr_thread, PJ_EINVAL);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      8|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 2, False: 0]
  |  |  |  Branch (98:23): [True: 2, False: 0]
  |  |  |  Branch (98:23): [True: 2, False: 0]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (871:5): [True: 0, False: 0]
  |  Branch (871:5): [True: 0, False: 0]
  |  Branch (871:5): [True: 0, False: 0]
  |  Branch (871:5): [True: 0, False: 0]
  |  Branch (871:5): [True: 0, False: 0]
  |  Branch (871:5): [True: 0, False: 0]
  ------------------
  872|       |
  873|       |    /* Create thread record and assign name for the thread */
  874|      2|    rec = (struct pj_thread_t*) pj_pool_zalloc(pool, sizeof(pj_thread_t));
  875|      2|    PJ_ASSERT_RETURN(rec, PJ_ENOMEM);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (875:5): [True: 0, False: 0]
  |  Branch (875:5): [True: 0, False: 0]
  ------------------
  876|       |
  877|       |#if defined(PJ_THREAD_ALLOCATE_STACK) && PJ_THREAD_ALLOCATE_STACK!=0
  878|       |    /* Allocate memory for the stack */
  879|       |    stack_addr = pj_pool_alloc(pool, stack_size);
  880|       |    PJ_ASSERT_RETURN(stack_addr, PJ_ENOMEM);
  881|       |#endif  /* PJ_THREAD_ALLOCATE_STACK */
  882|       |
  883|       |    /* Emulate suspended thread with mutex. */
  884|      2|    if (flags & PJ_THREAD_SUSPENDED) {
  ------------------
  |  Branch (884:9): [True: 2, False: 0]
  ------------------
  885|      2|        rc = pj_mutex_create_simple(pool, NULL, &rec->suspended_mutex);
  886|      2|        if (rc != PJ_SUCCESS) {
  ------------------
  |  Branch (886:13): [True: 0, False: 2]
  ------------------
  887|      0|            return rc;
  888|      0|        }
  889|       |
  890|      2|        pj_mutex_lock(rec->suspended_mutex);
  891|      2|    } else {
  892|      0|        pj_assert(rec->suspended_mutex == NULL);
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (892:9): [True: 0, False: 0]
  |  Branch (892:9): [True: 0, False: 0]
  ------------------
  893|      0|    }
  894|       |
  895|      2|    status = create_thread(thread_name, proc, arg, stack_size, stack_addr, rec);
  896|      2|    if (status == PJ_SUCCESS) {
  ------------------
  |  Branch (896:9): [True: 2, False: 0]
  ------------------
  897|       |        /* Success! */
  898|      2|        *ptr_thread = rec;
  899|      2|    }
  900|      2|    return status;
  901|       |
  902|       |#else
  903|       |    pj_assert(!"Threading is disabled!");
  904|       |    return PJ_EINVALIDOP;
  905|       |#endif
  906|      2|}
pj_thread_resume:
  952|      2|{
  953|      2|    pj_status_t rc;
  954|       |
  955|      2|    PJ_CHECK_STACK();
  956|      2|    PJ_ASSERT_RETURN(p, PJ_EINVAL);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (956:5): [True: 0, False: 0]
  |  Branch (956:5): [True: 0, False: 0]
  ------------------
  957|       |
  958|      2|    rc = pj_mutex_unlock(p->suspended_mutex);
  959|       |
  960|      2|    return rc;
  961|      2|}
pj_thread_this:
  967|   170k|{
  968|   170k|#if PJ_HAS_THREADS
  969|   170k|    pj_thread_t *rec = (pj_thread_t*)pj_thread_local_get(thread_tls_id);
  970|       |
  971|   170k|    if (rec == NULL) {
  ------------------
  |  Branch (971:9): [True: 0, False: 170k]
  ------------------
  972|      0|        pj_assert(!"Calling pjlib from unknown/external thread. You must "
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (972:9): [Folded, False: 0]
  |  Branch (972:9): [Folded, False: 0]
  ------------------
  973|      0|                   "register external threads with pj_thread_register() "
  974|      0|                   "before calling any pjlib functions.");
  975|      0|    }
  976|       |
  977|       |    /*
  978|       |     * MUST NOT check stack because this function is called
  979|       |     * by PJ_CHECK_STACK() itself!!!
  980|       |     *
  981|       |     */
  982|       |
  983|   170k|    return rec;
  984|       |#else
  985|       |    pj_assert(!"Threading is not enabled!");
  986|       |    return NULL;
  987|       |#endif
  988|   170k|}
pj_thread_sleep:
 1081|  6.76k|{
 1082|       |/* TODO: should change this to something like PJ_OS_HAS_NANOSLEEP */
 1083|       |#if defined(PJ_RTEMS) && PJ_RTEMS!=0
 1084|       |    enum { NANOSEC_PER_MSEC = 1000000 };
 1085|       |    struct timespec req;
 1086|       |
 1087|       |    PJ_CHECK_STACK();
 1088|       |    req.tv_sec = msec / 1000;
 1089|       |    req.tv_nsec = (msec % 1000) * NANOSEC_PER_MSEC;
 1090|       |
 1091|       |    if (nanosleep(&req, NULL) == 0)
 1092|       |        return PJ_SUCCESS;
 1093|       |
 1094|       |    return PJ_RETURN_OS_ERROR(pj_get_native_os_error());
 1095|       |#else
 1096|  6.76k|    PJ_CHECK_STACK();
 1097|       |
 1098|  6.76k|    pj_set_os_error(0);
 1099|       |
 1100|  6.76k|    usleep(msec * 1000);
 1101|       |
 1102|       |    /* MacOS X (reported on 10.5) seems to always set errno to ETIMEDOUT.
 1103|       |     * It does so because usleep() is declared to return int, and we're
 1104|       |     * supposed to check for errno only when usleep() returns non-zero.
 1105|       |     * Unfortunately, usleep() is declared to return void in other platforms
 1106|       |     * so it's not possible to always check for the return value (unless
 1107|       |     * we add a detection routine in autoconf).
 1108|       |     *
 1109|       |     * As a workaround, here we check if ETIMEDOUT is returned and
 1110|       |     * return successfully if it is.
 1111|       |     */
 1112|  6.76k|    if (pj_get_native_os_error() == ETIMEDOUT)
  ------------------
  |  |   33|  6.76k|#   define pj_get_native_os_error()         (errno)
  ------------------
  |  Branch (1112:9): [True: 0, False: 6.76k]
  ------------------
 1113|      0|        return PJ_SUCCESS;
 1114|       |
 1115|  6.76k|    return pj_get_os_error();
 1116|       |
 1117|  6.76k|#endif  /* PJ_RTEMS */
 1118|  6.76k|}
pj_atomic_create:
 1183|  6.80k|{
 1184|       |#if EMULATE_ATOMICS
 1185|       |    pj_status_t rc;
 1186|       |#endif
 1187|  6.80k|    pj_atomic_t *atomic_var;
 1188|       |
 1189|  6.80k|    atomic_var = PJ_POOL_ZALLOC_T(pool, pj_atomic_t);
  ------------------
  |  |  583|  6.80k|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
 1190|       |
 1191|  6.80k|    PJ_ASSERT_RETURN(atomic_var, PJ_ENOMEM);
  ------------------
  |  |   97|  6.80k|            do { \
  |  |   98|  6.80k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 6.80k]
  |  |  ------------------
  |  |   99|  6.80k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 6.80k]
  |  |  ------------------
  ------------------
  |  Branch (1191:5): [True: 0, False: 0]
  |  Branch (1191:5): [True: 0, False: 0]
  ------------------
 1192|       |
 1193|  6.80k|#if HAS_STD_ATOMICS
 1194|  6.80k|    atomic_init(&atomic_var->value, initial);
 1195|       |#elif EMULATE_ATOMICS
 1196|       |    rc = pj_mutex_create(pool, "atm%p", PJ_MUTEX_SIMPLE, &atomic_var->mutex);
 1197|       |    if (rc != PJ_SUCCESS)
 1198|       |        return rc;
 1199|       |    atomic_var->value = initial;
 1200|       |#else
 1201|       |    atomic_var->value = initial;
 1202|       |#endif
 1203|       |
 1204|  6.80k|    *ptr_atomic = atomic_var;
 1205|  6.80k|    return PJ_SUCCESS;
 1206|  6.80k|}
pj_atomic_destroy:
 1212|  6.79k|{
 1213|       |#if EMULATE_ATOMICS
 1214|       |    pj_status_t status;
 1215|       |#endif
 1216|       |
 1217|  6.79k|    PJ_ASSERT_RETURN(atomic_var, PJ_EINVAL);
  ------------------
  |  |   97|  6.79k|            do { \
  |  |   98|  6.79k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 6.79k]
  |  |  ------------------
  |  |   99|  6.79k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 6.79k]
  |  |  ------------------
  ------------------
  |  Branch (1217:5): [True: 0, False: 0]
  |  Branch (1217:5): [True: 0, False: 0]
  ------------------
 1218|       |
 1219|       |#if EMULATE_ATOMICS
 1220|       |    status = pj_mutex_destroy( atomic_var->mutex );
 1221|       |    if (status == PJ_SUCCESS) {
 1222|       |        atomic_var->mutex = NULL;
 1223|       |    }
 1224|       |    return status;
 1225|       |#else
 1226|  6.79k|    return 0;
 1227|  6.79k|#endif
 1228|  6.79k|}
pj_atomic_get:
 1260|  16.4k|{
 1261|  16.4k|    pj_atomic_value_t oldval;
 1262|       |
 1263|  16.4k|    PJ_CHECK_STACK();
 1264|       |
 1265|  16.4k|#if HAS_STD_ATOMICS
 1266|  16.4k|    oldval = atomic_load(&atomic_var->value);
 1267|       |#elif EMULATE_ATOMICS
 1268|       |    pj_mutex_lock( atomic_var->mutex );
 1269|       |    oldval = atomic_var->value;
 1270|       |    pj_mutex_unlock( atomic_var->mutex);
 1271|       |#else
 1272|       |    oldval = atomic_var->value;
 1273|       |#endif
 1274|       |
 1275|  16.4k|    return oldval;
 1276|  16.4k|}
pj_atomic_inc_and_get:
 1282|  28.9k|{
 1283|  28.9k|    pj_atomic_value_t new_value;
 1284|       |
 1285|  28.9k|    PJ_CHECK_STACK();
 1286|       |
 1287|  28.9k|#if HAS_STD_ATOMICS
 1288|  28.9k|    new_value = atomic_fetch_add(&atomic_var->value, 1) + 1;
 1289|       |#elif EMULATE_ATOMICS
 1290|       |    pj_mutex_lock( atomic_var->mutex );
 1291|       |    new_value = ++atomic_var->value;
 1292|       |    pj_mutex_unlock( atomic_var->mutex);
 1293|       |#else
 1294|       |    new_value = ++atomic_var->value;
 1295|       |#endif
 1296|       |
 1297|  28.9k|    return new_value;
 1298|  28.9k|}
pj_atomic_inc:
 1303|  28.9k|{
 1304|  28.9k|    PJ_ASSERT_ON_FAIL(atomic_var, return);
  ------------------
  |  |  111|  28.9k|            { \
  |  |  112|  28.9k|                pj_assert(expr); \
  |  |  ------------------
  |  |  |  |   65|  28.9k|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  113|  28.9k|                if (!(expr)) exec_on_fail; \
  |  |  ------------------
  |  |  |  Branch (113:21): [True: 0, False: 28.9k]
  |  |  ------------------
  |  |  114|  28.9k|            }
  ------------------
  |  Branch (1304:5): [True: 0, False: 28.9k]
  |  Branch (1304:5): [True: 28.9k, False: 0]
  ------------------
 1305|  28.9k|    pj_atomic_inc_and_get(atomic_var);
 1306|  28.9k|}
pj_atomic_dec_and_get:
 1312|  28.9k|{
 1313|  28.9k|    pj_atomic_value_t new_value;
 1314|       |
 1315|  28.9k|    PJ_CHECK_STACK();
 1316|       |
 1317|  28.9k|#if HAS_STD_ATOMICS
 1318|  28.9k|    new_value = atomic_fetch_sub(&atomic_var->value, 1) - 1;
 1319|       |#elif EMULATE_ATOMICS
 1320|       |    pj_mutex_lock( atomic_var->mutex );
 1321|       |    new_value = --atomic_var->value;
 1322|       |    pj_mutex_unlock( atomic_var->mutex);
 1323|       |#else
 1324|       |    new_value = --atomic_var->value;
 1325|       |#endif
 1326|       |
 1327|  28.9k|    return new_value;
 1328|  28.9k|}
pj_atomic_dec:
 1334|    449|{
 1335|    449|    PJ_ASSERT_ON_FAIL(atomic_var, return);
  ------------------
  |  |  111|    449|            { \
  |  |  112|    449|                pj_assert(expr); \
  |  |  ------------------
  |  |  |  |   65|    449|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  113|    449|                if (!(expr)) exec_on_fail; \
  |  |  ------------------
  |  |  |  Branch (113:21): [True: 0, False: 449]
  |  |  ------------------
  |  |  114|    449|            }
  ------------------
  |  Branch (1335:5): [True: 0, False: 449]
  |  Branch (1335:5): [True: 449, False: 0]
  ------------------
 1336|    449|    pj_atomic_dec_and_get(atomic_var);
 1337|    449|}
pj_thread_local_alloc:
 1375|     11|{
 1376|     11|#if PJ_HAS_THREADS
 1377|     11|    pthread_key_t key;
 1378|     11|    int rc;
 1379|       |
 1380|     11|    PJ_ASSERT_RETURN(p_index != NULL, PJ_EINVAL);
  ------------------
  |  |   97|     11|            do { \
  |  |   98|     11|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 11]
  |  |  ------------------
  |  |   99|     11|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 11]
  |  |  ------------------
  ------------------
  |  Branch (1380:5): [True: 0, False: 0]
  |  Branch (1380:5): [True: 0, False: 0]
  ------------------
 1381|       |
 1382|     11|    pj_assert( sizeof(pthread_key_t) <= sizeof(long));
  ------------------
  |  |   65|     11|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (1382:5): [True: 0, Folded]
  |  Branch (1382:5): [True: 11, Folded]
  ------------------
 1383|     11|    if ((rc=pthread_key_create(&key, NULL)) != 0)
  ------------------
  |  Branch (1383:9): [True: 0, False: 11]
  ------------------
 1384|      0|        return PJ_RETURN_OS_ERROR(rc);
  ------------------
  |  |  319|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (319:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  320|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  334|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (334:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1385|       |
 1386|     11|    *p_index = key;
 1387|     11|    return PJ_SUCCESS;
 1388|       |#else
 1389|       |    int i;
 1390|       |    for (i=0; i<MAX_THREADS; ++i) {
 1391|       |        if (tls_flag[i] == 0)
 1392|       |            break;
 1393|       |    }
 1394|       |    if (i == MAX_THREADS)
 1395|       |        return PJ_ETOOMANY;
 1396|       |
 1397|       |    tls_flag[i] = 1;
 1398|       |    tls[i] = NULL;
 1399|       |
 1400|       |    *p_index = i;
 1401|       |    return PJ_SUCCESS;
 1402|       |#endif
 1403|     11|}
pj_thread_local_set:
 1422|   125k|{
 1423|       |    //Can't check stack because this function is called in the
 1424|       |    //beginning before main thread is initialized.
 1425|       |    //PJ_CHECK_STACK();
 1426|   125k|#if PJ_HAS_THREADS
 1427|   125k|    int rc=pthread_setspecific(index, value);
 1428|   125k|    return rc==0 ? PJ_SUCCESS : PJ_RETURN_OS_ERROR(rc);
  ------------------
  |  |  319|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (319:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  320|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  334|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (334:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1428:12): [True: 125k, False: 0]
  ------------------
 1429|       |#else
 1430|       |    pj_assert(index >= 0 && index < MAX_THREADS);
 1431|       |    tls[index] = value;
 1432|       |    return PJ_SUCCESS;
 1433|       |#endif
 1434|   125k|}
pj_thread_local_get:
 1437|   357k|{
 1438|       |    //Can't check stack because this function is called
 1439|       |    //by PJ_CHECK_STACK() itself!!!
 1440|       |    //PJ_CHECK_STACK();
 1441|   357k|#if PJ_HAS_THREADS
 1442|   357k|    return pthread_getspecific(index);
 1443|       |#else
 1444|       |    pj_assert(index >= 0 && index < MAX_THREADS);
 1445|       |    return tls[index];
 1446|       |#endif
 1447|   357k|}
pj_enter_critical_section:
 1451|     10|{
 1452|     10|#if PJ_HAS_THREADS
 1453|     10|    pj_mutex_lock(&critical_section);
 1454|     10|#endif
 1455|     10|}
pj_leave_critical_section:
 1458|     10|{
 1459|     10|#if PJ_HAS_THREADS
 1460|     10|    pj_mutex_unlock(&critical_section);
 1461|     10|#endif
 1462|     10|}
pj_mutex_create:
 1562|  6.77k|{
 1563|  6.77k|#if PJ_HAS_THREADS
 1564|  6.77k|    pj_status_t rc;
 1565|  6.77k|    pj_mutex_t *mutex;
 1566|       |
 1567|  6.77k|    PJ_ASSERT_RETURN(pool && ptr_mutex, PJ_EINVAL);
  ------------------
  |  |   97|  6.77k|            do { \
  |  |   98|  13.5k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 6.77k, False: 0]
  |  |  |  Branch (98:23): [True: 6.77k, False: 0]
  |  |  ------------------
  |  |   99|  6.77k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 6.77k]
  |  |  ------------------
  ------------------
  |  Branch (1567:5): [True: 0, False: 0]
  |  Branch (1567:5): [True: 0, False: 0]
  |  Branch (1567:5): [True: 0, False: 0]
  |  Branch (1567:5): [True: 0, False: 0]
  ------------------
 1568|       |
 1569|  6.77k|    mutex = PJ_POOL_ALLOC_T(pool, pj_mutex_t);
  ------------------
  |  |  569|  6.77k|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
 1570|  6.77k|    PJ_ASSERT_RETURN(mutex, PJ_ENOMEM);
  ------------------
  |  |   97|  6.77k|            do { \
  |  |   98|  6.77k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 6.77k]
  |  |  ------------------
  |  |   99|  6.77k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 6.77k]
  |  |  ------------------
  ------------------
  |  Branch (1570:5): [True: 0, False: 0]
  |  Branch (1570:5): [True: 0, False: 0]
  ------------------
 1571|       |
 1572|  6.77k|    if ((rc=init_mutex(mutex, name, type)) != PJ_SUCCESS)
  ------------------
  |  Branch (1572:9): [True: 0, False: 6.77k]
  ------------------
 1573|      0|        return rc;
 1574|       |
 1575|  6.77k|    *ptr_mutex = mutex;
 1576|  6.77k|    return PJ_SUCCESS;
 1577|       |#else /* PJ_HAS_THREADS */
 1578|       |    *ptr_mutex = (pj_mutex_t*)1;
 1579|       |    return PJ_SUCCESS;
 1580|       |#endif
 1581|  6.77k|}
pj_mutex_create_simple:
 1589|    285|{
 1590|    285|    return pj_mutex_create(pool, name, PJ_MUTEX_SIMPLE, mutex);
 1591|    285|}
pj_mutex_create_recursive:
 1599|      6|{
 1600|      6|    return pj_mutex_create(pool, name, PJ_MUTEX_RECURSE, mutex);
 1601|      6|}
pj_mutex_lock:
 1607|  69.0k|{
 1608|  69.0k|#if PJ_HAS_THREADS
 1609|  69.0k|    pj_status_t status;
 1610|       |
 1611|  69.0k|    PJ_CHECK_STACK();
 1612|  69.0k|    PJ_ASSERT_RETURN(mutex, PJ_EINVAL);
  ------------------
  |  |   97|  69.0k|            do { \
  |  |   98|  69.0k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 69.0k]
  |  |  ------------------
  |  |   99|  69.0k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 69.0k]
  |  |  ------------------
  ------------------
  |  Branch (1612:5): [True: 0, False: 0]
  |  Branch (1612:5): [True: 0, False: 0]
  ------------------
 1613|       |
 1614|  69.0k|#if PJ_DEBUG
 1615|  69.0k|    PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s is waiting (mutex owner=%s)",
  ------------------
  |  |  106|  69.0k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  69.0k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|   138k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 69.0k]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  69.0k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 69.0k]
  |  |  ------------------
  ------------------
 1616|  69.0k|                                pj_thread_this()->obj_name,
 1617|  69.0k|                                mutex->owner_name));
 1618|       |#else
 1619|       |    PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s is waiting",
 1620|       |                                pj_thread_this()->obj_name));
 1621|       |#endif
 1622|       |
 1623|  69.0k|    status = pthread_mutex_lock( &mutex->mutex );
 1624|       |
 1625|       |
 1626|  69.0k|#if PJ_DEBUG
 1627|  69.0k|    if (status == PJ_SUCCESS) {
  ------------------
  |  Branch (1627:9): [True: 69.0k, False: 18.4E]
  ------------------
 1628|  69.0k|        mutex->owner = pj_thread_this();
 1629|  69.0k|        pj_ansi_strxcpy(mutex->owner_name, mutex->owner->obj_name,
 1630|  69.0k|                        sizeof(mutex->owner_name));
 1631|  69.0k|        ++mutex->nesting_level;
 1632|  69.0k|    }
 1633|       |
 1634|  69.0k|    PJ_LOG(6,(mutex->obj_name,
  ------------------
  |  |  106|  69.0k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  69.0k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|   138k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 69.0k]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  69.0k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 69.0k]
  |  |  ------------------
  ------------------
 1635|  69.0k|              (status==0 ?
 1636|  69.0k|                "Mutex acquired by thread %s (level=%d)" :
 1637|  69.0k|                "Mutex acquisition FAILED by %s (level=%d)"),
 1638|  69.0k|              pj_thread_this()->obj_name,
 1639|  69.0k|              mutex->nesting_level));
 1640|       |#else
 1641|       |    PJ_LOG(6,(mutex->obj_name,
 1642|       |              (status==0 ? "Mutex acquired by thread %s" : "FAILED by %s"),
 1643|       |              pj_thread_this()->obj_name));
 1644|       |#endif
 1645|       |
 1646|  69.0k|    if (status == 0)
  ------------------
  |  Branch (1646:9): [True: 69.0k, False: 18.4E]
  ------------------
 1647|  69.0k|        return PJ_SUCCESS;
 1648|  18.4E|    else
 1649|  18.4E|        return PJ_RETURN_OS_ERROR(status);
  ------------------
  |  |  319|  18.4E|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (319:43): [True: 0, False: 18.4E]
  |  |  ------------------
  |  |  320|  18.4E|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  334|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (334:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1650|       |#else   /* PJ_HAS_THREADS */
 1651|       |    pj_assert( mutex == (pj_mutex_t*)1 );
 1652|       |    return PJ_SUCCESS;
 1653|       |#endif
 1654|  69.0k|}
pj_mutex_unlock:
 1660|  69.0k|{
 1661|  69.0k|#if PJ_HAS_THREADS
 1662|  69.0k|    pj_status_t status;
 1663|       |
 1664|  69.0k|    PJ_CHECK_STACK();
 1665|  69.0k|    PJ_ASSERT_RETURN(mutex, PJ_EINVAL);
  ------------------
  |  |   97|  69.0k|            do { \
  |  |   98|  69.0k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 69.0k]
  |  |  ------------------
  |  |   99|  69.0k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 69.0k]
  |  |  ------------------
  ------------------
  |  Branch (1665:5): [True: 0, False: 0]
  |  Branch (1665:5): [True: 0, False: 0]
  ------------------
 1666|       |
 1667|  69.0k|#if PJ_DEBUG
 1668|  69.0k|    pj_assert(mutex->owner == pj_thread_this());
  ------------------
  |  |   65|  69.0k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (1668:5): [True: 0, False: 69.0k]
  |  Branch (1668:5): [True: 69.0k, False: 0]
  ------------------
 1669|  69.0k|    if (--mutex->nesting_level == 0) {
  ------------------
  |  Branch (1669:9): [True: 61.8k, False: 7.19k]
  ------------------
 1670|  61.8k|        mutex->owner = NULL;
 1671|  61.8k|        mutex->owner_name[0] = '\0';
 1672|  61.8k|    }
 1673|       |
 1674|  69.0k|    PJ_LOG(6,(mutex->obj_name, "Mutex released by thread %s (level=%d)",
  ------------------
  |  |  106|  69.0k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  69.0k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|   138k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 69.0k]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  69.0k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 69.0k]
  |  |  ------------------
  ------------------
 1675|  69.0k|                                pj_thread_this()->obj_name,
 1676|  69.0k|                                mutex->nesting_level));
 1677|       |#else
 1678|       |    PJ_LOG(6,(mutex->obj_name, "Mutex released by thread %s",
 1679|       |                                pj_thread_this()->obj_name));
 1680|       |#endif
 1681|       |
 1682|  69.0k|    status = pthread_mutex_unlock( &mutex->mutex );
 1683|  69.0k|    if (status == 0)
  ------------------
  |  Branch (1683:9): [True: 69.0k, False: 0]
  ------------------
 1684|  69.0k|        return PJ_SUCCESS;
 1685|      0|    else
 1686|      0|        return PJ_RETURN_OS_ERROR(status);
  ------------------
  |  |  319|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (319:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  320|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  334|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (334:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1687|       |
 1688|       |#else /* PJ_HAS_THREADS */
 1689|       |    pj_assert( mutex == (pj_mutex_t*)1 );
 1690|       |    return PJ_SUCCESS;
 1691|       |#endif
 1692|  69.0k|}
pj_mutex_destroy:
 1743|  6.62k|{
 1744|  6.62k|    enum { RETRY = 4 };
 1745|  6.62k|    int status = 0;
 1746|  6.62k|    unsigned retry;
 1747|       |
 1748|  6.62k|    PJ_CHECK_STACK();
 1749|  6.62k|    PJ_ASSERT_RETURN(mutex, PJ_EINVAL);
  ------------------
  |  |   97|  6.62k|            do { \
  |  |   98|  6.62k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 6.62k]
  |  |  ------------------
  |  |   99|  6.62k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 6.62k]
  |  |  ------------------
  ------------------
  |  Branch (1749:5): [True: 0, False: 0]
  |  Branch (1749:5): [True: 0, False: 0]
  ------------------
 1750|       |
 1751|  6.62k|#if PJ_HAS_THREADS
 1752|  6.62k|    PJ_LOG(6,(mutex->obj_name, "Mutex destroyed by thread %s",
  ------------------
  |  |  106|  6.62k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  6.62k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  13.2k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 6.62k]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  6.62k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 6.62k]
  |  |  ------------------
  ------------------
 1753|  6.62k|                               pj_thread_this()->obj_name));
 1754|       |
 1755|  6.62k|    for (retry=0; retry<RETRY; ++retry) {
  ------------------
  |  Branch (1755:19): [True: 6.62k, False: 0]
  ------------------
 1756|  6.62k|        status = pthread_mutex_destroy( &mutex->mutex );
 1757|  6.62k|        if (status == PJ_SUCCESS)
  ------------------
  |  Branch (1757:13): [True: 6.62k, False: 0]
  ------------------
 1758|  6.62k|            break;
 1759|      0|        else if (retry<RETRY-1 && status == EBUSY)
  ------------------
  |  Branch (1759:18): [True: 0, False: 0]
  |  Branch (1759:35): [True: 0, False: 0]
  ------------------
 1760|      0|            pthread_mutex_unlock(&mutex->mutex);
 1761|  6.62k|    }
 1762|       |
 1763|  6.62k|    if (status == 0)
  ------------------
  |  Branch (1763:9): [True: 6.62k, False: 0]
  ------------------
 1764|  6.62k|        return PJ_SUCCESS;
 1765|      0|    else {
 1766|      0|        return PJ_RETURN_OS_ERROR(status);
  ------------------
  |  |  319|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (319:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  320|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  334|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (334:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1767|      0|    }
 1768|       |#else
 1769|       |    pj_assert( mutex == (pj_mutex_t*)1 );
 1770|       |    status = PJ_SUCCESS;
 1771|       |    return status;
 1772|       |#endif
 1773|  6.62k|}
pj_rwmutex_create:
 1805|      2|{
 1806|      2|    pj_rwmutex_t *rwm;
 1807|      2|    pj_status_t status;
 1808|       |
 1809|      2|    PJ_UNUSED_ARG(name);
  ------------------
  |  | 1537|      2|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1810|       |
 1811|      2|    rwm = PJ_POOL_ALLOC_T(pool, pj_rwmutex_t);
  ------------------
  |  |  569|      2|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
 1812|      2|    PJ_ASSERT_RETURN(rwm, PJ_ENOMEM);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (1812:5): [True: 0, False: 0]
  |  Branch (1812:5): [True: 0, False: 0]
  ------------------
 1813|       |
 1814|      2|    status = pthread_rwlock_init(&rwm->rwlock, NULL);
 1815|      2|    if (status != 0)
  ------------------
  |  Branch (1815:9): [True: 0, False: 2]
  ------------------
 1816|      0|        return PJ_RETURN_OS_ERROR(status);
  ------------------
  |  |  319|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (319:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  320|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  334|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (334:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1817|       |
 1818|      2|    *p_mutex = rwm;
 1819|      2|    return PJ_SUCCESS;
 1820|      2|}
pj_rwmutex_lock_write:
 1842|     10|{
 1843|     10|    pj_status_t status;
 1844|       |
 1845|     10|    status = pthread_rwlock_wrlock(&mutex->rwlock);
 1846|     10|    if (status != 0)
  ------------------
  |  Branch (1846:9): [True: 0, False: 10]
  ------------------
 1847|      0|        return PJ_RETURN_OS_ERROR(status);
  ------------------
  |  |  319|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (319:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  320|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  334|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (334:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1848|       |
 1849|     10|    return PJ_SUCCESS;
 1850|     10|}
pj_rwmutex_unlock_write:
 1866|     10|{
 1867|     10|    pj_status_t status;
 1868|       |
 1869|     10|    status = pthread_rwlock_unlock(&mutex->rwlock);
 1870|     10|    if (status != 0)
  ------------------
  |  Branch (1870:9): [True: 0, False: 10]
  ------------------
 1871|      0|        return PJ_RETURN_OS_ERROR(status);
  ------------------
  |  |  319|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (319:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  320|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  334|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (334:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1872|       |
 1873|     10|    return PJ_SUCCESS;
 1874|     10|}
os_core_unix.c:create_thread:
  779|      2|{
  780|      2|    pthread_attr_t thread_attr;
  781|      2|    int rc;
  782|      2|    const char *ch;
  783|       |
  784|      2|    PJ_UNUSED_ARG(stack_addr);
  ------------------
  |  | 1537|      2|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  785|       |
  786|      2|    PJ_CHECK_STACK();
  787|      2|    PJ_ASSERT_RETURN(proc && rec, PJ_EINVAL);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      4|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 2, False: 0]
  |  |  |  Branch (98:23): [True: 2, False: 0]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (787:5): [True: 0, False: 0]
  |  Branch (787:5): [True: 0, False: 0]
  |  Branch (787:5): [True: 0, False: 0]
  |  Branch (787:5): [True: 0, False: 0]
  ------------------
  788|       |
  789|       |    /* Set name. */
  790|      2|    if (!thread_name)
  ------------------
  |  Branch (790:9): [True: 0, False: 2]
  ------------------
  791|      0|        thread_name = "thr%p";
  792|       |
  793|      2|    ch = pj_ansi_strchr(thread_name, '%');
  ------------------
  |  |   92|      2|#define pj_ansi_strchr          strchr
  ------------------
  794|      2|    if (ch && *(ch+1) == 'p') {
  ------------------
  |  Branch (794:9): [True: 0, False: 2]
  |  Branch (794:15): [True: 0, False: 0]
  ------------------
  795|      0|        pj_ansi_snprintf(rec->obj_name, PJ_MAX_OBJ_NAME, thread_name, rec);
  ------------------
  |  |  114|      0|#define pj_ansi_snprintf        snprintf
  ------------------
                      pj_ansi_snprintf(rec->obj_name, PJ_MAX_OBJ_NAME, thread_name, rec);
  ------------------
  |  |  320|      0|#define PJ_MAX_OBJ_NAME 32
  ------------------
  796|      2|    } else {
  797|      2|        pj_ansi_strxcpy(rec->obj_name, thread_name, PJ_MAX_OBJ_NAME);
  ------------------
  |  |  320|      2|#define PJ_MAX_OBJ_NAME 32
  ------------------
  798|      2|    }
  799|       |
  800|       |    /* Set default stack size */
  801|      2|    if (stack_size == 0)
  ------------------
  |  Branch (801:9): [True: 2, False: 0]
  ------------------
  802|      2|        stack_size = PJ_THREAD_DEFAULT_STACK_SIZE;
  ------------------
  |  |  623|      2|#  define PJ_THREAD_DEFAULT_STACK_SIZE    8192
  ------------------
  803|       |
  804|       |#if defined(PJ_OS_HAS_CHECK_STACK) && PJ_OS_HAS_CHECK_STACK!=0
  805|       |    rec->stk_size = stack_size;
  806|       |    rec->stk_max_usage = 0;
  807|       |#endif
  808|       |
  809|       |    /* Init thread attributes */
  810|      2|    pthread_attr_init(&thread_attr);
  811|       |
  812|       |#if defined(PJ_THREAD_SET_STACK_SIZE) && PJ_THREAD_SET_STACK_SIZE!=0
  813|       |    /* Set thread's stack size */
  814|       |    rc = pthread_attr_setstacksize(&thread_attr, stack_size);
  815|       |    if (rc != 0) {
  816|       |        pthread_attr_destroy(&thread_attr);
  817|       |        return PJ_RETURN_OS_ERROR(rc);
  818|       |    }
  819|       |#endif  /* PJ_THREAD_SET_STACK_SIZE */
  820|       |
  821|       |
  822|       |#if defined(PJ_THREAD_ALLOCATE_STACK) && PJ_THREAD_ALLOCATE_STACK!=0
  823|       |    /* Allocate memory for the stack */
  824|       |    PJ_ASSERT_RETURN(stack_addr, PJ_EINVAL);
  825|       |
  826|       |    rc = pthread_attr_setstackaddr(&thread_attr, stack_addr);
  827|       |    if (rc != 0) {
  828|       |        pthread_attr_destroy(&thread_attr);
  829|       |        return PJ_RETURN_OS_ERROR(rc);
  830|       |    }
  831|       |#endif  /* PJ_THREAD_ALLOCATE_STACK */
  832|       |
  833|       |
  834|       |    /* Create the thread. */
  835|      2|    rec->proc = proc;
  836|      2|    rec->arg = arg;
  837|      2|    rc = pthread_create( &rec->thread, &thread_attr, &thread_main, rec);
  838|      2|    if (rc != 0) {
  ------------------
  |  Branch (838:9): [True: 0, False: 2]
  ------------------
  839|      0|        pthread_attr_destroy(&thread_attr);
  840|      0|        return PJ_RETURN_OS_ERROR(rc);
  ------------------
  |  |  319|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (319:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  320|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  334|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (334:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  841|      0|    }
  842|       |
  843|       |    /* Destroy thread attributes */
  844|      2|    pthread_attr_destroy(&thread_attr);
  845|       |
  846|      2|    PJ_LOG(6, (rec->obj_name, "Thread created"));
  ------------------
  |  |  106|      2|#define PJ_LOG(level,arg)       do { \
  |  |  107|      2|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      4|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 2]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|      2|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 2]
  |  |  ------------------
  ------------------
  847|      2|    return PJ_SUCCESS;
  848|       |
  849|      2|}
os_core_unix.c:thread_main:
  736|      2|{
  737|      2|    pj_thread_t *rec = (pj_thread_t*)param;
  738|      2|    void *result;
  739|      2|    pj_status_t rc;
  740|       |
  741|       |#if defined(PJ_OS_HAS_CHECK_STACK) && PJ_OS_HAS_CHECK_STACK!=0
  742|       |    rec->stk_start = (char*)&rec;
  743|       |#endif
  744|       |
  745|       |    /* Store the thread. */
  746|      2|    rec->thread = pthread_self();
  747|       |
  748|       |    /* Set current thread id. */
  749|      2|    rc = pj_thread_local_set(thread_tls_id, rec);
  750|      2|    if (rc != PJ_SUCCESS) {
  ------------------
  |  Branch (750:9): [True: 0, False: 2]
  ------------------
  751|      0|        pj_assert(!"Thread TLS ID is not set (pj_init() error?)");
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (751:9): [Folded, False: 0]
  |  Branch (751:9): [Folded, False: 0]
  ------------------
  752|      0|    }
  753|       |
  754|       |    /* Check if suspension is required. */
  755|      2|    if (rec->suspended_mutex) {
  ------------------
  |  Branch (755:9): [True: 2, False: 0]
  ------------------
  756|      2|        pj_mutex_lock(rec->suspended_mutex);
  757|      2|        pj_mutex_unlock(rec->suspended_mutex);
  758|      2|    }
  759|       |
  760|      2|    PJ_LOG(6,(rec->obj_name, "Thread started"));
  ------------------
  |  |  106|      2|#define PJ_LOG(level,arg)       do { \
  |  |  107|      2|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      4|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 2]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|      2|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 2]
  |  |  ------------------
  ------------------
  761|       |
  762|      2|    set_thread_display_name(rec->obj_name);
  763|       |
  764|       |    /* Call user's entry! */
  765|      2|    result = (void*)(long)(*rec->proc)(rec->arg);
  766|       |
  767|       |    /* Done. */
  768|      2|    PJ_LOG(6,(rec->obj_name, "Thread quitting"));
  ------------------
  |  |  106|      2|#define PJ_LOG(level,arg)       do { \
  |  |  107|      2|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      4|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 2]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|      2|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 2]
  |  |  ------------------
  ------------------
  769|       |
  770|      2|    return result;
  771|      2|}
os_core_unix.c:set_thread_display_name:
  704|      2|{
  705|      2|#if (defined(PJ_LINUX) && PJ_LINUX != 0) || \
  706|      2|    (defined(PJ_ANDROID) && PJ_ANDROID != 0)
  707|      2|    char xname[16];
  708|       |    // On linux, thread display name length is restricted to 16 (include '\0')
  709|      2|    if (pj_ansi_strlen(name) >= 16) {
  ------------------
  |  |   69|      2|#define pj_ansi_strlen          strlen
  ------------------
  |  Branch (709:9): [True: 0, False: 2]
  ------------------
  710|      0|        pj_memcpy(xname, name, 15);
  711|      0|        xname[15] = '\0';
  712|      0|        name = xname;
  713|      0|    }
  714|      2|#endif
  715|       |
  716|      2|#if defined(PJ_HAS_PTHREAD_SETNAME_NP) && PJ_HAS_PTHREAD_SETNAME_NP != 0
  717|       |#   if defined(PJ_DARWINOS) && PJ_DARWINOS != 0
  718|       |    pthread_setname_np(name);
  719|       |#   else
  720|      2|    pthread_setname_np(pthread_self(), name);
  721|      2|#   endif
  722|       |#elif defined(PJ_HAS_PTHREAD_SET_NAME_NP) && PJ_HAS_PTHREAD_SET_NAME_NP != 0
  723|       |    pthread_set_name_np(pthread_self(), name);
  724|       |#else
  725|       |// #   warning "OS does not support set thread display name"
  726|       |    PJ_UNUSED_ARG(name);
  727|       |#endif
  728|      2|}
os_core_unix.c:init_mutex:
 1473|  6.77k|{
 1474|  6.77k|#if PJ_HAS_THREADS
 1475|  6.77k|    pthread_mutexattr_t attr;
 1476|  6.77k|    int rc;
 1477|       |
 1478|  6.77k|    PJ_CHECK_STACK();
 1479|       |
 1480|  6.77k|    rc = pthread_mutexattr_init(&attr);
 1481|  6.77k|    if (rc != 0)
  ------------------
  |  Branch (1481:9): [True: 0, False: 6.77k]
  ------------------
 1482|      0|        return PJ_RETURN_OS_ERROR(rc);
  ------------------
  |  |  319|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (319:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  320|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  334|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (334:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1483|       |
 1484|  6.77k|    if (type == PJ_MUTEX_SIMPLE) {
  ------------------
  |  Branch (1484:9): [True: 289, False: 6.48k]
  ------------------
 1485|    289|#if (defined(PJ_LINUX) && PJ_LINUX!=0) || \
 1486|    289|    defined(PJ_HAS_PTHREAD_MUTEXATTR_SETTYPE)
 1487|    289|        rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL);
 1488|       |#elif (defined(PJ_RTEMS) && PJ_RTEMS!=0) || \
 1489|       |       defined(PJ_PTHREAD_MUTEXATTR_T_HAS_RECURSIVE)
 1490|       |        /* Nothing to do, default is simple */
 1491|       |#else
 1492|       |        rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL);
 1493|       |#endif
 1494|  6.48k|    } else {
 1495|  6.48k|#if (defined(PJ_LINUX) && PJ_LINUX!=0) || \
 1496|  6.48k|     defined(PJ_HAS_PTHREAD_MUTEXATTR_SETTYPE)
 1497|  6.48k|        rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
 1498|       |#elif (defined(PJ_RTEMS) && PJ_RTEMS!=0) || \
 1499|       |       defined(PJ_PTHREAD_MUTEXATTR_T_HAS_RECURSIVE)
 1500|       |        // Phil Torre <ptorre@zetron.com>:
 1501|       |        // The RTEMS implementation of POSIX mutexes doesn't include
 1502|       |        // pthread_mutexattr_settype(), so what follows is a hack
 1503|       |        // until I get RTEMS patched to support the set/get functions.
 1504|       |        //
 1505|       |        // More info:
 1506|       |        //   newlib's pthread also lacks pthread_mutexattr_settype(),
 1507|       |        //   but it seems to have mutexattr.recursive.
 1508|       |        PJ_TODO(FIX_RTEMS_RECURSIVE_MUTEX_TYPE)
 1509|       |        attr.recursive = 1;
 1510|       |#else
 1511|       |        rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
 1512|       |#endif
 1513|  6.48k|    }
 1514|       |
 1515|  6.77k|    if (rc != 0) {
  ------------------
  |  Branch (1515:9): [True: 0, False: 6.77k]
  ------------------
 1516|      0|        return PJ_RETURN_OS_ERROR(rc);
  ------------------
  |  |  319|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (319:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  320|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  334|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (334:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1517|      0|    }
 1518|       |
 1519|  6.77k|    rc = pthread_mutex_init(&mutex->mutex, &attr);
 1520|  6.77k|    if (rc != 0) {
  ------------------
  |  Branch (1520:9): [True: 0, False: 6.77k]
  ------------------
 1521|      0|        return PJ_RETURN_OS_ERROR(rc);
  ------------------
  |  |  319|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (319:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  320|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  334|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (334:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1522|      0|    }
 1523|       |
 1524|  6.77k|    rc = pthread_mutexattr_destroy(&attr);
 1525|  6.77k|    if (rc != 0) {
  ------------------
  |  Branch (1525:9): [True: 0, False: 6.77k]
  ------------------
 1526|      0|        pj_status_t status = PJ_RETURN_OS_ERROR(rc);
  ------------------
  |  |  319|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (319:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  320|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  334|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (334:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1527|      0|        pthread_mutex_destroy(&mutex->mutex);
 1528|      0|        return status;
 1529|      0|    }
 1530|       |
 1531|  6.77k|#if PJ_DEBUG
 1532|       |    /* Set owner. */
 1533|  6.77k|    mutex->nesting_level = 0;
 1534|  6.77k|    mutex->owner = NULL;
 1535|  6.77k|    mutex->owner_name[0] = '\0';
 1536|  6.77k|#endif
 1537|       |
 1538|       |    /* Set name. */
 1539|  6.77k|    if (!name) {
  ------------------
  |  Branch (1539:9): [True: 132, False: 6.64k]
  ------------------
 1540|    132|        name = "mtx%p";
 1541|    132|    }
 1542|  6.77k|    if (strchr(name, '%')) {
  ------------------
  |  Branch (1542:9): [True: 142, False: 6.63k]
  ------------------
 1543|    142|        pj_ansi_snprintf(mutex->obj_name, PJ_MAX_OBJ_NAME, name, mutex);
  ------------------
  |  |  114|    142|#define pj_ansi_snprintf        snprintf
  ------------------
                      pj_ansi_snprintf(mutex->obj_name, PJ_MAX_OBJ_NAME, name, mutex);
  ------------------
  |  |  320|    142|#define PJ_MAX_OBJ_NAME 32
  ------------------
 1544|  6.63k|    } else {
 1545|  6.63k|        pj_ansi_strxcpy(mutex->obj_name, name, PJ_MAX_OBJ_NAME);
  ------------------
  |  |  320|  6.63k|#define PJ_MAX_OBJ_NAME 32
  ------------------
 1546|  6.63k|    }
 1547|       |
 1548|  6.77k|    PJ_LOG(6, (mutex->obj_name, "Mutex created"));
  ------------------
  |  |  106|  6.77k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  6.77k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  13.5k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 6.77k]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  6.77k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 6.77k]
  |  |  ------------------
  ------------------
 1549|  6.77k|    return PJ_SUCCESS;
 1550|       |#else /* PJ_HAS_THREADS */
 1551|       |    return PJ_SUCCESS;
 1552|       |#endif
 1553|  6.77k|}

pj_get_os_error:
   24|  6.76k|{
   25|  6.76k|    return PJ_STATUS_FROM_OS(errno);
  ------------------
  |  |  334|  6.76k|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  ------------------
  |  |  |  |  528|  6.76k|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (334:34): [True: 6.76k, False: 0]
  |  |  ------------------
  ------------------
   26|  6.76k|}
pj_set_os_error:
   29|  6.76k|{
   30|  6.76k|    errno = PJ_STATUS_TO_OS(code);
  ------------------
  |  |  350|  6.76k|#   define PJ_STATUS_TO_OS(e) (e == 0 ? PJ_SUCCESS : e - PJ_ERRNO_START_SYS)
  |  |  ------------------
  |  |  |  |  528|  6.76k|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (350:32): [True: 6.76k, False: 0]
  |  |  ------------------
  ------------------
   31|  6.76k|}

pj_time_decode:
   29|     18|{
   30|     18|    struct tm local_time;
   31|     18|    time_t sec = tv->sec; // time_t might be 64 bit even when long int is 32 bit, (time_t*) dangerous
   32|       |
   33|     18|    PJ_CHECK_STACK();
   34|       |
   35|     18|#if defined(PJ_HAS_LOCALTIME_R) && PJ_HAS_LOCALTIME_R != 0
   36|     18|    localtime_r(&sec, &local_time);
   37|       |#else
   38|       |    /* localtime() is NOT thread-safe. */
   39|       |    local_time = *localtime(&sec);
   40|       |#endif
   41|       |
   42|     18|    pt->year = local_time.tm_year+1900;
   43|     18|    pt->mon = local_time.tm_mon;
   44|     18|    pt->day = local_time.tm_mday;
   45|     18|    pt->hour = local_time.tm_hour;
   46|     18|    pt->min = local_time.tm_min;
   47|     18|    pt->sec = local_time.tm_sec;
   48|     18|    pt->wday = local_time.tm_wday;
   49|     18|    pt->msec = tv->msec;
   50|       |
   51|     18|    return PJ_SUCCESS;
   52|     18|}

pj_gettimeofday:
   32|  1.10k|{
   33|  1.10k|    struct timeval the_time;
   34|  1.10k|    int rc;
   35|       |
   36|  1.10k|    PJ_CHECK_STACK();
   37|       |
   38|  1.10k|    rc = gettimeofday(&the_time, NULL);
   39|  1.10k|    if (rc != 0)
  ------------------
  |  Branch (39:9): [True: 0, False: 1.10k]
  ------------------
   40|      0|        return PJ_RETURN_OS_ERROR(pj_get_native_os_error());
  ------------------
  |  |  319|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (319:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  320|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  334|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (334:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   41|       |
   42|  1.10k|    p_tv->sec = the_time.tv_sec;
   43|  1.10k|    p_tv->msec = the_time.tv_usec / 1000;
   44|  1.10k|    return PJ_SUCCESS;
   45|  1.10k|}

pj_elapsed_time:
  165|  8.94k|{
  166|  8.94k|    pj_highprec_t elapsed = elapsed_msec(start, stop);
  167|  8.94k|    pj_time_val tv_elapsed;
  168|       |
  169|  8.94k|    if (PJ_HIGHPREC_VALUE_IS_ZERO(elapsed)) {
  ------------------
  |  |   30|  8.94k|#   define PJ_HIGHPREC_VALUE_IS_ZERO(a)     (a==0)
  |  |  ------------------
  |  |  |  Branch (30:45): [True: 0, False: 8.94k]
  |  |  ------------------
  ------------------
  170|      0|        tv_elapsed.sec = tv_elapsed.msec = 0;
  171|      0|        return tv_elapsed;
  172|  8.94k|    } else {
  173|  8.94k|        pj_highprec_t sec, msec;
  174|       |
  175|  8.94k|        sec = elapsed;
  176|  8.94k|        pj_highprec_div(sec, MSEC);
  ------------------
  |  |   64|  8.94k|#   define pj_highprec_div(a1,a2)   (a1 = a1 / a2)
  ------------------
  177|  8.94k|        tv_elapsed.sec = (long)sec;
  178|       |
  179|  8.94k|        msec = elapsed;
  180|  8.94k|        pj_highprec_mod(msec, MSEC);
  ------------------
  |  |   31|  8.94k|#   define pj_highprec_mod(a,b)             (a=fmod(a,b))
  ------------------
  181|  8.94k|        tv_elapsed.msec = (long)msec;
  182|       |
  183|  8.94k|        return tv_elapsed;
  184|  8.94k|    }
  185|  8.94k|}
pj_gettickcount:
  194|  8.94k|{
  195|  8.94k|    pj_timestamp ts, start;
  196|  8.94k|    pj_status_t status;
  197|       |
  198|  8.94k|    if ((status = pj_get_timestamp(&ts)) != PJ_SUCCESS)
  ------------------
  |  Branch (198:9): [True: 0, False: 8.94k]
  ------------------
  199|      0|        return status;
  200|       |
  201|  8.94k|    pj_set_timestamp32(&start, 0, 0);
  202|  8.94k|    *tv = pj_elapsed_time(&start, &ts);
  203|       |
  204|  8.94k|    return PJ_SUCCESS;
  205|  8.94k|}
os_timestamp_common.c:get_elapsed:
   33|  8.94k|{
   34|  8.94k|#if defined(PJ_HAS_INT64) && PJ_HAS_INT64!=0
   35|  8.94k|    return u64tohighprec(stop->u64 - start->u64);
  ------------------
  |  |   29|  8.94k|#define u64tohighprec(u64)      ((pj_highprec_t)((pj_int64_t)(u64)))
  ------------------
   36|       |#else
   37|       |    pj_highprec_t elapsed_hi, elapsed_lo;
   38|       |
   39|       |    elapsed_hi = stop->u32.hi - start->u32.hi;
   40|       |    elapsed_lo = stop->u32.lo - start->u32.lo;
   41|       |
   42|       |    /* elapsed_hi = elapsed_hi * U32MAX */
   43|       |    pj_highprec_mul(elapsed_hi, U32MAX);
   44|       |
   45|       |    return elapsed_hi + elapsed_lo;
   46|       |#endif
   47|  8.94k|}
os_timestamp_common.c:elapsed_msec:
   51|  8.94k|{
   52|  8.94k|    pj_timestamp ts_freq;
   53|  8.94k|    pj_highprec_t freq, elapsed;
   54|       |
   55|  8.94k|    if (pj_get_timestamp_freq(&ts_freq) != PJ_SUCCESS)
  ------------------
  |  Branch (55:9): [True: 0, False: 8.94k]
  ------------------
   56|      0|        return 0;
   57|       |
   58|       |    /* Convert frequency timestamp */
   59|  8.94k|#if defined(PJ_HAS_INT64) && PJ_HAS_INT64!=0
   60|  8.94k|    freq = u64tohighprec(ts_freq.u64);
  ------------------
  |  |   29|  8.94k|#define u64tohighprec(u64)      ((pj_highprec_t)((pj_int64_t)(u64)))
  ------------------
   61|       |#else
   62|       |    freq = ts_freq.u32.hi;
   63|       |    pj_highprec_mul(freq, U32MAX);
   64|       |    freq += ts_freq.u32.lo;
   65|       |#endif
   66|       |
   67|       |    /* Get elapsed time in cycles. */
   68|  8.94k|    elapsed = get_elapsed(start, stop);
   69|       |
   70|       |    /* usec = elapsed * MSEC / freq */
   71|  8.94k|    pj_highprec_div(freq, MSEC);
  ------------------
  |  |   64|  8.94k|#   define pj_highprec_div(a1,a2)   (a1 = a1 / a2)
  ------------------
   72|       |     
   73|       |    /* Avoid division by zero. */
   74|  8.94k|    if (freq == 0) {
  ------------------
  |  Branch (74:9): [True: 0, False: 8.94k]
  ------------------
   75|       |      /* Regard freq = 1 */
   76|      0|      pj_highprec_mul(elapsed, MSEC);
  ------------------
  |  |   55|      0|#   define pj_highprec_mul(a1,a2)   (a1 = a1 * a2)
  ------------------
   77|  8.94k|    } else {
   78|  8.94k|      pj_highprec_div(elapsed, freq);
  ------------------
  |  |   64|  8.94k|#   define pj_highprec_div(a1,a2)   (a1 = a1 / a2)
  ------------------
   79|  8.94k|    }
   80|  8.94k|    return elapsed;
   81|  8.94k|}

pj_get_timestamp:
  228|  8.95k|{
  229|  8.95k|    struct timespec tp;
  230|       |
  231|  8.95k|    if (clock_gettime(CLOCK_MONOTONIC, &tp) != 0) {
  ------------------
  |  Branch (231:9): [True: 0, False: 8.95k]
  ------------------
  232|      0|        return PJ_RETURN_OS_ERROR(pj_get_native_os_error());
  ------------------
  |  |  319|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (319:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  320|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  334|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (334:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  233|      0|    }
  234|       |
  235|  8.95k|    ts->u64 = tp.tv_sec;
  236|  8.95k|    ts->u64 *= NSEC_PER_SEC;
  ------------------
  |  |  225|  8.95k|#define NSEC_PER_SEC    1000000000
  ------------------
  237|  8.95k|    ts->u64 += tp.tv_nsec;
  238|       |
  239|  8.95k|    return PJ_SUCCESS;
  240|  8.95k|}
pj_get_timestamp_freq:
  243|  8.94k|{
  244|  8.94k|    freq->u32.hi = 0;
  245|  8.94k|    freq->u32.lo = NSEC_PER_SEC;
  ------------------
  |  |  225|  8.94k|#define NSEC_PER_SEC    1000000000
  ------------------
  246|       |
  247|  8.94k|    return PJ_SUCCESS;
  248|  8.94k|}

pj_pool_allocate_find:
   94|  13.3k|{
   95|  13.3k|    pj_pool_block *block = pool->block_list.next;
   96|  13.3k|    void *p;
   97|  13.3k|    pj_size_t block_size;
   98|  13.3k|    unsigned i = 0;
   99|       |
  100|  13.3k|    PJ_CHECK_STACK();
  101|  13.3k|    pj_assert(PJ_IS_POWER_OF_TWO(alignment));
  ------------------
  |  |   65|  13.3k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (101:5): [True: 0, False: 13.3k]
  |  Branch (101:5): [True: 0, False: 0]
  |  Branch (101:5): [True: 13.3k, False: 0]
  |  Branch (101:5): [True: 13.3k, False: 0]
  ------------------
  102|       |
  103|  34.9k|    while (block != &pool->block_list) {
  ------------------
  |  Branch (103:12): [True: 26.6k, False: 8.30k]
  ------------------
  104|  26.6k|        p = pj_pool_alloc_from_block(block, alignment, size);
  105|  26.6k|        if (p != NULL)
  ------------------
  |  Branch (105:13): [True: 3.76k, False: 22.8k]
  ------------------
  106|  3.76k|            return p;
  107|       |
  108|  22.8k|#if PJ_POOL_MAX_SEARCH_BLOCK_COUNT > 0
  109|  22.8k|        if (i >= PJ_POOL_MAX_SEARCH_BLOCK_COUNT) {
  ------------------
  |  |  559|  22.8k|#   define PJ_POOL_MAX_SEARCH_BLOCK_COUNT 5
  ------------------
  |  Branch (109:13): [True: 1.31k, False: 21.5k]
  ------------------
  110|  1.31k|            break;
  111|  1.31k|        }
  112|  21.5k|#endif
  113|       |
  114|  21.5k|        i++;
  115|  21.5k|        block = block->next;
  116|  21.5k|    }
  117|       |    /* No available space in all blocks. */
  118|       |
  119|       |    /* If pool is configured NOT to expand, return error. */
  120|  9.62k|    if (pool->increment_size == 0) {
  ------------------
  |  Branch (120:9): [True: 0, False: 9.62k]
  ------------------
  121|      0|        LOG((pool->obj_name, "Can't expand pool to allocate %lu bytes "
  ------------------
  |  |   33|      0|#define LOG(expr)                   PJ_LOG(6,expr)
  |  |  ------------------
  |  |  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:41): [Folded, False: 0]
  |  |  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  |  |  109|      0|                                    } \
  |  |  |  |  110|      0|                                } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  122|      0|             "(used=%lu, cap=%lu)",
  123|      0|             (unsigned long)size, (unsigned long)pj_pool_get_used_size(pool),
  124|      0|             (unsigned long)pool->capacity));
  125|      0|        (*pool->callback)(pool, size);
  126|      0|        return NULL;
  127|      0|    }
  128|       |
  129|       |    /* If pool is configured to expand, but the increment size
  130|       |     * is less than the required size, expand the pool by multiple
  131|       |     * increment size. Also count the size wasted due to aligning
  132|       |     * the block.
  133|       |     */
  134|  9.62k|    if (pool->increment_size < 
  ------------------
  |  Branch (134:9): [True: 383, False: 9.24k]
  ------------------
  135|  9.62k|            sizeof(pj_pool_block)+ /*block header, itself may be unaligned*/
  136|  9.62k|            alignment-1 + /* gap [0:alignment-1] to align first allocation*/
  137|  9.62k|            size)                  /* allocation size (NOT aligned!)      */
  138|    383|    {
  139|    383|        pj_size_t count;
  140|    383|        count = (pool->increment_size + 
  141|    383|                 sizeof(pj_pool_block) + alignment-1 + size) /
  142|    383|                pool->increment_size;
  143|    383|        block_size = count * pool->increment_size;
  144|  9.24k|    } else {
  145|  9.24k|        block_size = pool->increment_size;
  146|  9.24k|    }
  147|       |
  148|  9.62k|    LOG((pool->obj_name, 
  ------------------
  |  |   33|  9.62k|#define LOG(expr)                   PJ_LOG(6,expr)
  |  |  ------------------
  |  |  |  |  106|  9.62k|#define PJ_LOG(level,arg)       do { \
  |  |  |  |  107|  9.62k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  417|  19.2k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:41): [Folded, False: 9.62k]
  |  |  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  |  |  109|      0|                                    } \
  |  |  |  |  110|  9.62k|                                } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (110:42): [Folded, False: 9.62k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  149|  9.62k|         "%lu bytes requested, resizing pool by %lu bytes (used=%lu, cap=%lu)",
  150|  9.62k|         (unsigned long)size, (unsigned long)block_size,
  151|  9.62k|         (unsigned long)pj_pool_get_used_size(pool),
  152|  9.62k|         (unsigned long)pool->capacity));
  153|       |
  154|  9.62k|    block = pj_pool_create_block(pool, block_size);
  155|  9.62k|    if (!block)
  ------------------
  |  Branch (155:9): [True: 0, False: 9.62k]
  ------------------
  156|      0|        return NULL;
  157|       |
  158|  9.62k|    p = pj_pool_alloc_from_block(block, alignment, size);
  159|  9.62k|    pj_assert(p != NULL);
  ------------------
  |  |   65|  9.62k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (159:5): [True: 0, False: 9.62k]
  |  Branch (159:5): [True: 9.62k, False: 0]
  ------------------
  160|  9.62k|#if PJ_DEBUG
  161|  9.62k|    if (p == NULL) {
  ------------------
  |  Branch (161:9): [True: 0, False: 9.62k]
  ------------------
  162|      0|        PJ_UNUSED_ARG(p);
  ------------------
  |  | 1537|      0|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  163|      0|    }
  164|  9.62k|#endif
  165|  9.62k|    return p;
  166|  9.62k|}
pj_pool_init_int:
  176|  18.4k|{
  177|       |
  178|  18.4k|    PJ_CHECK_STACK();
  179|  18.4k|    pj_assert(!alignment || PJ_IS_POWER_OF_TWO(alignment));
  ------------------
  |  |   65|  18.4k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (179:5): [True: 0, False: 0]
  |  Branch (179:5): [True: 0, False: 0]
  |  Branch (179:5): [True: 18.4k, False: 0]
  |  Branch (179:5): [True: 2, False: 0]
  |  Branch (179:5): [True: 2, False: 0]
  |  Branch (179:5): [True: 18.4k, False: 2]
  ------------------
  180|       |
  181|  18.4k|    pool->increment_size = increment_size;
  182|  18.4k|    pool->callback = callback;
  183|  18.4k|    pool->alignment = !alignment ? PJ_POOL_ALIGNMENT : alignment;
  ------------------
  |  |  182|  18.4k|#define PJ_POOL_ALIGNMENT 8
  ------------------
  |  Branch (183:23): [True: 18.4k, False: 2]
  ------------------
  184|       |
  185|  18.4k|    if (name) {
  ------------------
  |  Branch (185:9): [True: 18.4k, False: 0]
  ------------------
  186|  18.4k|        char *p = pj_ansi_strchr(name, '%');
  ------------------
  |  |   92|  18.4k|#define pj_ansi_strchr          strchr
  ------------------
  187|  18.4k|        if (p && *(p+1)=='p' && *(p+2)=='\0') {
  ------------------
  |  Branch (187:13): [True: 12.7k, False: 5.69k]
  |  Branch (187:18): [True: 12.7k, False: 0]
  |  Branch (187:33): [True: 12.7k, False: 0]
  ------------------
  188|       |            /* Special name with "%p" suffix */
  189|  12.7k|            pj_ansi_snprintf(pool->obj_name, sizeof(pool->obj_name), 
  ------------------
  |  |  114|  12.7k|#define pj_ansi_snprintf        snprintf
  ------------------
  190|  12.7k|                             name, pool);
  191|  12.7k|        } else {
  192|  5.69k|            pj_ansi_strxcpy(pool->obj_name, name, PJ_MAX_OBJ_NAME);
  ------------------
  |  |  320|  5.69k|#define PJ_MAX_OBJ_NAME 32
  ------------------
  193|  5.69k|        }
  194|  18.4k|    } else {
  195|      0|        pool->obj_name[0] = '\0';
  196|      0|    }
  197|  18.4k|}
pj_pool_create_int:
  207|    111|{
  208|    111|    pj_pool_t *pool;
  209|    111|    pj_pool_block *block;
  210|    111|    pj_uint8_t *buffer;
  211|       |
  212|    111|    PJ_CHECK_STACK();
  213|       |
  214|       |    /* Size must be at least sizeof(pj_pool)+sizeof(pj_pool_block) */
  215|    111|    PJ_ASSERT_RETURN(initial_size >= sizeof(pj_pool_t)+sizeof(pj_pool_block),
  ------------------
  |  |   97|    111|            do { \
  |  |   98|    111|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 111]
  |  |  ------------------
  |  |   99|    111|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 111]
  |  |  ------------------
  ------------------
  |  Branch (215:5): [True: 0, False: 0]
  |  Branch (215:5): [True: 0, False: 0]
  ------------------
  216|    111|                     NULL);
  217|    111|    PJ_ASSERT_RETURN(!alignment || PJ_IS_POWER_OF_TWO(alignment), NULL);
  ------------------
  |  |   97|    111|            do { \
  |  |   98|    117|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 2, False: 0]
  |  |  |  Branch (98:23): [True: 2, False: 0]
  |  |  |  Branch (98:23): [True: 109, False: 2]
  |  |  ------------------
  |  |   99|    111|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 111]
  |  |  ------------------
  ------------------
  |  Branch (217:5): [True: 0, False: 0]
  |  Branch (217:5): [True: 0, False: 0]
  |  Branch (217:5): [True: 0, False: 0]
  |  Branch (217:5): [True: 0, False: 0]
  |  Branch (217:5): [True: 0, False: 0]
  |  Branch (217:5): [True: 0, False: 0]
  ------------------
  218|       |
  219|       |    /* If callback is NULL, set calback from the policy */
  220|    111|    if (callback == NULL)
  ------------------
  |  Branch (220:9): [True: 0, False: 111]
  ------------------
  221|      0|        callback = f->policy.callback;
  222|       |
  223|       |    /* Allocate initial block */
  224|    111|    buffer = (pj_uint8_t*) (*f->policy.block_alloc)(f, initial_size);
  225|    111|    if (!buffer)
  ------------------
  |  Branch (225:9): [True: 0, False: 111]
  ------------------
  226|      0|        return NULL;
  227|       |
  228|       |    /* Set pool administrative data. */
  229|    111|    pool = (pj_pool_t*)buffer;
  230|    111|    pj_bzero(pool, sizeof(*pool));
  231|       |
  232|    111|    pj_list_init(&pool->block_list);
  233|    111|    pool->factory = f;
  234|       |
  235|       |    /* Create the first block from the memory. */
  236|    111|    block = (pj_pool_block*) (buffer + sizeof(*pool));
  237|    111|    block->buf = ((unsigned char*)block) + sizeof(pj_pool_block);
  238|    111|    block->end = buffer + initial_size;
  239|       |
  240|       |    /* Set the start pointer, unaligned! */
  241|    111|    block->cur = block->buf;
  242|       |
  243|    111|    pj_list_insert_after(&pool->block_list, block);
  244|       |
  245|    111|    pj_pool_init_int(pool, name, increment_size, alignment, callback);
  246|       |
  247|       |    /* Pool initial capacity and used size */
  248|    111|    pool->capacity = initial_size;
  249|       |
  250|    111|    LOG((pool->obj_name, "pool created, size=%lu",
  ------------------
  |  |   33|    111|#define LOG(expr)                   PJ_LOG(6,expr)
  |  |  ------------------
  |  |  |  |  106|    111|#define PJ_LOG(level,arg)       do { \
  |  |  |  |  107|    111|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  417|    222|#  define PJ_LOG_MAX_LEVEL   5
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:41): [Folded, False: 111]
  |  |  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  |  |  109|      0|                                    } \
  |  |  |  |  110|    111|                                } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (110:42): [Folded, False: 111]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  251|    111|                         (unsigned long)pool->capacity));
  252|    111|    return pool;
  253|    111|}
pj_pool_reset:
  295|  18.3k|{
  296|  18.3k|    LOG((pool->obj_name, "reset(): cap=%lu, used=%lu(%lu%%)", 
  ------------------
  |  |   33|  18.3k|#define LOG(expr)                   PJ_LOG(6,expr)
  |  |  ------------------
  |  |  |  |  106|  18.3k|#define PJ_LOG(level,arg)       do { \
  |  |  |  |  107|  18.3k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  417|  36.7k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:41): [Folded, False: 18.3k]
  |  |  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  |  |  109|      0|                                    } \
  |  |  |  |  110|  18.3k|                                } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (110:42): [Folded, False: 18.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  297|  18.3k|        (unsigned long)pool->capacity,
  298|  18.3k|        (unsigned long)pj_pool_get_used_size(pool), 
  299|  18.3k|        (unsigned long)(pj_pool_get_used_size(pool)*100/pool->capacity)));
  300|       |
  301|  18.3k|    reset_pool(pool);
  302|  18.3k|}
pj_pool_destroy_int:
  308|     92|{
  309|     92|    pj_size_t initial_size;
  310|       |
  311|     92|    LOG((pool->obj_name, "destroy(): cap=%lu, used=%lu(%lu%%), block0=%p-%p", 
  ------------------
  |  |   33|     92|#define LOG(expr)                   PJ_LOG(6,expr)
  |  |  ------------------
  |  |  |  |  106|     92|#define PJ_LOG(level,arg)       do { \
  |  |  |  |  107|     92|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  417|    184|#  define PJ_LOG_MAX_LEVEL   5
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:41): [Folded, False: 92]
  |  |  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  |  |  109|      0|                                    } \
  |  |  |  |  110|     92|                                } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (110:42): [Folded, False: 92]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  312|     92|        (unsigned long)pool->capacity,
  313|     92|        (unsigned long)pj_pool_get_used_size(pool),
  314|     92|        (unsigned long)(pj_pool_get_used_size(pool)*100/pool->capacity),
  315|     92|        ((pj_pool_block*)pool->block_list.next)->buf, 
  316|     92|        ((pj_pool_block*)pool->block_list.next)->end));
  317|       |
  318|     92|    reset_pool(pool);
  319|     92|    initial_size = ((pj_pool_block*)pool->block_list.next)->end - 
  320|     92|                   (unsigned char*)pool;
  321|     92|    if (pool->factory->policy.block_free)
  ------------------
  |  Branch (321:9): [True: 92, False: 0]
  ------------------
  322|     92|        (*pool->factory->policy.block_free)(pool->factory, pool, initial_size);
  323|     92|}
pool.c:pj_pool_create_block:
   48|  9.62k|{
   49|  9.62k|    pj_pool_block *block;
   50|       |
   51|  9.62k|    PJ_CHECK_STACK();
   52|  9.62k|    pj_assert(size >= sizeof(pj_pool_block));
  ------------------
  |  |   65|  9.62k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (52:5): [True: 0, False: 9.62k]
  |  Branch (52:5): [True: 9.62k, False: 0]
  ------------------
   53|       |
   54|  9.62k|    LOG((pool->obj_name, "create_block(sz=%lu), cur.cap=%lu, cur.used=%lu", 
  ------------------
  |  |   33|  9.62k|#define LOG(expr)                   PJ_LOG(6,expr)
  |  |  ------------------
  |  |  |  |  106|  9.62k|#define PJ_LOG(level,arg)       do { \
  |  |  |  |  107|  9.62k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  417|  19.2k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:41): [Folded, False: 9.62k]
  |  |  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  |  |  109|      0|                                    } \
  |  |  |  |  110|  9.62k|                                } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (110:42): [Folded, False: 9.62k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   55|  9.62k|         (unsigned long)size, (unsigned long)pool->capacity,
   56|  9.62k|         (unsigned long)pj_pool_get_used_size(pool)));
   57|       |
   58|       |    /* Request memory from allocator. */
   59|  9.62k|    block = (pj_pool_block*) 
   60|  9.62k|        (*pool->factory->policy.block_alloc)(pool->factory, size);
   61|  9.62k|    if (block == NULL) {
  ------------------
  |  Branch (61:9): [True: 0, False: 9.62k]
  ------------------
   62|      0|        (*pool->callback)(pool, size);
   63|      0|        return NULL;
   64|      0|    }
   65|       |
   66|       |    /* Add capacity. */
   67|  9.62k|    pool->capacity += size;
   68|       |
   69|       |    /* Set start and end of buffer. */
   70|  9.62k|    block->buf = ((unsigned char*)block) + sizeof(pj_pool_block);
   71|  9.62k|    block->end = ((unsigned char*)block) + size;
   72|       |
   73|       |    /* Set the start pointer, unaligned! */
   74|  9.62k|    block->cur = block->buf;
   75|       |
   76|       |    /* Insert in the front of the list. */
   77|  9.62k|    pj_list_insert_after(&pool->block_list, block);
   78|       |
   79|  9.62k|    LOG((pool->obj_name," block created, buffer=%p-%p",block->buf, block->end));
  ------------------
  |  |   33|  9.62k|#define LOG(expr)                   PJ_LOG(6,expr)
  |  |  ------------------
  |  |  |  |  106|  9.62k|#define PJ_LOG(level,arg)       do { \
  |  |  |  |  107|  9.62k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  417|  19.2k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:41): [Folded, False: 9.62k]
  |  |  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  |  |  109|      0|                                    } \
  |  |  |  |  110|  9.62k|                                } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (110:42): [Folded, False: 9.62k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   80|       |
   81|  9.62k|    return block;
   82|  9.62k|}
pool.c:reset_pool:
  261|  18.4k|{
  262|  18.4k|    pj_pool_block *block;
  263|       |
  264|  18.4k|    PJ_CHECK_STACK();
  265|       |
  266|  18.4k|    block = pool->block_list.prev;
  267|  18.4k|    if (block == &pool->block_list)
  ------------------
  |  Branch (267:9): [True: 0, False: 18.4k]
  ------------------
  268|      0|        return;
  269|       |
  270|       |    /* Skip the first block because it is occupying the same memory
  271|       |       as the pool itself.
  272|       |    */
  273|  18.4k|    block = block->prev;
  274|       |    
  275|  28.0k|    while (block != &pool->block_list) {
  ------------------
  |  Branch (275:12): [True: 9.58k, False: 18.4k]
  ------------------
  276|  9.58k|        pj_pool_block *prev = block->prev;
  277|  9.58k|        pj_list_erase(block);
  278|  9.58k|        (*pool->factory->policy.block_free)(pool->factory, block, 
  279|  9.58k|                                            block->end - (unsigned char*)block);
  280|  9.58k|        block = prev;
  281|  9.58k|    }
  282|       |
  283|  18.4k|    block = pool->block_list.next;
  284|       |
  285|       |    /* Set the start pointer, unaligned! */
  286|  18.4k|    block->cur = block->buf;
  287|       |
  288|  18.4k|    pool->capacity = block->end - (unsigned char*)pool;
  289|  18.4k|}

pj_pool_create_on_buf:
   82|      2|{
   83|      2|#if PJ_HAS_POOL_ALT_API == 0
   84|      2|    struct creation_param param;
   85|      2|    pj_size_t align_diff;
   86|       |
   87|      2|    PJ_ASSERT_RETURN(buf && size, NULL);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      4|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 2, False: 0]
  |  |  |  Branch (98:23): [True: 2, False: 0]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (87:5): [True: 0, False: 0]
  |  Branch (87:5): [True: 0, False: 0]
  |  Branch (87:5): [True: 0, False: 0]
  |  Branch (87:5): [True: 0, False: 0]
  ------------------
   88|       |
   89|      2|    if (!is_initialized) {
  ------------------
  |  Branch (89:9): [True: 2, False: 0]
  ------------------
   90|      2|        if (pool_buf_initialize() != PJ_SUCCESS)
  ------------------
  |  Branch (90:13): [True: 0, False: 2]
  ------------------
   91|      0|            return NULL;
   92|      2|        is_initialized = 1;
   93|      2|    }
   94|       |
   95|       |    /* Check and align buffer */
   96|      2|    align_diff = (pj_size_t)buf;
   97|      2|    if (align_diff & (PJ_POOL_ALIGNMENT-1)) {
  ------------------
  |  |  182|      2|#define PJ_POOL_ALIGNMENT 8
  ------------------
  |  Branch (97:9): [True: 0, False: 2]
  ------------------
   98|      0|        align_diff &= (PJ_POOL_ALIGNMENT-1);
  ------------------
  |  |  182|      0|#define PJ_POOL_ALIGNMENT 8
  ------------------
   99|      0|        buf = (void*) (((char*)buf) + align_diff);
  100|      0|        size -= align_diff;
  101|      0|    }
  102|       |
  103|      2|    param.stack_buf = buf;
  104|      2|    param.size = size;
  105|      2|    pj_thread_local_set(tls, &param);
  106|       |
  107|      2|    return pj_pool_create_int(&stack_based_factory, name, size, 0, 
  108|      2|                              PJ_POOL_ALIGNMENT,
  ------------------
  |  |  182|      2|#define PJ_POOL_ALIGNMENT 8
  ------------------
  109|      2|                              pj_pool_factory_default_policy.callback);
  110|       |#else
  111|       |    PJ_UNUSED_ARG(buf);
  112|       |    PJ_UNUSED_ARG(pool_buf_initialize);
  113|       |    return pj_pool_create(NULL, name, size, size, NULL);
  114|       |#endif
  115|      2|}
pool_buf.c:pool_buf_initialize:
   46|      2|{
   47|      2|    pj_atexit(&pool_buf_cleanup);
   48|       |
   49|      2|    stack_based_factory.policy.block_alloc = &stack_alloc;
   50|      2|    return pj_thread_local_alloc(&tls);
   51|      2|}
pool_buf.c:stack_alloc:
   54|      2|{
   55|      2|    struct creation_param *param;
   56|      2|    void *buf;
   57|       |
   58|      2|    PJ_UNUSED_ARG(factory);
  ------------------
  |  | 1537|      2|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
   59|       |
   60|      2|    param = (struct creation_param*) pj_thread_local_get(tls);
   61|      2|    if (param == NULL) {
  ------------------
  |  Branch (61:9): [True: 0, False: 2]
  ------------------
   62|       |        /* Don't assert(), this is normal no-memory situation */
   63|      0|        return NULL;
   64|      0|    }
   65|       |
   66|      2|    pj_thread_local_set(tls, NULL);
   67|       |
   68|      2|    PJ_ASSERT_RETURN(size <= param->size, NULL);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (68:5): [True: 0, False: 0]
  |  Branch (68:5): [True: 0, False: 0]
  ------------------
   69|       |
   70|      2|    buf = param->stack_buf;
   71|       |
   72|       |    /* Prevent the buffer from being reused */
   73|      2|    param->stack_buf = NULL;
   74|       |
   75|      2|    return buf;
   76|      2|}

pj_caching_pool_init:
   57|      2|{
   58|      2|    int i;
   59|      2|    pj_pool_t *pool;
   60|      2|    pj_status_t status;
   61|       |
   62|      2|    PJ_CHECK_STACK();
   63|       |
   64|      2|    pj_bzero(cp, sizeof(*cp));
   65|       |    
   66|      2|    cp->max_capacity = max_capacity;
   67|      2|    pj_list_init(&cp->used_list);
   68|     34|    for (i=0; i<PJ_CACHING_POOL_ARRAY_SIZE; ++i)
  ------------------
  |  |  889|     34|#define PJ_CACHING_POOL_ARRAY_SIZE      16
  ------------------
  |  Branch (68:15): [True: 32, False: 2]
  ------------------
   69|     32|        pj_list_init(&cp->free_list[i]);
   70|       |
   71|      2|    if (policy == NULL) {
  ------------------
  |  Branch (71:9): [True: 0, False: 2]
  ------------------
   72|      0|        policy = &pj_pool_factory_default_policy;
   73|      0|    }
   74|       |    
   75|      2|    pj_memcpy(&cp->factory.policy, policy, sizeof(pj_pool_factory_policy));
   76|      2|    cp->factory.create_pool = &cpool_create_pool;
   77|      2|    cp->factory.release_pool = &cpool_release_pool;
   78|      2|    cp->factory.dump_status = &cpool_dump_status;
   79|       |
   80|       |    /* Deprecated, these callbacks are only used for updating cp.used_size &
   81|       |     * cp.peak_used_size which are no longer used.
   82|       |     */
   83|       |    //cp->factory.on_block_alloc = &cpool_on_block_alloc;
   84|       |    //cp->factory.on_block_free = &cpool_on_block_free;
   85|      2|    PJ_UNUSED_ARG(cpool_on_block_alloc);
  ------------------
  |  | 1537|      2|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
   86|      2|    PJ_UNUSED_ARG(cpool_on_block_free);
  ------------------
  |  | 1537|      2|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
   87|       |
   88|      2|    pool = pj_pool_create_on_buf("cachingpool", cp->pool_buf, sizeof(cp->pool_buf));
   89|      2|    status = pj_lock_create_simple_mutex(pool, "cachingpool", &cp->lock);
   90|       |    /* This mostly serves to silent coverity warning about unchecked 
   91|       |     * return value. There's not much we can do if it fails. */
   92|      2|    PJ_ASSERT_ON_FAIL(status==PJ_SUCCESS, return);
  ------------------
  |  |  111|      2|            { \
  |  |  112|      2|                pj_assert(expr); \
  |  |  ------------------
  |  |  |  |   65|      2|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  113|      2|                if (!(expr)) exec_on_fail; \
  |  |  ------------------
  |  |  |  Branch (113:21): [True: 0, False: 2]
  |  |  ------------------
  |  |  114|      2|            }
  ------------------
  |  Branch (92:5): [True: 0, False: 2]
  |  Branch (92:5): [True: 2, False: 0]
  ------------------
   93|      2|}
pool_caching.c:cpool_create_pool:
  138|  18.4k|{
  139|  18.4k|    pj_caching_pool *cp = (pj_caching_pool*)pf;
  140|  18.4k|    pj_pool_t *pool;
  141|  18.4k|    int idx;
  142|       |
  143|  18.4k|    PJ_CHECK_STACK();
  144|       |
  145|  18.4k|    pj_lock_acquire(cp->lock);
  146|       |
  147|       |    /* Use pool factory's policy when callback is NULL */
  148|  18.4k|    if (callback == NULL) {
  ------------------
  |  Branch (148:9): [True: 6.34k, False: 12.1k]
  ------------------
  149|  6.34k|        callback = pf->policy.callback;
  150|  6.34k|    }
  151|       |
  152|       |    /* Search the suitable size for the pool. 
  153|       |     * We'll just do linear search to the size array, as the array size itself
  154|       |     * is only a few elements. Binary search I suspect will be less efficient
  155|       |     * for this purpose.
  156|       |     */
  157|  18.4k|    if (initial_size <= pool_sizes[START_SIZE]) {
  ------------------
  |  |   51|  18.4k|#define START_SIZE  5
  ------------------
  |  Branch (157:9): [True: 18.4k, False: 2]
  ------------------
  158|  18.4k|        for (idx=START_SIZE-1; 
  ------------------
  |  |   51|  18.4k|#define START_SIZE  5
  ------------------
  159|  50.9k|             idx >= 0 && pool_sizes[idx] >= initial_size;
  ------------------
  |  Branch (159:14): [True: 50.9k, False: 0]
  |  Branch (159:26): [True: 32.4k, False: 18.4k]
  ------------------
  160|  32.4k|             --idx)
  161|  32.4k|            ;
  162|  18.4k|        ++idx;
  163|  18.4k|    } else {
  164|      2|        for (idx=START_SIZE+1; 
  ------------------
  |  |   51|      2|#define START_SIZE  5
  ------------------
  165|      4|             idx < PJ_CACHING_POOL_ARRAY_SIZE && 
  ------------------
  |  |  889|      8|#define PJ_CACHING_POOL_ARRAY_SIZE      16
  ------------------
  |  Branch (165:14): [True: 4, False: 0]
  ------------------
  166|      4|                  pool_sizes[idx] < initial_size;
  ------------------
  |  Branch (166:19): [True: 2, False: 2]
  ------------------
  167|      2|             ++idx)
  168|      2|            ;
  169|      2|    }
  170|       |
  171|       |    /* Check whether there's a pool in the list. */
  172|  18.4k|    if (idx==PJ_CACHING_POOL_ARRAY_SIZE || pj_list_empty(&cp->free_list[idx])) {
  ------------------
  |  |  889|  36.9k|#define PJ_CACHING_POOL_ARRAY_SIZE      16
  ------------------
  |  Branch (172:9): [True: 0, False: 18.4k]
  |  Branch (172:44): [True: 109, False: 18.3k]
  ------------------
  173|       |        /* No pool is available. */
  174|       |        /* Set minimum size. */
  175|    109|        if (idx < PJ_CACHING_POOL_ARRAY_SIZE)
  ------------------
  |  |  889|    109|#define PJ_CACHING_POOL_ARRAY_SIZE      16
  ------------------
  |  Branch (175:13): [True: 109, False: 0]
  ------------------
  176|    109|            initial_size =  pool_sizes[idx];
  177|       |
  178|       |        /* Create new pool */
  179|    109|        pool = pj_pool_create_int(&cp->factory, name, initial_size, 
  180|    109|                                  increment_sz, alignment, callback);
  181|    109|        if (!pool) {
  ------------------
  |  Branch (181:13): [True: 0, False: 109]
  ------------------
  182|      0|            pj_lock_release(cp->lock);
  183|      0|            return NULL;
  184|      0|        }
  185|       |
  186|  18.3k|    } else {
  187|       |        /* Get one pool from the list. */
  188|  18.3k|        pool = (pj_pool_t*) cp->free_list[idx].next;
  189|  18.3k|        pj_list_erase(pool);
  190|       |
  191|       |        /* Initialize the pool. */
  192|  18.3k|        pj_pool_init_int(pool, name, increment_sz, alignment, callback);
  193|       |
  194|       |        /* Update pool manager's free capacity. */
  195|  18.3k|        if (cp->capacity > pj_pool_get_capacity(pool)) {
  ------------------
  |  Branch (195:13): [True: 17.5k, False: 833]
  ------------------
  196|  17.5k|            cp->capacity -= pj_pool_get_capacity(pool);
  197|  17.5k|        } else {
  198|    833|            cp->capacity = 0;
  199|    833|        }
  200|       |
  201|  18.3k|        PJ_LOG(6, (pool->obj_name, "pool reused, size=%lu",
  ------------------
  |  |  106|  18.3k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  18.3k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  36.7k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 18.3k]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  18.3k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 18.3k]
  |  |  ------------------
  ------------------
  202|  18.3k|                   (unsigned long)pool->capacity));
  203|  18.3k|    }
  204|       |
  205|       |    /* Put in used list. */
  206|  18.4k|    pj_list_insert_before( &cp->used_list, pool );
  207|       |
  208|       |    /* Mark factory data */
  209|  18.4k|    pool->factory_data = (void*) (pj_ssize_t) idx;
  210|       |
  211|       |    /* Increment used count. */
  212|  18.4k|    ++cp->used_count;
  213|       |
  214|  18.4k|    pj_lock_release(cp->lock);
  215|  18.4k|    return pool;
  216|  18.4k|}
pool_caching.c:cpool_release_pool:
  219|  18.4k|{
  220|  18.4k|    pj_caching_pool *cp = (pj_caching_pool*)pf;
  221|  18.4k|    pj_size_t pool_capacity;
  222|  18.4k|    unsigned i;
  223|       |
  224|  18.4k|    PJ_CHECK_STACK();
  225|       |
  226|  18.4k|    PJ_ASSERT_ON_FAIL(pf && pool, return);
  ------------------
  |  |  111|  18.4k|            { \
  |  |  112|  18.4k|                pj_assert(expr); \
  |  |  ------------------
  |  |  |  |   65|  18.4k|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  113|  36.9k|                if (!(expr)) exec_on_fail; \
  |  |  ------------------
  |  |  |  Branch (113:23): [True: 18.4k, False: 0]
  |  |  |  Branch (113:23): [True: 18.4k, False: 0]
  |  |  ------------------
  |  |  114|  18.4k|            }
  ------------------
  |  Branch (226:5): [True: 0, False: 18.4k]
  |  Branch (226:5): [True: 0, False: 0]
  |  Branch (226:5): [True: 18.4k, False: 0]
  |  Branch (226:5): [True: 18.4k, False: 0]
  ------------------
  227|       |
  228|  18.4k|    pj_lock_acquire(cp->lock);
  229|       |
  230|       |#if PJ_SAFE_POOL
  231|       |    /* Make sure pool is still in our used list */
  232|       |    if (pj_list_find_node(&cp->used_list, pool) != pool) {
  233|       |        pj_lock_release(cp->lock);
  234|       |        pj_assert(!"Attempt to destroy pool that has been destroyed before");
  235|       |        return;
  236|       |    }
  237|       |#endif
  238|       |
  239|       |    /* Erase from the used list. */
  240|  18.4k|    pj_list_erase(pool);
  241|       |
  242|       |    /* Decrement used count. */
  243|  18.4k|    --cp->used_count;
  244|       |
  245|  18.4k|    pool_capacity = pj_pool_get_capacity(pool);
  246|       |
  247|       |    /* Destroy the pool if the size is greater than our size or if the total
  248|       |     * capacity in our recycle list (plus the size of the pool) exceeds 
  249|       |     * maximum capacity.
  250|       |   . */
  251|  18.4k|    if (pool_capacity > pool_sizes[PJ_CACHING_POOL_ARRAY_SIZE-1] ||
  ------------------
  |  |  889|  18.4k|#define PJ_CACHING_POOL_ARRAY_SIZE      16
  ------------------
  |  Branch (251:9): [True: 92, False: 18.3k]
  ------------------
  252|  18.3k|        cp->capacity + pool_capacity > cp->max_capacity)
  ------------------
  |  Branch (252:9): [True: 0, False: 18.3k]
  ------------------
  253|     92|    {
  254|     92|        pj_pool_destroy_int(pool);
  255|     92|        pj_lock_release(cp->lock);
  256|     92|        return;
  257|     92|    }
  258|       |
  259|       |    /* Reset pool. */
  260|  18.3k|    PJ_LOG(6, (pool->obj_name, "recycle(): cap=%lu, used=%lu(%lu%%)", 
  ------------------
  |  |  106|  18.3k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  18.3k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  36.7k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 18.3k]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  18.3k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 18.3k]
  |  |  ------------------
  ------------------
  261|  18.3k|               (unsigned long)pool_capacity,
  262|  18.3k|               (unsigned long)pj_pool_get_used_size(pool), 
  263|  18.3k|               (unsigned long)(pj_pool_get_used_size(pool)*100/
  264|  18.3k|                               pool_capacity)));
  265|  18.3k|    pj_pool_reset(pool);
  266|       |
  267|  18.3k|    pool_capacity = pj_pool_get_capacity(pool);
  268|       |
  269|       |    /*
  270|       |     * Otherwise put the pool in our recycle list.
  271|       |     */
  272|  18.3k|    i = (unsigned) (unsigned long) (pj_ssize_t) pool->factory_data;
  273|       |
  274|  18.3k|    pj_assert(i<PJ_CACHING_POOL_ARRAY_SIZE);
  ------------------
  |  |   65|  18.3k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (274:5): [True: 0, False: 18.3k]
  |  Branch (274:5): [True: 18.3k, False: 0]
  ------------------
  275|  18.3k|    if (i >= PJ_CACHING_POOL_ARRAY_SIZE ) {
  ------------------
  |  |  889|  18.3k|#define PJ_CACHING_POOL_ARRAY_SIZE      16
  ------------------
  |  Branch (275:9): [True: 0, False: 18.3k]
  ------------------
  276|       |        /* Something has gone wrong with the pool. */
  277|      0|        pj_pool_destroy_int(pool);
  278|      0|        pj_lock_release(cp->lock);
  279|      0|        return;
  280|      0|    }
  281|       |
  282|  18.3k|    pj_list_insert_after(&cp->free_list[i], pool);
  283|  18.3k|    cp->capacity += pool_capacity;
  284|       |
  285|  18.3k|    pj_lock_release(cp->lock);
  286|  18.3k|}

pool_policy_malloc.c:default_block_alloc:
   33|  9.73k|{
   34|  9.73k|    void *p;
   35|       |
   36|  9.73k|    PJ_CHECK_STACK();
   37|       |
   38|  9.73k|    if (factory->on_block_alloc) {
  ------------------
  |  Branch (38:9): [True: 0, False: 9.73k]
  ------------------
   39|      0|        int rc;
   40|      0|        rc = factory->on_block_alloc(factory, size);
   41|      0|        if (!rc)
  ------------------
  |  Branch (41:13): [True: 0, False: 0]
  ------------------
   42|      0|            return NULL;
   43|      0|    }
   44|       |
   45|  9.73k|    p = malloc(size+(SIG_SIZE << 1));
  ------------------
  |  |   64|  9.73k|#   define SIG_SIZE         0
  ------------------
   46|       |
   47|  9.73k|    if (p == NULL) {
  ------------------
  |  Branch (47:9): [True: 0, False: 9.73k]
  ------------------
   48|      0|        if (factory->on_block_free) 
  ------------------
  |  Branch (48:13): [True: 0, False: 0]
  ------------------
   49|      0|            factory->on_block_free(factory, size);
   50|  9.73k|    } else {
   51|       |        /* Apply signature when PJ_SAFE_POOL is set. It will move
   52|       |         * "p" pointer forward.
   53|       |         */
   54|  9.73k|        APPLY_SIG(p, size);
   55|  9.73k|    }
   56|       |
   57|  9.73k|    return p;
   58|  9.73k|}
pool_policy_malloc.c:default_block_free:
   62|  9.67k|{
   63|  9.67k|    PJ_CHECK_STACK();
   64|       |
   65|  9.67k|    if (factory->on_block_free) 
  ------------------
  |  Branch (65:9): [True: 0, False: 9.67k]
  ------------------
   66|      0|        factory->on_block_free(factory, size);
   67|       |
   68|       |    /* Check and remove signature when PJ_SAFE_POOL is set. It will
   69|       |     * move "mem" pointer backward.
   70|       |     */
   71|  9.67k|    REMOVE_SIG(mem, size);
   72|       |
   73|       |    /* Note that when PJ_SAFE_POOL is set, the actual size of the block
   74|       |     * is size + SIG_SIZE*2.
   75|       |     */
   76|       |
   77|  9.67k|    free(mem);
   78|  9.67k|}

pj_rand:
   30|  9.63k|{
   31|  9.63k|    PJ_CHECK_STACK();
   32|  9.63k|    return platform_rand();
  ------------------
  |  |   43|  9.63k|#      define platform_rand rand
  ------------------
   33|  9.63k|}

PJ_FD_ZERO:
   43|      6|{
   44|      6|    PJ_CHECK_STACK();
   45|      6|    pj_assert(sizeof(pj_fd_set_t)-sizeof(pj_sock_t) >= sizeof(fd_set));
  ------------------
  |  |   65|      6|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (45:5): [True: 0, Folded]
  |  Branch (45:5): [True: 6, Folded]
  ------------------
   46|       |
   47|      6|    FD_ZERO(PART_FDSET(fdsetp));
  ------------------
  |  Branch (47:5): [Folded, False: 6]
  ------------------
   48|      6|    PART_COUNT(fdsetp) = 0;
  ------------------
  |  |   40|      6|#define PART_COUNT(ps)          (ps->data[0])
  ------------------
   49|      6|}
PJ_FD_COUNT:
   84|  17.0k|{
   85|  17.0k|    return PART_COUNT(fdsetp);
  ------------------
  |  |   40|  17.0k|#define PART_COUNT(ps)          (ps->data[0])
  ------------------
   86|  17.0k|}

pj_strstr:
  147|  11.8k|{
  148|  11.8k|    const char *s, *ends;
  149|  11.8k|    int first;
  150|       |
  151|  11.8k|    PJ_ASSERT_RETURN(str->slen >= 0 && substr->slen >= 0, NULL);
  ------------------
  |  |   97|  11.8k|            do { \
  |  |   98|  23.7k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 11.8k, False: 0]
  |  |  |  Branch (98:23): [True: 11.8k, False: 0]
  |  |  ------------------
  |  |   99|  11.8k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 11.8k]
  |  |  ------------------
  ------------------
  |  Branch (151:5): [True: 0, False: 0]
  |  Branch (151:5): [True: 0, False: 0]
  |  Branch (151:5): [True: 0, False: 0]
  |  Branch (151:5): [True: 0, False: 0]
  ------------------
  152|       |
  153|       |    /* Check if the string is empty */
  154|  11.8k|    if (str->slen <= 0)
  ------------------
  |  Branch (154:9): [True: 20, False: 11.8k]
  ------------------
  155|     20|        return NULL;
  156|       |
  157|       |    /* Special case when substr is empty */
  158|  11.8k|    if (substr->slen <= 0) {
  ------------------
  |  Branch (158:9): [True: 0, False: 11.8k]
  ------------------
  159|      0|        return (char*)str->ptr;
  160|      0|    }
  161|       |
  162|  11.8k|    s = str->ptr;
  163|  11.8k|    ends = str->ptr + str->slen - substr->slen;
  164|  11.8k|    first = substr->ptr[0];
  165|   317k|    for (; s<=ends; ++s) {
  ------------------
  |  Branch (165:12): [True: 317k, False: 311]
  ------------------
  166|   317k|        if (s[0] == first && pj_memcmp(s, substr->ptr, substr->slen) == 0)
  ------------------
  |  Branch (166:13): [True: 21.0k, False: 296k]
  |  Branch (166:30): [True: 11.5k, False: 9.52k]
  ------------------
  167|  11.5k|            return (char*)s;
  168|   317k|    }
  169|    311|    return NULL;
  170|  11.8k|}
pj_strltrim:
  201|  22.8k|{
  202|  22.8k|    char *end = str->ptr + str->slen;
  203|  22.8k|    register char *p = str->ptr;
  204|       |
  205|  22.8k|    pj_assert(str->slen >= 0);
  ------------------
  |  |   65|  22.8k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (205:5): [True: 0, False: 22.8k]
  |  Branch (205:5): [True: 22.8k, False: 0]
  ------------------
  206|       |
  207|  23.7k|    while (p < end && pj_isspace(*p))
  ------------------
  |  Branch (207:12): [True: 22.9k, False: 749]
  |  Branch (207:23): [True: 865, False: 22.0k]
  ------------------
  208|    865|        ++p;
  209|  22.8k|    str->slen -= (p - str->ptr);
  210|  22.8k|    str->ptr = p;
  211|  22.8k|    return str;
  212|  22.8k|}
pj_strrtrim:
  215|  1.76k|{
  216|  1.76k|    char *end = str->ptr + str->slen;
  217|  1.76k|    register char *p = end - 1;
  218|       |
  219|  1.76k|    pj_assert(str->slen >= 0);
  ------------------
  |  |   65|  1.76k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (219:5): [True: 0, False: 1.76k]
  |  Branch (219:5): [True: 1.76k, False: 0]
  ------------------
  220|       |
  221|  2.21k|    while (p >= str->ptr && pj_isspace(*p))
  ------------------
  |  Branch (221:12): [True: 1.92k, False: 293]
  |  Branch (221:29): [True: 453, False: 1.47k]
  ------------------
  222|    453|        --p;
  223|  1.76k|    str->slen -= ((end - p) - 1);
  224|  1.76k|    return str;
  225|  1.76k|}
pj_strtol2:
  274|  10.6k|{
  275|  10.6k|    pj_str_t s;
  276|  10.6k|    unsigned long retval = 0;
  277|  10.6k|    pj_bool_t is_negative = PJ_FALSE;
  278|  10.6k|    int rc = 0;
  279|       |
  280|  10.6k|    PJ_CHECK_STACK();
  281|       |
  282|  10.6k|    if (!str || !value) {
  ------------------
  |  Branch (282:9): [True: 0, False: 10.6k]
  |  Branch (282:17): [True: 0, False: 10.6k]
  ------------------
  283|      0|        return PJ_EINVAL;
  ------------------
  |  |  393|      0|#define PJ_EINVAL           (PJ_ERRNO_START_STATUS + 4) /* 70004 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  284|      0|    }
  285|  10.6k|    PJ_ASSERT_RETURN(str->slen >= 0, PJ_EINVAL);
  ------------------
  |  |   97|  10.6k|            do { \
  |  |   98|  10.6k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 10.6k]
  |  |  ------------------
  |  |   99|  10.6k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 10.6k]
  |  |  ------------------
  ------------------
  |  Branch (285:5): [True: 0, False: 0]
  |  Branch (285:5): [True: 0, False: 0]
  ------------------
  286|       |
  287|  10.6k|    s = *str;
  288|  10.6k|    pj_strltrim(&s);
  289|       |
  290|  10.6k|    if (s.slen == 0)
  ------------------
  |  Branch (290:9): [True: 224, False: 10.4k]
  ------------------
  291|    224|        return PJ_EINVAL;
  ------------------
  |  |  393|    224|#define PJ_EINVAL           (PJ_ERRNO_START_STATUS + 4) /* 70004 */
  |  |  ------------------
  |  |  |  |  521|    224|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|    224|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|    224|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  292|       |
  293|  10.4k|    if (s.ptr[0] == '+' || s.ptr[0] == '-') {
  ------------------
  |  Branch (293:9): [True: 466, False: 9.96k]
  |  Branch (293:28): [True: 937, False: 9.02k]
  ------------------
  294|  1.40k|        is_negative = (s.ptr[0] == '-');
  295|  1.40k|        s.ptr += 1;
  296|  1.40k|        s.slen -= 1;
  297|  1.40k|    }
  298|       |
  299|  10.4k|    rc = pj_strtoul3(&s, &retval, 10);
  300|  10.4k|    if (rc == PJ_EINVAL) {
  ------------------
  |  |  393|  10.4k|#define PJ_EINVAL           (PJ_ERRNO_START_STATUS + 4) /* 70004 */
  |  |  ------------------
  |  |  |  |  521|  10.4k|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|  10.4k|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|  10.4k|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (300:9): [True: 736, False: 9.69k]
  ------------------
  301|    736|        return rc;
  302|  9.69k|    } else if (rc != PJ_SUCCESS) {
  ------------------
  |  Branch (302:16): [True: 405, False: 9.28k]
  ------------------
  303|    405|        *value = is_negative ? PJ_MINLONG : PJ_MAXLONG;
  ------------------
  |  |   45|    405|#define PJ_MINLONG      LONG_MIN
  ------------------
                      *value = is_negative ? PJ_MINLONG : PJ_MAXLONG;
  ------------------
  |  |   42|    405|#define PJ_MAXLONG      LONG_MAX
  ------------------
  |  Branch (303:18): [True: 1, False: 404]
  ------------------
  304|    405|        return is_negative ? PJ_ETOOSMALL : PJ_ETOOBIG;
  ------------------
  |  |  469|      1|#define PJ_ETOOSMALL        (PJ_ERRNO_START_STATUS + 19)/* 70019 */
  |  |  ------------------
  |  |  |  |  521|      1|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      1|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      1|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      return is_negative ? PJ_ETOOSMALL : PJ_ETOOBIG;
  ------------------
  |  |  458|    404|#define PJ_ETOOBIG          (PJ_ERRNO_START_STATUS + 17)/* 70017 */
  |  |  ------------------
  |  |  |  |  521|    404|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|    404|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|    404|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (304:16): [True: 1, False: 404]
  ------------------
  305|    405|    }
  306|       |
  307|  9.28k|    if (retval > PJ_MAXLONG && !is_negative) {
  ------------------
  |  |   42|  18.5k|#define PJ_MAXLONG      LONG_MAX
  ------------------
  |  Branch (307:9): [True: 406, False: 8.88k]
  |  Branch (307:32): [True: 254, False: 152]
  ------------------
  308|    254|        *value = PJ_MAXLONG;
  ------------------
  |  |   42|    254|#define PJ_MAXLONG      LONG_MAX
  ------------------
  309|    254|        return PJ_ETOOBIG;
  ------------------
  |  |  458|    254|#define PJ_ETOOBIG          (PJ_ERRNO_START_STATUS + 17)/* 70017 */
  |  |  ------------------
  |  |  |  |  521|    254|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|    254|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|    254|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  310|    254|    }
  311|       |
  312|  9.03k|    if (retval > (PJ_MAXLONG + 1UL) && is_negative) {
  ------------------
  |  |   42|  9.03k|#define PJ_MAXLONG      LONG_MAX
  ------------------
  |  Branch (312:9): [True: 85, False: 8.94k]
  |  Branch (312:40): [True: 85, False: 0]
  ------------------
  313|     85|        *value = PJ_MINLONG;
  ------------------
  |  |   45|     85|#define PJ_MINLONG      LONG_MIN
  ------------------
  314|     85|        return PJ_ETOOSMALL;
  ------------------
  |  |  469|     85|#define PJ_ETOOSMALL        (PJ_ERRNO_START_STATUS + 19)/* 70019 */
  |  |  ------------------
  |  |  |  |  521|     85|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|     85|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|     85|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  315|     85|    }
  316|       |
  317|  8.94k|    if (is_negative && retval == PJ_MAXLONG + 1UL) {
  ------------------
  |  |   42|    645|#define PJ_MAXLONG      LONG_MAX
  ------------------
  |  Branch (317:9): [True: 645, False: 8.30k]
  |  Branch (317:24): [True: 67, False: 578]
  ------------------
  318|     67|        *value = PJ_MINLONG;
  ------------------
  |  |   45|     67|#define PJ_MINLONG      LONG_MIN
  ------------------
  319|     67|        return PJ_SUCCESS;
  320|     67|    }
  321|       |
  322|  8.88k|    *value = is_negative ? -(long)retval : retval;
  ------------------
  |  Branch (322:14): [True: 578, False: 8.30k]
  ------------------
  323|       |
  324|  8.88k|    return PJ_SUCCESS;
  325|  8.94k|}
pj_strtoul:
  328|  1.43k|{
  329|  1.43k|    unsigned long value;
  330|  1.43k|    unsigned i;
  331|       |
  332|  1.43k|    PJ_CHECK_STACK();
  333|       |
  334|  1.43k|    pj_assert(str->slen >= 0);
  ------------------
  |  |   65|  1.43k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (334:5): [True: 0, False: 1.43k]
  |  Branch (334:5): [True: 1.43k, False: 0]
  ------------------
  335|       |
  336|  1.43k|    value = 0;
  337|  12.4k|    for (i=0; i<(unsigned)str->slen; ++i) {
  ------------------
  |  Branch (337:15): [True: 11.5k, False: 945]
  ------------------
  338|  11.5k|        if (!pj_isdigit(str->ptr[i]))
  ------------------
  |  Branch (338:13): [True: 492, False: 11.0k]
  ------------------
  339|    492|            break;
  340|  11.0k|        value = value * 10 + (str->ptr[i] - '0');
  341|  11.0k|    }
  342|  1.43k|    return value;
  343|  1.43k|}
pj_strtoul3:
  385|  10.4k|{
  386|  10.4k|    pj_str_t s;
  387|  10.4k|    unsigned i;
  388|       |
  389|  10.4k|    PJ_CHECK_STACK();
  390|       |
  391|  10.4k|    if (!str || !value) {
  ------------------
  |  Branch (391:9): [True: 0, False: 10.4k]
  |  Branch (391:17): [True: 0, False: 10.4k]
  ------------------
  392|      0|        return PJ_EINVAL;
  ------------------
  |  |  393|      0|#define PJ_EINVAL           (PJ_ERRNO_START_STATUS + 4) /* 70004 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  393|      0|    }
  394|  10.4k|    PJ_ASSERT_RETURN(str->slen >= 0, PJ_EINVAL);
  ------------------
  |  |   97|  10.4k|            do { \
  |  |   98|  10.4k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 10.4k]
  |  |  ------------------
  |  |   99|  10.4k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 10.4k]
  |  |  ------------------
  ------------------
  |  Branch (394:5): [True: 0, False: 0]
  |  Branch (394:5): [True: 0, False: 0]
  ------------------
  395|       |    
  396|  10.4k|    s = *str;
  397|  10.4k|    pj_strltrim(&s);
  398|       |
  399|  10.4k|    if (s.slen == 0 || s.ptr[0] < '0' ||
  ------------------
  |  Branch (399:9): [True: 232, False: 10.1k]
  |  Branch (399:24): [True: 228, False: 9.96k]
  ------------------
  400|  9.96k|        (base <= 10 && (unsigned)s.ptr[0] > ('0' - 1) + base) ||
  ------------------
  |  Branch (400:10): [True: 9.96k, False: 0]
  |  Branch (400:24): [True: 276, False: 9.69k]
  ------------------
  401|  9.69k|        (base == 16 && !pj_isxdigit(s.ptr[0])))
  ------------------
  |  Branch (401:10): [True: 0, False: 9.69k]
  |  Branch (401:24): [True: 0, False: 0]
  ------------------
  402|    736|    {
  403|    736|        return PJ_EINVAL;
  ------------------
  |  |  393|    736|#define PJ_EINVAL           (PJ_ERRNO_START_STATUS + 4) /* 70004 */
  |  |  ------------------
  |  |  |  |  521|    736|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|    736|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|    736|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  404|    736|    }
  405|       |
  406|  9.69k|    *value = 0;
  407|  9.69k|    if (base <= 10) {
  ------------------
  |  Branch (407:9): [True: 9.69k, False: 0]
  ------------------
  408|  52.8k|        for (i=0; i<(unsigned)s.slen; ++i) {
  ------------------
  |  Branch (408:19): [True: 46.3k, False: 6.53k]
  ------------------
  409|  46.3k|            unsigned c = s.ptr[i] - '0';
  410|  46.3k|            if (s.ptr[i] < '0' || (unsigned)s.ptr[i] > ('0' - 1) + base) {
  ------------------
  |  Branch (410:17): [True: 596, False: 45.7k]
  |  Branch (410:35): [True: 2.15k, False: 43.5k]
  ------------------
  411|  2.75k|                break;
  412|  2.75k|            }
  413|  43.5k|            if (*value > PJ_MAXULONG / base) {
  ------------------
  |  |   48|  43.5k|#define PJ_MAXULONG     ULONG_MAX
  ------------------
  |  Branch (413:17): [True: 209, False: 43.3k]
  ------------------
  414|    209|                *value = PJ_MAXULONG;
  ------------------
  |  |   48|    209|#define PJ_MAXULONG     ULONG_MAX
  ------------------
  415|    209|                return PJ_ETOOBIG;
  ------------------
  |  |  458|    209|#define PJ_ETOOBIG          (PJ_ERRNO_START_STATUS + 17)/* 70017 */
  |  |  ------------------
  |  |  |  |  521|    209|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|    209|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|    209|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  416|    209|            }
  417|       |
  418|  43.3k|            *value *= base;
  419|  43.3k|            if ((PJ_MAXULONG - *value) < c) {
  ------------------
  |  |   48|  43.3k|#define PJ_MAXULONG     ULONG_MAX
  ------------------
  |  Branch (419:17): [True: 196, False: 43.1k]
  ------------------
  420|    196|                *value = PJ_MAXULONG;
  ------------------
  |  |   48|    196|#define PJ_MAXULONG     ULONG_MAX
  ------------------
  421|    196|                return PJ_ETOOBIG;
  ------------------
  |  |  458|    196|#define PJ_ETOOBIG          (PJ_ERRNO_START_STATUS + 17)/* 70017 */
  |  |  ------------------
  |  |  |  |  521|    196|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|    196|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|    196|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  422|    196|            }
  423|  43.1k|            *value += c;
  424|  43.1k|        }
  425|  9.69k|    } else if (base == 16) {
  ------------------
  |  Branch (425:16): [True: 0, False: 0]
  ------------------
  426|      0|        for (i=0; i<(unsigned)s.slen; ++i) {
  ------------------
  |  Branch (426:19): [True: 0, False: 0]
  ------------------
  427|      0|            unsigned c = pj_hex_digit_to_val(s.ptr[i]);
  428|      0|            if (!pj_isxdigit(s.ptr[i]))
  ------------------
  |  Branch (428:17): [True: 0, False: 0]
  ------------------
  429|      0|                break;
  430|       |
  431|      0|            if (*value > PJ_MAXULONG / base) {
  ------------------
  |  |   48|      0|#define PJ_MAXULONG     ULONG_MAX
  ------------------
  |  Branch (431:17): [True: 0, False: 0]
  ------------------
  432|      0|                *value = PJ_MAXULONG;
  ------------------
  |  |   48|      0|#define PJ_MAXULONG     ULONG_MAX
  ------------------
  433|      0|                return PJ_ETOOBIG;
  ------------------
  |  |  458|      0|#define PJ_ETOOBIG          (PJ_ERRNO_START_STATUS + 17)/* 70017 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  434|      0|            }
  435|      0|            *value *= base;
  436|      0|            if ((PJ_MAXULONG - *value) < c) {
  ------------------
  |  |   48|      0|#define PJ_MAXULONG     ULONG_MAX
  ------------------
  |  Branch (436:17): [True: 0, False: 0]
  ------------------
  437|      0|                *value = PJ_MAXULONG;
  ------------------
  |  |   48|      0|#define PJ_MAXULONG     ULONG_MAX
  ------------------
  438|      0|                return PJ_ETOOBIG;
  ------------------
  |  |  458|      0|#define PJ_ETOOBIG          (PJ_ERRNO_START_STATUS + 17)/* 70017 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  439|      0|            }
  440|      0|            *value += c;
  441|      0|        }
  442|      0|    } else {
  443|      0|        pj_assert(!"Unsupported base");
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (443:9): [Folded, False: 0]
  |  Branch (443:9): [Folded, False: 0]
  ------------------
  444|      0|        return PJ_EINVAL;
  ------------------
  |  |  393|      0|#define PJ_EINVAL           (PJ_ERRNO_START_STATUS + 4) /* 70004 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  445|      0|    }
  446|  9.28k|    return PJ_SUCCESS;
  447|  9.69k|}
pj_utoa:
  556|    827|{
  557|    827|    return pj_utoa_pad(val, buf, 0, 0);
  558|    827|}
pj_utoa_pad:
  561|    899|{
  562|    899|    char *p;
  563|    899|    int len;
  564|       |
  565|    899|    PJ_CHECK_STACK();
  566|       |
  567|    899|    p = buf;
  568|  1.18k|    do {
  569|  1.18k|        unsigned long digval = (unsigned long) (val % 10);
  570|  1.18k|        val /= 10;
  571|  1.18k|        *p++ = (char) (digval + '0');
  572|  1.18k|    } while (val > 0);
  ------------------
  |  Branch (572:14): [True: 281, False: 899]
  ------------------
  573|       |
  574|    899|    len = (int)(p-buf);
  575|    917|    while (len < min_dig) {
  ------------------
  |  Branch (575:12): [True: 18, False: 899]
  ------------------
  576|     18|        *p++ = (char)pad;
  577|     18|        ++len;
  578|     18|    }
  579|    899|    *p-- = '\0';
  580|       |
  581|    961|    do {
  582|    961|        char temp = *p;
  583|    961|        *p = *buf;
  584|    961|        *buf = temp;
  585|    961|        --p;
  586|    961|        ++buf;
  587|    961|    } while (buf < p);
  ------------------
  |  Branch (587:14): [True: 62, False: 899]
  ------------------
  588|       |
  589|    899|    return len;
  590|    899|}
pj_ansi_strxcpy:
  631|  81.6k|{
  632|  81.6k|    char *odst = dst;
  633|       |
  634|  81.6k|    PJ_ASSERT_RETURN(dst && src, -PJ_EINVAL);
  ------------------
  |  |   97|  81.6k|            do { \
  |  |   98|   163k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 81.6k, False: 0]
  |  |  |  Branch (98:23): [True: 81.6k, False: 0]
  |  |  ------------------
  |  |   99|  81.6k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 81.6k]
  |  |  ------------------
  ------------------
  |  Branch (634:5): [True: 0, False: 0]
  |  Branch (634:5): [True: 0, False: 0]
  |  Branch (634:5): [True: 0, False: 0]
  |  Branch (634:5): [True: 0, False: 0]
  ------------------
  635|       |
  636|  81.6k|    if (dst_size==0)
  ------------------
  |  Branch (636:9): [True: 0, False: 81.6k]
  ------------------
  637|      0|        return -PJ_ETOOBIG;
  ------------------
  |  |  458|      0|#define PJ_ETOOBIG          (PJ_ERRNO_START_STATUS + 17)/* 70017 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  638|       |
  639|  1.42M|    while (--dst_size && (*dst=*src) != 0) {
  ------------------
  |  Branch (639:12): [True: 1.42M, False: 0]
  |  Branch (639:26): [True: 1.34M, False: 81.6k]
  ------------------
  640|  1.34M|        ++dst;
  641|  1.34M|        ++src;
  642|  1.34M|    }
  643|       |
  644|  81.6k|    if (!*dst && !*src) {
  ------------------
  |  Branch (644:9): [True: 81.6k, False: 18.4E]
  |  Branch (644:18): [True: 81.6k, False: 0]
  ------------------
  645|  81.6k|        return (int)(dst-odst);
  646|  18.4E|    } else {
  647|  18.4E|        *dst = '\0';
  648|  18.4E|        return *src? -PJ_ETOOBIG : (int)(dst-odst);
  ------------------
  |  |  458|      0|#define PJ_ETOOBIG          (PJ_ERRNO_START_STATUS + 17)/* 70017 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (648:16): [True: 0, False: 18.4E]
  ------------------
  649|  18.4E|    }
  650|  81.6k|}

pj_timer_heap_create:
  592|      2|{
  593|      2|    pj_timer_heap_t *ht;
  594|      2|    pj_size_t i;
  595|       |
  596|      2|    PJ_ASSERT_RETURN(pool && p_heap, PJ_EINVAL);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      4|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 2, False: 0]
  |  |  |  Branch (98:23): [True: 2, False: 0]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (596:5): [True: 0, False: 0]
  |  Branch (596:5): [True: 0, False: 0]
  |  Branch (596:5): [True: 0, False: 0]
  |  Branch (596:5): [True: 0, False: 0]
  ------------------
  597|       |
  598|      2|    *p_heap = NULL;
  599|       |
  600|       |    /* Magic? */
  601|      2|    size += 2;
  602|       |
  603|       |    /* Allocate timer heap data structure from the pool */
  604|      2|    ht = PJ_POOL_ZALLOC_T(pool, pj_timer_heap_t);
  ------------------
  |  |  583|      2|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  605|      2|    if (!ht)
  ------------------
  |  Branch (605:9): [True: 0, False: 2]
  ------------------
  606|      0|        return PJ_ENOMEM;
  ------------------
  |  |  408|      0|#define PJ_ENOMEM           (PJ_ERRNO_START_STATUS + 7) /* 70007 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  607|       |
  608|       |    /* Initialize timer heap sizes */
  609|      2|    ht->max_size = size;
  610|      2|    ht->cur_size = 0;
  611|      2|    ht->max_entries_per_poll = DEFAULT_MAX_TIMED_OUT_PER_POLL;
  ------------------
  |  |   46|      2|#define DEFAULT_MAX_TIMED_OUT_PER_POLL  (64)
  ------------------
  612|      2|    ht->timer_ids_freelist = 1;
  613|      2|    ht->pool = pool;
  614|       |
  615|       |    /* Lock. */
  616|      2|    ht->lock = NULL;
  617|      2|    ht->auto_delete_lock = 0;
  618|       |
  619|       |    // Create the heap array.
  620|      2|    ht->heap = (pj_timer_entry_dup**)
  621|      2|               pj_pool_calloc(pool, (unsigned)size,
  622|      2|                              sizeof(pj_timer_entry_dup*));
  623|      2|    if (!ht->heap)
  ------------------
  |  Branch (623:9): [True: 0, False: 2]
  ------------------
  624|      0|        return PJ_ENOMEM;
  ------------------
  |  |  408|      0|#define PJ_ENOMEM           (PJ_ERRNO_START_STATUS + 7) /* 70007 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  625|       |
  626|      2|#if PJ_TIMER_USE_COPY
  627|       |    // Create the timer entry copies array.
  628|      2|    ht->timer_dups = (pj_timer_entry_dup*)
  629|      2|                     pj_pool_alloc(pool, sizeof(pj_timer_entry_dup) * size);
  630|      2|    if (!ht->timer_dups)
  ------------------
  |  Branch (630:9): [True: 0, False: 2]
  ------------------
  631|      0|        return PJ_ENOMEM;
  ------------------
  |  |  408|      0|#define PJ_ENOMEM           (PJ_ERRNO_START_STATUS + 7) /* 70007 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  632|      2|#endif
  633|       |
  634|       |    // Create the parallel
  635|      2|    ht->timer_ids = (pj_timer_id_t *)
  636|      2|                    pj_pool_alloc( pool, sizeof(pj_timer_id_t) * size);
  637|      2|    if (!ht->timer_ids)
  ------------------
  |  Branch (637:9): [True: 0, False: 2]
  ------------------
  638|      0|        return PJ_ENOMEM;
  ------------------
  |  |  408|      0|#define PJ_ENOMEM           (PJ_ERRNO_START_STATUS + 7) /* 70007 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  639|       |
  640|       |    // Initialize the "freelist," which uses negative values to
  641|       |    // distinguish freelist elements from "pointers" into the <heap_>
  642|       |    // array.
  643|  6.14k|    for (i=0; i<size; ++i)
  ------------------
  |  Branch (643:15): [True: 6.14k, False: 2]
  ------------------
  644|  6.14k|        ht->timer_ids[i] = -((pj_timer_id_t) (i + 1));
  645|       |
  646|       |#if PJ_TIMER_USE_LINKED_LIST
  647|       |    pj_list_init(&ht->head_list);
  648|       |#endif
  649|       |
  650|      2|    *p_heap = ht;
  651|      2|    return PJ_SUCCESS;
  652|      2|}
pj_timer_heap_set_lock:
  665|      2|{
  666|      2|    if (ht->lock && ht->auto_delete_lock)
  ------------------
  |  Branch (666:9): [True: 0, False: 2]
  |  Branch (666:21): [True: 0, False: 0]
  ------------------
  667|      0|        pj_lock_destroy(ht->lock);
  668|       |
  669|      2|    ht->lock = lock;
  670|      2|    ht->auto_delete_lock = auto_del;
  671|      2|}
pj_timer_heap_set_max_timed_out_per_poll:
  676|      2|{
  677|      2|    unsigned old_count = ht->max_entries_per_poll;
  678|      2|    ht->max_entries_per_poll = count;
  679|      2|    return old_count;
  680|      2|}
pj_timer_entry_running:
  701|    323|{
  702|    323|    return (entry->_timer_id >= 1);
  703|    323|}
pj_timer_heap_schedule_w_grp_lock_dbg:
  785|    302|{
  786|    302|    return schedule_w_grp_lock_dbg(ht, entry, delay, PJ_TRUE, id_val,
  787|    302|                                   grp_lock, src_file, src_line);
  788|    302|}
pj_timer_heap_cancel:
  847|     20|{
  848|     20|    return cancel_timer(ht, entry, 0, 0);
  849|     20|}
pj_timer_heap_cancel_if_active:
  854|    843|{
  855|    843|    return cancel_timer(ht, entry, F_SET_ID | F_DONT_ASSERT, id_val);
  856|    843|}
pj_timer_heap_poll:
  860|  5.68k|{
  861|  5.68k|    pj_time_val now;
  862|  5.68k|    pj_time_val min_time_node = {0,0};
  863|  5.68k|    unsigned count;
  864|  5.68k|    pj_timer_id_t slot = 0;
  865|       |
  866|  5.68k|    PJ_ASSERT_RETURN(ht, 0);
  ------------------
  |  |   97|  5.68k|            do { \
  |  |   98|  5.68k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 5.68k]
  |  |  ------------------
  |  |   99|  5.68k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 5.68k]
  |  |  ------------------
  ------------------
  |  Branch (866:5): [True: 0, False: 0]
  |  Branch (866:5): [True: 0, False: 0]
  ------------------
  867|       |
  868|  5.68k|    lock_timer_heap(ht);
  869|  5.68k|    if (!ht->cur_size && next_delay) {
  ------------------
  |  Branch (869:9): [True: 3.26k, False: 2.41k]
  |  Branch (869:26): [True: 3.26k, False: 0]
  ------------------
  870|  3.26k|        next_delay->sec = next_delay->msec = PJ_MAXINT32;
  ------------------
  |  |   30|  3.26k|#define PJ_MAXINT32     0x7fffffff
  ------------------
  871|  3.26k|        unlock_timer_heap(ht);
  872|  3.26k|        return 0;
  873|  3.26k|    }
  874|       |
  875|  2.41k|    count = 0;
  876|  2.41k|    pj_gettickcount(&now);
  877|       |
  878|  2.41k|    if (ht->cur_size) {
  ------------------
  |  Branch (878:9): [True: 2.41k, False: 0]
  ------------------
  879|       |#if PJ_TIMER_USE_LINKED_LIST
  880|       |        slot = ht->timer_ids[GET_FIELD(ht->head_list.next, _timer_id)];
  881|       |#endif
  882|  2.41k|        min_time_node = ht->heap[slot]->_timer_value;
  883|  2.41k|    }
  884|       |
  885|  2.69k|    while ( ht->cur_size && 
  ------------------
  |  Branch (885:13): [True: 2.69k, False: 8]
  ------------------
  886|  2.69k|            PJ_TIME_VAL_LTE(min_time_node, now) &&
  ------------------
  |  |  529|  5.39k|#define PJ_TIME_VAL_LTE(t1, t2) (!PJ_TIME_VAL_GT(t1, t2))
  |  |  ------------------
  |  |  |  |  497|  2.69k|#define PJ_TIME_VAL_GT(t1, t2)  ((t1).sec>(t2).sec || \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (497:34): [True: 2.41k, False: 281]
  |  |  |  |  ------------------
  |  |  |  |  498|  2.69k|                                ((t1).sec==(t2).sec && (t1).msec>(t2).msec))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (498:34): [True: 281, False: 0]
  |  |  |  |  |  Branch (498:56): [True: 0, False: 281]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  887|    281|            count < ht->max_entries_per_poll ) 
  ------------------
  |  Branch (887:13): [True: 281, False: 0]
  ------------------
  888|    281|    {
  889|    281|        pj_timer_entry_dup *node = remove_node(ht, slot);
  890|    281|        pj_timer_entry *entry = GET_ENTRY(node);
  ------------------
  |  |  106|    281|#define GET_ENTRY(node) node->entry
  ------------------
  891|       |        /* Avoid re-use of this timer until the callback is done. */
  892|       |        ///Not necessary, even causes problem (see also #2176).
  893|       |        ///pj_timer_id_t node_timer_id = pop_freelist(ht);
  894|    281|        pj_grp_lock_t *grp_lock;
  895|    281|        pj_bool_t valid = PJ_TRUE;
  896|       |
  897|    281|        ++count;
  898|       |
  899|    281|        grp_lock = node->_grp_lock;
  900|    281|        node->_grp_lock = NULL;
  901|    281|        if (GET_FIELD(node, cb) != entry->cb ||
  ------------------
  |  |  107|    281|#define GET_FIELD(node, _timer_id) node->dup._timer_id
  ------------------
  |  Branch (901:13): [True: 0, False: 281]
  ------------------
  902|    281|            GET_FIELD(node, user_data) != entry->user_data)
  ------------------
  |  |  107|    281|#define GET_FIELD(node, _timer_id) node->dup._timer_id
  ------------------
  |  Branch (902:13): [True: 0, False: 281]
  ------------------
  903|      0|        {
  904|      0|            valid = PJ_FALSE;
  905|      0|#if PJ_TIMER_DEBUG
  906|      0|            PJ_LOG(3,(THIS_FILE, "Bug! Polling entry %p from %s line %d has "
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  464|      0|    #define pj_log_wrapper_3(arg)       pj_log_3 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  907|      0|                                 "been deallocated without being cancelled",
  908|      0|                                 GET_ENTRY(node),
  909|      0|                                 node->src_file, node->src_line));
  910|       |#else
  911|       |            PJ_LOG(3,(THIS_FILE, "Bug! Polling entry %p has "
  912|       |                                 "been deallocated without being cancelled",
  913|       |                                 GET_ENTRY(node)));
  914|       |#endif
  915|       |#if ASSERT_IF_ENTRY_DESTROYED
  916|       |            pj_assert(node->dup.cb == entry->cb);
  917|       |            pj_assert(node->dup.user_data == entry->user_data);
  918|       |#endif
  919|      0|        }
  920|       |
  921|    281|        unlock_timer_heap(ht);
  922|       |
  923|    281|        PJ_RACE_ME(5);
  924|       |
  925|    281|        if (valid && entry->cb)
  ------------------
  |  Branch (925:13): [True: 281, False: 0]
  |  Branch (925:22): [True: 281, False: 0]
  ------------------
  926|    281|            (*entry->cb)(ht, entry);
  927|       |
  928|    281|        if (valid && grp_lock)
  ------------------
  |  Branch (928:13): [True: 281, False: 0]
  |  Branch (928:22): [True: 281, False: 0]
  ------------------
  929|    281|            pj_grp_lock_dec_ref(grp_lock);
  930|       |
  931|    281|        lock_timer_heap(ht);
  932|       |        /* Now, the timer is really free for re-use. */
  933|       |        ///push_freelist(ht, node_timer_id);
  934|       |
  935|    281|        if (ht->cur_size) {
  ------------------
  |  Branch (935:13): [True: 273, False: 8]
  ------------------
  936|       |#if PJ_TIMER_USE_LINKED_LIST
  937|       |            slot = ht->timer_ids[GET_FIELD(ht->head_list.next, _timer_id)];
  938|       |#endif
  939|    273|            min_time_node = ht->heap[slot]->_timer_value;
  940|       |            /* Update now */
  941|    273|            pj_gettickcount(&now);
  942|    273|        }
  943|    281|    }
  944|  2.41k|    if (ht->cur_size && next_delay) {
  ------------------
  |  Branch (944:9): [True: 2.41k, False: 8]
  |  Branch (944:25): [True: 2.41k, False: 0]
  ------------------
  945|  2.41k|        *next_delay = ht->heap[0]->_timer_value;
  946|  2.41k|        if (count > 0)
  ------------------
  |  Branch (946:13): [True: 273, False: 2.13k]
  ------------------
  947|    273|            pj_gettickcount(&now);
  948|  2.41k|        PJ_TIME_VAL_SUB(*next_delay, now);
  ------------------
  |  |  554|  2.41k|#define PJ_TIME_VAL_SUB(t1, t2)     do {                            \
  |  |  555|  2.41k|                                        (t1).sec -= (t2).sec;       \
  |  |  556|  2.41k|                                        (t1).msec -= (t2).msec;     \
  |  |  557|  2.41k|                                        pj_time_val_normalize(&(t1)); \
  |  |  558|  2.41k|                                    } while (0)
  |  |  ------------------
  |  |  |  Branch (558:46): [Folded, False: 2.41k]
  |  |  ------------------
  ------------------
  949|  2.41k|        if (next_delay->sec < 0 || next_delay->msec < 0)
  ------------------
  |  Branch (949:13): [True: 0, False: 2.41k]
  |  Branch (949:36): [True: 0, False: 2.41k]
  ------------------
  950|      0|            next_delay->sec = next_delay->msec = 0;
  951|  2.41k|    } else if (next_delay) {
  ------------------
  |  Branch (951:16): [True: 8, False: 0]
  ------------------
  952|      8|        next_delay->sec = next_delay->msec = PJ_MAXINT32;
  ------------------
  |  |   30|      8|#define PJ_MAXINT32     0x7fffffff
  ------------------
  953|      8|    }
  954|  2.41k|    unlock_timer_heap(ht);
  955|       |
  956|  2.41k|    return count;
  957|  5.68k|}
timer.c:schedule_w_grp_lock_dbg:
  722|    302|{
  723|    302|    pj_status_t status;
  724|    302|    pj_time_val expires;
  725|       |
  726|    302|    PJ_ASSERT_RETURN(ht && entry && delay, PJ_EINVAL);
  ------------------
  |  |   97|    302|            do { \
  |  |   98|  1.20k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 302, False: 0]
  |  |  |  Branch (98:23): [True: 302, False: 0]
  |  |  |  Branch (98:23): [True: 302, False: 0]
  |  |  ------------------
  |  |   99|    302|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 302]
  |  |  ------------------
  ------------------
  |  Branch (726:5): [True: 0, False: 0]
  |  Branch (726:5): [True: 0, False: 0]
  |  Branch (726:5): [True: 0, False: 0]
  |  Branch (726:5): [True: 0, False: 0]
  |  Branch (726:5): [True: 0, False: 0]
  |  Branch (726:5): [True: 0, False: 0]
  ------------------
  727|    302|    PJ_ASSERT_RETURN(entry->cb != NULL, PJ_EINVAL);
  ------------------
  |  |   97|    302|            do { \
  |  |   98|    302|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 302]
  |  |  ------------------
  |  |   99|    302|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 302]
  |  |  ------------------
  ------------------
  |  Branch (727:5): [True: 0, False: 0]
  |  Branch (727:5): [True: 0, False: 0]
  ------------------
  728|       |
  729|       |    /* Prevent same entry from being scheduled more than once */
  730|       |    //PJ_ASSERT_RETURN(entry->_timer_id < 1, PJ_EINVALIDOP);
  731|       |
  732|    302|    pj_gettickcount(&expires);
  733|    302|    PJ_TIME_VAL_ADD(expires, *delay);
  ------------------
  |  |  539|    302|#define PJ_TIME_VAL_ADD(t1, t2)     do {                            \
  |  |  540|    302|                                        (t1).sec += (t2).sec;       \
  |  |  541|    302|                                        (t1).msec += (t2).msec;     \
  |  |  542|    302|                                        pj_time_val_normalize(&(t1)); \
  |  |  543|    302|                                    } while (0)
  |  |  ------------------
  |  |  |  Branch (543:46): [Folded, False: 302]
  |  |  ------------------
  ------------------
  734|       |
  735|    302|    lock_timer_heap(ht);
  736|       |
  737|       |    /* Prevent same entry from being scheduled more than once */
  738|    302|    if (pj_timer_entry_running(entry)) {
  ------------------
  |  Branch (738:9): [True: 0, False: 302]
  ------------------
  739|      0|        unlock_timer_heap(ht);
  740|      0|        PJ_LOG(3,(THIS_FILE, "Warning! Rescheduling outstanding entry (%p)",
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  464|      0|    #define pj_log_wrapper_3(arg)       pj_log_3 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  741|      0|                  entry));
  742|      0|        return PJ_EINVALIDOP;
  ------------------
  |  |  438|      0|#define PJ_EINVALIDOP       (PJ_ERRNO_START_STATUS + 13)/* 70013 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  743|      0|    }
  744|       |
  745|    302|    status = schedule_entry(ht, entry, &expires);
  746|    302|    if (status == PJ_SUCCESS) {
  ------------------
  |  Branch (746:9): [True: 302, False: 0]
  ------------------
  747|    302|        pj_timer_entry_dup *timer_copy = GET_TIMER(ht, entry);
  ------------------
  |  |  105|    302|#define GET_TIMER(ht, node) &ht->timer_dups[node->_timer_id]
  ------------------
  748|       |
  749|    302|        if (set_id)
  ------------------
  |  Branch (749:13): [True: 302, False: 0]
  ------------------
  750|    302|            GET_FIELD(timer_copy, id) = entry->id = id_val;
  ------------------
  |  |  107|    302|#define GET_FIELD(node, _timer_id) node->dup._timer_id
  ------------------
  751|    302|        timer_copy->_grp_lock = grp_lock;
  752|    302|        if (timer_copy->_grp_lock) {
  ------------------
  |  Branch (752:13): [True: 281, False: 21]
  ------------------
  753|    281|            pj_grp_lock_add_ref(timer_copy->_grp_lock);
  754|    281|        }
  755|    302|#if PJ_TIMER_DEBUG
  756|    302|        timer_copy->src_file = src_file;
  757|    302|        timer_copy->src_line = src_line;
  758|    302|#endif
  759|    302|    }
  760|    302|    unlock_timer_heap(ht);
  761|       |
  762|    302|    return status;
  763|    302|}
timer.c:schedule_entry:
  517|    302|{
  518|    302|    if (ht->cur_size < ht->max_size)
  ------------------
  |  Branch (518:9): [True: 302, False: 0]
  ------------------
  519|    302|    {
  520|       |        // Obtain the next unique sequence number.
  521|       |        // Set the entry
  522|    302|        entry->_timer_id = pop_freelist(ht);
  523|       |
  524|    302|        return insert_node( ht, entry, future_time );
  525|    302|    }
  526|      0|    else
  527|      0|        return -1;
  528|    302|}
timer.c:pop_freelist:
  216|    302|{
  217|       |    // We need to truncate this to <int> for backwards compatibility.
  218|    302|    pj_timer_id_t new_id = ht->timer_ids_freelist;
  219|       |
  220|    302|    PJ_CHECK_STACK();
  221|       |
  222|       |    // The freelist values in the <timer_ids_> are negative, so we need
  223|       |    // to negate them to get the next freelist "pointer."
  224|    302|    ht->timer_ids_freelist =
  225|    302|        -ht->timer_ids[ht->timer_ids_freelist];
  226|       |
  227|    302|    return new_id;
  228|       |
  229|    302|}
timer.c:insert_node:
  456|    302|{
  457|    302|    pj_timer_entry_dup *timer_copy;
  458|       |
  459|       |#if PJ_TIMER_USE_LINKED_LIST
  460|       |    pj_timer_entry_dup *tmp_node = NULL;
  461|       |#endif
  462|       |
  463|    302|    if (ht->cur_size + 2 >= ht->max_size) {
  ------------------
  |  Branch (463:9): [True: 0, False: 302]
  ------------------
  464|      0|        pj_status_t status = grow_heap(ht);
  465|      0|        if (status != PJ_SUCCESS)
  ------------------
  |  Branch (465:13): [True: 0, False: 0]
  ------------------
  466|      0|            return status;
  467|      0|    }
  468|       |
  469|    302|    timer_copy = GET_TIMER(ht, new_node);
  ------------------
  |  |  105|    302|#define GET_TIMER(ht, node) &ht->timer_dups[node->_timer_id]
  ------------------
  470|    302|#if PJ_TIMER_USE_COPY
  471|       |    // Create a duplicate of the timer entry.
  472|    302|    pj_bzero(timer_copy, sizeof(*timer_copy));
  473|    302|    pj_memcpy(&timer_copy->dup, new_node, sizeof(*new_node));
  474|    302|    timer_copy->entry = new_node;
  475|    302|#endif
  476|       |
  477|       |#if PJ_TIMER_USE_LINKED_LIST
  478|       |    pj_list_init(timer_copy);
  479|       |#endif
  480|       |
  481|    302|    timer_copy->_timer_value = *future_time;
  482|       |
  483|    302|#if !PJ_TIMER_USE_LINKED_LIST
  484|    302|    reheap_up(ht, timer_copy, ht->cur_size, HEAP_PARENT(ht->cur_size));
  ------------------
  |  |   42|    302|#define HEAP_PARENT(X)  (X == 0 ? 0 : (((X) - 1) / 2))
  |  |  ------------------
  |  |  |  Branch (42:26): [True: 50, False: 252]
  |  |  ------------------
  ------------------
  485|       |#else
  486|       |    if (ht->cur_size == 0) {
  487|       |        pj_list_push_back(&ht->head_list, timer_copy);
  488|       |    } else if (PJ_TIME_VAL_GTE(*future_time,
  489|       |                               ht->head_list.prev->_timer_value))
  490|       |    {
  491|       |        /* Insert the max value to the end of the list. */
  492|       |        pj_list_insert_before(&ht->head_list, timer_copy);
  493|       |    } else {
  494|       |        tmp_node = ht->head_list.next;
  495|       |        while (tmp_node->next != &ht->head_list &&
  496|       |               PJ_TIME_VAL_GT(*future_time, tmp_node->_timer_value))
  497|       |        {
  498|       |            tmp_node = tmp_node->next;
  499|       |        }
  500|       |        if (PJ_TIME_VAL_LT(*future_time, tmp_node->_timer_value)) {
  501|       |            pj_list_insert_before(tmp_node, timer_copy);
  502|       |        } else {
  503|       |            pj_list_insert_after(tmp_node, timer_copy);
  504|       |        }
  505|       |    }
  506|       |    copy_node(ht, new_node->_timer_id-1, timer_copy);
  507|       |#endif
  508|    302|    ht->cur_size++;
  509|       |
  510|    302|    return PJ_SUCCESS;
  511|    302|}
timer.c:reheap_up:
  278|    302|{
  279|       |    // Restore the heap property after an insertion.
  280|       |
  281|    554|    while (slot > 0)
  ------------------
  |  Branch (281:12): [True: 252, False: 302]
  ------------------
  282|    252|    {
  283|       |        // If the parent node is greater than the <moved_node> we need
  284|       |        // to copy it down.
  285|    252|        if (PJ_TIME_VAL_LT(moved_node->_timer_value,
  ------------------
  |  |  519|    252|#define PJ_TIME_VAL_LT(t1, t2)  (!(PJ_TIME_VAL_GTE(t1,t2)))
  |  |  ------------------
  |  |  |  |  508|    252|#define PJ_TIME_VAL_GTE(t1, t2) (PJ_TIME_VAL_GT(t1,t2) || \
  |  |  |  |  ------------------
  |  |  |  |  |  |  497|    504|#define PJ_TIME_VAL_GT(t1, t2)  ((t1).sec>(t2).sec || \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (497:34): [True: 0, False: 252]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  498|    504|                                ((t1).sec==(t2).sec && (t1).msec>(t2).msec))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (498:34): [True: 0, False: 252]
  |  |  |  |  |  |  |  Branch (498:56): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  509|    252|                                 PJ_TIME_VAL_EQ(t1,t2))
  |  |  |  |  ------------------
  |  |  |  |  |  |  487|    252|#define PJ_TIME_VAL_EQ(t1, t2)  ((t1).sec==(t2).sec && (t1).msec==(t2).msec)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (487:34): [True: 0, False: 252]
  |  |  |  |  |  |  |  Branch (487:56): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  286|    252|                           ht->heap[parent]->_timer_value))
  287|    252|        {
  288|    252|            copy_node(ht, slot, ht->heap[parent]);
  289|    252|            slot = parent;
  290|    252|            parent = HEAP_PARENT(slot);
  ------------------
  |  |   42|    252|#define HEAP_PARENT(X)  (X == 0 ? 0 : (((X) - 1) / 2))
  |  |  ------------------
  |  |  |  Branch (42:26): [True: 252, False: 0]
  |  |  ------------------
  ------------------
  291|    252|        }
  292|      0|        else
  293|      0|            break;
  294|    252|    }
  295|       |
  296|       |    // Insert the new node into its proper resting place in the heap and
  297|       |    // update the corresponding slot in the parallel <timer_ids> array.
  298|    302|    copy_node(ht, slot, moved_node);
  299|    302|}
timer.c:copy_node:
  205|  1.05k|{
  206|  1.05k|    PJ_CHECK_STACK();
  207|       |
  208|       |    // Insert <moved_node> into its new location in the heap.
  209|  1.05k|    ht->heap[slot] = moved_node;
  210|       |
  211|       |    // Update the corresponding slot in the parallel <timer_ids_> array.
  212|  1.05k|    ht->timer_ids[GET_FIELD(moved_node, _timer_id)] = (int)slot;
  ------------------
  |  |  107|  1.05k|#define GET_FIELD(node, _timer_id) node->dup._timer_id
  ------------------
  213|  1.05k|}
timer.c:cancel_timer:
  812|    863|{
  813|    863|    pj_timer_entry_dup *timer_copy;
  814|    863|    pj_grp_lock_t *grp_lock;
  815|    863|    int count;
  816|       |
  817|    863|    PJ_ASSERT_RETURN(ht && entry, PJ_EINVAL);
  ------------------
  |  |   97|    863|            do { \
  |  |   98|  1.72k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 863, False: 0]
  |  |  |  Branch (98:23): [True: 863, False: 0]
  |  |  ------------------
  |  |   99|    863|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 863]
  |  |  ------------------
  ------------------
  |  Branch (817:5): [True: 0, False: 0]
  |  Branch (817:5): [True: 0, False: 0]
  |  Branch (817:5): [True: 0, False: 0]
  |  Branch (817:5): [True: 0, False: 0]
  ------------------
  818|       |
  819|    863|    lock_timer_heap(ht);
  820|       |
  821|       |    // Check to see if the timer_id is out of range
  822|    863|    if (entry->_timer_id < 1 || (pj_size_t)entry->_timer_id >= ht->max_size) {
  ------------------
  |  Branch (822:9): [True: 843, False: 20]
  |  Branch (822:33): [True: 0, False: 20]
  ------------------
  823|    843|        unlock_timer_heap(ht);
  824|    843|        return 0;
  825|    843|    }
  826|       |
  827|     20|    timer_copy = GET_TIMER(ht, entry);
  ------------------
  |  |  105|     20|#define GET_TIMER(ht, node) &ht->timer_dups[node->_timer_id]
  ------------------
  828|     20|    grp_lock = timer_copy->_grp_lock;
  829|       |
  830|     20|    count = cancel(ht, entry, flags | F_DONT_CALL);
  831|     20|    if (count > 0) {
  ------------------
  |  Branch (831:9): [True: 20, False: 0]
  ------------------
  832|       |        /* Timer entry found & cancelled */
  833|     20|        if (flags & F_SET_ID) {
  ------------------
  |  Branch (833:13): [True: 0, False: 20]
  ------------------
  834|      0|            entry->id = id_val;
  835|      0|        }
  836|     20|        if (grp_lock) {
  ------------------
  |  Branch (836:13): [True: 0, False: 20]
  ------------------
  837|      0|            pj_grp_lock_dec_ref(grp_lock);
  838|      0|        }
  839|     20|    }
  840|     20|    unlock_timer_heap(ht);
  841|       |
  842|     20|    return count;
  843|    863|}
timer.c:cancel:
  534|     20|{
  535|     20|    long timer_node_slot;
  536|       |
  537|     20|    PJ_CHECK_STACK();
  538|       |
  539|       |    // Check to see if the timer_id is out of range.
  540|       |    // Moved to cancel_timer() as it needs to validate _timer_id earlier
  541|       |    /*
  542|       |    if (entry->_timer_id < 1 || (pj_size_t)entry->_timer_id >= ht->max_size) {
  543|       |        entry->_timer_id = -1;
  544|       |        return 0;
  545|       |    }
  546|       |    */
  547|       |
  548|     20|    timer_node_slot = ht->timer_ids[entry->_timer_id];
  549|       |
  550|     20|    if (timer_node_slot < 0) { // Check to see if timer_id is still valid.
  ------------------
  |  Branch (550:9): [True: 0, False: 20]
  ------------------
  551|      0|        entry->_timer_id = -1;
  552|      0|        return 0;
  553|      0|    }
  554|       |
  555|     20|    if (entry != GET_ENTRY(ht->heap[timer_node_slot])) {
  ------------------
  |  |  106|     20|#define GET_ENTRY(node) node->entry
  ------------------
  |  Branch (555:9): [True: 0, False: 20]
  ------------------
  556|      0|        if ((flags & F_DONT_ASSERT) == 0)
  ------------------
  |  Branch (556:13): [True: 0, False: 0]
  ------------------
  557|      0|            pj_assert(entry == GET_ENTRY(ht->heap[timer_node_slot]));
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (557:13): [True: 0, False: 0]
  |  Branch (557:13): [True: 0, False: 0]
  ------------------
  558|      0|        entry->_timer_id = -1;
  559|      0|        return 0;
  560|     20|    } else {
  561|     20|        remove_node( ht, timer_node_slot);
  562|       |
  563|     20|        if ((flags & F_DONT_CALL) == 0) {
  ------------------
  |  Branch (563:13): [True: 0, False: 20]
  ------------------
  564|       |            // Call the close hook.
  565|      0|            (*ht->callback)(ht, entry);
  566|      0|        }
  567|     20|        return 1;
  568|     20|    }
  569|     20|}
timer.c:lock_timer_heap:
  189|  7.12k|{
  190|  7.12k|    if (ht->lock) {
  ------------------
  |  Branch (190:9): [True: 7.12k, False: 0]
  ------------------
  191|  7.12k|        pj_lock_acquire(ht->lock);
  192|  7.12k|    }
  193|  7.12k|}
timer.c:unlock_timer_heap:
  196|  7.12k|{
  197|  7.12k|    if (ht->lock) {
  ------------------
  |  Branch (197:9): [True: 7.12k, False: 0]
  ------------------
  198|  7.12k|        pj_lock_release(ht->lock);
  199|  7.12k|    }
  200|  7.12k|}
timer.c:remove_node:
  303|    301|{
  304|    301|    pj_timer_entry_dup *removed_node = ht->heap[slot];
  305|       |
  306|       |    // Return this timer id to the freelist.
  307|    301|    push_freelist( ht, GET_FIELD(removed_node, _timer_id) );
  ------------------
  |  |  107|    301|#define GET_FIELD(node, _timer_id) node->dup._timer_id
  ------------------
  308|       |
  309|       |    // Decrement the size of the heap by one since we're removing the
  310|       |    // "slot"th node.
  311|    301|    ht->cur_size--;
  312|       |
  313|       |    // Set the ID
  314|    301|    if (GET_FIELD(removed_node, _timer_id) !=
  ------------------
  |  |  107|    301|#define GET_FIELD(node, _timer_id) node->dup._timer_id
  ------------------
  |  Branch (314:9): [True: 0, False: 301]
  ------------------
  315|    301|        GET_ENTRY(removed_node)->_timer_id)
  ------------------
  |  |  106|    301|#define GET_ENTRY(node) node->entry
  ------------------
  316|      0|    {
  317|      0|#if PJ_TIMER_DEBUG
  318|      0|        PJ_LOG(3,(THIS_FILE, "Bug! Trying to remove entry %p from %s "
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  464|      0|    #define pj_log_wrapper_3(arg)       pj_log_3 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  319|      0|                             "line %d, which has been deallocated "
  320|      0|                             "without being cancelled",
  321|      0|                             GET_ENTRY(removed_node),
  322|      0|                             removed_node->src_file,
  323|      0|                             removed_node->src_line));
  324|       |#else
  325|       |        PJ_LOG(3,(THIS_FILE, "Bug! Trying to remove entry %p "
  326|       |                             "which has been deallocated "
  327|       |                             "without being cancelled",
  328|       |                             GET_ENTRY(removed_node)));
  329|       |#endif
  330|       |#if ASSERT_IF_ENTRY_DESTROYED
  331|       |        pj_assert(removed_node->dup._timer_id==removed_node->entry->_timer_id);
  332|       |#endif
  333|    301|    } else {
  334|    301|        GET_ENTRY(removed_node)->_timer_id = -1;
  ------------------
  |  |  106|    301|#define GET_ENTRY(node) node->entry
  ------------------
  335|    301|    }
  336|    301|    GET_FIELD(removed_node, _timer_id) = -1;
  ------------------
  |  |  107|    301|#define GET_FIELD(node, _timer_id) node->dup._timer_id
  ------------------
  337|       |
  338|    301|#if !PJ_TIMER_USE_LINKED_LIST
  339|       |    // Only try to reheapify if we're not deleting the last entry.
  340|       |
  341|    301|    if (slot < ht->cur_size)
  ------------------
  |  Branch (341:9): [True: 252, False: 49]
  ------------------
  342|    252|    {
  343|    252|        pj_size_t parent;
  344|    252|        pj_timer_entry_dup *moved_node = ht->heap[ht->cur_size];
  345|       |
  346|       |        // Move the end node to the location being removed and update
  347|       |        // the corresponding slot in the parallel <timer_ids> array.
  348|    252|        copy_node( ht, slot, moved_node);
  349|       |
  350|       |        // If the <moved_node->time_value_> is great than or equal its
  351|       |        // parent it needs be moved down the heap.
  352|    252|        parent = HEAP_PARENT (slot);
  ------------------
  |  |   42|    252|#define HEAP_PARENT(X)  (X == 0 ? 0 : (((X) - 1) / 2))
  |  |  ------------------
  |  |  |  Branch (42:26): [True: 252, False: 0]
  |  |  ------------------
  ------------------
  353|       |
  354|    252|        if (PJ_TIME_VAL_GTE(moved_node->_timer_value,
  ------------------
  |  |  508|    252|#define PJ_TIME_VAL_GTE(t1, t2) (PJ_TIME_VAL_GT(t1,t2) || \
  |  |  ------------------
  |  |  |  |  497|    504|#define PJ_TIME_VAL_GT(t1, t2)  ((t1).sec>(t2).sec || \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (497:34): [True: 0, False: 252]
  |  |  |  |  ------------------
  |  |  |  |  498|    504|                                ((t1).sec==(t2).sec && (t1).msec>(t2).msec))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (498:34): [True: 252, False: 0]
  |  |  |  |  |  Branch (498:56): [True: 0, False: 252]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  509|    252|                                 PJ_TIME_VAL_EQ(t1,t2))
  |  |  ------------------
  |  |  |  |  487|    252|#define PJ_TIME_VAL_EQ(t1, t2)  ((t1).sec==(t2).sec && (t1).msec==(t2).msec)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (487:34): [True: 252, False: 0]
  |  |  |  |  |  Branch (487:56): [True: 252, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  355|    252|                            ht->heap[parent]->_timer_value))
  356|    252|        {
  357|    252|            reheap_down( ht, moved_node, slot, HEAP_LEFT(slot));
  ------------------
  |  |   43|    252|#define HEAP_LEFT(X)    (((X)+(X))+1)
  ------------------
  358|    252|        } else {
  359|      0|            reheap_up( ht, moved_node, slot, parent);
  360|      0|        }
  361|    252|    }
  362|       |#else
  363|       |    pj_list_erase(removed_node);
  364|       |#endif
  365|       |
  366|    301|    return removed_node;
  367|    301|}
timer.c:push_freelist:
  232|    301|{
  233|    301|    PJ_CHECK_STACK();
  234|       |
  235|       |    // The freelist values in the <timer_ids_> are negative, so we need
  236|       |    // to negate them to get the next freelist "pointer."
  237|    301|    ht->timer_ids[old_id] = -ht->timer_ids_freelist;
  238|    301|    ht->timer_ids_freelist = old_id;
  239|    301|}
timer.c:reheap_down:
  244|    252|{
  245|    252|    PJ_CHECK_STACK();
  246|       |
  247|       |    // Restore the heap property after a deletion.
  248|       |
  249|    252|    while (child < ht->cur_size)
  ------------------
  |  Branch (249:12): [True: 0, False: 252]
  ------------------
  250|      0|    {
  251|       |        // Choose the smaller of the two children.
  252|      0|        if (child + 1 < ht->cur_size &&
  ------------------
  |  Branch (252:13): [True: 0, False: 0]
  ------------------
  253|      0|            PJ_TIME_VAL_LT(ht->heap[child + 1]->_timer_value,
  ------------------
  |  |  519|      0|#define PJ_TIME_VAL_LT(t1, t2)  (!(PJ_TIME_VAL_GTE(t1,t2)))
  |  |  ------------------
  |  |  |  |  508|      0|#define PJ_TIME_VAL_GTE(t1, t2) (PJ_TIME_VAL_GT(t1,t2) || \
  |  |  |  |  ------------------
  |  |  |  |  |  |  497|      0|#define PJ_TIME_VAL_GT(t1, t2)  ((t1).sec>(t2).sec || \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (497:34): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  498|      0|                                ((t1).sec==(t2).sec && (t1).msec>(t2).msec))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (498:34): [True: 0, False: 0]
  |  |  |  |  |  |  |  Branch (498:56): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  509|      0|                                 PJ_TIME_VAL_EQ(t1,t2))
  |  |  |  |  ------------------
  |  |  |  |  |  |  487|      0|#define PJ_TIME_VAL_EQ(t1, t2)  ((t1).sec==(t2).sec && (t1).msec==(t2).msec)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (487:34): [True: 0, False: 0]
  |  |  |  |  |  |  |  Branch (487:56): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  254|      0|                           ht->heap[child]->_timer_value))
  255|      0|        {
  256|      0|            child++;
  257|      0|        }
  258|       |
  259|       |        // Perform a <copy> if the child has a larger timeout value than
  260|       |        // the <moved_node>.
  261|      0|        if (PJ_TIME_VAL_LT(ht->heap[child]->_timer_value,
  ------------------
  |  |  519|      0|#define PJ_TIME_VAL_LT(t1, t2)  (!(PJ_TIME_VAL_GTE(t1,t2)))
  |  |  ------------------
  |  |  |  |  508|      0|#define PJ_TIME_VAL_GTE(t1, t2) (PJ_TIME_VAL_GT(t1,t2) || \
  |  |  |  |  ------------------
  |  |  |  |  |  |  497|      0|#define PJ_TIME_VAL_GT(t1, t2)  ((t1).sec>(t2).sec || \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (497:34): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  498|      0|                                ((t1).sec==(t2).sec && (t1).msec>(t2).msec))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (498:34): [True: 0, False: 0]
  |  |  |  |  |  |  |  Branch (498:56): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  509|      0|                                 PJ_TIME_VAL_EQ(t1,t2))
  |  |  |  |  ------------------
  |  |  |  |  |  |  487|      0|#define PJ_TIME_VAL_EQ(t1, t2)  ((t1).sec==(t2).sec && (t1).msec==(t2).msec)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (487:34): [True: 0, False: 0]
  |  |  |  |  |  |  |  Branch (487:56): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  262|      0|                           moved_node->_timer_value))
  263|      0|        {
  264|      0|            copy_node( ht, slot, ht->heap[child]);
  265|      0|            slot = child;
  266|      0|            child = HEAP_LEFT(child);
  ------------------
  |  |   43|      0|#define HEAP_LEFT(X)    (((X)+(X))+1)
  ------------------
  267|      0|        }
  268|      0|        else
  269|       |            // We've found our location in the heap.
  270|      0|            break;
  271|      0|    }
  272|       |
  273|    252|    copy_node( ht, slot, moved_node);
  274|    252|}

pj_time_val_normalize:
   23|  2.71k|{
   24|  2.71k|    PJ_CHECK_STACK();
   25|       |
   26|  2.71k|    if (t->msec >= 1000) {
  ------------------
  |  Branch (26:9): [True: 0, False: 2.71k]
  ------------------
   27|      0|        t->sec += (t->msec / 1000);
   28|      0|        t->msec = (t->msec % 1000);
   29|      0|    }
   30|  2.71k|    else if (t->msec <= -1000) {
  ------------------
  |  Branch (30:14): [True: 0, False: 2.71k]
  ------------------
   31|      0|        do {
   32|      0|            t->sec--;
   33|      0|            t->msec += 1000;
   34|      0|        } while (t->msec <= -1000);
  ------------------
  |  Branch (34:18): [True: 0, False: 0]
  ------------------
   35|      0|    }
   36|       |
   37|  2.71k|    if (t->sec >= 1 && t->msec < 0) {
  ------------------
  |  Branch (37:9): [True: 2.71k, False: 0]
  |  Branch (37:24): [True: 2.28k, False: 429]
  ------------------
   38|  2.28k|        t->sec--;
   39|  2.28k|        t->msec += 1000;
   40|       |
   41|  2.28k|    } else if (t->sec < 0 && t->msec > 0) {
  ------------------
  |  Branch (41:16): [True: 0, False: 429]
  |  Branch (41:30): [True: 0, False: 0]
  ------------------
   42|      0|        t->sec++;
   43|      0|        t->msec -= 1000;
   44|      0|    }
   45|  2.71k|}

sip_msg.c:init_hdr:
  153|  69.7k|{
  154|  69.7k|    pjsip_hdr *hdr = (pjsip_hdr*) hptr;
  155|  69.7k|    hdr->type = htype;
  156|  69.7k|    hdr->name.ptr = pjsip_hdr_names[htype].name;
  157|  69.7k|    hdr->name.slen = pjsip_hdr_names[htype].name_len;
  158|  69.7k|    if (pjsip_hdr_names[htype].sname) {
  ------------------
  |  Branch (158:9): [True: 58.6k, False: 11.1k]
  ------------------
  159|  58.6k|        hdr->sname.ptr = pjsip_hdr_names[htype].sname;
  160|  58.6k|        hdr->sname.slen = 1;
  161|  58.6k|    } else {
  162|  11.1k|        hdr->sname = hdr->name;
  163|  11.1k|    }
  164|  69.7k|    hdr->vptr = (pjsip_hdr_vptr*) vptr;
  165|  69.7k|    pj_list_init(hdr);
  166|  69.7k|}

sip_uri.c:pjsip_cfg:
  301|    499|{
  302|    499|    return &pjsip_sip_cfg_var;
  303|    499|}
sip_endpoint.c:pjsip_cfg:
  301|      2|{
  302|      2|    return &pjsip_sip_cfg_var;
  303|      2|}
sip_transaction.c:pjsip_cfg:
  301|     20|{
  302|     20|    return &pjsip_sip_cfg_var;
  303|     20|}
sip_util.c:pjsip_cfg:
  301|    168|{
  302|    168|    return &pjsip_sip_cfg_var;
  303|    168|}

sip_dialog.c:pjsip_msg_add_hdr:
  981|     27|{
  982|     27|    pj_list_insert_before(&msg->hdr, hdr);
  983|     27|}
sip_util.c:pjsip_msg_add_hdr:
  981|  3.14k|{
  982|  3.14k|    pj_list_insert_before(&msg->hdr, hdr);
  983|  3.14k|}
sip_util.c:pjsip_msg_insert_first_hdr:
  995|    168|{
  996|    168|    pj_list_insert_after(&msg->hdr, hdr);
  997|    168|}

sip_msg.c:pjsip_uri_clone:
  316|  2.66k|{
  317|  2.66k|    return (*((const pjsip_uri*)uri)->vptr->p_clone)(pool, uri);
  318|  2.66k|}
sip_uri.c:pjsip_uri_get_scheme:
  259|  2.12k|{
  260|  2.12k|    return (*((pjsip_uri*)uri)->vptr->p_get_scheme)(uri);
  261|  2.12k|}
sip_uri.c:pjsip_uri_get_uri:
  271|  1.44k|{
  272|  1.44k|    PJ_ASSERT_RETURN(uri, NULL);
  ------------------
  |  |   97|  1.44k|            do { \
  |  |   98|  1.44k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1.44k]
  |  |  ------------------
  |  |   99|  1.44k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1.44k]
  |  |  ------------------
  ------------------
  |  Branch (272:5): [True: 0, False: 0]
  |  Branch (272:5): [True: 0, False: 0]
  ------------------
  273|  1.44k|    return (*((pjsip_uri*)uri)->vptr->p_get_uri)((void*)uri);
  274|  1.44k|}
sip_uri.c:pjsip_uri_print:
  303|  1.39k|{
  304|  1.39k|    return (int)(*((const pjsip_uri*)uri)->vptr->p_print)(context, uri, 
  305|  1.39k|                                                          buf, size);
  306|  1.39k|}
sip_uri.c:pjsip_uri_clone:
  316|  2.44k|{
  317|  2.44k|    return (*((const pjsip_uri*)uri)->vptr->p_clone)(pool, uri);
  318|  2.44k|}
sip_dialog.c:pjsip_uri_get_scheme:
  259|  2.56k|{
  260|  2.56k|    return (*((pjsip_uri*)uri)->vptr->p_get_scheme)(uri);
  261|  2.56k|}
sip_dialog.c:pjsip_uri_get_uri:
  271|    218|{
  272|    218|    PJ_ASSERT_RETURN(uri, NULL);
  ------------------
  |  |   97|    218|            do { \
  |  |   98|    218|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 218]
  |  |  ------------------
  |  |   99|    218|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 218]
  |  |  ------------------
  ------------------
  |  Branch (272:5): [True: 0, False: 0]
  |  Branch (272:5): [True: 0, False: 0]
  ------------------
  273|    218|    return (*((pjsip_uri*)uri)->vptr->p_get_uri)((void*)uri);
  274|    218|}
sip_dialog.c:pjsip_uri_print:
  303|  1.48k|{
  304|  1.48k|    return (int)(*((const pjsip_uri*)uri)->vptr->p_print)(context, uri, 
  305|  1.48k|                                                          buf, size);
  306|  1.48k|}
sip_util.c:pjsip_uri_clone:
  316|    734|{
  317|    734|    return (*((const pjsip_uri*)uri)->vptr->p_clone)(pool, uri);
  318|    734|}
sip_util.c:pjsip_uri_get_scheme:
  259|    310|{
  260|    310|    return (*((pjsip_uri*)uri)->vptr->p_get_scheme)(uri);
  261|    310|}
sip_util.c:pjsip_uri_get_uri:
  271|     34|{
  272|     34|    PJ_ASSERT_RETURN(uri, NULL);
  ------------------
  |  |   97|     34|            do { \
  |  |   98|     34|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 34]
  |  |  ------------------
  |  |   99|     34|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 34]
  |  |  ------------------
  ------------------
  |  Branch (272:5): [True: 0, False: 0]
  |  Branch (272:5): [True: 0, False: 0]
  ------------------
  273|     34|    return (*((pjsip_uri*)uri)->vptr->p_get_uri)((void*)uri);
  274|     34|}

sip_dialog.c:pjsip_target_set_init:
  122|  5.99k|{
  123|  5.99k|    pj_list_init(&tset->head);
  124|       |    tset->current = NULL;
  125|  5.99k|}

pjsip_auth_clt_init:
  916|  5.99k|{
  917|  5.99k|    PJ_ASSERT_RETURN(sess && endpt && pool && (options==0), PJ_EINVAL);
  ------------------
  |  |   97|  5.99k|            do { \
  |  |   98|  35.9k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 5.99k, False: 0]
  |  |  |  Branch (98:23): [True: 5.99k, False: 0]
  |  |  |  Branch (98:23): [True: 5.99k, False: 0]
  |  |  |  Branch (98:23): [True: 5.99k, False: 0]
  |  |  ------------------
  |  |   99|  5.99k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 5.99k]
  |  |  ------------------
  ------------------
  |  Branch (917:5): [True: 0, False: 0]
  |  Branch (917:5): [True: 0, False: 0]
  |  Branch (917:5): [True: 0, False: 0]
  |  Branch (917:5): [True: 0, False: 0]
  |  Branch (917:5): [True: 0, False: 0]
  |  Branch (917:5): [True: 0, False: 0]
  |  Branch (917:5): [True: 0, False: 0]
  |  Branch (917:5): [True: 0, False: 0]
  ------------------
  918|       |
  919|  5.99k|    sess->pool = pool;
  920|  5.99k|    sess->endpt = endpt;
  921|  5.99k|    sess->cred_cnt = 0;
  922|  5.99k|    sess->cred_info = NULL;
  923|  5.99k|    pj_list_init(&sess->cached_auth);
  924|  5.99k|    pj_bzero(&sess->pref, sizeof(sess->pref));
  925|       |
  926|  5.99k|    sess->parent = NULL;
  927|  5.99k|    sess->lock = NULL;
  928|       |    sess->async_opt = NULL;
  929|  5.99k|    return PJ_SUCCESS;
  930|  5.99k|}
pjsip_auth_clt_deinit:
  951|  5.99k|{
  952|  5.99k|    pjsip_cached_auth *auth;
  953|       |    
  954|  5.99k|    PJ_ASSERT_RETURN(sess && sess->endpt, PJ_EINVAL);
  ------------------
  |  |   97|  5.99k|            do { \
  |  |   98|  11.9k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 5.99k, False: 0]
  |  |  |  Branch (98:23): [True: 5.99k, False: 0]
  |  |  ------------------
  |  |   99|  5.99k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 5.99k]
  |  |  ------------------
  ------------------
  |  Branch (954:5): [True: 0, False: 0]
  |  Branch (954:5): [True: 0, False: 0]
  |  Branch (954:5): [True: 0, False: 0]
  |  Branch (954:5): [True: 0, False: 0]
  ------------------
  955|       |    
  956|  5.99k|    auth = sess->cached_auth.next;
  957|  5.99k|    while (auth != &sess->cached_auth) {
  ------------------
  |  Branch (957:12): [True: 0, False: 5.99k]
  ------------------
  958|      0|        pjsip_endpt_release_pool(sess->endpt, auth->pool);
  959|      0|        auth = auth->next;
  960|      0|    }
  961|       |
  962|  5.99k|    sess->parent = NULL;
  963|  5.99k|    if (sess->lock) {
  ------------------
  |  Branch (963:9): [True: 0, False: 5.99k]
  ------------------
  964|      0|        return pj_lock_destroy(sess->lock);
  965|  5.99k|    } else {
  966|  5.99k|        return PJ_SUCCESS;
  967|  5.99k|    }
  968|  5.99k|}
pjsip_auth_clt_init_req:
 1368|    168|{
 1369|    168|    const pjsip_method *method;
 1370|    168|    pjsip_cached_auth *auth;
 1371|    168|    pjsip_hdr added;
 1372|       |
 1373|    168|    PJ_ASSERT_RETURN(sess && tdata, PJ_EINVAL);
  ------------------
  |  |   97|    168|            do { \
  |  |   98|    336|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 168, False: 0]
  |  |  |  Branch (98:23): [True: 168, False: 0]
  |  |  ------------------
  |  |   99|    168|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 168]
  |  |  ------------------
  ------------------
  |  Branch (1373:5): [True: 0, False: 0]
  |  Branch (1373:5): [True: 0, False: 0]
  |  Branch (1373:5): [True: 0, False: 0]
  |  Branch (1373:5): [True: 0, False: 0]
  ------------------
 1374|    168|    PJ_ASSERT_RETURN(sess->pool, PJSIP_ENOTINITIALIZED);
  ------------------
  |  |   97|    168|            do { \
  |  |   98|    168|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 168]
  |  |  ------------------
  |  |   99|    168|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 168]
  |  |  ------------------
  ------------------
  |  Branch (1374:5): [True: 0, False: 0]
  |  Branch (1374:5): [True: 0, False: 0]
  ------------------
 1375|    168|    PJ_ASSERT_RETURN(tdata->msg->type==PJSIP_REQUEST_MSG,
  ------------------
  |  |   97|    168|            do { \
  |  |   98|    168|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 168]
  |  |  ------------------
  |  |   99|    168|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 168]
  |  |  ------------------
  ------------------
  |  Branch (1375:5): [True: 0, False: 0]
  |  Branch (1375:5): [True: 0, False: 0]
  ------------------
 1376|    168|                     PJSIP_ENOTREQUESTMSG);
 1377|       |
 1378|       |
 1379|    168|    DO_ON_PARENT_LOCKED(sess, pjsip_auth_clt_init_req(sess->parent, tdata));
  ------------------
  |  |  137|    168|    do { \
  |  |  138|    168|        pj_status_t on_parent = PJ_SUCCESS; \
  |  |  139|    168|        pj_bool_t with_parent = PJ_FALSE; \
  |  |  140|    168|        if (sess->parent) { \
  |  |  ------------------
  |  |  |  Branch (140:13): [True: 0, False: 168]
  |  |  ------------------
  |  |  141|      0|            pj_lock_acquire(sess->parent->lock); \
  |  |  142|      0|            with_parent = PJ_TRUE; \
  |  |  143|      0|            on_parent = call; \
  |  |  144|      0|            pj_lock_release(sess->parent->lock); \
  |  |  145|      0|        } \
  |  |  146|    168|        if (with_parent) { \
  |  |  ------------------
  |  |  |  Branch (146:13): [True: 0, False: 168]
  |  |  ------------------
  |  |  147|      0|            return on_parent; \
  |  |  148|      0|        } \
  |  |  149|    168|    } while(0)
  |  |  ------------------
  |  |  |  Branch (149:13): [Folded, False: 168]
  |  |  ------------------
  ------------------
 1380|       |    /* Init list */
 1381|    168|    pj_list_init(&added);
 1382|       |
 1383|       |    /* Get the method. */
 1384|    168|    method = &tdata->msg->line.req.method;
 1385|    168|    PJ_UNUSED_ARG(method); /* Warning about unused var caused by #if below */
  ------------------
  |  | 1537|    168|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1386|       |
 1387|    168|    auth = sess->cached_auth.next;
 1388|    168|    while (auth != &sess->cached_auth) {
  ------------------
  |  Branch (1388:12): [True: 0, False: 168]
  ------------------
 1389|       |        /* Reset stale counter */
 1390|      0|        auth->stale_cnt = 0;
 1391|       |
 1392|      0|        if (auth->qop_value == PJSIP_AUTH_QOP_NONE) {
  ------------------
  |  Branch (1392:13): [True: 0, False: 0]
  ------------------
 1393|       |#           if defined(PJSIP_AUTH_HEADER_CACHING) && \
 1394|       |               PJSIP_AUTH_HEADER_CACHING!=0
 1395|       |            {
 1396|       |                pjsip_cached_auth_hdr *entry = auth->cached_hdr.next;
 1397|       |                while (entry != &auth->cached_hdr) {
 1398|       |                    if (pjsip_method_cmp(&entry->method, method)==0) {
 1399|       |                        pjsip_authorization_hdr *hauth;
 1400|       |                        hauth = pjsip_hdr_shallow_clone(tdata->pool, entry->hdr);
 1401|       |                        //pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)hauth);
 1402|       |                        pj_list_push_back(&added, hauth);
 1403|       |                        break;
 1404|       |                    }
 1405|       |                    entry = entry->next;
 1406|       |                }
 1407|       |
 1408|       |#               if defined(PJSIP_AUTH_AUTO_SEND_NEXT) && \
 1409|       |                           PJSIP_AUTH_AUTO_SEND_NEXT!=0
 1410|       |                {
 1411|       |                    if (entry == &auth->cached_hdr)
 1412|       |                        new_auth_for_req( tdata, sess, auth, NULL);
 1413|       |                }
 1414|       |#               endif
 1415|       |
 1416|       |            }
 1417|       |#           elif defined(PJSIP_AUTH_AUTO_SEND_NEXT) && \
 1418|       |                 PJSIP_AUTH_AUTO_SEND_NEXT!=0
 1419|       |            {
 1420|       |                new_auth_for_req( tdata, sess, auth, NULL);
 1421|       |            }
 1422|       |#           endif
 1423|       |
 1424|      0|        }
 1425|       |#       if defined(PJSIP_AUTH_QOP_SUPPORT) && \
 1426|       |           defined(PJSIP_AUTH_AUTO_SEND_NEXT) && \
 1427|       |           (PJSIP_AUTH_QOP_SUPPORT && PJSIP_AUTH_AUTO_SEND_NEXT)
 1428|       |        else if (auth->qop_value == PJSIP_AUTH_QOP_AUTH) {
 1429|       |            /* For qop="auth", we have to re-create the authorization header.
 1430|       |             */
 1431|       |            const pjsip_cred_info *cred;
 1432|       |            pjsip_authorization_hdr *hauth;
 1433|       |            pj_status_t status;
 1434|       |
 1435|       |            cred = auth_find_cred(sess, &auth->realm,
 1436|       |                                  &auth->last_chal->scheme,
 1437|       |                                  auth->challenge_algorithm_type);
 1438|       |            if (!cred) {
 1439|       |                auth = auth->next;
 1440|       |                continue;
 1441|       |            }
 1442|       |
 1443|       |            status = auth_respond( tdata->pool, auth->last_chal,
 1444|       |                                   tdata->msg->line.req.uri,
 1445|       |                                   cred,
 1446|       |                                   &tdata->msg->line.req.method,
 1447|       |                                   sess->pool, auth, &hauth,
 1448|       |                                   auth->challenge_algorithm_type);
 1449|       |            if (status != PJ_SUCCESS)
 1450|       |                return status;
 1451|       |
 1452|       |            //pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)hauth);
 1453|       |            pj_list_push_back(&added, hauth);
 1454|       |        }
 1455|       |#       endif   /* PJSIP_AUTH_QOP_SUPPORT && PJSIP_AUTH_AUTO_SEND_NEXT */
 1456|       |
 1457|      0|        auth = auth->next;
 1458|      0|    }
 1459|       |
 1460|    168|    if (sess->pref.initial_auth == PJ_FALSE) {
  ------------------
  |  Branch (1460:9): [True: 168, False: 0]
  ------------------
 1461|    168|        pjsip_hdr *h;
 1462|       |
 1463|       |        /* Don't want to send initial empty Authorization header, so
 1464|       |         * just send whatever available in the list (maybe empty).
 1465|       |         */
 1466|       |
 1467|    168|        h = added.next;
 1468|    168|        while (h != &added) {
  ------------------
  |  Branch (1468:16): [True: 0, False: 168]
  ------------------
 1469|      0|            pjsip_hdr *next = h->next;
 1470|      0|            pjsip_msg_add_hdr(tdata->msg, h);
 1471|      0|            h = next;
 1472|      0|        }
 1473|    168|    } else {
 1474|       |        /* For each realm, add either the cached authorization header
 1475|       |         * or add an empty authorization header.
 1476|       |         */
 1477|      0|        unsigned i;
 1478|      0|        pj_str_t uri;
 1479|       |
 1480|      0|        uri.ptr = (char*)pj_pool_alloc(tdata->pool, PJSIP_MAX_URL_SIZE);
  ------------------
  |  |  354|      0|#   define PJSIP_MAX_URL_SIZE           256
  ------------------
 1481|      0|        uri.slen = pjsip_uri_print(PJSIP_URI_IN_REQ_URI,
 1482|      0|                                   tdata->msg->line.req.uri,
 1483|      0|                                   uri.ptr, PJSIP_MAX_URL_SIZE);
  ------------------
  |  |  354|      0|#   define PJSIP_MAX_URL_SIZE           256
  ------------------
 1484|      0|        if (uri.slen < 1 || uri.slen >= PJSIP_MAX_URL_SIZE)
  ------------------
  |  |  354|      0|#   define PJSIP_MAX_URL_SIZE           256
  ------------------
  |  Branch (1484:13): [True: 0, False: 0]
  |  Branch (1484:29): [True: 0, False: 0]
  ------------------
 1485|      0|            return PJSIP_EURITOOLONG;
  ------------------
  |  |  164|      0|#define PJSIP_EURITOOLONG       (PJSIP_ERRNO_START_PJSIP + 43)  /* 171043 */
  |  |  ------------------
  |  |  |  |   73|      0|#define PJSIP_ERRNO_START_PJSIP (PJSIP_ERRNO_START + 1000)
  |  |  |  |  ------------------
  |  |  |  |  |  |   47|      0|#define PJSIP_ERRNO_START       (PJ_ERRNO_START_USER)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  535|      0|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1486|       |
 1487|      0|        for (i=0; i<sess->cred_cnt; ++i) {
  ------------------
  |  Branch (1487:19): [True: 0, False: 0]
  ------------------
 1488|      0|            pjsip_cred_info *c = &sess->cred_info[i];
 1489|      0|            pjsip_authorization_hdr *h;
 1490|       |
 1491|      0|            h = get_header_for_cred_info(&added, c);
 1492|      0|            if (h) {
  ------------------
  |  Branch (1492:17): [True: 0, False: 0]
  ------------------
 1493|      0|                pj_list_erase(h);
 1494|      0|                pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)h);
 1495|      0|            } else {
 1496|      0|                pjsip_authorization_hdr *hs;
 1497|       |
 1498|      0|                hs = pjsip_authorization_hdr_create(tdata->pool);
 1499|      0|                pj_strdup(tdata->pool, &hs->scheme, &c->scheme);
 1500|      0|                if (pj_stricmp(&c->scheme, &pjsip_BEARER_STR)==0) {
  ------------------
  |  Branch (1500:21): [True: 0, False: 0]
  ------------------
 1501|      0|                        pj_strdup(tdata->pool, &hs->credential.oauth.username,
 1502|      0|                                  &c->username);
 1503|      0|                        pj_strdup(tdata->pool, &hs->credential.oauth.realm,
 1504|      0|                                  &c->realm);
 1505|      0|                        pj_strdup(tdata->pool, &hs->credential.oauth.token,
 1506|      0|                                  &c->data);
 1507|      0|                } else { //if (pj_stricmp(&c->scheme, &pjsip_DIGEST_STR)==0)
 1508|      0|                        pj_strdup(tdata->pool, &hs->credential.digest.username,
 1509|      0|                                  &c->username);
 1510|      0|                        pj_strdup(tdata->pool, &hs->credential.digest.realm,
 1511|      0|                                  &c->realm);
 1512|      0|                        pj_strdup(tdata->pool,&hs->credential.digest.uri, &uri);
 1513|       |
 1514|      0|                        if (c->algorithm_type == PJSIP_AUTH_ALGORITHM_NOT_SET) {
  ------------------
  |  Branch (1514:29): [True: 0, False: 0]
  ------------------
 1515|      0|                            pj_strdup(tdata->pool, &hs->credential.digest.algorithm,
 1516|      0|                                &sess->pref.algorithm);
 1517|      0|                        } else {
 1518|      0|                            pj_strdup(tdata->pool, &hs->credential.digest.algorithm,
 1519|      0|                                &pjsip_auth_algorithms[c->algorithm_type].iana_name);
 1520|      0|                        }
 1521|      0|                }
 1522|       |
 1523|      0|                pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)hs);
 1524|      0|            }
 1525|      0|        }
 1526|      0|    }
 1527|       |
 1528|    168|    return PJ_SUCCESS;
 1529|    168|}

pjsip_auth_init_parser:
  295|      2|{
  296|      2|    pj_status_t status;
  297|       |
  298|      2|    status = pjsip_register_hdr_parser( "Authorization", NULL, 
  299|      2|                                        &parse_hdr_authorization);
  300|      2|    PJ_ASSERT_RETURN(status==PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (300:5): [True: 0, False: 0]
  |  Branch (300:5): [True: 0, False: 0]
  ------------------
  301|      2|    status = pjsip_register_hdr_parser( "Proxy-Authorization", NULL, 
  302|      2|                                        &parse_hdr_proxy_authorization);
  303|      2|    PJ_ASSERT_RETURN(status==PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (303:5): [True: 0, False: 0]
  |  Branch (303:5): [True: 0, False: 0]
  ------------------
  304|      2|    status = pjsip_register_hdr_parser( "WWW-Authenticate", NULL, 
  305|      2|                                        &parse_hdr_www_authenticate);
  306|      2|    PJ_ASSERT_RETURN(status==PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (306:5): [True: 0, False: 0]
  |  Branch (306:5): [True: 0, False: 0]
  ------------------
  307|      2|    status = pjsip_register_hdr_parser( "Proxy-Authenticate", NULL, 
  308|      2|                                        &parse_hdr_proxy_authenticate);
  309|      2|    PJ_ASSERT_RETURN(status==PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (309:5): [True: 0, False: 0]
  |  Branch (309:5): [True: 0, False: 0]
  ------------------
  310|       |
  311|      2|    return PJ_SUCCESS;
  312|      2|}

pjsip_method_creates_dialog:
   50|  1.71k|{
   51|  1.71k|    const pjsip_method subscribe = { PJSIP_OTHER_METHOD, {"SUBSCRIBE", 9}};
   52|  1.71k|    const pjsip_method refer = { PJSIP_OTHER_METHOD, {"REFER", 5}};
   53|  1.71k|    const pjsip_method notify = { PJSIP_OTHER_METHOD, {"NOTIFY", 6}};
   54|  1.71k|    const pjsip_method update = { PJSIP_OTHER_METHOD, {"UPDATE", 6}};
   55|       |
   56|  1.71k|    return m->id == PJSIP_INVITE_METHOD ||
  ------------------
  |  Branch (56:12): [True: 1.28k, False: 435]
  ------------------
   57|    435|           (pjsip_method_cmp(m, &subscribe)==0) ||
  ------------------
  |  Branch (57:12): [True: 41, False: 394]
  ------------------
   58|    394|           (pjsip_method_cmp(m, &refer)==0) ||
  ------------------
  |  Branch (58:12): [True: 6, False: 388]
  ------------------
   59|    388|           (pjsip_method_cmp(m, &notify)==0) ||
  ------------------
  |  Branch (59:12): [True: 32, False: 356]
  ------------------
   60|    356|           (pjsip_method_cmp(m, &update)==0);
  ------------------
  |  Branch (60:12): [True: 69, False: 287]
  ------------------
   61|  1.71k|}
pjsip_dlg_create_uac:
  173|  5.28k|{
  174|  5.28k|    pjsip_dlg_create_uac_param create_param;
  175|       |
  176|  5.28k|    PJ_ASSERT_RETURN(ua && local_uri && remote_uri && p_dlg, PJ_EINVAL);
  ------------------
  |  |   97|  5.28k|            do { \
  |  |   98|  31.7k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 5.28k, False: 0]
  |  |  |  Branch (98:23): [True: 5.28k, False: 0]
  |  |  |  Branch (98:23): [True: 5.28k, False: 0]
  |  |  |  Branch (98:23): [True: 5.28k, False: 0]
  |  |  ------------------
  |  |   99|  5.28k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 5.28k]
  |  |  ------------------
  ------------------
  |  Branch (176:5): [True: 0, False: 0]
  |  Branch (176:5): [True: 0, False: 0]
  |  Branch (176:5): [True: 0, False: 0]
  |  Branch (176:5): [True: 0, False: 0]
  |  Branch (176:5): [True: 0, False: 0]
  |  Branch (176:5): [True: 0, False: 0]
  |  Branch (176:5): [True: 0, False: 0]
  |  Branch (176:5): [True: 0, False: 0]
  ------------------
  177|       |
  178|  5.28k|    pj_bzero(&create_param, sizeof(create_param));
  179|  5.28k|    create_param.ua = ua;
  180|  5.28k|    create_param.local_uri = *local_uri;
  181|  5.28k|    create_param.remote_uri = *remote_uri;
  182|  5.28k|    if (local_contact)
  ------------------
  |  Branch (182:9): [True: 0, False: 5.28k]
  ------------------
  183|      0|        create_param.local_contact = *local_contact;
  184|       |
  185|  5.28k|    if (target)
  ------------------
  |  Branch (185:9): [True: 5.28k, False: 0]
  ------------------
  186|  5.28k|        create_param.target = *target;
  187|       |
  188|  5.28k|    return pjsip_dlg_create_uac2(&create_param, p_dlg);
  189|  5.28k|}
pjsip_dlg_create_uac2:
  194|  5.28k|{
  195|  5.28k|    pj_status_t status;
  196|  5.28k|    pj_str_t tmp;
  197|  5.28k|    pjsip_dialog *dlg;
  198|       |
  199|       |    /* Check arguments. */
  200|  5.28k|    PJ_ASSERT_RETURN(create_param->ua && create_param->local_uri.slen &&
  ------------------
  |  |   97|  5.28k|            do { \
  |  |   98|  31.7k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 5.28k, False: 0]
  |  |  |  Branch (98:23): [True: 5.28k, False: 0]
  |  |  |  Branch (98:23): [True: 5.28k, False: 0]
  |  |  |  Branch (98:23): [True: 5.28k, False: 0]
  |  |  ------------------
  |  |   99|  5.28k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 5.28k]
  |  |  ------------------
  ------------------
  |  Branch (200:5): [True: 0, False: 0]
  |  Branch (200:5): [True: 0, False: 0]
  |  Branch (200:5): [True: 0, False: 0]
  |  Branch (200:5): [True: 0, False: 0]
  |  Branch (200:5): [True: 0, False: 0]
  |  Branch (200:5): [True: 0, False: 0]
  |  Branch (200:5): [True: 0, False: 0]
  |  Branch (200:5): [True: 0, False: 0]
  ------------------
  201|  5.28k|                     create_param->remote_uri.slen && p_dlg, PJ_EINVAL);
  202|       |
  203|       |    /* Create dialog instance. */
  204|  5.28k|    status = create_dialog(create_param->ua, create_param->grp_lock, &dlg);
  205|  5.28k|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (205:9): [True: 0, False: 5.28k]
  ------------------
  206|      0|        return status;
  207|       |
  208|       |    /* Parse target. */
  209|  5.28k|    pj_strdup_with_null(dlg->pool, &tmp, create_param->target.slen ?
  ------------------
  |  Branch (209:42): [True: 5.28k, False: 0]
  ------------------
  210|  5.28k|                        &create_param->target : &create_param->remote_uri);
  211|  5.28k|    dlg->target = pjsip_parse_uri(dlg->pool, tmp.ptr, tmp.slen, 0);
  212|  5.28k|    if (!dlg->target) {
  ------------------
  |  Branch (212:9): [True: 4.71k, False: 573]
  ------------------
  213|  4.71k|        status = PJSIP_EINVALIDURI;
  ------------------
  |  |  144|  4.71k|#define PJSIP_EINVALIDURI       (PJSIP_ERRNO_START_PJSIP + 39)  /* 171039 */
  |  |  ------------------
  |  |  |  |   73|  4.71k|#define PJSIP_ERRNO_START_PJSIP (PJSIP_ERRNO_START + 1000)
  |  |  |  |  ------------------
  |  |  |  |  |  |   47|  4.71k|#define PJSIP_ERRNO_START       (PJ_ERRNO_START_USER)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  535|  4.71k|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  528|  4.71k|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  521|  4.71k|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  509|  4.71k|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  515|  4.71k|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|  4.71k|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|  4.71k|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  214|  4.71k|        goto on_error;
  215|  4.71k|    }
  216|       |
  217|       |    /* Put any header param in the target URI into INVITE header list. */
  218|    573|    if (PJSIP_URI_SCHEME_IS_SIP(dlg->target) ||
  ------------------
  |  |  234|  1.14k|    (pj_stricmp2(pjsip_uri_get_scheme(url), "sip")==0)
  |  |  ------------------
  |  |  |  Branch (234:5): [True: 107, False: 466]
  |  |  ------------------
  ------------------
  219|    466|        PJSIP_URI_SCHEME_IS_SIPS(dlg->target))
  ------------------
  |  |  242|    466|    (pj_stricmp2(pjsip_uri_get_scheme(url), "sips")==0)
  |  |  ------------------
  |  |  |  Branch (242:5): [True: 14, False: 452]
  |  |  ------------------
  ------------------
  220|    121|    {
  221|    121|        pjsip_param *param;
  222|    121|        pjsip_sip_uri *uri = (pjsip_sip_uri*)pjsip_uri_get_uri(dlg->target);
  223|       |
  224|    121|        param = uri->header_param.next;
  225|    329|        while (param != &uri->header_param) {
  ------------------
  |  Branch (225:16): [True: 215, False: 114]
  ------------------
  226|    215|            if (param->value.ptr) {
  ------------------
  |  Branch (226:17): [True: 141, False: 74]
  ------------------
  227|    141|                pjsip_hdr *hdr;
  228|    141|                int c;
  229|       |
  230|    141|                c = param->value.ptr[param->value.slen];
  231|    141|                param->value.ptr[param->value.slen] = '\0';
  232|       |
  233|    141|                hdr = (pjsip_hdr*)
  234|    141|                    pjsip_parse_hdr(dlg->pool, &param->name, param->value.ptr,
  235|    141|                                    param->value.slen, NULL);
  236|       |
  237|    141|                param->value.ptr[param->value.slen] = (char)c;
  238|       |
  239|    141|                if (hdr == NULL) {
  ------------------
  |  Branch (239:21): [True: 7, False: 134]
  ------------------
  240|      7|                    status = PJSIP_EINVALIDURI;
  ------------------
  |  |  144|      7|#define PJSIP_EINVALIDURI       (PJSIP_ERRNO_START_PJSIP + 39)  /* 171039 */
  |  |  ------------------
  |  |  |  |   73|      7|#define PJSIP_ERRNO_START_PJSIP (PJSIP_ERRNO_START + 1000)
  |  |  |  |  ------------------
  |  |  |  |  |  |   47|      7|#define PJSIP_ERRNO_START       (PJ_ERRNO_START_USER)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  535|      7|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  528|      7|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  521|      7|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  509|      7|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  515|      7|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|      7|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      7|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  241|      7|                    goto on_error;
  242|      7|                }
  243|    134|                pj_list_push_back(&dlg->inv_hdr, hdr);
  244|    134|            }
  245|       |
  246|    208|            param = param->next;
  247|    208|        }
  248|       |
  249|       |        /* Now must remove any header params from URL, since that would
  250|       |         * create another header in pjsip_endpt_create_request().
  251|       |         */
  252|    114|        pj_list_init(&uri->header_param);
  253|    114|    }
  254|       |
  255|       |    /* Add target to the target set */
  256|    566|    pjsip_target_set_add_uri(&dlg->target_set, dlg->pool, dlg->target, 0);
  257|       |
  258|       |    /* Init local info. */
  259|    566|    dlg->local.info = pjsip_from_hdr_create(dlg->pool);
  260|    566|    pj_strdup_with_null(dlg->pool, &dlg->local.info_str,
  261|    566|                        &create_param->local_uri);
  262|    566|    dlg->local.info->uri = pjsip_parse_uri(dlg->pool,
  263|    566|                                           dlg->local.info_str.ptr,
  264|    566|                                           dlg->local.info_str.slen, 0);
  265|    566|    if (!dlg->local.info->uri) {
  ------------------
  |  Branch (265:9): [True: 356, False: 210]
  ------------------
  266|    356|        status = PJSIP_EINVALIDURI;
  ------------------
  |  |  144|    356|#define PJSIP_EINVALIDURI       (PJSIP_ERRNO_START_PJSIP + 39)  /* 171039 */
  |  |  ------------------
  |  |  |  |   73|    356|#define PJSIP_ERRNO_START_PJSIP (PJSIP_ERRNO_START + 1000)
  |  |  |  |  ------------------
  |  |  |  |  |  |   47|    356|#define PJSIP_ERRNO_START       (PJ_ERRNO_START_USER)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  535|    356|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  528|    356|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  521|    356|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  509|    356|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  515|    356|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|    356|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|    356|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  267|    356|        goto on_error;
  268|    356|    }
  269|       |
  270|       |    /* Generate local tag. */
  271|    210|    pj_create_unique_string(dlg->pool, &dlg->local.info->tag);
  272|       |
  273|       |    /* Calculate hash value of local tag. */
  274|    210|    dlg->local.tag_hval = pj_hash_calc_tolower(0, NULL,
  275|    210|                                               &dlg->local.info->tag);
  276|       |
  277|       |    /* Randomize local CSeq. */
  278|    210|    dlg->local.first_cseq = pj_rand() & 0x7FFF;
  279|    210|    dlg->local.cseq = dlg->local.first_cseq;
  280|       |
  281|       |    /* Init local contact. */
  282|    210|    pj_strdup_with_null(dlg->pool, &tmp,
  283|    210|                    create_param->local_contact.slen ?
  ------------------
  |  Branch (283:21): [True: 0, False: 210]
  ------------------
  284|    210|                    &create_param->local_contact : &create_param->local_uri);
  285|    210|    dlg->local.contact = (pjsip_contact_hdr*)
  286|    210|                         pjsip_parse_hdr(dlg->pool, &HCONTACT, tmp.ptr,
  287|    210|                                         tmp.slen, NULL);
  288|    210|    if (!dlg->local.contact) {
  ------------------
  |  Branch (288:9): [True: 4, False: 206]
  ------------------
  289|      4|        status = PJSIP_EINVALIDURI;
  ------------------
  |  |  144|      4|#define PJSIP_EINVALIDURI       (PJSIP_ERRNO_START_PJSIP + 39)  /* 171039 */
  |  |  ------------------
  |  |  |  |   73|      4|#define PJSIP_ERRNO_START_PJSIP (PJSIP_ERRNO_START + 1000)
  |  |  |  |  ------------------
  |  |  |  |  |  |   47|      4|#define PJSIP_ERRNO_START       (PJ_ERRNO_START_USER)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  535|      4|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  528|      4|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  521|      4|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  509|      4|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  515|      4|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|      4|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      4|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  290|      4|        goto on_error;
  291|      4|    }
  292|       |
  293|       |    /* Init remote info. */
  294|    206|    dlg->remote.info = pjsip_to_hdr_create(dlg->pool);
  295|    206|    pj_strdup_with_null(dlg->pool, &dlg->remote.info_str,
  296|    206|                        &create_param->remote_uri);
  297|    206|    dlg->remote.info->uri = pjsip_parse_uri(dlg->pool,
  298|    206|                                            dlg->remote.info_str.ptr,
  299|    206|                                            dlg->remote.info_str.slen, 0);
  300|    206|    if (!dlg->remote.info->uri) {
  ------------------
  |  Branch (300:9): [True: 33, False: 173]
  ------------------
  301|     33|        status = PJSIP_EINVALIDURI;
  ------------------
  |  |  144|     33|#define PJSIP_EINVALIDURI       (PJSIP_ERRNO_START_PJSIP + 39)  /* 171039 */
  |  |  ------------------
  |  |  |  |   73|     33|#define PJSIP_ERRNO_START_PJSIP (PJSIP_ERRNO_START + 1000)
  |  |  |  |  ------------------
  |  |  |  |  |  |   47|     33|#define PJSIP_ERRNO_START       (PJ_ERRNO_START_USER)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  535|     33|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  528|     33|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  521|     33|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  509|     33|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  515|     33|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|     33|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|     33|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  302|     33|        goto on_error;
  303|     33|    }
  304|       |
  305|       |    /* Remove header param from remote.info_str, if any */
  306|    173|    if (PJSIP_URI_SCHEME_IS_SIP(dlg->remote.info->uri) ||
  ------------------
  |  |  234|    346|    (pj_stricmp2(pjsip_uri_get_scheme(url), "sip")==0)
  |  |  ------------------
  |  |  |  Branch (234:5): [True: 90, False: 83]
  |  |  ------------------
  ------------------
  307|     83|        PJSIP_URI_SCHEME_IS_SIPS(dlg->remote.info->uri))
  ------------------
  |  |  242|     83|    (pj_stricmp2(pjsip_uri_get_scheme(url), "sips")==0)
  |  |  ------------------
  |  |  |  Branch (242:5): [True: 7, False: 76]
  |  |  ------------------
  ------------------
  308|     97|    {
  309|     97|        pjsip_sip_uri *sip_uri = (pjsip_sip_uri *)
  310|     97|                                 pjsip_uri_get_uri(dlg->remote.info->uri);
  311|     97|        if (!pj_list_empty(&sip_uri->header_param)) {
  ------------------
  |  Branch (311:13): [True: 63, False: 34]
  ------------------
  312|     63|            pj_str_t tmp2;
  313|       |
  314|       |            /* Remove all header param */
  315|     63|            pj_list_init(&sip_uri->header_param);
  316|       |
  317|       |            /* Print URI */
  318|     63|            tmp2.ptr = (char*) pj_pool_alloc(dlg->pool,
  319|     63|                                            dlg->remote.info_str.slen);
  320|     63|            tmp2.slen = pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR,
  321|     63|                                       sip_uri, tmp2.ptr,
  322|     63|                                       dlg->remote.info_str.slen);
  323|       |
  324|     63|            if (tmp2.slen < 1) {
  ------------------
  |  Branch (324:17): [True: 5, False: 58]
  ------------------
  325|      5|                status = PJSIP_EURITOOLONG;
  ------------------
  |  |  164|      5|#define PJSIP_EURITOOLONG       (PJSIP_ERRNO_START_PJSIP + 43)  /* 171043 */
  |  |  ------------------
  |  |  |  |   73|      5|#define PJSIP_ERRNO_START_PJSIP (PJSIP_ERRNO_START + 1000)
  |  |  |  |  ------------------
  |  |  |  |  |  |   47|      5|#define PJSIP_ERRNO_START       (PJ_ERRNO_START_USER)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  535|      5|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  528|      5|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  521|      5|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  509|      5|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  515|      5|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|      5|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      5|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  326|      5|                goto on_error;
  327|      5|            }
  328|       |
  329|       |            /* Assign remote.info_str */
  330|     58|            dlg->remote.info_str = tmp2;
  331|     58|        }
  332|     97|    }
  333|       |
  334|       |
  335|       |    /* Initialize remote's CSeq to -1. */
  336|    168|    dlg->remote.cseq = dlg->remote.first_cseq = -1;
  337|       |
  338|       |    /* Initial role is UAC. */
  339|    168|    dlg->role = PJSIP_ROLE_UAC;
  340|       |
  341|       |    /* Secure? */
  342|    168|    dlg->secure = PJSIP_URI_SCHEME_IS_SIPS(dlg->target);
  ------------------
  |  |  242|    168|    (pj_stricmp2(pjsip_uri_get_scheme(url), "sips")==0)
  ------------------
  343|       |
  344|       |    /* Generate Call-ID header. */
  345|    168|    dlg->call_id = pjsip_cid_hdr_create(dlg->pool);
  346|    168|    pj_create_unique_string(dlg->pool, &dlg->call_id->id);
  347|       |
  348|       |    /* Initial route set is empty. */
  349|    168|    pj_list_init(&dlg->route_set);
  350|       |
  351|       |    /* Register this dialog to user agent. */
  352|    168|    status = pjsip_ua_register_dlg( create_param->ua, dlg );
  353|    168|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (353:9): [True: 0, False: 168]
  ------------------
  354|      0|        goto on_error;
  355|       |
  356|       |    /* Done! */
  357|    168|    *p_dlg = dlg;
  358|       |
  359|    168|    PJ_LOG(5,(dlg->obj_name, "UAC dialog created"));
  ------------------
  |  |  106|    168|#define PJ_LOG(level,arg)       do { \
  |  |  107|    168|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|    336|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 168, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 168]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|    168|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 168]
  |  |  ------------------
  ------------------
  360|       |
  361|    168|    return PJ_SUCCESS;
  362|       |
  363|  5.12k|on_error:
  364|  5.12k|    destroy_dialog(dlg, PJ_FALSE);
  365|  5.12k|    return status;
  366|    168|}
create_uas_dialog:
  377|    709|{
  378|    709|    pj_status_t status;
  379|    709|    pjsip_hdr *pos = NULL;
  380|    709|    pjsip_contact_hdr *contact_hdr;
  381|    709|    pjsip_rr_hdr *rr;
  382|    709|    pjsip_transaction *tsx = NULL;
  383|    709|    pj_grp_lock_t *tsx_lock = NULL;
  384|    709|    pj_str_t tmp;
  385|    709|    enum { TMP_LEN=PJSIP_MAX_URL_SIZE };
  386|    709|    pj_ssize_t len;
  387|    709|    pjsip_dialog *dlg;
  388|    709|    pj_bool_t lock_incremented = PJ_FALSE;
  389|       |
  390|       |    /* Check arguments. */
  391|    709|    PJ_ASSERT_RETURN(ua && rdata && p_dlg, PJ_EINVAL);
  ------------------
  |  |   97|    709|            do { \
  |  |   98|  2.83k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 709, False: 0]
  |  |  |  Branch (98:23): [True: 709, False: 0]
  |  |  |  Branch (98:23): [True: 709, False: 0]
  |  |  ------------------
  |  |   99|    709|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 709]
  |  |  ------------------
  ------------------
  |  Branch (391:5): [True: 0, False: 0]
  |  Branch (391:5): [True: 0, False: 0]
  |  Branch (391:5): [True: 0, False: 0]
  |  Branch (391:5): [True: 0, False: 0]
  |  Branch (391:5): [True: 0, False: 0]
  |  Branch (391:5): [True: 0, False: 0]
  ------------------
  392|       |
  393|       |    /* rdata must have request message. */
  394|    709|    PJ_ASSERT_RETURN(rdata->msg_info.msg->type == PJSIP_REQUEST_MSG,
  ------------------
  |  |   97|    709|            do { \
  |  |   98|    709|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 709]
  |  |  ------------------
  |  |   99|    709|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 709]
  |  |  ------------------
  ------------------
  |  Branch (394:5): [True: 0, False: 0]
  |  Branch (394:5): [True: 0, False: 0]
  ------------------
  395|    709|                     PJSIP_ENOTREQUESTMSG);
  396|       |
  397|       |    /* Request must not have To tag.
  398|       |     * This should have been checked in the user agent (or application?).
  399|       |     */
  400|    709|    PJ_ASSERT_RETURN(rdata->msg_info.to->tag.slen == 0, PJ_EINVALIDOP);
  ------------------
  |  |   97|    709|            do { \
  |  |   98|    709|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 709]
  |  |  ------------------
  |  |   99|    709|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 709]
  |  |  ------------------
  ------------------
  |  Branch (400:5): [True: 0, False: 0]
  |  Branch (400:5): [True: 0, False: 0]
  ------------------
  401|       |
  402|       |    /* The request must be a dialog establishing request. */
  403|    709|    PJ_ASSERT_RETURN(
  ------------------
  |  |   97|    709|            do { \
  |  |   98|    709|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 709]
  |  |  ------------------
  |  |   99|    709|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 709]
  |  |  ------------------
  ------------------
  |  Branch (403:5): [True: 0, False: 0]
  |  Branch (403:5): [True: 0, False: 0]
  ------------------
  404|    709|        pjsip_method_creates_dialog(&rdata->msg_info.msg->line.req.method),
  405|    709|        PJ_EINVALIDOP);
  406|       |
  407|       |    /* Create dialog instance. */
  408|    709|    status = create_dialog(ua, NULL, &dlg);
  409|    709|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (409:9): [True: 0, False: 709]
  ------------------
  410|      0|        return status;
  411|       |
  412|       |    /* Temprary string for getting the string representation of
  413|       |     * both local and remote URI.
  414|       |     */
  415|    709|    tmp.ptr = (char*) pj_pool_alloc(rdata->tp_info.pool, TMP_LEN);
  416|       |
  417|       |    /* Init local info from the To header. */
  418|    709|    dlg->local.info = (pjsip_fromto_hdr*)
  419|    709|                      pjsip_hdr_clone(dlg->pool, rdata->msg_info.to);
  420|    709|    pjsip_fromto_hdr_set_from(dlg->local.info);
  421|       |
  422|       |    /* Generate local tag. */
  423|    709|    pj_create_unique_string(dlg->pool, &dlg->local.info->tag);
  424|       |
  425|       |
  426|       |    /* Print the local info. */
  427|    709|    len = pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR,
  428|    709|                          dlg->local.info->uri, tmp.ptr, TMP_LEN);
  429|    709|    if (len < 1) {
  ------------------
  |  Branch (429:9): [True: 144, False: 565]
  ------------------
  430|    144|        tmp.slen=pj_ansi_strxcpy(tmp.ptr, "<-error: uri too long->", TMP_LEN);
  431|    144|        if (tmp.slen < 0)
  ------------------
  |  Branch (431:13): [True: 0, False: 144]
  ------------------
  432|      0|            tmp.slen = pj_ansi_strlen(tmp.ptr);
  ------------------
  |  |   69|      0|#define pj_ansi_strlen          strlen
  ------------------
  433|    144|    } else
  434|    565|        tmp.slen = len;
  435|       |
  436|       |    /* Save the local info. */
  437|    709|    pj_strdup(dlg->pool, &dlg->local.info_str, &tmp);
  438|       |
  439|       |    /* Calculate hash value of local tag. */
  440|    709|    dlg->local.tag_hval = pj_hash_calc_tolower(0, NULL, &dlg->local.info->tag);
  441|       |
  442|       |
  443|       |    /* Randomize local cseq */
  444|    709|    dlg->local.first_cseq = pj_rand() & 0x7FFF;
  445|    709|    dlg->local.cseq = dlg->local.first_cseq;
  446|       |
  447|       |    /* Init local contact. */
  448|       |    /* TODO:
  449|       |     *  Section 12.1.1, paragraph about using SIPS URI in Contact.
  450|       |     *  If the request that initiated the dialog contained a SIPS URI
  451|       |     *  in the Request-URI or in the top Record-Route header field value,
  452|       |     *  if there was any, or the Contact header field if there was no
  453|       |     *  Record-Route header field, the Contact header field in the response
  454|       |     *  MUST be a SIPS URI.
  455|       |     */
  456|    709|    if (contact) {
  ------------------
  |  Branch (456:9): [True: 0, False: 709]
  ------------------
  457|      0|        pj_str_t tmp2;
  458|       |
  459|      0|        pj_strdup_with_null(dlg->pool, &tmp2, contact);
  460|      0|        dlg->local.contact = (pjsip_contact_hdr*)
  461|      0|                             pjsip_parse_hdr(dlg->pool, &HCONTACT, tmp2.ptr,
  462|      0|                                             tmp2.slen, NULL);
  463|      0|        if (!dlg->local.contact) {
  ------------------
  |  Branch (463:13): [True: 0, False: 0]
  ------------------
  464|      0|            status = PJSIP_EINVALIDURI;
  ------------------
  |  |  144|      0|#define PJSIP_EINVALIDURI       (PJSIP_ERRNO_START_PJSIP + 39)  /* 171039 */
  |  |  ------------------
  |  |  |  |   73|      0|#define PJSIP_ERRNO_START_PJSIP (PJSIP_ERRNO_START + 1000)
  |  |  |  |  ------------------
  |  |  |  |  |  |   47|      0|#define PJSIP_ERRNO_START       (PJ_ERRNO_START_USER)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  535|      0|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  465|      0|            goto on_error;
  466|      0|        }
  467|       |
  468|    709|    } else {
  469|    709|        dlg->local.contact = pjsip_contact_hdr_create(dlg->pool);
  470|    709|        dlg->local.contact->uri = dlg->local.info->uri;
  471|    709|    }
  472|       |
  473|       |    /* Init remote info from the From header. */
  474|    709|    dlg->remote.info = (pjsip_fromto_hdr*)
  475|    709|                       pjsip_hdr_clone(dlg->pool, rdata->msg_info.from);
  476|    709|    pjsip_fromto_hdr_set_to(dlg->remote.info);
  477|       |
  478|       |    /* Print the remote info. */
  479|    709|    len = pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR,
  480|    709|                          dlg->remote.info->uri, tmp.ptr, TMP_LEN);
  481|    709|    if (len < 1) {
  ------------------
  |  Branch (481:9): [True: 132, False: 577]
  ------------------
  482|    132|        tmp.slen=pj_ansi_strxcpy(tmp.ptr, "<-error: uri too long->", TMP_LEN);
  483|    132|        if (tmp.slen<0)
  ------------------
  |  Branch (483:13): [True: 0, False: 132]
  ------------------
  484|      0|            tmp.slen = pj_ansi_strlen(tmp.ptr);
  ------------------
  |  |   69|      0|#define pj_ansi_strlen          strlen
  ------------------
  485|    132|    } else
  486|    577|        tmp.slen = len;
  487|       |
  488|       |    /* Save the remote info. */
  489|    709|    pj_strdup(dlg->pool, &dlg->remote.info_str, &tmp);
  490|       |    
  491|       |    /* Save initial destination host from transport's info */
  492|    709|    if (rdata->tp_info.transport->dir == PJSIP_TP_DIR_OUTGOING) {
  ------------------
  |  Branch (492:9): [True: 0, False: 709]
  ------------------
  493|      0|        pj_strdup(dlg->pool, &dlg->initial_dest,
  494|      0|                  &rdata->tp_info.transport->remote_name.host);
  495|      0|        PJ_LOG(5, (THIS_FILE, "Saving initial dest %.*s",
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  496|      0|                   (int)dlg->initial_dest.slen, dlg->initial_dest.ptr));
  497|      0|    }
  498|       |
  499|       |    /* Init remote's contact from Contact header.
  500|       |     * Iterate the Contact URI until we find sip: or sips: scheme.
  501|       |     */
  502|  1.28k|    do {
  503|  1.28k|        contact_hdr = (pjsip_contact_hdr*)
  504|  1.28k|                      pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT,
  505|  1.28k|                                         pos);
  506|  1.28k|        if (contact_hdr) {
  ------------------
  |  Branch (506:13): [True: 925, False: 356]
  ------------------
  507|    925|            if (!contact_hdr->uri ||
  ------------------
  |  Branch (507:17): [True: 202, False: 723]
  ------------------
  508|    723|                (!PJSIP_URI_SCHEME_IS_SIP(contact_hdr->uri) &&
  ------------------
  |  |  234|  1.44k|    (pj_stricmp2(pjsip_uri_get_scheme(url), "sip")==0)
  ------------------
  |  Branch (508:18): [True: 380, False: 343]
  ------------------
  509|    380|                 !PJSIP_URI_SCHEME_IS_SIPS(contact_hdr->uri)))
  ------------------
  |  |  242|    380|    (pj_stricmp2(pjsip_uri_get_scheme(url), "sips")==0)
  ------------------
  |  Branch (509:18): [True: 376, False: 4]
  ------------------
  510|    578|            {
  511|    578|                pos = (pjsip_hdr*)contact_hdr->next;
  512|    578|                if (pos == &rdata->msg_info.msg->hdr)
  ------------------
  |  Branch (512:21): [True: 6, False: 572]
  ------------------
  513|      6|                    contact_hdr = NULL;
  514|    578|            } else {
  515|    347|                break;
  516|    347|            }
  517|    925|        }
  518|  1.28k|    } while (contact_hdr);
  ------------------
  |  Branch (518:14): [True: 572, False: 362]
  ------------------
  519|       |
  520|    709|    if (!contact_hdr) {
  ------------------
  |  Branch (520:9): [True: 362, False: 347]
  ------------------
  521|    362|        status = PJSIP_ERRNO_FROM_SIP_STATUS(PJSIP_SC_BAD_REQUEST);
  ------------------
  |  |   54|    362|#define PJSIP_ERRNO_FROM_SIP_STATUS(code)   (PJSIP_ERRNO_START+code)
  |  |  ------------------
  |  |  |  |   47|    362|#define PJSIP_ERRNO_START       (PJ_ERRNO_START_USER)
  |  |  |  |  ------------------
  |  |  |  |  |  |  535|    362|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  528|    362|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  521|    362|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  509|    362|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|    362|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|    362|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|    362|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  522|    362|        goto on_error;
  523|    362|    }
  524|       |
  525|    347|    dlg->remote.contact = (pjsip_contact_hdr*)
  526|    347|                          pjsip_hdr_clone(dlg->pool, (pjsip_hdr*)contact_hdr);
  527|       |
  528|       |    /* Init remote's CSeq from CSeq header */
  529|    347|    dlg->remote.cseq = dlg->remote.first_cseq = rdata->msg_info.cseq->cseq;
  530|       |
  531|       |    /* Set initial target to remote's Contact. */
  532|    347|    dlg->target = dlg->remote.contact->uri;
  533|       |
  534|       |    /* Initial role is UAS */
  535|    347|    dlg->role = PJSIP_ROLE_UAS;
  536|       |
  537|       |    /* Secure?
  538|       |     *  RFC 3261 Section 12.1.1:
  539|       |     *  If the request arrived over TLS, and the Request-URI contained a
  540|       |     *  SIPS URI, the 'secure' flag is set to TRUE.
  541|       |     */
  542|    347|    dlg->secure = PJSIP_TRANSPORT_IS_SECURE(rdata->tp_info.transport) &&
  ------------------
  |  |   88|    694|            ((tp)->flag & PJSIP_TRANSPORT_SECURE)
  |  |  ------------------
  |  |  |  Branch (88:13): [True: 0, False: 347]
  |  |  ------------------
  ------------------
  543|      0|                  PJSIP_URI_SCHEME_IS_SIPS(rdata->msg_info.msg->line.req.uri);
  ------------------
  |  |  242|    347|    (pj_stricmp2(pjsip_uri_get_scheme(url), "sips")==0)
  |  |  ------------------
  |  |  |  Branch (242:5): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  544|       |
  545|       |    /* Call-ID */
  546|    347|    dlg->call_id = (pjsip_cid_hdr*)
  547|    347|                   pjsip_hdr_clone(dlg->pool, rdata->msg_info.cid);
  548|       |
  549|       |    /* Route set.
  550|       |     *  RFC 3261 Section 12.1.1:
  551|       |     *  The route set MUST be set to the list of URIs in the Record-Route
  552|       |     *  header field from the request, taken in order and preserving all URI
  553|       |     *  parameters. If no Record-Route header field is present in the request,
  554|       |     * the route set MUST be set to the empty set.
  555|       |     */
  556|    347|    pj_list_init(&dlg->route_set);
  557|    347|    rr = rdata->msg_info.record_route;
  558|    347|    while (rr != NULL) {
  ------------------
  |  Branch (558:12): [True: 0, False: 347]
  ------------------
  559|      0|        pjsip_route_hdr *route;
  560|       |
  561|       |        /* Clone the Record-Route, change the type to Route header. */
  562|      0|        route = (pjsip_route_hdr*) pjsip_hdr_clone(dlg->pool, rr);
  563|      0|        pjsip_routing_hdr_set_route(route);
  564|       |
  565|       |        /* Add to route set. */
  566|      0|        pj_list_push_back(&dlg->route_set, route);
  567|       |
  568|       |        /* Find next Record-Route header. */
  569|      0|        rr = rr->next;
  570|      0|        if (rr == (void*)&rdata->msg_info.msg->hdr)
  ------------------
  |  Branch (570:13): [True: 0, False: 0]
  ------------------
  571|      0|            break;
  572|      0|        rr = (pjsip_route_hdr*) pjsip_msg_find_hdr(rdata->msg_info.msg,
  573|      0|                                                   PJSIP_H_RECORD_ROUTE, rr);
  574|      0|    }
  575|    347|    dlg->route_set_frozen = PJ_TRUE;
  576|       |
  577|       |    /* Increment the dialog's lock since tsx may cause the dialog to be
  578|       |     * destroyed prematurely (such as in case of transport error).
  579|       |     */
  580|    347|    if (inc_lock) {
  ------------------
  |  Branch (580:9): [True: 347, False: 0]
  ------------------
  581|    347|        pjsip_dlg_inc_lock(dlg);
  582|    347|        lock_incremented = PJ_TRUE;
  583|    347|    }
  584|       |
  585|       |    /* Create tsx lock first so we can lock it before creating
  586|       |     * the transaction. This is to avoid deadlock by preventing
  587|       |     * the newly created transaction to process messages before
  588|       |     * this function returns.
  589|       |     */
  590|    347|    status = pj_grp_lock_create(dlg->pool, NULL, &tsx_lock);
  591|    347|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (591:9): [True: 0, False: 347]
  ------------------
  592|      0|        goto on_error;
  593|       |
  594|    347|    pj_grp_lock_add_ref(tsx_lock);
  595|       |    /* Add ref to dialog group lock before chaining the lock */
  596|    347|    pj_grp_lock_add_ref(dlg->grp_lock_);
  597|       |    /* Chain locks so dlg lock is always acquired first before tsx. */
  598|    347|    pj_grp_lock_chain_lock(tsx_lock, (pj_lock_t *)dlg->grp_lock_, 0);
  599|    347|    pj_grp_lock_acquire(tsx_lock);
  600|       |
  601|       |    /* Create UAS transaction for this request. */
  602|    347|    status = pjsip_tsx_create_uas2(dlg->ua, rdata, tsx_lock, &tsx);
  603|    347|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (603:9): [True: 66, False: 281]
  ------------------
  604|     66|        goto on_error;
  605|       |
  606|       |    /* Store the chained dialog lock in tsx for cleanup in tsx_on_destroy() */
  607|    281|    tsx->chained_lock = dlg->grp_lock_;
  608|       |
  609|       |    /* Associate this dialog to the transaction. */
  610|    281|    tsx->mod_data[dlg->ua->id] = dlg;
  611|       |
  612|       |    /* Increment tsx counter */
  613|    281|    ++dlg->tsx_count;
  614|       |
  615|       |    /* Calculate hash value of remote tag. */
  616|    281|    dlg->remote.tag_hval = pj_hash_calc_tolower(0, NULL, &dlg->remote.info->tag);
  617|       |
  618|       |    /* Update remote capabilities info */
  619|    281|    pjsip_dlg_update_remote_cap(dlg, rdata->msg_info.msg, PJ_TRUE);
  620|       |
  621|       |    /* Register this dialog to user agent. */
  622|    281|    status = pjsip_ua_register_dlg( ua, dlg );
  623|    281|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (623:9): [True: 0, False: 281]
  ------------------
  624|      0|        goto on_error;
  625|       |
  626|       |    /* Put this dialog in rdata's mod_data */
  627|    281|    rdata->endpt_info.mod_data[ua->id] = dlg;
  628|       |
  629|    281|    PJ_TODO(DIALOG_APP_TIMER);
  ------------------
  |  | 1546|    281|#  define PJ_TODO(id)       TODO___##id:
  ------------------
  630|       |
  631|       |    /* Feed the first request to the transaction. */
  632|    281|    pjsip_tsx_recv_msg(tsx, rdata);
  633|       |
  634|    281|    pj_grp_lock_release(tsx_lock);
  635|    281|    pj_grp_lock_dec_ref(tsx_lock);
  636|       |
  637|       |    /* Done. */
  638|    281|    *p_dlg = dlg;
  639|    281|    PJ_LOG(5,(dlg->obj_name, "UAS dialog created"));
  ------------------
  |  |  106|    281|#define PJ_LOG(level,arg)       do { \
  |  |  107|    281|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|    562|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 281, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 281]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|    281|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 281]
  |  |  ------------------
  ------------------
  640|    281|    return PJ_SUCCESS;
  641|       |
  642|    428|on_error:
  643|    428|    if (tsx_lock) {
  ------------------
  |  Branch (643:9): [True: 66, False: 362]
  ------------------
  644|     66|        pj_grp_lock_release(tsx_lock);
  645|     66|        if (!tsx) {
  ------------------
  |  Branch (645:13): [True: 66, False: 0]
  ------------------
  646|       |            /* tsx_lock is non-NULL only if lock creation succeeded above.
  647|       |             * If tsx is NULL, the transaction was never created, so
  648|       |             * tsx_on_destroy() will never run. We must unchain and dec-ref
  649|       |             * the dialog lock ourselves.
  650|       |             * If tsx is non-NULL, tsx_on_destroy() will handle the
  651|       |             * unchaining and dec-ref, so we must NOT do it here to avoid
  652|       |             * a double dec-ref.
  653|       |             */
  654|     66|            pj_grp_lock_unchain_lock(tsx_lock, (pj_lock_t *)dlg->grp_lock_);
  655|     66|            pj_grp_lock_dec_ref(dlg->grp_lock_);
  656|     66|        }
  657|     66|        pj_grp_lock_dec_ref(tsx_lock);
  658|     66|    }
  659|       |
  660|    428|    if (tsx) {
  ------------------
  |  Branch (660:9): [True: 0, False: 428]
  ------------------
  661|      0|        int st_code;
  662|       |
  663|      0|        st_code = (status == PJSIP_ENOTREQUESTMSG ||
  ------------------
  |  |  117|      0|#define PJSIP_ENOTREQUESTMSG    (PJSIP_ERRNO_START_PJSIP + 21)  /* 171021 */
  |  |  ------------------
  |  |  |  |   73|      0|#define PJSIP_ERRNO_START_PJSIP (PJSIP_ERRNO_START + 1000)
  |  |  |  |  ------------------
  |  |  |  |  |  |   47|      0|#define PJSIP_ERRNO_START       (PJ_ERRNO_START_USER)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  535|      0|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (663:20): [True: 0, False: 0]
  ------------------
  664|      0|                   status == PJSIP_EMISSINGHDR ||
  ------------------
  |  |  170|      0|#define PJSIP_EMISSINGHDR       (PJSIP_ERRNO_START_PJSIP + 50)  /* 171050 */
  |  |  ------------------
  |  |  |  |   73|      0|#define PJSIP_ERRNO_START_PJSIP (PJSIP_ERRNO_START + 1000)
  |  |  |  |  ------------------
  |  |  |  |  |  |   47|      0|#define PJSIP_ERRNO_START       (PJ_ERRNO_START_USER)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  535|      0|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (664:20): [True: 0, False: 0]
  ------------------
  665|      0|                   status == PJSIP_EINVALIDHDR)? PJSIP_SC_BAD_REQUEST:
  ------------------
  |  |  175|      0|#define PJSIP_EINVALIDHDR       (PJSIP_ERRNO_START_PJSIP + 51)  /* 171051 */
  |  |  ------------------
  |  |  |  |   73|      0|#define PJSIP_ERRNO_START_PJSIP (PJSIP_ERRNO_START + 1000)
  |  |  |  |  ------------------
  |  |  |  |  |  |   47|      0|#define PJSIP_ERRNO_START       (PJ_ERRNO_START_USER)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  535|      0|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (665:20): [True: 0, False: 0]
  ------------------
  666|      0|                  PJSIP_SC_INTERNAL_SERVER_ERROR;
  667|      0|        pjsip_tsx_terminate(tsx, st_code);
  668|      0|        pj_assert(dlg->tsx_count>0);
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (668:9): [True: 0, False: 0]
  |  Branch (668:9): [True: 0, False: 0]
  ------------------
  669|      0|        --dlg->tsx_count;
  670|      0|    }
  671|       |
  672|    428|    if (lock_incremented) {
  ------------------
  |  Branch (672:9): [True: 66, False: 362]
  ------------------
  673|     66|        pjsip_dlg_dec_lock(dlg);
  674|    362|    } else {
  675|    362|        destroy_dialog(dlg, PJ_FALSE);
  676|    362|    }
  677|       |
  678|    428|    return status;
  679|    428|}
pjsip_dlg_create_uas_and_inc_lock:
  704|    709|{
  705|    709|    return create_uas_dialog(ua, rdata, contact, PJ_TRUE, p_dlg);
  706|    709|}
pjsip_dlg_set_route_set:
  936|     27|{
  937|     27|    pjsip_route_hdr *r;
  938|       |
  939|     27|    PJ_ASSERT_RETURN(dlg, PJ_EINVAL);
  ------------------
  |  |   97|     27|            do { \
  |  |   98|     27|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 27]
  |  |  ------------------
  |  |   99|     27|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 27]
  |  |  ------------------
  ------------------
  |  Branch (939:5): [True: 0, False: 0]
  |  Branch (939:5): [True: 0, False: 0]
  ------------------
  940|       |
  941|     27|    pjsip_dlg_inc_lock(dlg);
  942|       |
  943|       |    /* Clear route set. */
  944|     27|    pj_list_init(&dlg->route_set);
  945|       |
  946|     27|    if (!route_set) {
  ------------------
  |  Branch (946:9): [True: 0, False: 27]
  ------------------
  947|      0|        pjsip_dlg_dec_lock(dlg);
  948|      0|        return PJ_SUCCESS;
  949|      0|    }
  950|       |
  951|     27|    r = route_set->next;
  952|     54|    while (r != route_set) {
  ------------------
  |  Branch (952:12): [True: 27, False: 27]
  ------------------
  953|     27|        pjsip_route_hdr *new_r;
  954|       |
  955|     27|        new_r = (pjsip_route_hdr*) pjsip_hdr_clone(dlg->pool, r);
  956|     27|        pj_list_push_back(&dlg->route_set, new_r);
  957|       |
  958|     27|        r = r->next;
  959|     27|    }
  960|       |
  961|     27|    pjsip_dlg_dec_lock(dlg);
  962|     27|    return PJ_SUCCESS;
  963|     27|}
pjsip_dlg_inc_session:
  971|    449|{
  972|    449|    PJ_ASSERT_RETURN(dlg && mod, PJ_EINVAL);
  ------------------
  |  |   97|    449|            do { \
  |  |   98|    898|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 449, False: 0]
  |  |  |  Branch (98:23): [True: 449, False: 0]
  |  |  ------------------
  |  |   99|    449|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 449]
  |  |  ------------------
  ------------------
  |  Branch (972:5): [True: 0, False: 0]
  |  Branch (972:5): [True: 0, False: 0]
  |  Branch (972:5): [True: 0, False: 0]
  |  Branch (972:5): [True: 0, False: 0]
  ------------------
  973|       |
  974|    449|    pj_log_push_indent();
  975|       |
  976|    449|    pjsip_dlg_inc_lock(dlg);
  977|    449|    ++dlg->sess_count;
  978|    449|    pjsip_dlg_dec_lock(dlg);
  979|       |
  980|    449|    PJ_LOG(5,(dlg->obj_name, "Session count inc to %d by %.*s",
  ------------------
  |  |  106|    449|#define PJ_LOG(level,arg)       do { \
  |  |  107|    449|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|    898|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 449, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 449]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|    449|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 449]
  |  |  ------------------
  ------------------
  981|    449|              dlg->sess_count, (int)mod->name.slen, mod->name.ptr));
  982|       |
  983|    449|    pj_log_pop_indent();
  984|    449|    return PJ_SUCCESS;
  985|    449|}
pjsip_dlg_inc_lock:
  993|  4.41k|{
  994|       |    /* Add ref temporarily to avoid possible dialog destroy while waiting
  995|       |     * the lock.
  996|       |     */
  997|  4.41k|    pj_grp_lock_add_ref(dlg->grp_lock_);
  998|       |
  999|  4.41k|    PJ_LOG(6,(dlg->obj_name, "Entering pjsip_dlg_inc_lock(), sess_count=%d",
  ------------------
  |  |  106|  4.41k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  4.41k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  8.83k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 4.41k]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  4.41k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 4.41k]
  |  |  ------------------
  ------------------
 1000|  4.41k|              dlg->sess_count));
 1001|       |
 1002|  4.41k|    pj_grp_lock_acquire(dlg->grp_lock_);
 1003|  4.41k|    dlg->sess_count++;
 1004|       |
 1005|  4.41k|    PJ_LOG(6,(dlg->obj_name, "Leaving pjsip_dlg_inc_lock(), sess_count=%d",
  ------------------
  |  |  106|  4.41k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  4.41k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  8.83k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 4.41k]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  4.41k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 4.41k]
  |  |  ------------------
  ------------------
 1006|  4.41k|              dlg->sess_count));
 1007|       |
 1008|       |    /* Lock has been acquired, dec ref */
 1009|  4.41k|    pj_grp_lock_dec_ref(dlg->grp_lock_);
 1010|  4.41k|}
pjsip_dlg_dec_lock:
 1042|  4.41k|{
 1043|  4.41k|    PJ_ASSERT_ON_FAIL(dlg!=NULL, return);
  ------------------
  |  |  111|  4.41k|            { \
  |  |  112|  4.41k|                pj_assert(expr); \
  |  |  ------------------
  |  |  |  |   65|  4.41k|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  113|  4.41k|                if (!(expr)) exec_on_fail; \
  |  |  ------------------
  |  |  |  Branch (113:21): [True: 0, False: 4.41k]
  |  |  ------------------
  |  |  114|  4.41k|            }
  ------------------
  |  Branch (1043:5): [True: 0, False: 4.41k]
  |  Branch (1043:5): [True: 4.41k, False: 0]
  ------------------
 1044|       |
 1045|  4.41k|    PJ_LOG(6,(dlg->obj_name, "Entering pjsip_dlg_dec_lock(), sess_count=%d, "
  ------------------
  |  |  106|  4.41k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  4.41k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  8.83k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 4.41k]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  4.41k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 4.41k]
  |  |  ------------------
  ------------------
 1046|  4.41k|                             "tsx_count=%d", dlg->sess_count, dlg->tsx_count));
 1047|       |
 1048|  4.41k|    pj_assert(dlg->sess_count > 0);
  ------------------
  |  |   65|  4.41k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (1048:5): [True: 0, False: 4.41k]
  |  Branch (1048:5): [True: 4.41k, False: 0]
  ------------------
 1049|  4.41k|    --dlg->sess_count;
 1050|       |
 1051|  4.41k|    if (dlg->sess_count==0 && dlg->tsx_count==0) {
  ------------------
  |  Branch (1051:9): [True: 515, False: 3.90k]
  |  Branch (1051:31): [True: 515, False: 0]
  ------------------
 1052|    515|        pj_grp_lock_release(dlg->grp_lock_);
 1053|    515|        pj_grp_lock_acquire(dlg->grp_lock_);
 1054|       |        /* We are holding the dialog group lock here, so before we destroy
 1055|       |         * the dialog, make sure that we unlock it first to avoid
 1056|       |         * undefined behaviour on some platforms. See ticket #1886.
 1057|       |         */
 1058|    515|        unregister_and_destroy_dialog(dlg, PJ_TRUE);
 1059|  3.90k|    } else {
 1060|  3.90k|        pj_grp_lock_release(dlg->grp_lock_);
 1061|  3.90k|    }
 1062|       |
 1063|  4.41k|    PJ_LOG(6,(THIS_FILE, "Leaving pjsip_dlg_dec_lock() (dlg=%p)", dlg));
  ------------------
  |  |  106|  4.41k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  4.41k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  8.83k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 4.41k]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  4.41k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 4.41k]
  |  |  ------------------
  ------------------
 1064|  4.41k|}
pjsip_dlg_dec_session:
 1072|    449|{
 1073|    449|    PJ_ASSERT_RETURN(dlg, PJ_EINVAL);
  ------------------
  |  |   97|    449|            do { \
  |  |   98|    449|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 449]
  |  |  ------------------
  |  |   99|    449|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 449]
  |  |  ------------------
  ------------------
  |  Branch (1073:5): [True: 0, False: 0]
  |  Branch (1073:5): [True: 0, False: 0]
  ------------------
 1074|       |
 1075|    449|    pj_log_push_indent();
 1076|       |
 1077|    449|    PJ_LOG(5,(dlg->obj_name, "Session count dec to %d by %.*s",
  ------------------
  |  |  106|    449|#define PJ_LOG(level,arg)       do { \
  |  |  107|    449|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|    898|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 449, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 449]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|    449|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 449]
  |  |  ------------------
  ------------------
 1078|    449|              dlg->sess_count-1, (int)mod->name.slen, mod->name.ptr));
 1079|       |
 1080|    449|    pjsip_dlg_inc_lock(dlg);
 1081|    449|    --dlg->sess_count;
 1082|    449|    pjsip_dlg_dec_lock(dlg);
 1083|       |
 1084|    449|    pj_log_pop_indent();
 1085|    449|    return PJ_SUCCESS;
 1086|    449|}
pjsip_dlg_create_request:
 1299|    168|{
 1300|    168|    pj_status_t status;
 1301|    168|    pjsip_tx_data *tdata = NULL;
 1302|    168|    PJ_USE_EXCEPTION;
  ------------------
  |  |  367|    168|#define PJ_USE_EXCEPTION    struct pj_exception_state_t pj_x_except__; int pj_x_code__
  ------------------
 1303|       |
 1304|    168|    PJ_ASSERT_RETURN(dlg && method && p_tdata, PJ_EINVAL);
  ------------------
  |  |   97|    168|            do { \
  |  |   98|    672|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 168, False: 0]
  |  |  |  Branch (98:23): [True: 168, False: 0]
  |  |  |  Branch (98:23): [True: 168, False: 0]
  |  |  ------------------
  |  |   99|    168|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 168]
  |  |  ------------------
  ------------------
  |  Branch (1304:5): [True: 0, False: 0]
  |  Branch (1304:5): [True: 0, False: 0]
  |  Branch (1304:5): [True: 0, False: 0]
  |  Branch (1304:5): [True: 0, False: 0]
  |  Branch (1304:5): [True: 0, False: 0]
  |  Branch (1304:5): [True: 0, False: 0]
  ------------------
 1305|       |
 1306|       |    /* Lock dialog. */
 1307|    168|    pjsip_dlg_inc_lock(dlg);
 1308|       |
 1309|       |    /* Use outgoing CSeq, if set to -1 (other than ACK/CANCEL). */
 1310|    168|    if (cseq < 0)
  ------------------
  |  Branch (1310:9): [True: 168, False: 0]
  ------------------
 1311|    168|        cseq = dlg->local.cseq;
 1312|       |
 1313|       |    /* Keep compiler happy */
 1314|    168|    status = PJ_EBUG;
  ------------------
  |  |  413|    168|#define PJ_EBUG             (PJ_ERRNO_START_STATUS + 8) /* 70008 */
  |  |  ------------------
  |  |  |  |  521|    168|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|    168|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|    168|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1315|       |
 1316|       |    /* Create the request. */
 1317|    168|    PJ_TRY {
  ------------------
  |  |  373|    168|#define PJ_TRY              if (1) { \
  |  |  ------------------
  |  |  |  Branch (373:33): [True: 168, Folded]
  |  |  ------------------
  |  |  374|    168|                                pj_push_exception_handler_(&pj_x_except__); \
  |  |  375|    168|                                pj_x_code__ = pj_setjmp(pj_x_except__.state); \
  |  |  ------------------
  |  |  |  |   31|    168|#    define pj_setjmp(buf)      setjmp(buf)
  |  |  ------------------
  |  |  376|    168|                                if (pj_x_code__ == 0)
  |  |  ------------------
  |  |  |  Branch (376:37): [True: 168, False: 0]
  |  |  ------------------
  ------------------
 1318|    168|        status = dlg_create_request_throw(dlg, method, cseq, &tdata);
 1319|    168|    }
 1320|      0|    PJ_CATCH_ANY {
 1321|      0|        status = PJ_ENOMEM;
  ------------------
  |  |  408|      0|#define PJ_ENOMEM           (PJ_ERRNO_START_STATUS + 7) /* 70007 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1322|      0|    }
 1323|    168|    PJ_END;
  ------------------
  |  |  394|    168|#define PJ_END                  pj_pop_exception_handler_(&pj_x_except__); \
  |  |  395|    168|                            } else {}
  ------------------
 1324|       |
 1325|       |    /* Failed! Delete transmit data. */
 1326|    168|    if (status != PJ_SUCCESS && tdata) {
  ------------------
  |  Branch (1326:9): [True: 0, False: 168]
  |  Branch (1326:33): [True: 0, False: 0]
  ------------------
 1327|      0|        pjsip_tx_data_dec_ref( tdata );
 1328|      0|        tdata = NULL;
 1329|      0|    }
 1330|       |
 1331|       |    /* Unlock dialog. */
 1332|    168|    pjsip_dlg_dec_lock(dlg);
 1333|       |
 1334|    168|    *p_tdata = tdata;
 1335|       |
 1336|    168|    return status;
 1337|    168|}
pjsip_dlg_create_response:
 1563|    281|{
 1564|    281|    pj_status_t status;
 1565|    281|    pjsip_tx_data *tdata;
 1566|       |
 1567|       |    /* Create generic response.
 1568|       |     * This will initialize response's Via, To, From, Call-ID, CSeq
 1569|       |     * and Record-Route headers from the request.
 1570|       |     */
 1571|    281|    status = pjsip_endpt_create_response(dlg->endpt,
 1572|    281|                                         rdata, st_code, st_text, &tdata);
 1573|    281|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (1573:9): [True: 0, False: 281]
  ------------------
 1574|      0|        return status;
 1575|       |
 1576|       |    /* Lock the dialog. */
 1577|    281|    pjsip_dlg_inc_lock(dlg);
 1578|       |
 1579|       |    /* Put this dialog in tdata's mod_data */
 1580|    281|    tdata->mod_data[dlg->ua->id] = dlg;
 1581|       |
 1582|    281|    dlg_beautify_response(dlg, PJ_FALSE, st_code, tdata);
 1583|       |
 1584|       |    /* Unlock the dialog. */
 1585|    281|    pjsip_dlg_dec_lock(dlg);
 1586|       |
 1587|       |    /* Done. */
 1588|    281|    *p_tdata = tdata;
 1589|    281|    return PJ_SUCCESS;
 1590|    281|}
pjsip_dlg_on_tsx_state:
 2346|    562|{
 2347|    562|    unsigned i;
 2348|       |
 2349|    562|    PJ_LOG(5,(dlg->obj_name, "Transaction %s state changed to %s",
  ------------------
  |  |  106|    562|#define PJ_LOG(level,arg)       do { \
  |  |  107|    562|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  1.12k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 562, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 562]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|    562|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 562]
  |  |  ------------------
  ------------------
 2350|    562|              tsx->obj_name, pjsip_tsx_state_str(tsx->state)));
 2351|    562|    pj_log_push_indent();
 2352|       |
 2353|       |    /* Lock the dialog and increment session. */
 2354|    562|    pjsip_dlg_inc_lock(dlg);
 2355|       |
 2356|       |    /* Pass to dialog usages. */
 2357|    562|    for (i=0; i<dlg->usage_cnt; ++i) {
  ------------------
  |  Branch (2357:15): [True: 0, False: 562]
  ------------------
 2358|       |
 2359|      0|        if (!dlg->usage[i]->on_tsx_state)
  ------------------
  |  Branch (2359:13): [True: 0, False: 0]
  ------------------
 2360|      0|            continue;
 2361|       |
 2362|      0|        (*dlg->usage[i]->on_tsx_state)(tsx, e);
 2363|      0|    }
 2364|       |
 2365|       |
 2366|       |    /* It is possible that the transaction is terminated and this function
 2367|       |     * is called while we're calling on_tsx_state(). So only decrement
 2368|       |     * the tsx_count if we're still attached to the transaction.
 2369|       |     */
 2370|    562|    if (tsx->state == PJSIP_TSX_STATE_TERMINATED &&
  ------------------
  |  Branch (2370:9): [True: 281, False: 281]
  ------------------
 2371|    281|        tsx->mod_data[dlg->ua->id] == dlg)
  ------------------
  |  Branch (2371:9): [True: 281, False: 0]
  ------------------
 2372|    281|    {
 2373|    281|        pj_assert(dlg->tsx_count>0);
  ------------------
  |  |   65|    281|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (2373:9): [True: 0, False: 281]
  |  Branch (2373:9): [True: 281, False: 0]
  ------------------
 2374|    281|        --dlg->tsx_count;
 2375|    281|        tsx->mod_data[dlg->ua->id] = NULL;
 2376|    281|    }
 2377|       |
 2378|       |    /* Unlock dialog and dec session, may destroy dialog. */
 2379|    562|    pjsip_dlg_dec_lock(dlg);
 2380|    562|    pj_log_pop_indent();
 2381|    562|}
pjsip_dlg_update_remote_cap:
 2427|    281|{
 2428|    281|    pjsip_hdr_e htypes[] =
 2429|    281|        { PJSIP_H_ACCEPT, PJSIP_H_ALLOW, PJSIP_H_SUPPORTED };
 2430|    281|    unsigned i;
 2431|       |
 2432|    281|    PJ_ASSERT_RETURN(dlg && msg, PJ_EINVAL);
  ------------------
  |  |   97|    281|            do { \
  |  |   98|    562|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 281, False: 0]
  |  |  |  Branch (98:23): [True: 281, False: 0]
  |  |  ------------------
  |  |   99|    281|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 281]
  |  |  ------------------
  ------------------
  |  Branch (2432:5): [True: 0, False: 0]
  |  Branch (2432:5): [True: 0, False: 0]
  |  Branch (2432:5): [True: 0, False: 0]
  |  Branch (2432:5): [True: 0, False: 0]
  ------------------
 2433|       |
 2434|    281|    pjsip_dlg_inc_lock(dlg);
 2435|       |
 2436|       |    /* Retrieve all specified capability header types */
 2437|  1.12k|    for (i = 0; i < PJ_ARRAY_SIZE(htypes); ++i) {
  ------------------
  |  |  315|  1.12k|#define PJ_ARRAY_SIZE(a)    (sizeof(a)/sizeof(a[0]))
  ------------------
  |  Branch (2437:17): [True: 843, False: 281]
  ------------------
 2438|    843|        const pjsip_generic_array_hdr *hdr;
 2439|    843|        pj_status_t status;
 2440|       |
 2441|       |        /* Find this capability type in the message */
 2442|    843|        hdr = (const pjsip_generic_array_hdr*)
 2443|    843|              pjsip_msg_find_hdr(msg, htypes[i], NULL);
 2444|    843|        if (!hdr) {
  ------------------
  |  Branch (2444:13): [True: 784, False: 59]
  ------------------
 2445|       |            /* Not found.
 2446|       |             * If strict update is specified, remote this capability type
 2447|       |             * from the capability list.
 2448|       |             */
 2449|    784|            if (strict)
  ------------------
  |  Branch (2449:17): [True: 784, False: 0]
  ------------------
 2450|    784|                pjsip_dlg_remove_remote_cap_hdr(dlg, htypes[i], NULL);
 2451|    784|        } else {
 2452|       |            /* Found, a capability type may be specified in multiple headers,
 2453|       |             * so combine all the capability tags/values into a temporary
 2454|       |             * header.
 2455|       |             */
 2456|     59|            pjsip_generic_array_hdr tmp_hdr;
 2457|       |
 2458|       |            /* Init temporary header */
 2459|     59|            pjsip_generic_array_hdr_init(dlg->pool, &tmp_hdr, NULL);
 2460|     59|            pj_memcpy(&tmp_hdr, hdr, sizeof(pjsip_hdr));
 2461|       |
 2462|  1.84k|            while (hdr) {
  ------------------
  |  Branch (2462:20): [True: 1.78k, False: 59]
  ------------------
 2463|  1.78k|                unsigned j;
 2464|       |
 2465|       |                /* Append the header content to temporary header */
 2466|  2.48k|                for(j=0; j<hdr->count &&
  ------------------
  |  Branch (2466:26): [True: 1.53k, False: 955]
  ------------------
 2467|  1.53k|                         tmp_hdr.count<PJSIP_GENERIC_ARRAY_MAX_COUNT; ++j)
  ------------------
  |  | 1191|  1.53k|#define PJSIP_GENERIC_ARRAY_MAX_COUNT   32
  ------------------
  |  Branch (2467:26): [True: 697, False: 833]
  ------------------
 2468|    697|                {
 2469|    697|                    tmp_hdr.values[tmp_hdr.count++] = hdr->values[j];
 2470|    697|                }
 2471|       |
 2472|       |                /* Get the next header for this capability */
 2473|  1.78k|                hdr = (const pjsip_generic_array_hdr*)
 2474|  1.78k|                      pjsip_msg_find_hdr(msg, htypes[i], hdr->next);
 2475|  1.78k|            }
 2476|       |
 2477|       |            /* Save this capability */
 2478|     59|            status = pjsip_dlg_set_remote_cap_hdr(dlg, &tmp_hdr);
 2479|     59|            if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (2479:17): [True: 0, False: 59]
  ------------------
 2480|      0|                pjsip_dlg_dec_lock(dlg);
 2481|      0|                return status;
 2482|      0|            }
 2483|     59|        }
 2484|    843|    }
 2485|       |
 2486|    281|    pjsip_dlg_dec_lock(dlg);
 2487|       |
 2488|    281|    return PJ_SUCCESS;
 2489|    281|}
pjsip_dlg_get_remote_cap_hdr:
 2498|    843|{
 2499|    843|    pjsip_hdr *hdr;
 2500|       |
 2501|       |    /* Check arguments. */
 2502|    843|    PJ_ASSERT_RETURN(dlg, NULL);
  ------------------
  |  |   97|    843|            do { \
  |  |   98|    843|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 843]
  |  |  ------------------
  |  |   99|    843|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 843]
  |  |  ------------------
  ------------------
  |  Branch (2502:5): [True: 0, False: 0]
  |  Branch (2502:5): [True: 0, False: 0]
  ------------------
 2503|    843|    PJ_ASSERT_RETURN((htype != PJSIP_H_OTHER) || (hname && hname->slen),
  ------------------
  |  |   97|    843|            do { \
  |  |   98|    843|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 0, False: 0]
  |  |  |  Branch (98:23): [True: 0, False: 0]
  |  |  |  Branch (98:23): [True: 843, False: 0]
  |  |  ------------------
  |  |   99|    843|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 843]
  |  |  ------------------
  ------------------
  |  Branch (2503:5): [True: 0, False: 0]
  |  Branch (2503:5): [True: 0, False: 0]
  |  Branch (2503:5): [True: 0, False: 0]
  |  Branch (2503:5): [True: 0, False: 0]
  |  Branch (2503:5): [True: 0, False: 0]
  |  Branch (2503:5): [True: 0, False: 0]
  ------------------
 2504|    843|                     NULL);
 2505|       |
 2506|    843|    pjsip_dlg_inc_lock(dlg);
 2507|       |
 2508|    843|    hdr = dlg->rem_cap_hdr.next;
 2509|    843|    while (hdr != &dlg->rem_cap_hdr) {
  ------------------
  |  Branch (2509:12): [True: 0, False: 843]
  ------------------
 2510|      0|        if ((htype != PJSIP_H_OTHER && htype == (int)hdr->type) ||
  ------------------
  |  Branch (2510:14): [True: 0, False: 0]
  |  Branch (2510:40): [True: 0, False: 0]
  ------------------
 2511|      0|            (htype == PJSIP_H_OTHER && pj_stricmp(&hdr->name, hname) == 0))
  ------------------
  |  Branch (2511:14): [True: 0, False: 0]
  |  Branch (2511:40): [True: 0, False: 0]
  ------------------
 2512|      0|        {
 2513|      0|            pjsip_dlg_dec_lock(dlg);
 2514|      0|            return hdr;
 2515|      0|        }
 2516|      0|        hdr = hdr->next;
 2517|      0|    }
 2518|       |
 2519|    843|    pjsip_dlg_dec_lock(dlg);
 2520|       |
 2521|       |    return NULL;
 2522|    843|}
pjsip_dlg_set_remote_cap_hdr:
 2532|     59|{
 2533|     59|    pjsip_generic_array_hdr *hdr;
 2534|       |
 2535|       |    /* Check arguments. */
 2536|     59|    PJ_ASSERT_RETURN(dlg && cap_hdr, PJ_EINVAL);
  ------------------
  |  |   97|     59|            do { \
  |  |   98|    118|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 59, False: 0]
  |  |  |  Branch (98:23): [True: 59, False: 0]
  |  |  ------------------
  |  |   99|     59|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 59]
  |  |  ------------------
  ------------------
  |  Branch (2536:5): [True: 0, False: 0]
  |  Branch (2536:5): [True: 0, False: 0]
  |  Branch (2536:5): [True: 0, False: 0]
  |  Branch (2536:5): [True: 0, False: 0]
  ------------------
 2537|       |
 2538|     59|    pjsip_dlg_inc_lock(dlg);
 2539|       |
 2540|       |    /* Find the header. */
 2541|     59|    hdr = (pjsip_generic_array_hdr*)
 2542|     59|          pjsip_dlg_get_remote_cap_hdr(dlg, cap_hdr->type, &cap_hdr->name);
 2543|       |
 2544|       |    /* Quick compare if the capability is up to date */
 2545|     59|    if (hdr && hdr->count == cap_hdr->count) {
  ------------------
  |  Branch (2545:9): [True: 0, False: 59]
  |  Branch (2545:16): [True: 0, False: 0]
  ------------------
 2546|      0|        unsigned i;
 2547|      0|        pj_bool_t uptodate = PJ_TRUE;
 2548|       |
 2549|      0|        for (i=0; i<hdr->count; ++i) {
  ------------------
  |  Branch (2549:19): [True: 0, False: 0]
  ------------------
 2550|      0|            if (pj_stricmp(&hdr->values[i], &cap_hdr->values[i]))
  ------------------
  |  Branch (2550:17): [True: 0, False: 0]
  ------------------
 2551|      0|                uptodate = PJ_FALSE;
 2552|      0|        }
 2553|       |
 2554|       |        /* Capability is up to date, just return PJ_SUCCESS */
 2555|      0|        if (uptodate) {
  ------------------
  |  Branch (2555:13): [True: 0, False: 0]
  ------------------
 2556|      0|            pjsip_dlg_dec_lock(dlg);
 2557|      0|            return PJ_SUCCESS;
 2558|      0|        }
 2559|      0|    }
 2560|       |
 2561|       |    /* Remove existing capability header if any */
 2562|     59|    if (hdr)
  ------------------
  |  Branch (2562:9): [True: 0, False: 59]
  ------------------
 2563|      0|        pj_list_erase(hdr);
 2564|       |
 2565|       |    /* Add the new capability header */
 2566|     59|    hdr = (pjsip_generic_array_hdr*) pjsip_hdr_clone(dlg->pool, cap_hdr);
 2567|     59|    hdr->type = cap_hdr->type;
 2568|     59|    pj_strdup(dlg->pool, &hdr->name, &cap_hdr->name);
 2569|     59|    pj_list_push_back(&dlg->rem_cap_hdr, hdr);
 2570|       |
 2571|     59|    pjsip_dlg_dec_lock(dlg);
 2572|       |
 2573|       |    /* Done. */
 2574|     59|    return PJ_SUCCESS;
 2575|     59|}
pjsip_dlg_remove_remote_cap_hdr:
 2583|    784|{
 2584|    784|    pjsip_generic_array_hdr *hdr;
 2585|       |
 2586|       |    /* Check arguments. */
 2587|    784|    PJ_ASSERT_RETURN(dlg, PJ_EINVAL);
  ------------------
  |  |   97|    784|            do { \
  |  |   98|    784|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 784]
  |  |  ------------------
  |  |   99|    784|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 784]
  |  |  ------------------
  ------------------
  |  Branch (2587:5): [True: 0, False: 0]
  |  Branch (2587:5): [True: 0, False: 0]
  ------------------
 2588|    784|    PJ_ASSERT_RETURN((htype != PJSIP_H_OTHER) || (hname && hname->slen),
  ------------------
  |  |   97|    784|            do { \
  |  |   98|    784|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 0, False: 0]
  |  |  |  Branch (98:23): [True: 0, False: 0]
  |  |  |  Branch (98:23): [True: 784, False: 0]
  |  |  ------------------
  |  |   99|    784|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 784]
  |  |  ------------------
  ------------------
  |  Branch (2588:5): [True: 0, False: 0]
  |  Branch (2588:5): [True: 0, False: 0]
  |  Branch (2588:5): [True: 0, False: 0]
  |  Branch (2588:5): [True: 0, False: 0]
  |  Branch (2588:5): [True: 0, False: 0]
  |  Branch (2588:5): [True: 0, False: 0]
  ------------------
 2589|    784|                     PJ_EINVAL);
 2590|       |
 2591|    784|    pjsip_dlg_inc_lock(dlg);
 2592|       |
 2593|    784|    hdr = (pjsip_generic_array_hdr*)
 2594|    784|          pjsip_dlg_get_remote_cap_hdr(dlg, htype, hname);
 2595|    784|    if (!hdr) {
  ------------------
  |  Branch (2595:9): [True: 784, False: 0]
  ------------------
 2596|    784|        pjsip_dlg_dec_lock(dlg);
 2597|    784|        return PJ_ENOTFOUND;
  ------------------
  |  |  403|    784|#define PJ_ENOTFOUND        (PJ_ERRNO_START_STATUS + 6) /* 70006 */
  |  |  ------------------
  |  |  |  |  521|    784|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|    784|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|    784|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2598|    784|    }
 2599|       |
 2600|      0|    pj_list_erase(hdr);
 2601|       |
 2602|      0|    pjsip_dlg_dec_lock(dlg);
 2603|       |
 2604|      0|    return PJ_SUCCESS;
 2605|    784|}
sip_dialog.c:create_dialog:
   81|  5.99k|{
   82|  5.99k|    pjsip_endpoint *endpt;
   83|  5.99k|    pj_pool_t *pool;
   84|  5.99k|    pjsip_dialog *dlg;
   85|  5.99k|    pj_status_t status;
   86|       |
   87|  5.99k|    endpt = pjsip_ua_get_endpt(ua);
   88|  5.99k|    if (!endpt)
  ------------------
  |  Branch (88:9): [True: 0, False: 5.99k]
  ------------------
   89|      0|        return PJ_EINVALIDOP;
  ------------------
  |  |  438|      0|#define PJ_EINVALIDOP       (PJ_ERRNO_START_STATUS + 13)/* 70013 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   90|       |
   91|  5.99k|    pool = pjsip_endpt_create_pool(endpt, "dlg%p",
   92|  5.99k|                                   PJSIP_POOL_LEN_DIALOG,
  ------------------
  |  | 1148|  5.99k|#define PJSIP_POOL_LEN_DIALOG           4000
  ------------------
   93|  5.99k|                                   PJSIP_POOL_INC_DIALOG);
  ------------------
  |  | 1150|  5.99k|#define PJSIP_POOL_INC_DIALOG           4000
  ------------------
   94|  5.99k|    if (!pool)
  ------------------
  |  Branch (94:9): [True: 0, False: 5.99k]
  ------------------
   95|      0|        return PJ_ENOMEM;
  ------------------
  |  |  408|      0|#define PJ_ENOMEM           (PJ_ERRNO_START_STATUS + 7) /* 70007 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   96|       |
   97|  5.99k|    dlg = PJ_POOL_ZALLOC_T(pool, pjsip_dialog);
  ------------------
  |  |  583|  5.99k|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
   98|  5.99k|    PJ_ASSERT_RETURN(dlg != NULL, PJ_ENOMEM);
  ------------------
  |  |   97|  5.99k|            do { \
  |  |   98|  5.99k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 5.99k]
  |  |  ------------------
  |  |   99|  5.99k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 5.99k]
  |  |  ------------------
  ------------------
  |  Branch (98:5): [True: 0, False: 0]
  |  Branch (98:5): [True: 0, False: 0]
  ------------------
   99|       |
  100|  5.99k|    dlg->pool = pool;
  101|  5.99k|    pj_ansi_snprintf(dlg->obj_name, sizeof(dlg->obj_name), "dlg%p", dlg);
  ------------------
  |  |  114|  5.99k|#define pj_ansi_snprintf        snprintf
  ------------------
  102|  5.99k|    dlg->ua = ua;
  103|  5.99k|    dlg->endpt = endpt;
  104|  5.99k|    dlg->state = PJSIP_DIALOG_STATE_NULL;
  105|  5.99k|    dlg->add_allow = pjsip_include_allow_hdr_in_dlg;
  106|       |
  107|  5.99k|    pj_list_init(&dlg->inv_hdr);
  108|  5.99k|    pj_list_init(&dlg->rem_cap_hdr);
  109|       |
  110|       |    /* Init client authentication session. */
  111|  5.99k|    status = pjsip_auth_clt_init(&dlg->auth_sess, dlg->endpt,
  112|  5.99k|                                 dlg->pool, 0);
  113|  5.99k|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (113:9): [True: 0, False: 5.99k]
  ------------------
  114|      0|        goto on_error;
  115|       |
  116|  5.99k|    if (grp_lock) {
  ------------------
  |  Branch (116:9): [True: 0, False: 5.99k]
  ------------------
  117|      0|        dlg->grp_lock_ = grp_lock;
  118|  5.99k|    } else {
  119|  5.99k|        status = pj_grp_lock_create(pool, NULL, &dlg->grp_lock_);
  120|  5.99k|        if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (120:13): [True: 0, False: 5.99k]
  ------------------
  121|      0|            goto on_error;
  122|      0|        }
  123|  5.99k|    }
  124|       |
  125|  5.99k|    pj_grp_lock_add_ref(dlg->grp_lock_);
  126|  5.99k|    pj_grp_lock_add_handler(dlg->grp_lock_, pool, dlg, &dlg_on_destroy);
  127|       |
  128|  5.99k|    pjsip_target_set_init(&dlg->target_set);
  129|       |
  130|  5.99k|    *p_dlg = dlg;
  131|  5.99k|    return PJ_SUCCESS;
  132|       |
  133|      0|on_error:
  134|      0|    pjsip_endpt_release_pool(endpt, pool);
  135|      0|    return status;
  136|  5.99k|}
sip_dialog.c:dlg_on_destroy:
   64|  5.99k|{
   65|  5.99k|    pjsip_dialog *dlg = (pjsip_dialog *)arg;
   66|       |
   67|  5.99k|    PJ_LOG(5,(dlg->obj_name, "Dialog destroyed!"));
  ------------------
  |  |  106|  5.99k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  5.99k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  11.9k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 5.99k, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 5.99k]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|  5.99k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 5.99k]
  |  |  ------------------
  ------------------
   68|       |
   69|  5.99k|    pjsip_endpt_release_pool(dlg->endpt, dlg->pool);
   70|  5.99k|}
sip_dialog.c:destroy_dialog:
  151|  5.99k|{
  152|  5.99k|    if (dlg->tp_sel.type != PJSIP_TPSELECTOR_NONE) {
  ------------------
  |  Branch (152:9): [True: 0, False: 5.99k]
  ------------------
  153|      0|        pjsip_tpselector_dec_ref(&dlg->tp_sel);
  154|      0|        pj_bzero(&dlg->tp_sel, sizeof(pjsip_tpselector));
  155|      0|    }
  156|  5.99k|    pjsip_auth_clt_deinit(&dlg->auth_sess);
  157|       |
  158|  5.99k|    pj_grp_lock_dec_ref(dlg->grp_lock_);
  159|       |
  160|  5.99k|    if (unlock_mutex)
  ------------------
  |  Branch (160:9): [True: 515, False: 5.48k]
  ------------------
  161|    515|        pj_grp_lock_release(dlg->grp_lock_);
  162|  5.99k|}
sip_dialog.c:unregister_and_destroy_dialog:
  888|    515|{
  889|    515|    pj_status_t status;
  890|       |
  891|       |    /* Lock must have been held. */
  892|       |
  893|       |    /* Check dialog state. */
  894|       |    /* Number of sessions must be zero. */
  895|    515|    PJ_ASSERT_RETURN(dlg->sess_count==0, PJ_EINVALIDOP);
  ------------------
  |  |   97|    515|            do { \
  |  |   98|    515|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 515]
  |  |  ------------------
  |  |   99|    515|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 515]
  |  |  ------------------
  ------------------
  |  Branch (895:5): [True: 0, False: 0]
  |  Branch (895:5): [True: 0, False: 0]
  ------------------
  896|       |
  897|       |    /* MUST not have pending transactions. */
  898|    515|    PJ_ASSERT_RETURN(dlg->tsx_count==0, PJ_EINVALIDOP);
  ------------------
  |  |   97|    515|            do { \
  |  |   98|    515|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 515]
  |  |  ------------------
  |  |   99|    515|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 515]
  |  |  ------------------
  ------------------
  |  Branch (898:5): [True: 0, False: 0]
  |  Branch (898:5): [True: 0, False: 0]
  ------------------
  899|       |
  900|       |    /* Unregister from user agent, if it has been registered (see #1924) */
  901|    515|    if (dlg->dlg_set) {
  ------------------
  |  Branch (901:9): [True: 449, False: 66]
  ------------------
  902|    449|        status = pjsip_ua_unregister_dlg(dlg->ua, dlg);
  903|    449|        if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (903:13): [True: 0, False: 449]
  ------------------
  904|      0|            pj_assert(!"Unexpected failed unregistration!");
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (904:13): [Folded, False: 0]
  |  Branch (904:13): [Folded, False: 0]
  ------------------
  905|      0|            return status;
  906|      0|        }
  907|    449|    }
  908|       |
  909|       |    /* Destroy this dialog. */
  910|    515|    destroy_dialog(dlg, unlock_mutex);
  911|       |
  912|    515|    return PJ_SUCCESS;
  913|    515|}
sip_dialog.c:dlg_create_request_throw:
 1220|    168|{
 1221|    168|    pjsip_tx_data *tdata;
 1222|    168|    pjsip_contact_hdr *contact;
 1223|    168|    pjsip_route_hdr *route, *end_list;
 1224|    168|    pj_status_t status;
 1225|       |
 1226|       |    /* Contact Header field.
 1227|       |     * Contact can only be present in requests that establish dialog (in the
 1228|       |     * core SIP spec, only INVITE).
 1229|       |     */
 1230|    168|    if (pjsip_method_creates_dialog(method))
  ------------------
  |  Branch (1230:9): [True: 0, False: 168]
  ------------------
 1231|      0|        contact = dlg->local.contact;
 1232|    168|    else
 1233|    168|        contact = NULL;
 1234|       |
 1235|       |    /*
 1236|       |     * Create the request by cloning from the headers in the
 1237|       |     * dialog.
 1238|       |     */
 1239|    168|    status = pjsip_endpt_create_request_from_hdr(dlg->endpt,
 1240|    168|                                                 method,
 1241|    168|                                                 dlg->target,
 1242|    168|                                                 dlg->local.info,
 1243|    168|                                                 dlg->remote.info,
 1244|    168|                                                 contact,
 1245|    168|                                                 dlg->call_id,
 1246|    168|                                                 cseq,
 1247|    168|                                                 NULL,
 1248|    168|                                                 &tdata);
 1249|    168|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (1249:9): [True: 0, False: 168]
  ------------------
 1250|      0|        return status;
 1251|       |
 1252|       |    /* Put this dialog in tdata's mod_data */
 1253|    168|    tdata->mod_data[dlg->ua->id] = dlg;
 1254|       |
 1255|       |    /* Just copy dialog route-set to Route header.
 1256|       |     * The transaction will do the processing as specified in Section 12.2.1
 1257|       |     * of RFC 3261 in function tsx_process_route() in sip_transaction.c.
 1258|       |     */
 1259|    168|    route = dlg->route_set.next;
 1260|    168|    end_list = &dlg->route_set;
 1261|    195|    for (; route != end_list; route = route->next ) {
  ------------------
  |  Branch (1261:12): [True: 27, False: 168]
  ------------------
 1262|     27|        pjsip_route_hdr *r;
 1263|     27|        r = (pjsip_route_hdr*) pjsip_hdr_shallow_clone( tdata->pool, route );
 1264|     27|        pjsip_routing_hdr_set_route(r);
 1265|     27|        pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)r);
 1266|     27|    }
 1267|       |
 1268|       |    /* Copy authorization headers, if request is not ACK or CANCEL. */
 1269|    168|    if (method->id != PJSIP_ACK_METHOD && method->id != PJSIP_CANCEL_METHOD) {
  ------------------
  |  Branch (1269:9): [True: 168, False: 0]
  |  Branch (1269:43): [True: 168, False: 0]
  ------------------
 1270|    168|        status = pjsip_auth_clt_init_req( &dlg->auth_sess, tdata );
 1271|    168|        if (status != PJ_SUCCESS)
  ------------------
  |  Branch (1271:13): [True: 0, False: 168]
  ------------------
 1272|      0|            return status;
 1273|    168|    }
 1274|       |
 1275|       |    /* Copy the initial destination host to tdata. This information can be
 1276|       |     * used later by transport for transport selection.
 1277|       |     */
 1278|    168|    if (dlg->initial_dest.slen) {
  ------------------
  |  Branch (1278:9): [True: 0, False: 168]
  ------------------
 1279|      0|        pj_strdup(tdata->pool, &tdata->dest_info.name, &dlg->initial_dest);
 1280|      0|        PJ_LOG(5, (THIS_FILE, "Setting initial dest %.*s",
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1281|      0|                   (int)dlg->initial_dest.slen, dlg->initial_dest.ptr));
 1282|      0|    }
 1283|       |
 1284|       |    /* Done. */
 1285|    168|    *p_tdata = tdata;
 1286|       |
 1287|    168|    return PJ_SUCCESS;
 1288|    168|}
sip_dialog.c:dlg_beautify_response:
 1486|    281|{
 1487|    281|    pjsip_cseq_hdr *cseq;
 1488|    281|    int st_class;
 1489|    281|    const pjsip_hdr *c_hdr;
 1490|    281|    pjsip_hdr *hdr;
 1491|       |
 1492|    281|    cseq = PJSIP_MSG_CSEQ_HDR(tdata->msg);
  ------------------
  |  | 1034|    281|            ((pjsip_cseq_hdr*)pjsip_msg_find_hdr(msg, PJSIP_H_CSEQ, NULL))
  ------------------
 1493|    281|    pj_assert(cseq != NULL);
  ------------------
  |  |   65|    281|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (1493:5): [True: 0, False: 281]
  |  Branch (1493:5): [True: 281, False: 0]
  ------------------
 1494|       |
 1495|    281|    st_class = st_code / 100;
 1496|       |
 1497|       |    /* Contact, Allow, Supported header. */
 1498|    281|    if (add_headers && pjsip_method_creates_dialog(&cseq->method)) {
  ------------------
  |  Branch (1498:9): [True: 0, False: 281]
  |  Branch (1498:24): [True: 0, False: 0]
  ------------------
 1499|       |        /* Add Contact header for 1xx, 2xx, 3xx and 485 response. */
 1500|      0|        if (st_class==2 || st_class==3 || (st_class==1 && st_code != 100) ||
  ------------------
  |  Branch (1500:13): [True: 0, False: 0]
  |  Branch (1500:28): [True: 0, False: 0]
  |  Branch (1500:44): [True: 0, False: 0]
  |  Branch (1500:59): [True: 0, False: 0]
  ------------------
 1501|      0|            st_code==485)
  ------------------
  |  Branch (1501:13): [True: 0, False: 0]
  ------------------
 1502|      0|        {
 1503|       |            /* Add contact header only if one is not present. */
 1504|      0|            if (pjsip_msg_find_hdr(tdata->msg, PJSIP_H_CONTACT, NULL) == 0 &&
  ------------------
  |  Branch (1504:17): [True: 0, False: 0]
  ------------------
 1505|      0|                pjsip_msg_find_hdr_by_name(tdata->msg, &HCONTACT, NULL) == 0)
  ------------------
  |  Branch (1505:17): [True: 0, False: 0]
  ------------------
 1506|      0|            {
 1507|      0|                hdr = (pjsip_hdr*) pjsip_hdr_clone(tdata->pool,
 1508|      0|                                                   dlg->local.contact);
 1509|      0|                pjsip_msg_add_hdr(tdata->msg, hdr);
 1510|      0|            }
 1511|      0|        }
 1512|       |
 1513|       |        /* Add Allow header in 18x, 2xx and 405 response. */
 1514|      0|        if ((((st_code/10==18 || st_class==2) && dlg->add_allow)
  ------------------
  |  Branch (1514:16): [True: 0, False: 0]
  |  Branch (1514:34): [True: 0, False: 0]
  |  Branch (1514:50): [True: 0, False: 0]
  ------------------
 1515|      0|             || st_code==405) &&
  ------------------
  |  Branch (1515:17): [True: 0, False: 0]
  ------------------
 1516|      0|            pjsip_msg_find_hdr(tdata->msg, PJSIP_H_ALLOW, NULL)==NULL)
  ------------------
  |  Branch (1516:13): [True: 0, False: 0]
  ------------------
 1517|      0|        {
 1518|      0|            c_hdr = pjsip_endpt_get_capability(dlg->endpt,
 1519|      0|                                               PJSIP_H_ALLOW, NULL);
 1520|      0|            if (c_hdr) {
  ------------------
  |  Branch (1520:17): [True: 0, False: 0]
  ------------------
 1521|      0|                hdr = (pjsip_hdr*) pjsip_hdr_clone(tdata->pool, c_hdr);
 1522|      0|                pjsip_msg_add_hdr(tdata->msg, hdr);
 1523|      0|            }
 1524|      0|        }
 1525|       |
 1526|       |        /* Add Supported header in 2xx response. */
 1527|      0|        if (st_class==2 &&
  ------------------
  |  Branch (1527:13): [True: 0, False: 0]
  ------------------
 1528|      0|            pjsip_msg_find_hdr(tdata->msg, PJSIP_H_SUPPORTED, NULL)==NULL)
  ------------------
  |  Branch (1528:13): [True: 0, False: 0]
  ------------------
 1529|      0|        {
 1530|      0|            c_hdr = pjsip_endpt_get_capability(dlg->endpt,
 1531|      0|                                               PJSIP_H_SUPPORTED, NULL);
 1532|      0|            if (c_hdr) {
  ------------------
  |  Branch (1532:17): [True: 0, False: 0]
  ------------------
 1533|      0|                hdr = (pjsip_hdr*) pjsip_hdr_clone(tdata->pool, c_hdr);
 1534|      0|                pjsip_msg_add_hdr(tdata->msg, hdr);
 1535|      0|            }
 1536|      0|        }
 1537|       |
 1538|      0|    }
 1539|       |
 1540|       |    /* Add To tag in all responses except 100 */
 1541|    281|    if (st_code != 100) {
  ------------------
  |  Branch (1541:9): [True: 281, False: 0]
  ------------------
 1542|    281|        pjsip_to_hdr *to;
 1543|       |
 1544|    281|        to = PJSIP_MSG_TO_HDR(tdata->msg);
  ------------------
  |  | 1052|    281|            ((pjsip_to_hdr*)pjsip_msg_find_hdr(msg, PJSIP_H_TO, NULL))
  ------------------
 1545|    281|        pj_assert(to != NULL);
  ------------------
  |  |   65|    281|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (1545:9): [True: 0, False: 281]
  |  Branch (1545:9): [True: 281, False: 0]
  ------------------
 1546|       |
 1547|    281|        to->tag = dlg->local.info->tag;
 1548|       |
 1549|    281|        if (dlg->state == PJSIP_DIALOG_STATE_NULL)
  ------------------
  |  Branch (1549:13): [True: 281, False: 0]
  ------------------
 1550|    281|            dlg->state = PJSIP_DIALOG_STATE_ESTABLISHED;
 1551|    281|    }
 1552|    281|}

pjsip_endpt_register_module:
  161|     10|{
  162|     10|    pj_status_t status = PJ_SUCCESS;
  163|     10|    pjsip_module *m;
  164|     10|    unsigned i;
  165|       |
  166|     10|    pj_rwmutex_lock_write(endpt->mod_mutex);
  167|       |
  168|     10|    if (endpt->mod_running && !endpt->mod_reg_unreg) {
  ------------------
  |  Branch (168:9): [True: 0, False: 10]
  |  Branch (168:31): [True: 0, False: 0]
  ------------------
  169|      0|        PJ_LOG(2, (THIS_FILE, "Warning: Module \"%.*s\" registered during "
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  448|      0|    #define pj_log_wrapper_2(arg)       pj_log_2 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  170|      0|                              "operation. Enable PJSIP_SAFE_MODULE to prevent "
  171|      0|                              "race condition.",
  172|      0|                              (int)mod->name.slen, mod->name.ptr));
  173|       |
  174|      0|        endpt->mod_reg_unreg = PJ_TRUE;
  175|       |        /* Give some time to allow pjsip_endpt_process_rx_data() and
  176|       |         * endpt_on_tx_msg() to complete.
  177|       |         */
  178|      0|        pj_thread_sleep(100);
  179|      0|    }
  180|       |
  181|       |    /* Make sure that this module has not been registered. */
  182|     20|    PJ_ASSERT_ON_FAIL(  pj_list_find_node(&endpt->module_list, mod) == NULL,
  ------------------
  |  |  111|     10|            { \
  |  |  112|     10|                pj_assert(expr); \
  |  |  ------------------
  |  |  |  |   65|     10|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  113|     10|                if (!(expr)) exec_on_fail; \
  |  |  ------------------
  |  |  |  Branch (113:21): [True: 0, False: 10]
  |  |  ------------------
  |  |  114|     10|            }
  ------------------
  |  Branch (182:5): [True: 0, False: 10]
  |  Branch (182:5): [True: 10, False: 0]
  ------------------
  183|     20|                        {status = PJ_EEXISTS; goto on_return;});
  184|       |
  185|       |    /* Make sure that no module with the same name has been registered. */
  186|     20|    PJ_ASSERT_ON_FAIL(  pj_list_search(&endpt->module_list, &mod->name, 
  ------------------
  |  |  111|     10|            { \
  |  |  112|     10|                pj_assert(expr); \
  |  |  ------------------
  |  |  |  |   65|     10|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  113|     10|                if (!(expr)) exec_on_fail; \
  |  |  ------------------
  |  |  |  Branch (113:21): [True: 0, False: 10]
  |  |  ------------------
  |  |  114|     10|            }
  ------------------
  |  Branch (186:5): [True: 0, False: 10]
  |  Branch (186:5): [True: 10, False: 0]
  ------------------
  187|     20|                                       &cmp_mod_name)==NULL,
  188|     20|                        {status = PJ_EEXISTS; goto on_return; });
  189|       |
  190|       |    /* Find unused ID for this module. */
  191|     30|    for (i=0; i<PJ_ARRAY_SIZE(endpt->modules); ++i) {
  ------------------
  |  |  315|     30|#define PJ_ARRAY_SIZE(a)    (sizeof(a)/sizeof(a[0]))
  ------------------
  |  Branch (191:15): [True: 30, False: 0]
  ------------------
  192|     30|        if (endpt->modules[i] == NULL)
  ------------------
  |  Branch (192:13): [True: 10, False: 20]
  ------------------
  193|     10|            break;
  194|     30|    }
  195|     20|    if (i == PJ_ARRAY_SIZE(endpt->modules)) {
  ------------------
  |  |  315|     10|#define PJ_ARRAY_SIZE(a)    (sizeof(a)/sizeof(a[0]))
  ------------------
  |  Branch (195:9): [True: 0, False: 10]
  ------------------
  196|      0|        pj_assert(!"Too many modules registered!");
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (196:9): [Folded, False: 0]
  |  Branch (196:9): [Folded, False: 0]
  ------------------
  197|      0|        status = PJ_ETOOMANY;
  ------------------
  |  |  423|      0|#define PJ_ETOOMANY         (PJ_ERRNO_START_STATUS + 10)/* 70010 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  198|      0|        goto on_return;
  199|      0|    }
  200|       |
  201|       |    /* Assign the ID. */
  202|     10|    mod->id = i;
  203|       |
  204|       |    /* Try to load the module. */
  205|     10|    if (mod->load) {
  ------------------
  |  Branch (205:9): [True: 4, False: 6]
  ------------------
  206|      4|        status = (*mod->load)(endpt);
  207|      4|        if (status != PJ_SUCCESS)
  ------------------
  |  Branch (207:13): [True: 0, False: 4]
  ------------------
  208|      0|            goto on_return;
  209|      4|    }
  210|       |
  211|       |    /* Try to start the module. */
  212|     10|    if (mod->start) {
  ------------------
  |  Branch (212:9): [True: 2, False: 8]
  ------------------
  213|      2|        status = (*mod->start)();
  214|      2|        if (status != PJ_SUCCESS)
  ------------------
  |  Branch (214:13): [True: 0, False: 2]
  ------------------
  215|      0|            goto on_return;
  216|      2|    }
  217|       |
  218|       |    /* Save the module. */
  219|     10|    endpt->modules[i] = mod;
  220|       |
  221|       |    /* Put in the module list, sorted by priority. */
  222|     10|    m = endpt->module_list.next;
  223|     28|    while (m != &endpt->module_list) {
  ------------------
  |  Branch (223:12): [True: 20, False: 8]
  ------------------
  224|     20|        if (m->priority > mod->priority)
  ------------------
  |  Branch (224:13): [True: 2, False: 18]
  ------------------
  225|      2|            break;
  226|     18|        m = m->next;
  227|     18|    }
  228|     10|    pj_list_insert_before(m, mod);
  229|       |
  230|       |    /* Done. */
  231|       |
  232|     10|    PJ_LOG(4,(THIS_FILE, "Module \"%.*s\" registered", 
  ------------------
  |  |  106|     10|#define PJ_LOG(level,arg)       do { \
  |  |  107|     10|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|     20|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 10, Folded]
  |  |  |  Branch (107:70): [True: 10, False: 0]
  |  |  ------------------
  |  |  108|     10|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|     10|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|     10|                                    } \
  |  |  110|     10|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 10]
  |  |  ------------------
  ------------------
  233|     10|              (int)mod->name.slen, mod->name.ptr));
  234|       |
  235|     10|on_return:
  236|     10|    pj_rwmutex_unlock_write(endpt->mod_mutex);
  237|     10|    return status;
  238|     10|}
pjsip_endpt_get_request_headers:
  441|    504|{
  442|    504|    return &endpt->req_hdr;
  443|    504|}
pjsip_endpt_create:
  452|      2|{
  453|      2|    pj_status_t status;
  454|      2|    pj_pool_t *pool;
  455|      2|    pjsip_endpoint *endpt;
  456|      2|    pjsip_max_fwd_hdr *mf_hdr;
  457|      2|    pj_lock_t *lock = NULL;
  458|       |
  459|       |
  460|      2|    status = pj_register_strerror(PJSIP_ERRNO_START, PJ_ERRNO_SPACE_SIZE,
  ------------------
  |  |   47|      2|#define PJSIP_ERRNO_START       (PJ_ERRNO_START_USER)
  |  |  ------------------
  |  |  |  |  535|      2|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  528|      2|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  521|      2|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  509|      2|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      2|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      2|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      2|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  status = pj_register_strerror(PJSIP_ERRNO_START, PJ_ERRNO_SPACE_SIZE,
  ------------------
  |  |  515|      2|#define PJ_ERRNO_SPACE_SIZE     50000
  ------------------
  461|      2|                                  &pjsip_strerror);
  462|      2|    pj_assert(status == PJ_SUCCESS);
  ------------------
  |  |   65|      2|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (462:5): [True: 0, False: 2]
  |  Branch (462:5): [True: 2, False: 0]
  ------------------
  463|       |
  464|      2|    PJ_LOG(5, (THIS_FILE, "Creating endpoint instance..."));
  ------------------
  |  |  106|      2|#define PJ_LOG(level,arg)       do { \
  |  |  107|      2|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      4|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 2, Folded]
  |  |  |  Branch (107:70): [True: 2, False: 0]
  |  |  ------------------
  |  |  108|      2|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  496|      2|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  ------------------
  |  |  109|      2|                                    } \
  |  |  110|      2|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 2]
  |  |  ------------------
  ------------------
  465|       |
  466|      2|    *p_endpt = NULL;
  467|       |
  468|       |    /* Create pool */
  469|      2|    pool = pj_pool_create(pf, "pept%p", 
  470|      2|                          PJSIP_POOL_LEN_ENDPT, PJSIP_POOL_INC_ENDPT,
  ------------------
  |  |  974|      2|#   define PJSIP_POOL_LEN_ENDPT         (16000)
  ------------------
                                        PJSIP_POOL_LEN_ENDPT, PJSIP_POOL_INC_ENDPT,
  ------------------
  |  |  981|      2|#   define PJSIP_POOL_INC_ENDPT         (4000)
  ------------------
  471|      2|                          &pool_callback);
  472|      2|    if (!pool)
  ------------------
  |  Branch (472:9): [True: 0, False: 2]
  ------------------
  473|      0|        return PJ_ENOMEM;
  ------------------
  |  |  408|      0|#define PJ_ENOMEM           (PJ_ERRNO_START_STATUS + 7) /* 70007 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  474|       |
  475|       |    /* Create endpoint. */
  476|      2|    endpt = PJ_POOL_ZALLOC_T(pool, pjsip_endpoint);
  ------------------
  |  |  583|      2|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  477|      2|    endpt->pool = pool;
  478|      2|    endpt->pf = pf;
  479|       |
  480|       |    /* Init modules list. */
  481|      2|    pj_list_init(&endpt->module_list);
  482|       |
  483|       |    /* Initialize exit callback list. */
  484|      2|    pj_list_init(&endpt->exit_cb_list);
  485|       |
  486|       |    /* Create R/W mutex for module manipulation. */
  487|      2|    status = pj_rwmutex_create(endpt->pool, "ept%p", &endpt->mod_mutex);
  488|      2|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (488:9): [True: 0, False: 2]
  ------------------
  489|      0|        goto on_error;
  490|       |
  491|       |    /* Init parser. */
  492|      2|    init_sip_parser();
  493|       |
  494|       |    /* Init tel: uri */
  495|      2|    pjsip_tel_uri_subsys_init();
  496|       |
  497|       |    /* Get name. */
  498|      2|    if (name != NULL) {
  ------------------
  |  Branch (498:9): [True: 2, False: 0]
  ------------------
  499|      2|        pj_str_t temp;
  500|      2|        pj_strdup_with_null(endpt->pool, &endpt->name, pj_cstr(&temp, name));
  501|      2|    } else {
  502|      0|        pj_strdup_with_null(endpt->pool, &endpt->name, pj_gethostname());
  503|      0|    }
  504|       |
  505|       |    /* Create mutex for the events, etc. */
  506|      2|    status = pj_mutex_create_recursive( endpt->pool, "ept%p", &endpt->mutex );
  507|      2|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (507:9): [True: 0, False: 2]
  ------------------
  508|      0|        goto on_error;
  509|      0|    }
  510|       |
  511|       |    /* Create timer heap to manage all timers within this endpoint. */
  512|      2|    status = pj_timer_heap_create( endpt->pool, PJSIP_MAX_TIMER_COUNT, 
  ------------------
  |  |  966|      2|#   define PJSIP_MAX_TIMER_COUNT        (2*pjsip_cfg()->tsx.max_count + \
  |  |  967|      2|                                         2*PJSIP_MAX_DIALOG_COUNT)
  |  |  ------------------
  |  |  |  |  327|      2|#   define PJSIP_MAX_DIALOG_COUNT       (512-1)
  |  |  ------------------
  ------------------
  513|      2|                                   &endpt->timer_heap);
  514|      2|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (514:9): [True: 0, False: 2]
  ------------------
  515|      0|        goto on_error;
  516|      0|    }
  517|       |
  518|       |    /* Set recursive lock for the timer heap. */
  519|      2|    status = pj_lock_create_recursive_mutex( endpt->pool, "edpt%p", &lock);
  520|      2|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (520:9): [True: 0, False: 2]
  ------------------
  521|      0|        goto on_error;
  522|      0|    }
  523|      2|    pj_timer_heap_set_lock(endpt->timer_heap, lock, PJ_TRUE);
  524|       |
  525|       |    /* Set maximum timed out entries to process in a single poll. */
  526|      2|    pj_timer_heap_set_max_timed_out_per_poll(endpt->timer_heap, 
  527|      2|                                             PJSIP_MAX_TIMED_OUT_ENTRIES);
  ------------------
  |  |  660|      2|#   define PJSIP_MAX_TIMED_OUT_ENTRIES  10
  ------------------
  528|       |
  529|       |    /* Create ioqueue. */
  530|      2|    status = pj_ioqueue_create( endpt->pool, PJSIP_MAX_TRANSPORTS, &endpt->ioqueue);
  ------------------
  |  |  337|      2|#   define PJSIP_MAX_TRANSPORTS         (PJ_IOQUEUE_MAX_HANDLES)
  |  |  ------------------
  |  |  |  |  738|      2|#   define PJ_IOQUEUE_MAX_HANDLES       (64)
  |  |  ------------------
  ------------------
  531|      2|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (531:9): [True: 0, False: 2]
  ------------------
  532|      0|        goto on_error;
  533|      0|    }
  534|       |
  535|       |    /* Create transport manager. */
  536|      2|    status = pjsip_tpmgr_create( endpt->pool, endpt,
  537|      2|                                 &endpt_on_rx_msg,
  538|      2|                                 &endpt_on_tx_msg,
  539|      2|                                 &endpt->transport_mgr);
  540|      2|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (540:9): [True: 0, False: 2]
  ------------------
  541|      0|        goto on_error;
  542|      0|    }
  543|       |
  544|       |    /* Create asynchronous DNS resolver. */
  545|      2|    status = pjsip_resolver_create(endpt->pool, &endpt->resolver);
  546|      2|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (546:9): [True: 0, False: 2]
  ------------------
  547|      0|        PJ_PERROR(4, (THIS_FILE, status,
  ------------------
  |  |  189|      0|#define PJ_PERROR(level,arg)    do { \
  |  |  190|      0|                                    pj_perror_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  611|      0|    #define pj_perror_wrapper_4(arg)    pj_perror_4 arg
  |  |  ------------------
  |  |  191|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (191:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  548|      0|                      "Error creating resolver instance"));
  549|      0|        goto on_error;
  550|      0|    }
  551|       |
  552|       |    /* Initialize request headers. */
  553|      2|    pj_list_init(&endpt->req_hdr);
  554|       |
  555|       |    /* Add "Max-Forwards" for request header. */
  556|      2|    mf_hdr = pjsip_max_fwd_hdr_create(endpt->pool,
  557|      2|                                      PJSIP_MAX_FORWARDS_VALUE);
  ------------------
  |  | 1060|      2|#define PJSIP_MAX_FORWARDS_VALUE        70
  ------------------
  558|      2|    pj_list_insert_before( &endpt->req_hdr, mf_hdr);
  559|       |
  560|       |    /* Initialize capability header list. */
  561|      2|    pj_list_init(&endpt->cap_hdr);
  562|       |
  563|       |
  564|       |    /* Done. */
  565|      2|    *p_endpt = endpt;
  566|      2|    return status;
  567|       |
  568|      0|on_error:
  569|      0|    if (endpt->transport_mgr) {
  ------------------
  |  Branch (569:9): [True: 0, False: 0]
  ------------------
  570|      0|        pjsip_tpmgr_destroy(endpt->transport_mgr);
  571|      0|        endpt->transport_mgr = NULL;
  572|      0|    }
  573|      0|    if (endpt->ioqueue) {
  ------------------
  |  Branch (573:9): [True: 0, False: 0]
  ------------------
  574|      0|        pj_ioqueue_destroy(endpt->ioqueue);
  575|      0|        endpt->ioqueue = NULL;
  576|      0|    }
  577|      0|    if (endpt->timer_heap) {
  ------------------
  |  Branch (577:9): [True: 0, False: 0]
  ------------------
  578|      0|        pj_timer_heap_destroy(endpt->timer_heap);
  579|      0|        endpt->timer_heap = NULL;
  580|      0|    }
  581|      0|    if (endpt->mutex) {
  ------------------
  |  Branch (581:9): [True: 0, False: 0]
  ------------------
  582|      0|        pj_mutex_destroy(endpt->mutex);
  583|      0|        endpt->mutex = NULL;
  584|      0|    }
  585|      0|    deinit_sip_parser();
  586|      0|    if (endpt->mod_mutex) {
  ------------------
  |  Branch (586:9): [True: 0, False: 0]
  ------------------
  587|      0|        pj_rwmutex_destroy(endpt->mod_mutex);
  588|      0|        endpt->mod_mutex = NULL;
  589|      0|    }
  590|      0|    pj_pool_release( endpt->pool );
  591|       |
  592|      0|    PJ_PERROR(4, (THIS_FILE, status, "Error creating endpoint"));
  ------------------
  |  |  189|      0|#define PJ_PERROR(level,arg)    do { \
  |  |  190|      0|                                    pj_perror_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  611|      0|    #define pj_perror_wrapper_4(arg)    pj_perror_4 arg
  |  |  ------------------
  |  |  191|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (191:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  593|      0|    return status;
  594|      2|}
pjsip_endpt_create_pool:
  677|  12.1k|{
  678|  12.1k|    pj_pool_t *pool;
  679|       |
  680|       |    /* Lock endpoint mutex. */
  681|       |    /* No need to lock mutex. Factory is thread safe.
  682|       |    pj_mutex_lock(endpt->mutex);
  683|       |     */
  684|       |
  685|       |    /* Create pool */
  686|  12.1k|    pool = pj_pool_create( endpt->pf, pool_name,
  687|  12.1k|                           initial, increment, &pool_callback);
  688|       |
  689|       |    /* Unlock mutex. */
  690|       |    /* No need to lock mutex. Factory is thread safe.
  691|       |    pj_mutex_unlock(endpt->mutex);
  692|       |     */
  693|       |
  694|  12.1k|    if (!pool) {
  ------------------
  |  Branch (694:9): [True: 0, False: 12.1k]
  ------------------
  695|      0|        PJ_LOG(4, (THIS_FILE, "Unable to create pool %s!", pool_name));
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  696|      0|    }
  697|       |
  698|  12.1k|    return pool;
  699|  12.1k|}
pjsip_endpt_release_pool:
  706|  12.1k|{
  707|  12.1k|    PJ_LOG(6, (THIS_FILE, "Releasing pool %s", pj_pool_getobjname(pool)));
  ------------------
  |  |  106|  12.1k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  12.1k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  24.2k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 12.1k]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  12.1k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 12.1k]
  |  |  ------------------
  ------------------
  708|       |
  709|       |    /* Don't need to acquire mutex since pool factory is thread safe
  710|       |       pj_mutex_lock(endpt->mutex);
  711|       |     */
  712|  12.1k|    pj_pool_release( pool );
  713|       |
  714|  12.1k|    PJ_UNUSED_ARG(endpt);
  ------------------
  |  | 1537|  12.1k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  715|       |    /*
  716|       |    pj_mutex_unlock(endpt->mutex);
  717|       |     */
  718|  12.1k|}
pjsip_endpt_handle_events2:
  724|  5.68k|{
  725|  5.68k|    enum { MAX_TIMEOUT_ON_ERR = 10 };
  726|       |    /* timeout is 'out' var. This just to make compiler happy. */
  727|  5.68k|    pj_time_val timeout = { 0, 0};
  728|  5.68k|    unsigned count = 0, net_event_count = 0;
  729|  5.68k|    int c;
  730|       |
  731|  5.68k|    PJ_LOG(6, (THIS_FILE, "pjsip_endpt_handle_events()"));
  ------------------
  |  |  106|  5.68k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  5.68k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  11.3k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 5.68k]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  5.68k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 5.68k]
  |  |  ------------------
  ------------------
  732|       |
  733|       |    /* Poll the timer. The timer heap has its own mutex for better 
  734|       |     * granularity, so we don't need to lock end endpoint. 
  735|       |     */
  736|  5.68k|    timeout.sec = timeout.msec = 0;
  737|  5.68k|    c = pj_timer_heap_poll( endpt->timer_heap, &timeout );
  738|  5.68k|    if (c > 0)
  ------------------
  |  Branch (738:9): [True: 281, False: 5.40k]
  ------------------
  739|    281|        count += c;
  740|       |
  741|       |    /* timer_heap_poll should never ever returns negative value, or otherwise
  742|       |     * ioqueue_poll() will block forever!
  743|       |     */
  744|  5.68k|    pj_assert(timeout.sec >= 0 && timeout.msec >= 0);
  ------------------
  |  |   65|  5.68k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (744:5): [True: 0, False: 5.68k]
  |  Branch (744:5): [True: 0, False: 0]
  |  Branch (744:5): [True: 5.68k, False: 0]
  |  Branch (744:5): [True: 5.68k, False: 0]
  ------------------
  745|  5.68k|    if (timeout.msec >= 1000) timeout.msec = 999;
  ------------------
  |  Branch (745:9): [True: 3.27k, False: 2.41k]
  ------------------
  746|       |
  747|       |    /* If caller specifies maximum time to wait, then compare the value with
  748|       |     * the timeout to wait from timer, and use the minimum value.
  749|       |     */
  750|  5.68k|    if (max_timeout && PJ_TIME_VAL_GT(timeout, *max_timeout)) {
  ------------------
  |  |  497|  5.68k|#define PJ_TIME_VAL_GT(t1, t2)  ((t1).sec>(t2).sec || \
  |  |  ------------------
  |  |  |  Branch (497:34): [True: 5.68k, False: 0]
  |  |  ------------------
  |  |  498|  5.68k|                                ((t1).sec==(t2).sec && (t1).msec>(t2).msec))
  |  |  ------------------
  |  |  |  Branch (498:34): [True: 0, False: 0]
  |  |  |  Branch (498:56): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (750:9): [True: 5.68k, False: 0]
  ------------------
  751|  5.68k|        timeout = *max_timeout;
  752|  5.68k|    }
  753|       |
  754|       |    /* Poll ioqueue. 
  755|       |     * Repeat polling the ioqueue while we have immediate events, because
  756|       |     * timer heap may process more than one events, so if we only process
  757|       |     * one network events at a time (such as when IOCP backend is used),
  758|       |     * the ioqueue may have trouble keeping up with the request rate.
  759|       |     *
  760|       |     * For example, for each send() request, one network event will be
  761|       |     *   reported by ioqueue for the send() completion. If we don't poll
  762|       |     *   the ioqueue often enough, the send() completion will not be
  763|       |     *   reported in timely manner.
  764|       |     */
  765|  5.68k|    do {
  766|  5.68k|        c = pj_ioqueue_poll( endpt->ioqueue, &timeout);
  767|  5.68k|        if (c < 0) {
  ------------------
  |  Branch (767:13): [True: 0, False: 5.68k]
  ------------------
  768|      0|            pj_status_t err = pj_get_netos_error();
  769|      0|#if PJSIP_HANDLE_EVENTS_HAS_SLEEP_ON_ERR
  770|      0|            unsigned msec = PJ_TIME_VAL_MSEC(timeout);
  ------------------
  |  |  477|      0|#define PJ_TIME_VAL_MSEC(t)     ((t).sec * 1000 + (t).msec)
  ------------------
  771|      0|            pj_thread_sleep(PJ_MIN(msec, MAX_TIMEOUT_ON_ERR));
  ------------------
  |  |   62|      0|#define PJ_MIN(x, y)    ((x) < (y)? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (62:26): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  772|      0|#endif
  773|       |
  774|      0|            if (p_count)
  ------------------
  |  Branch (774:17): [True: 0, False: 0]
  ------------------
  775|      0|                *p_count = count;
  776|      0|            return err;
  777|  5.68k|        } else if (c == 0) {
  ------------------
  |  Branch (777:20): [True: 5.68k, False: 0]
  ------------------
  778|  5.68k|            break;
  779|  5.68k|        } else {
  780|      0|            net_event_count += c;
  781|      0|            timeout.sec = timeout.msec = 0;
  782|      0|        }
  783|  5.68k|    } while (c > 0 && net_event_count < PJSIP_MAX_NET_EVENTS);
  ------------------
  |  |  650|      0|#   define PJSIP_MAX_NET_EVENTS         1
  ------------------
  |  Branch (783:14): [True: 0, False: 0]
  |  Branch (783:23): [True: 0, False: 0]
  ------------------
  784|       |
  785|  5.68k|    count += net_event_count;
  786|  5.68k|    if (p_count)
  ------------------
  |  Branch (786:9): [True: 0, False: 5.68k]
  ------------------
  787|      0|        *p_count = count;
  788|       |
  789|  5.68k|    return PJ_SUCCESS;
  790|  5.68k|}
pjsip_endpt_handle_events:
  797|  5.68k|{
  798|       |    return pjsip_endpt_handle_events2(endpt, max_timeout, NULL);
  799|  5.68k|}
pjsip_endpt_schedule_timer_w_grp_lock_dbg:
  841|     21|{
  842|     21|    PJ_LOG(6, (THIS_FILE, "pjsip_endpt_schedule_timer_w_grp_lock"
  ------------------
  |  |  106|     21|#define PJ_LOG(level,arg)       do { \
  |  |  107|     21|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|     42|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 21]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|     21|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 21]
  |  |  ------------------
  ------------------
  843|     21|                          "(entry=%p, delay=%lu.%lu, grp_lock=%p)",
  844|     21|                          entry, (unsigned long)delay->sec,
  845|     21|                          (unsigned long)delay->msec, grp_lock));
  846|     21|    return pj_timer_heap_schedule_w_grp_lock_dbg(endpt->timer_heap, entry,
  847|     21|                                                 delay, id_val, grp_lock,
  848|     21|                                                 src_file, src_line);
  849|     21|}
pjsip_endpt_cancel_timer:
  872|     20|{
  873|     20|    PJ_LOG(6, (THIS_FILE, "pjsip_endpt_cancel_timer(entry=%p)", entry));
  ------------------
  |  |  106|     20|#define PJ_LOG(level,arg)       do { \
  |  |  107|     20|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|     40|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 20]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|     20|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 20]
  |  |  ------------------
  ------------------
  874|     20|    pj_timer_heap_cancel( endpt->timer_heap, entry );
  875|     20|}
pjsip_endpt_get_timer_heap:
  881|  1.12k|{
  882|  1.12k|    return endpt->timer_heap;
  883|  1.12k|}
pjsip_endpt_create_tdata:
 1185|    449|{
 1186|    449|    return pjsip_tx_data_create(endpt->transport_mgr, p_tdata);
 1187|    449|}
pjsip_endpt_get_tpmgr:
 1250|      2|{
 1251|      2|    return endpt->transport_mgr;
 1252|      2|}
sip_endpoint.c:cmp_mod_name:
  149|     40|{
  150|     40|    return pj_stricmp((const pj_str_t*)name, &((pjsip_module*)mod)->name);
  151|     40|}

pjsip_method_init_np:
  272|  4.49k|{
  273|  4.49k|    unsigned i;
  274|  22.2k|    for (i=0; i<PJ_ARRAY_SIZE(method_names); ++i) {
  ------------------
  |  |  315|  22.2k|#define PJ_ARRAY_SIZE(a)    (sizeof(a)/sizeof(a[0]))
  ------------------
  |  Branch (274:15): [True: 19.2k, False: 2.95k]
  ------------------
  275|  19.2k|        if (pj_memcmp(str, method_names[i], sizeof(pj_str_t))==0 || 
  ------------------
  |  Branch (275:13): [True: 0, False: 19.2k]
  ------------------
  276|  19.2k|            pj_stricmp(str, method_names[i])==0) 
  ------------------
  |  Branch (276:13): [True: 1.54k, False: 17.7k]
  ------------------
  277|  1.54k|        {
  278|  1.54k|            m->id = (pjsip_method_e)i;
  279|  1.54k|            m->name = *method_names[i];
  280|  1.54k|            return;
  281|  1.54k|        }
  282|  19.2k|    }
  283|  2.95k|    m->id = PJSIP_OTHER_METHOD;
  284|  2.95k|    m->name = *str;
  285|  2.95k|}
pjsip_method_copy:
  290|    730|{
  291|    730|    method->id = rhs->id;
  292|    730|    if (rhs->id != PJSIP_OTHER_METHOD) {
  ------------------
  |  Branch (292:9): [True: 726, False: 4]
  ------------------
  293|    726|        method->name = rhs->name;
  294|    726|    } else {
  295|      4|        pj_strdup(pool, &method->name, &rhs->name);
  296|      4|    }
  297|    730|}
pjsip_method_cmp:
  301|  1.92k|{
  302|  1.92k|    if (m1->id == m2->id) {
  ------------------
  |  Branch (302:9): [True: 1.23k, False: 688]
  ------------------
  303|  1.23k|        if (m1->id != PJSIP_OTHER_METHOD)
  ------------------
  |  Branch (303:13): [True: 279, False: 953]
  ------------------
  304|    279|            return 0;
  305|       |        /* Method comparison is case sensitive! */
  306|    953|        return pj_strcmp(&m1->name, &m2->name);
  307|  1.23k|    }
  308|       |    
  309|    688|    return ( m1->id < m2->id ) ? -1 : 1;
  ------------------
  |  Branch (309:12): [True: 687, False: 1]
  ------------------
  310|  1.92k|}
pjsip_msg_create:
  318|  5.80k|{
  319|  5.80k|    pjsip_msg *msg = PJ_POOL_ALLOC_T(pool, pjsip_msg);
  ------------------
  |  |  569|  5.80k|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
  320|  5.80k|    pj_list_init(&msg->hdr);
  321|  5.80k|    msg->type = type;
  322|       |    msg->body = NULL;
  323|  5.80k|    return msg;
  324|  5.80k|}
pjsip_hdr_find:
  361|  11.3k|{
  362|  11.3k|    const pjsip_hdr *hdr=(const pjsip_hdr*) start, *end=hdr_list;
  363|       |
  364|  11.3k|    if (hdr == NULL) {
  ------------------
  |  Branch (364:9): [True: 7.86k, False: 3.51k]
  ------------------
  365|  7.86k|        hdr = end->next;
  366|  7.86k|    }
  367|  68.6k|    for (; hdr!=end; hdr = hdr->next) {
  ------------------
  |  Branch (367:12): [True: 66.0k, False: 2.58k]
  ------------------
  368|  66.0k|        if (hdr->type == hdr_type)
  ------------------
  |  Branch (368:13): [True: 8.79k, False: 57.2k]
  ------------------
  369|  8.79k|            return (void*)hdr;
  370|  66.0k|    }
  371|  2.58k|    return NULL;
  372|  11.3k|}
pjsip_msg_find_hdr:
  411|  11.3k|{
  412|  11.3k|    return pjsip_hdr_find(&msg->hdr, hdr_type, start);
  413|  11.3k|}
pjsip_hdr_clone:
  613|  4.83k|{
  614|  4.83k|    const pjsip_hdr *hdr = (const pjsip_hdr*) hdr_ptr;
  615|  4.83k|    return (*hdr->vptr->clone)(pool, hdr_ptr);
  616|  4.83k|}
pjsip_hdr_shallow_clone:
  620|    195|{
  621|    195|    const pjsip_hdr *hdr = (const pjsip_hdr*) hdr_ptr;
  622|    195|    return (*hdr->vptr->shallow_clone)(pool, hdr_ptr);
  623|    195|}
pjsip_get_status_text:
  638|    562|{
  639|    562|    static int is_initialized;
  640|    562|    if (is_initialized == 0) {
  ------------------
  |  Branch (640:9): [True: 1, False: 561]
  ------------------
  641|      1|        is_initialized = 1;
  642|      1|        init_status_phrase();
  643|      1|    }
  644|       |
  645|    562|    return (code>=100 && code<(int)PJ_ARRAY_SIZE(status_phrase)) ?
  ------------------
  |  |  315|    562|#define PJ_ARRAY_SIZE(a)    (sizeof(a)/sizeof(a[0]))
  ------------------
  |  Branch (645:13): [True: 562, False: 0]
  |  Branch (645:26): [True: 562, False: 0]
  ------------------
  646|    562|        &status_phrase[code] : &status_phrase[0];
  647|    562|}
pjsip_media_type_cp:
  718|    996|{
  719|    996|    PJ_ASSERT_ON_FAIL(pool && dst && src, return);
  ------------------
  |  |  111|    996|            { \
  |  |  112|    996|                pj_assert(expr); \
  |  |  ------------------
  |  |  |  |   65|    996|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  113|  3.98k|                if (!(expr)) exec_on_fail; \
  |  |  ------------------
  |  |  |  Branch (113:23): [True: 996, False: 0]
  |  |  |  Branch (113:23): [True: 996, False: 0]
  |  |  |  Branch (113:23): [True: 996, False: 0]
  |  |  ------------------
  |  |  114|    996|            }
  ------------------
  |  Branch (719:5): [True: 0, False: 996]
  |  Branch (719:5): [True: 0, False: 0]
  |  Branch (719:5): [True: 0, False: 0]
  |  Branch (719:5): [True: 996, False: 0]
  |  Branch (719:5): [True: 996, False: 0]
  |  Branch (719:5): [True: 996, False: 0]
  ------------------
  720|    996|    pj_strdup(pool, &dst->type,    &src->type);
  721|    996|    pj_strdup(pool, &dst->subtype, &src->subtype);
  722|    996|    pjsip_param_clone(pool, &dst->param, &src->param);
  723|    996|}
pjsip_generic_string_hdr_init2:
  748|  6.12k|{
  749|  6.12k|    init_hdr(hdr, PJSIP_H_OTHER, &generic_hdr_vptr);
  750|  6.12k|    if (hname) {
  ------------------
  |  Branch (750:9): [True: 6.12k, False: 0]
  ------------------
  751|  6.12k|        hdr->name = *hname;
  752|  6.12k|        hdr->sname = *hname;
  753|  6.12k|    }
  754|  6.12k|    if (hvalue) {
  ------------------
  |  Branch (754:9): [True: 6.12k, False: 0]
  ------------------
  755|  6.12k|        hdr->hvalue = *hvalue;
  756|  6.12k|    } else {
  757|       |        hdr->hvalue.ptr = NULL;
  758|      0|        hdr->hvalue.slen = 0;
  759|      0|    }
  760|  6.12k|}
pjsip_generic_string_hdr_init:
  767|  6.12k|{
  768|  6.12k|    pjsip_generic_string_hdr *hdr = (pjsip_generic_string_hdr*) mem;
  769|  6.12k|    pj_str_t dup_hname, dup_hval;
  770|       |
  771|  6.12k|    if (hnames) {
  ------------------
  |  Branch (771:9): [True: 628, False: 5.50k]
  ------------------
  772|    628|        pj_strdup(pool, &dup_hname, hnames);
  773|  5.50k|    } else {
  774|  5.50k|        pj_bzero(&dup_hname, sizeof(pj_str_t));
  775|  5.50k|    }
  776|       |
  777|  6.12k|    if (hvalue) {
  ------------------
  |  Branch (777:9): [True: 628, False: 5.50k]
  ------------------
  778|    628|        pj_strdup(pool, &dup_hval, hvalue);
  779|  5.50k|    } else {
  780|  5.50k|        pj_bzero(&dup_hval, sizeof(pj_str_t));
  781|  5.50k|    }
  782|       |
  783|  6.12k|    pjsip_generic_string_hdr_init2(hdr, &dup_hname, &dup_hval);
  784|  6.12k|    return hdr;
  785|  6.12k|}
pjsip_generic_string_hdr_create:
  790|  6.12k|{
  791|  6.12k|    void *mem = pj_pool_alloc(pool, sizeof(pjsip_generic_string_hdr));
  792|  6.12k|    return pjsip_generic_string_hdr_init(pool, mem, hnames, hvalue);
  793|  6.12k|}
pjsip_generic_array_hdr_init:
  939|    118|{
  940|    118|    pjsip_generic_array_hdr *hdr = (pjsip_generic_array_hdr*) mem;
  941|       |
  942|    118|    init_hdr(hdr, PJSIP_H_OTHER, &generic_array_hdr_vptr);
  943|    118|    if (hnames) {
  ------------------
  |  Branch (943:9): [True: 59, False: 59]
  ------------------
  944|     59|        pj_strdup(pool, &hdr->name, hnames);
  945|     59|        hdr->sname = hdr->name;
  946|     59|    }
  947|    118|    hdr->count = 0;
  948|    118|    return hdr;
  949|    118|}
pjsip_generic_array_hdr_create:
  953|     59|{
  954|     59|    void *mem = pj_pool_alloc(pool, sizeof(pjsip_generic_array_hdr));
  955|     59|    return pjsip_generic_array_hdr_init(pool, mem, hnames);
  956|       |
  957|     59|}
pjsip_cid_hdr_init:
 1060|  2.01k|{
 1061|  2.01k|    pjsip_cid_hdr *hdr = (pjsip_cid_hdr*) mem;
 1062|       |
 1063|  2.01k|    PJ_UNUSED_ARG(pool);
  ------------------
  |  | 1537|  2.01k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1064|       |
 1065|  2.01k|    init_hdr(hdr, PJSIP_H_CALL_ID, &generic_hdr_vptr);
 1066|  2.01k|    return hdr;
 1067|       |
 1068|  2.01k|}
pjsip_cid_hdr_create:
 1071|  2.01k|{
 1072|  2.01k|    void *mem = pj_pool_alloc(pool, sizeof(pjsip_cid_hdr));
 1073|  2.01k|    return pjsip_cid_hdr_init(pool, mem);
 1074|  2.01k|}
pjsip_clen_hdr_init:
 1094|    950|{
 1095|    950|    pjsip_clen_hdr *hdr = (pjsip_clen_hdr*) mem;
 1096|       |
 1097|    950|    PJ_UNUSED_ARG(pool);
  ------------------
  |  | 1537|    950|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1098|       |
 1099|    950|    init_hdr(hdr, PJSIP_H_CONTENT_LENGTH, &clen_hdr_vptr);
 1100|    950|    hdr->len = 0;
 1101|    950|    return hdr;
 1102|    950|}
pjsip_clen_hdr_create:
 1105|    950|{
 1106|    950|    void *mem = pj_pool_alloc(pool, sizeof(pjsip_clen_hdr));
 1107|    950|    return pjsip_clen_hdr_init(pool, mem);
 1108|    950|}
pjsip_cseq_hdr_init:
 1158|  2.25k|{
 1159|  2.25k|    pjsip_cseq_hdr *hdr = (pjsip_cseq_hdr*) mem;
 1160|       |
 1161|  2.25k|    PJ_UNUSED_ARG(pool);
  ------------------
  |  | 1537|  2.25k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1162|       |
 1163|  2.25k|    init_hdr(hdr, PJSIP_H_CSEQ, &cseq_hdr_vptr);
 1164|  2.25k|    hdr->cseq = 0;
 1165|  2.25k|    hdr->method.id = PJSIP_OTHER_METHOD;
 1166|       |    hdr->method.name.ptr = NULL;
 1167|  2.25k|    hdr->method.name.slen = 0;
 1168|  2.25k|    return hdr;
 1169|  2.25k|}
pjsip_cseq_hdr_create:
 1172|  2.25k|{
 1173|  2.25k|    void *mem = pj_pool_alloc(pool, sizeof(pjsip_cseq_hdr));
 1174|  2.25k|    return pjsip_cseq_hdr_init(pool, mem);
 1175|  2.25k|}
pjsip_contact_hdr_init:
 1238|  9.05k|{
 1239|  9.05k|    pjsip_contact_hdr *hdr = (pjsip_contact_hdr*) mem;
 1240|       |
 1241|  9.05k|    PJ_UNUSED_ARG(pool);
  ------------------
  |  | 1537|  9.05k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1242|       |
 1243|  9.05k|    pj_bzero(mem, sizeof(pjsip_contact_hdr));
 1244|  9.05k|    init_hdr(hdr, PJSIP_H_CONTACT, &contact_hdr_vptr);
 1245|  9.05k|    hdr->expires = PJSIP_EXPIRES_NOT_SPECIFIED;
  ------------------
  |  | 1427|  9.05k|#define PJSIP_EXPIRES_NOT_SPECIFIED     ((pj_uint32_t)0xFFFFFFFFUL)
  ------------------
 1246|  9.05k|    pj_list_init(&hdr->other_param);
 1247|  9.05k|    return hdr;
 1248|  9.05k|}
pjsip_contact_hdr_create:
 1251|  9.05k|{
 1252|  9.05k|    void *mem = pj_pool_alloc(pool, sizeof(pjsip_contact_hdr));
 1253|  9.05k|    return pjsip_contact_hdr_init(pool, mem);
 1254|  9.05k|}
pjsip_ctype_hdr_init:
 1379|  2.97k|{
 1380|  2.97k|    pjsip_ctype_hdr *hdr = (pjsip_ctype_hdr*) mem;
 1381|       |
 1382|  2.97k|    PJ_UNUSED_ARG(pool);
  ------------------
  |  | 1537|  2.97k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1383|       |
 1384|  2.97k|    pj_bzero(mem, sizeof(pjsip_ctype_hdr));
 1385|  2.97k|    init_hdr(hdr, PJSIP_H_CONTENT_TYPE, &ctype_hdr_vptr);
 1386|  2.97k|    pj_list_init(&hdr->media.param);
 1387|  2.97k|    return hdr;
 1388|       |
 1389|  2.97k|}
pjsip_ctype_hdr_create:
 1392|  2.97k|{
 1393|  2.97k|    void *mem = pj_pool_alloc(pool, sizeof(pjsip_ctype_hdr));
 1394|  2.97k|    return pjsip_ctype_hdr_init(pool, mem);
 1395|  2.97k|}
pjsip_expires_hdr_init:
 1473|    415|{
 1474|    415|    pjsip_expires_hdr *hdr = (pjsip_expires_hdr*) mem;
 1475|       |
 1476|    415|    PJ_UNUSED_ARG(pool);
  ------------------
  |  | 1537|    415|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1477|       |
 1478|    415|    init_hdr(hdr, PJSIP_H_EXPIRES, &generic_int_hdr_vptr);
 1479|    415|    hdr->ivalue = value;
 1480|    415|    return hdr;
 1481|       |
 1482|    415|}
pjsip_expires_hdr_create:
 1486|    415|{
 1487|    415|    void *mem = pj_pool_alloc(pool, sizeof(pjsip_expires_hdr));
 1488|    415|    return pjsip_expires_hdr_init(pool, mem, value);
 1489|    415|}
pjsip_from_hdr_init:
 1512|  5.38k|{
 1513|  5.38k|    pjsip_from_hdr *hdr = (pjsip_from_hdr*) mem;
 1514|       |
 1515|  5.38k|    PJ_UNUSED_ARG(pool);
  ------------------
  |  | 1537|  5.38k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1516|       |
 1517|  5.38k|    pj_bzero(mem, sizeof(pjsip_from_hdr));
 1518|  5.38k|    init_hdr(hdr, PJSIP_H_FROM, &fromto_hdr_vptr);
 1519|  5.38k|    pj_list_init(&hdr->other_param);
 1520|  5.38k|    return hdr;
 1521|  5.38k|}
pjsip_from_hdr_create:
 1524|  5.38k|{
 1525|  5.38k|    void *mem = pj_pool_alloc(pool, sizeof(pjsip_from_hdr));
 1526|  5.38k|    return pjsip_from_hdr_init(pool, mem);
 1527|  5.38k|}
pjsip_to_hdr_init:
 1531|  4.78k|{
 1532|  4.78k|    pjsip_to_hdr *hdr = (pjsip_to_hdr*) mem;
 1533|       |
 1534|  4.78k|    PJ_UNUSED_ARG(pool);
  ------------------
  |  | 1537|  4.78k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1535|       |
 1536|  4.78k|    pj_bzero(mem, sizeof(pjsip_to_hdr));
 1537|  4.78k|    init_hdr(hdr, PJSIP_H_TO, &fromto_hdr_vptr);
 1538|  4.78k|    pj_list_init(&hdr->other_param);
 1539|  4.78k|    return hdr;
 1540|       |
 1541|  4.78k|}
pjsip_to_hdr_create:
 1544|  4.78k|{
 1545|  4.78k|    void *mem = pj_pool_alloc(pool, sizeof(pjsip_to_hdr));
 1546|  4.78k|    return pjsip_to_hdr_init(pool, mem);
 1547|  4.78k|}
pjsip_fromto_hdr_set_from:
 1550|    877|{
 1551|    877|    hdr->type = PJSIP_H_FROM;
 1552|    877|    hdr->name.ptr = pjsip_hdr_names[PJSIP_H_FROM].name;
 1553|    877|    hdr->name.slen = pjsip_hdr_names[PJSIP_H_FROM].name_len;
 1554|    877|    hdr->sname.ptr = pjsip_hdr_names[PJSIP_H_FROM].sname;
 1555|    877|    hdr->sname.slen = 1;
 1556|    877|    return hdr;
 1557|    877|}
pjsip_fromto_hdr_set_to:
 1560|    877|{
 1561|    877|    hdr->type = PJSIP_H_TO;
 1562|    877|    hdr->name.ptr = pjsip_hdr_names[PJSIP_H_TO].name;
 1563|    877|    hdr->name.slen = pjsip_hdr_names[PJSIP_H_TO].name_len;
 1564|    877|    hdr->sname.ptr = pjsip_hdr_names[PJSIP_H_TO].sname;
 1565|    877|    hdr->sname.slen = 1;
 1566|    877|    return hdr;
 1567|    877|}
pjsip_max_fwd_hdr_init:
 1636|    575|{
 1637|    575|    pjsip_max_fwd_hdr *hdr = (pjsip_max_fwd_hdr*) mem;
 1638|       |
 1639|    575|    PJ_UNUSED_ARG(pool);
  ------------------
  |  | 1537|    575|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1640|       |
 1641|    575|    init_hdr(hdr, PJSIP_H_MAX_FORWARDS, &generic_int_hdr_vptr);
 1642|    575|    hdr->ivalue = value;
 1643|    575|    return hdr;
 1644|       |
 1645|    575|}
pjsip_max_fwd_hdr_create:
 1649|    575|{
 1650|    575|    void *mem = pj_pool_alloc(pool, sizeof(pjsip_max_fwd_hdr));
 1651|    575|    return pjsip_max_fwd_hdr_init(pool, mem, value);
 1652|    575|}
pjsip_route_hdr_init:
 1716|  1.61k|{
 1717|  1.61k|    pjsip_route_hdr *hdr = (pjsip_route_hdr*) mem;
 1718|       |
 1719|  1.61k|    PJ_UNUSED_ARG(pool);
  ------------------
  |  | 1537|  1.61k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1720|       |
 1721|  1.61k|    init_hdr(hdr, PJSIP_H_ROUTE, &routing_hdr_vptr);
 1722|  1.61k|    pjsip_name_addr_init(&hdr->name_addr);
 1723|  1.61k|    pj_list_init(&hdr->other_param);
 1724|  1.61k|    return hdr;
 1725|  1.61k|}
pjsip_route_hdr_create:
 1728|  1.61k|{
 1729|  1.61k|    void *mem = pj_pool_alloc(pool, sizeof(pjsip_route_hdr));
 1730|  1.61k|    return pjsip_route_hdr_init(pool, mem);
 1731|  1.61k|}
pjsip_routing_hdr_set_route:
 1743|     27|{
 1744|     27|    hdr->type = PJSIP_H_ROUTE;
 1745|     27|    hdr->name.ptr = pjsip_hdr_names[PJSIP_H_ROUTE].name;
 1746|     27|    hdr->name.slen = pjsip_hdr_names[PJSIP_H_ROUTE].name_len;
 1747|     27|    hdr->sname = hdr->name;
 1748|     27|    return hdr;
 1749|     27|}
pjsip_supported_hdr_init:
 1964|  12.1k|{
 1965|  12.1k|    pjsip_supported_hdr *hdr = (pjsip_supported_hdr*) mem;
 1966|       |
 1967|  12.1k|    PJ_UNUSED_ARG(pool);
  ------------------
  |  | 1537|  12.1k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1968|  12.1k|    init_hdr(hdr, PJSIP_H_SUPPORTED, &generic_array_hdr_vptr);
 1969|  12.1k|    hdr->count = 0;
 1970|  12.1k|    return hdr;
 1971|  12.1k|}
pjsip_supported_hdr_create:
 1974|  12.1k|{
 1975|  12.1k|    void *mem = pj_pool_alloc(pool, sizeof(pjsip_supported_hdr));
 1976|  12.1k|    return pjsip_supported_hdr_init(pool, mem);
 1977|  12.1k|}
pjsip_via_hdr_init:
 2019|  21.3k|{
 2020|  21.3k|    pjsip_via_hdr *hdr = (pjsip_via_hdr*) mem;
 2021|       |
 2022|  21.3k|    PJ_UNUSED_ARG(pool);
  ------------------
  |  | 1537|  21.3k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 2023|       |
 2024|  21.3k|    pj_bzero(mem, sizeof(pjsip_via_hdr));
 2025|  21.3k|    init_hdr(hdr, PJSIP_H_VIA, &via_hdr_vptr);
 2026|  21.3k|    hdr->ttl_param = -1;
 2027|  21.3k|    hdr->rport_param = -1;
 2028|  21.3k|    pj_list_init(&hdr->other_param);
 2029|  21.3k|    return hdr;
 2030|       |
 2031|  21.3k|}
pjsip_via_hdr_create:
 2034|  21.3k|{
 2035|  21.3k|    void *mem = pj_pool_alloc(pool, sizeof(pjsip_via_hdr));
 2036|  21.3k|    return pjsip_via_hdr_init(pool, mem);
 2037|  21.3k|}
sip_msg.c:init_status_phrase:
  153|      1|{
  154|      1|    unsigned i;
  155|      1|    pj_str_t default_reason_phrase = { "Default status message", 22};
  156|       |
  157|    711|    for (i=0; i<PJ_ARRAY_SIZE(status_phrase); ++i)
  ------------------
  |  |  315|    711|#define PJ_ARRAY_SIZE(a)    (sizeof(a)/sizeof(a[0]))
  ------------------
  |  Branch (157:15): [True: 710, False: 1]
  ------------------
  158|    710|        status_phrase[i] = default_reason_phrase;
  159|       |
  160|      1|    pj_strset2( &status_phrase[100], "Trying");
  161|      1|    pj_strset2( &status_phrase[180], "Ringing");
  162|      1|    pj_strset2( &status_phrase[181], "Call Is Being Forwarded");
  163|      1|    pj_strset2( &status_phrase[182], "Queued");
  164|      1|    pj_strset2( &status_phrase[183], "Session Progress");
  165|      1|    pj_strset2( &status_phrase[199], "Early Dialog Terminated");
  166|       |
  167|      1|    pj_strset2( &status_phrase[200], "OK");
  168|      1|    pj_strset2( &status_phrase[202], "Accepted");
  169|      1|    pj_strset2( &status_phrase[204], "No Notification");
  170|       |
  171|      1|    pj_strset2( &status_phrase[300], "Multiple Choices");
  172|      1|    pj_strset2( &status_phrase[301], "Moved Permanently");
  173|      1|    pj_strset2( &status_phrase[302], "Moved Temporarily");
  174|      1|    pj_strset2( &status_phrase[305], "Use Proxy");
  175|      1|    pj_strset2( &status_phrase[380], "Alternative Service");
  176|       |
  177|      1|    pj_strset2( &status_phrase[400], "Bad Request");
  178|      1|    pj_strset2( &status_phrase[401], "Unauthorized");
  179|      1|    pj_strset2( &status_phrase[402], "Payment Required");
  180|      1|    pj_strset2( &status_phrase[403], "Forbidden");
  181|      1|    pj_strset2( &status_phrase[404], "Not Found");
  182|      1|    pj_strset2( &status_phrase[405], "Method Not Allowed");
  183|      1|    pj_strset2( &status_phrase[406], "Not Acceptable");
  184|      1|    pj_strset2( &status_phrase[407], "Proxy Authentication Required");
  185|      1|    pj_strset2( &status_phrase[408], "Request Timeout");
  186|      1|    pj_strset2( &status_phrase[409], "Conflict");
  187|      1|    pj_strset2( &status_phrase[410], "Gone");
  188|      1|    pj_strset2( &status_phrase[411], "Length Required");
  189|      1|    pj_strset2( &status_phrase[412], "Conditional Request Failed");
  190|      1|    pj_strset2( &status_phrase[413], "Request Entity Too Large");
  191|      1|    pj_strset2( &status_phrase[414], "Request-URI Too Long");
  192|      1|    pj_strset2( &status_phrase[415], "Unsupported Media Type");
  193|      1|    pj_strset2( &status_phrase[416], "Unsupported URI Scheme");
  194|      1|    pj_strset2( &status_phrase[417], "Unknown Resource-Priority");
  195|      1|    pj_strset2( &status_phrase[420], "Bad Extension");
  196|      1|    pj_strset2( &status_phrase[421], "Extension Required");
  197|      1|    pj_strset2( &status_phrase[422], "Session Interval Too Small");
  198|      1|    pj_strset2( &status_phrase[423], "Interval Too Brief");
  199|      1|    pj_strset2( &status_phrase[424], "Bad Location Information");
  200|      1|    pj_strset2( &status_phrase[428], "Use Identity Header");
  201|      1|    pj_strset2( &status_phrase[429], "Provide Referrer Identity");
  202|      1|    pj_strset2( &status_phrase[430], "Flow Failed");
  203|      1|    pj_strset2( &status_phrase[433], "Anonymity Disallowed");
  204|      1|    pj_strset2( &status_phrase[436], "Bad Identity-Info");
  205|      1|    pj_strset2( &status_phrase[437], "Unsupported Certificate");
  206|      1|    pj_strset2( &status_phrase[438], "Invalid Identity Header");
  207|      1|    pj_strset2( &status_phrase[439], "First Hop Lacks Outbound Support");
  208|      1|    pj_strset2( &status_phrase[440], "Max-Breadth Exceeded");
  209|      1|    pj_strset2( &status_phrase[469], "Bad Info Package");
  210|      1|    pj_strset2( &status_phrase[470], "Consent Needed");
  211|      1|    pj_strset2( &status_phrase[480], "Temporarily Unavailable");
  212|      1|    pj_strset2( &status_phrase[481], "Call/Transaction Does Not Exist");
  213|      1|    pj_strset2( &status_phrase[482], "Loop Detected");
  214|      1|    pj_strset2( &status_phrase[483], "Too Many Hops");
  215|      1|    pj_strset2( &status_phrase[484], "Address Incomplete");
  216|      1|    pj_strset2( &status_phrase[485], "Ambiguous");
  217|      1|    pj_strset2( &status_phrase[486], "Busy Here");
  218|      1|    pj_strset2( &status_phrase[487], "Request Terminated");
  219|      1|    pj_strset2( &status_phrase[488], "Not Acceptable Here");
  220|      1|    pj_strset2( &status_phrase[489], "Bad Event");
  221|      1|    pj_strset2( &status_phrase[490], "Request Updated");
  222|      1|    pj_strset2( &status_phrase[491], "Request Pending");
  223|      1|    pj_strset2( &status_phrase[493], "Undecipherable");
  224|      1|    pj_strset2( &status_phrase[494], "Security Agreement Required");
  225|       |
  226|      1|    pj_strset2( &status_phrase[500], "Server Internal Error");
  227|      1|    pj_strset2( &status_phrase[501], "Not Implemented");
  228|      1|    pj_strset2( &status_phrase[502], "Bad Gateway");
  229|      1|    pj_strset2( &status_phrase[503], "Service Unavailable");
  230|      1|    pj_strset2( &status_phrase[504], "Server Time-out");
  231|      1|    pj_strset2( &status_phrase[505], "Version Not Supported");
  232|      1|    pj_strset2( &status_phrase[513], "Message Too Large");
  233|      1|    pj_strset2( &status_phrase[555], "Push Notification Service Not Supported");
  234|      1|    pj_strset2( &status_phrase[580], "Precondition Failure");
  235|       |
  236|      1|    pj_strset2( &status_phrase[600], "Busy Everywhere");
  237|      1|    pj_strset2( &status_phrase[603], "Decline");
  238|      1|    pj_strset2( &status_phrase[604], "Does Not Exist Anywhere");
  239|      1|    pj_strset2( &status_phrase[606], "Not Acceptable");
  240|      1|    pj_strset2( &status_phrase[607], "Unwanted");
  241|      1|    pj_strset2( &status_phrase[608], "Rejected");
  242|       |
  243|      1|    pj_strset2( &status_phrase[701], "No response from destination server");
  244|      1|    pj_strset2( &status_phrase[702], "Unable to resolve destination server");
  245|      1|    pj_strset2( &status_phrase[703], "Error sending message to destination server");
  246|       |
  247|      1|    return 1;
  248|      1|}
sip_msg.c:pjsip_generic_string_hdr_clone:
  818|    628|{
  819|    628|    pjsip_generic_string_hdr *hdr;
  820|       |    
  821|    628|    hdr = pjsip_generic_string_hdr_create(pool, &rhs->name, &rhs->hvalue);
  822|       |
  823|    628|    hdr->type = rhs->type;
  824|    628|    pj_strdup(pool, &hdr->sname, &rhs->sname);
  825|    628|    return hdr;
  826|    628|}
sip_msg.c:pjsip_generic_int_hdr_shallow_clone:
  912|    168|{
  913|    168|    pjsip_generic_int_hdr *hdr = PJ_POOL_ALLOC_T(pool, pjsip_generic_int_hdr);
  ------------------
  |  |  569|    168|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
  914|    168|    pj_memcpy(hdr, rhs, sizeof(*hdr));
  915|    168|    return hdr;
  916|    168|}
sip_msg.c:pjsip_generic_array_hdr_clone:
  984|     59|{
  985|     59|    unsigned i;
  986|     59|    pjsip_generic_array_hdr *hdr;
  987|       |
  988|     59|    hdr = pjsip_generic_array_hdr_create(pool, &rhs->name);
  989|     59|    hdr->type = rhs->type;
  990|     59|    hdr->count = PJ_MIN(rhs->count, PJSIP_GENERIC_ARRAY_MAX_COUNT);
  ------------------
  |  |   62|     59|#define PJ_MIN(x, y)    ((x) < (y)? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (62:26): [True: 49, False: 10]
  |  |  ------------------
  ------------------
  991|    756|    for (i=0; i<hdr->count; ++i) {
  ------------------
  |  Branch (991:15): [True: 697, False: 59]
  ------------------
  992|    697|        pj_strdup(pool, &hdr->values[i], &rhs->values[i]);
  993|    697|    }
  994|       |
  995|     59|    return hdr;
  996|     59|}
sip_msg.c:pjsip_cseq_hdr_clone:
 1205|    281|{
 1206|    281|    pjsip_cseq_hdr *hdr = pjsip_cseq_hdr_create(pool);
 1207|    281|    hdr->cseq = rhs->cseq;
 1208|    281|    pjsip_method_copy(pool, &hdr->method, &rhs->method);
 1209|    281|    return hdr;
 1210|    281|}
sip_msg.c:pjsip_contact_hdr_clone:
 1336|    347|{
 1337|    347|    pjsip_contact_hdr *hdr = pjsip_contact_hdr_create(pool);
 1338|       |
 1339|    347|    hdr->star = rhs->star;
 1340|    347|    if (hdr->star)
  ------------------
  |  Branch (1340:9): [True: 0, False: 347]
  ------------------
 1341|      0|        return hdr;
 1342|       |
 1343|    347|    hdr->uri = (pjsip_uri*) pjsip_uri_clone(pool, rhs->uri);
 1344|    347|    hdr->q1000 = rhs->q1000;
 1345|    347|    hdr->expires = rhs->expires;
 1346|    347|    pjsip_param_clone(pool, &hdr->other_param, &rhs->other_param);
 1347|    347|    return hdr;
 1348|    347|}
sip_msg.c:pjsip_fromto_hdr_clone:
 1605|  2.31k|{
 1606|  2.31k|    pjsip_fromto_hdr *hdr = pjsip_from_hdr_create(pool);
 1607|       |
 1608|  2.31k|    hdr->type = rhs->type;
 1609|  2.31k|    hdr->name = rhs->name;
 1610|  2.31k|    hdr->sname = rhs->sname;
 1611|  2.31k|    hdr->uri = (pjsip_uri*) pjsip_uri_clone(pool, rhs->uri);
 1612|  2.31k|    pj_strdup( pool, &hdr->tag, &rhs->tag);
 1613|  2.31k|    pjsip_param_clone( pool, &hdr->other_param, &rhs->other_param);
 1614|       |
 1615|  2.31k|    return hdr;
 1616|  2.31k|}
sip_msg.c:pjsip_routing_hdr_clone:
 1805|     27|{
 1806|     27|    pjsip_routing_hdr *hdr = PJ_POOL_ALLOC_T(pool, pjsip_routing_hdr);
  ------------------
  |  |  569|     27|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
 1807|       |
 1808|     27|    init_hdr(hdr, rhs->type, rhs->vptr);
 1809|     27|    pjsip_name_addr_init(&hdr->name_addr);
 1810|     27|    pjsip_name_addr_assign(pool, &hdr->name_addr, &rhs->name_addr);
 1811|     27|    pjsip_param_clone( pool, &hdr->other_param, &rhs->other_param);
 1812|     27|    return hdr;
 1813|     27|}
sip_msg.c:pjsip_routing_hdr_shallow_clone:
 1817|     27|{
 1818|     27|    pjsip_routing_hdr *hdr = PJ_POOL_ALLOC_T(pool, pjsip_routing_hdr);
  ------------------
  |  |  569|     27|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
 1819|     27|    pj_memcpy(hdr, rhs, sizeof(*hdr));
 1820|     27|    pjsip_param_shallow_clone( pool, &hdr->other_param, &rhs->other_param);
 1821|     27|    return hdr;
 1822|     27|}
sip_msg.c:pjsip_via_hdr_clone:
 2136|  1.17k|{
 2137|  1.17k|    pjsip_via_hdr *hdr = pjsip_via_hdr_create(pool);
 2138|  1.17k|    pj_strdup(pool, &hdr->transport, &rhs->transport);
 2139|  1.17k|    pj_strdup(pool, &hdr->sent_by.host, &rhs->sent_by.host);
 2140|  1.17k|    hdr->sent_by.port = rhs->sent_by.port;
 2141|  1.17k|    hdr->ttl_param = rhs->ttl_param;
 2142|  1.17k|    hdr->rport_param = rhs->rport_param;
 2143|  1.17k|    pj_strdup(pool, &hdr->maddr_param, &rhs->maddr_param);
 2144|  1.17k|    pj_strdup(pool, &hdr->recvd_param, &rhs->recvd_param);
 2145|  1.17k|    pj_strdup(pool, &hdr->branch_param, &rhs->branch_param);
 2146|  1.17k|    pjsip_param_clone(pool, &hdr->other_param, &rhs->other_param);
 2147|  1.17k|    return hdr;
 2148|  1.17k|}

pjsip_multipart_create:
  224|    651|{
  225|    651|    pjsip_msg_body *body;
  226|    651|    pjsip_param *ctype_param;
  227|    651|    struct multipart_data *mp_data;
  228|    651|    pj_str_t STR_BOUNDARY = { "boundary", 8 };
  229|       |
  230|    651|    PJ_ASSERT_RETURN(pool, NULL);
  ------------------
  |  |   97|    651|            do { \
  |  |   98|    651|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 651]
  |  |  ------------------
  |  |   99|    651|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 651]
  |  |  ------------------
  ------------------
  |  Branch (230:5): [True: 0, False: 0]
  |  Branch (230:5): [True: 0, False: 0]
  ------------------
  231|       |
  232|    651|    body = PJ_POOL_ZALLOC_T(pool, pjsip_msg_body);
  ------------------
  |  |  583|    651|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  233|       |
  234|       |    /* content-type */
  235|    651|    if (ctype && ctype->type.slen) {
  ------------------
  |  Branch (235:9): [True: 651, False: 0]
  |  Branch (235:18): [True: 651, False: 0]
  ------------------
  236|    651|        pjsip_media_type_cp(pool, &body->content_type, ctype);
  237|    651|    } else {
  238|      0|        pj_str_t STR_MULTIPART = {"multipart", 9};
  239|      0|        pj_str_t STR_MIXED = { "mixed", 5 };
  240|       |
  241|      0|        pjsip_media_type_init(&body->content_type,
  242|      0|                              &STR_MULTIPART, &STR_MIXED);
  243|      0|    }
  244|       |
  245|       |    /* multipart data */
  246|    651|    mp_data = PJ_POOL_ZALLOC_T(pool, struct multipart_data);
  ------------------
  |  |  583|    651|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  247|    651|    pj_list_init(&mp_data->part_head);
  248|    651|    if (boundary) {
  ------------------
  |  Branch (248:9): [True: 651, False: 0]
  ------------------
  249|    651|        pj_strdup(pool, &mp_data->boundary, boundary);
  250|    651|    } else {
  251|      0|        pj_create_unique_string(pool, &mp_data->boundary);
  252|      0|    }
  253|    651|    body->data = mp_data;
  254|       |
  255|       |    /* Add ";boundary" parameter to content_type parameter. */
  256|    651|    ctype_param = pjsip_param_find(&body->content_type.param, &STR_BOUNDARY);
  257|    651|    if (!ctype_param) {
  ------------------
  |  Branch (257:9): [True: 650, False: 1]
  ------------------
  258|    650|        ctype_param = PJ_POOL_ALLOC_T(pool, pjsip_param);
  ------------------
  |  |  569|    650|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
  259|    650|        ctype_param->name = STR_BOUNDARY;
  260|    650|        pj_list_push_back(&body->content_type.param, ctype_param);
  261|    650|    }
  262|    651|    ctype_param->value = mp_data->boundary;
  263|       |
  264|       |    /* function pointers */
  265|    651|    body->print_body = &multipart_print_body;
  266|    651|    body->clone_data = &multipart_clone_data;
  267|       |
  268|    651|    return body;
  269|    651|}
pjsip_multipart_create_part:
  275|  10.8k|{
  276|  10.8k|    pjsip_multipart_part *mp;
  277|       |
  278|  10.8k|    mp = PJ_POOL_ZALLOC_T(pool, pjsip_multipart_part);
  ------------------
  |  |  583|  10.8k|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  279|  10.8k|    pj_list_init(&mp->hdr);
  280|       |
  281|  10.8k|    return mp;
  282|  10.8k|}
pjsip_multipart_add_part:
  315|  10.8k|{
  316|  10.8k|    struct multipart_data *m_data;
  317|       |
  318|       |    /* All params must be specified */
  319|  10.8k|    PJ_ASSERT_RETURN(pool && mp && part, PJ_EINVAL);
  ------------------
  |  |   97|  10.8k|            do { \
  |  |   98|  43.5k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 10.8k, False: 0]
  |  |  |  Branch (98:23): [True: 10.8k, False: 0]
  |  |  |  Branch (98:23): [True: 10.8k, False: 0]
  |  |  ------------------
  |  |   99|  10.8k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 10.8k]
  |  |  ------------------
  ------------------
  |  Branch (319:5): [True: 0, False: 0]
  |  Branch (319:5): [True: 0, False: 0]
  |  Branch (319:5): [True: 0, False: 0]
  |  Branch (319:5): [True: 0, False: 0]
  |  Branch (319:5): [True: 0, False: 0]
  |  Branch (319:5): [True: 0, False: 0]
  ------------------
  320|       |
  321|       |    /* mp must really point to an actual multipart msg body */
  322|  10.8k|    PJ_ASSERT_RETURN(mp->print_body==&multipart_print_body, PJ_EINVAL);
  ------------------
  |  |   97|  10.8k|            do { \
  |  |   98|  10.8k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 10.8k]
  |  |  ------------------
  |  |   99|  10.8k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 10.8k]
  |  |  ------------------
  ------------------
  |  Branch (322:5): [True: 0, False: 0]
  |  Branch (322:5): [True: 0, False: 0]
  ------------------
  323|       |
  324|       |    /* The multipart part must contain a valid message body */
  325|  10.8k|    PJ_ASSERT_RETURN(part->body && part->body->print_body, PJ_EINVAL);
  ------------------
  |  |   97|  10.8k|            do { \
  |  |   98|  21.7k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 10.8k, False: 0]
  |  |  |  Branch (98:23): [True: 10.8k, False: 0]
  |  |  ------------------
  |  |   99|  10.8k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 10.8k]
  |  |  ------------------
  ------------------
  |  Branch (325:5): [True: 0, False: 0]
  |  Branch (325:5): [True: 0, False: 0]
  |  Branch (325:5): [True: 0, False: 0]
  |  Branch (325:5): [True: 0, False: 0]
  ------------------
  326|       |
  327|  10.8k|    m_data = (struct multipart_data*)mp->data;
  328|  10.8k|    pj_list_push_back(&m_data->part_head, part);
  329|       |
  330|  10.8k|    PJ_UNUSED_ARG(pool);
  ------------------
  |  | 1537|  10.8k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  331|       |
  332|  10.8k|    return PJ_SUCCESS;
  333|  10.8k|}
pjsip_multipart_parse:
  731|    701|{
  732|    701|    pj_str_t boundary, delim;
  733|    701|    char *curptr, *endptr;
  734|    701|    const pjsip_param *ctype_param;
  735|    701|    const pj_str_t STR_BOUNDARY = { "boundary", 8 };
  736|    701|    pjsip_msg_body *body = NULL;
  737|       |
  738|    701|    PJ_ASSERT_RETURN(pool && buf && len && ctype && !options, NULL);
  ------------------
  |  |   97|    701|            do { \
  |  |   98|  5.60k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 701, False: 0]
  |  |  |  Branch (98:23): [True: 701, False: 0]
  |  |  |  Branch (98:23): [True: 701, False: 0]
  |  |  |  Branch (98:23): [True: 701, False: 0]
  |  |  |  Branch (98:23): [True: 701, False: 0]
  |  |  ------------------
  |  |   99|    701|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 701]
  |  |  ------------------
  ------------------
  |  Branch (738:5): [True: 0, False: 0]
  |  Branch (738:5): [True: 0, False: 0]
  |  Branch (738:5): [True: 0, False: 0]
  |  Branch (738:5): [True: 0, False: 0]
  |  Branch (738:5): [True: 0, False: 0]
  |  Branch (738:5): [True: 0, False: 0]
  |  Branch (738:5): [True: 0, False: 0]
  |  Branch (738:5): [True: 0, False: 0]
  |  Branch (738:5): [True: 0, False: 0]
  |  Branch (738:5): [True: 0, False: 0]
  ------------------
  739|       |
  740|    701|    TRACE_((THIS_FILE, "Started parsing multipart body"));
  741|       |
  742|       |    /* Get the boundary value in the ctype */
  743|    701|    boundary.ptr = NULL;
  744|    701|    boundary.slen = 0;
  745|    701|    ctype_param = pjsip_param_find(&ctype->param, &STR_BOUNDARY);
  746|    701|    if (ctype_param) {
  ------------------
  |  Branch (746:9): [True: 6, False: 695]
  ------------------
  747|      6|        boundary = ctype_param->value;
  748|      6|        if (boundary.slen>2 && *boundary.ptr=='"') {
  ------------------
  |  Branch (748:13): [True: 4, False: 2]
  |  Branch (748:32): [True: 0, False: 4]
  ------------------
  749|       |            /* Remove quote */
  750|      0|            boundary.ptr++;
  751|      0|            boundary.slen -= 2;
  752|      0|        }
  753|      6|        TRACE_((THIS_FILE, "Boundary is specified: '%.*s'", (int)boundary.slen,
  754|      6|                boundary.ptr));
  755|      6|    }
  756|       |
  757|    701|    if (!boundary.slen) {
  ------------------
  |  Branch (757:9): [True: 697, False: 4]
  ------------------
  758|       |        /* Boundary not found or not specified. Try to be clever, get
  759|       |         * the boundary from the body.
  760|       |         */
  761|    697|        char *p=buf, *end=buf+len;
  762|       |
  763|    697|        PJ_LOG(4,(THIS_FILE, "Warning: boundary parameter not found or "
  ------------------
  |  |  106|    697|#define PJ_LOG(level,arg)       do { \
  |  |  107|    697|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  1.39k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 697, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 697]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|    697|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 697]
  |  |  ------------------
  ------------------
  764|    697|                             "not specified when parsing multipart body"));
  765|       |
  766|       |        /* Find the first "--". This "--" must be right after a CRLF, unless
  767|       |         * it really appears at the start of the buffer.
  768|       |         */
  769|  1.51k|        for (;;) {
  770|  5.41k|            while (p!=end && *p!='-') ++p;
  ------------------
  |  Branch (770:20): [True: 5.36k, False: 46]
  |  Branch (770:30): [True: 3.89k, False: 1.47k]
  ------------------
  771|       |
  772|  1.51k|            if (p == end)
  ------------------
  |  Branch (772:17): [True: 46, False: 1.47k]
  ------------------
  773|     46|                break;
  774|       |
  775|  1.47k|            if ((p+1<end) && *(p+1)=='-' &&
  ------------------
  |  Branch (775:17): [True: 1.46k, False: 5]
  |  Branch (775:30): [True: 1.06k, False: 406]
  ------------------
  776|  1.06k|                ((p>buf && *(p-1)=='\n') || (p==buf)))
  ------------------
  |  Branch (776:19): [True: 521, False: 541]
  |  Branch (776:28): [True: 110, False: 411]
  |  Branch (776:45): [True: 541, False: 411]
  ------------------
  777|    651|            {
  778|    651|                p+=2;
  779|    651|                break;
  780|    822|            } else {
  781|    822|                ++p;
  782|    822|            }
  783|  1.47k|        }
  784|       |
  785|    697|        if (p==end) {
  ------------------
  |  Branch (785:13): [True: 46, False: 651]
  ------------------
  786|       |            /* Unable to determine boundary. Maybe this is not a multipart
  787|       |             * message?
  788|       |             */
  789|     46|            PJ_LOG(4,(THIS_FILE, "Error: multipart boundary not specified and"
  ------------------
  |  |  106|     46|#define PJ_LOG(level,arg)       do { \
  |  |  107|     46|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|     92|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 46, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 46]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|     46|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 46]
  |  |  ------------------
  ------------------
  790|     46|                                 " unable to calculate from the body"));
  791|     46|            return NULL;
  792|     46|        }
  793|       |
  794|    651|        boundary.ptr = p;
  795|  58.5k|        while (p!=end && !pj_isspace(*p)) ++p;
  ------------------
  |  Branch (795:16): [True: 58.4k, False: 28]
  |  Branch (795:26): [True: 57.8k, False: 623]
  ------------------
  796|    651|        boundary.slen = p - boundary.ptr;
  797|       |
  798|    651|        TRACE_((THIS_FILE, "Boundary is calculated: '%.*s'",
  799|    651|                (int)boundary.slen, boundary.ptr));
  800|    651|    }
  801|       |
  802|       |
  803|       |    /* Build the delimiter:
  804|       |     *   delimiter = "--" boundary
  805|       |     */
  806|    655|    delim.slen = boundary.slen+2;
  807|    655|    delim.ptr = (char*)pj_pool_alloc(pool, (int)delim.slen);
  808|    655|    delim.ptr[0] = '-';
  809|    655|    delim.ptr[1] = '-';
  810|    655|    pj_memcpy(delim.ptr+2, boundary.ptr, boundary.slen);
  811|       |
  812|       |    /* Start parsing the body, skip until the first delimiter. */
  813|    655|    curptr = buf;
  814|    655|    endptr = buf + len;
  815|    655|    {
  816|    655|        pj_str_t strbody;
  817|       |
  818|    655|        strbody.ptr = buf; strbody.slen = len;
  819|    655|        curptr = pj_strstr(&strbody, &delim);
  820|    655|        if (!curptr)
  ------------------
  |  Branch (820:13): [True: 4, False: 651]
  ------------------
  821|      4|            return NULL;
  822|    655|    }
  823|       |
  824|    651|    body = pjsip_multipart_create(pool, ctype, &boundary);
  825|       |
  826|       |    /* Save full raw body */
  827|    651|    {
  828|    651|        struct multipart_data *mp = (struct multipart_data*)body->data;
  829|    651|        pj_strset(&mp->raw_data, buf, len);
  830|    651|    }
  831|       |
  832|  11.5k|    for (;;) {
  833|  11.5k|        char *start_body, *end_body;
  834|  11.5k|        pjsip_multipart_part *part;
  835|       |
  836|       |        /* Eat the boundary */
  837|  11.5k|        curptr += delim.slen;
  838|  11.5k|        if (curptr+1 < endptr && *curptr=='-' && *(curptr+1)=='-') {
  ------------------
  |  Branch (838:13): [True: 11.3k, False: 161]
  |  Branch (838:34): [True: 20, False: 11.3k]
  |  Branch (838:50): [True: 3, False: 17]
  ------------------
  839|       |            /* Found the closing delimiter */
  840|      3|            curptr += 2;
  841|      3|            break;
  842|      3|        }
  843|       |        /* Optional whitespace after delimiter */
  844|  11.9k|        while (curptr!=endptr && IS_SPACE(*curptr)) ++curptr;
  ------------------
  |  |   33|  11.8k|#define IS_SPACE(c)     ((c)==' ' || (c)=='\t')
  |  |  ------------------
  |  |  |  Branch (33:26): [True: 201, False: 11.6k]
  |  |  |  Branch (33:38): [True: 228, False: 11.4k]
  |  |  ------------------
  ------------------
  |  Branch (844:16): [True: 11.8k, False: 105]
  ------------------
  845|       |        /* Mandatory CRLF */
  846|  11.5k|        if (curptr == endptr) {
  ------------------
  |  Branch (846:13): [True: 105, False: 11.4k]
  ------------------
  847|    105|            PJ_LOG(2, (THIS_FILE, "Unexpected end of buffer after boundary"));
  ------------------
  |  |  106|    105|#define PJ_LOG(level,arg)       do { \
  |  |  107|    105|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|    210|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 105, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 105]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  448|      0|    #define pj_log_wrapper_2(arg)       pj_log_2 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|    105|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 105]
  |  |  ------------------
  ------------------
  848|    105|            return NULL;
  849|    105|        }
  850|  11.4k|        if (*curptr=='\r') ++curptr;
  ------------------
  |  Branch (850:13): [True: 439, False: 10.9k]
  ------------------
  851|  11.4k|        if (curptr == endptr || *curptr!='\n') {
  ------------------
  |  Branch (851:13): [True: 3, False: 11.4k]
  |  Branch (851:33): [True: 213, False: 11.2k]
  ------------------
  852|       |            /* Expecting a newline here */
  853|    216|            PJ_LOG(2, (THIS_FILE, "Failed to find newline"));
  ------------------
  |  |  106|    216|#define PJ_LOG(level,arg)       do { \
  |  |  107|    216|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|    432|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 216, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 216]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  448|      0|    #define pj_log_wrapper_2(arg)       pj_log_2 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|    216|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 216]
  |  |  ------------------
  ------------------
  854|       |
  855|    216|            return NULL;
  856|    216|        }
  857|  11.2k|        ++curptr;
  858|       |
  859|       |        /* We now in the start of the body */
  860|  11.2k|        start_body = curptr;
  861|       |
  862|       |        /* Find the next delimiter */
  863|  11.2k|        {
  864|  11.2k|            pj_str_t subbody;
  865|       |
  866|  11.2k|            subbody.ptr = curptr; subbody.slen = endptr - curptr;
  867|  11.2k|            curptr = pj_strstr(&subbody, &delim);
  868|  11.2k|            if (!curptr) {
  ------------------
  |  Branch (868:17): [True: 327, False: 10.8k]
  ------------------
  869|       |                /* We're really expecting end delimiter to be found. */
  870|    327|                PJ_LOG(2, (THIS_FILE, "Failed to find end-delimiter"));
  ------------------
  |  |  106|    327|#define PJ_LOG(level,arg)       do { \
  |  |  107|    327|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|    654|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 327, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 327]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  448|      0|    #define pj_log_wrapper_2(arg)       pj_log_2 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|    327|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 327]
  |  |  ------------------
  ------------------
  871|    327|                return NULL;
  872|    327|            }
  873|  11.2k|        }
  874|       |
  875|  10.8k|        end_body = curptr;
  876|       |
  877|       |        /* Note that when body is empty, end_body will be equal
  878|       |         * to start_body.
  879|       |         */
  880|  10.8k|        if (end_body > start_body) {
  ------------------
  |  Branch (880:13): [True: 9.28k, False: 1.60k]
  ------------------
  881|       |            /* The newline preceeding the delimiter is conceptually part of
  882|       |             * the delimiter, so trim it from the body.
  883|       |             */
  884|  9.28k|            if (*(end_body-1) == '\n')
  ------------------
  |  Branch (884:17): [True: 1.82k, False: 7.45k]
  ------------------
  885|  1.82k|                --end_body;
  886|  9.28k|            if (end_body > start_body && *(end_body-1) == '\r')
  ------------------
  |  Branch (886:17): [True: 8.89k, False: 390]
  |  Branch (886:42): [True: 5.39k, False: 3.49k]
  ------------------
  887|  5.39k|                --end_body;
  888|  9.28k|        }
  889|       |
  890|       |        /* Now that we have determined the part's boundary, parse it
  891|       |         * to get the header and body part of the part.
  892|       |         */
  893|  10.8k|        part = parse_multipart_part(pool, start_body, end_body - start_body,
  894|  10.8k|                                    ctype);
  895|  10.8k|        if (part) {
  ------------------
  |  Branch (895:13): [True: 10.8k, False: 0]
  ------------------
  896|  10.8k|            TRACE_((THIS_FILE, "Adding part"));
  897|  10.8k|            pjsip_multipart_add_part(pool, body, part);
  898|  10.8k|        } else {
  899|      0|            PJ_LOG(2, (THIS_FILE, "Failed to add part"));
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  448|      0|    #define pj_log_wrapper_2(arg)       pj_log_2 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  900|      0|        }
  901|  10.8k|    }
  902|      3|    TRACE_((THIS_FILE, "pjsip_multipart_parse finished: %p", body));
  903|       |
  904|      3|    return body;
  905|    651|}
sip_multipart.c:parse_multipart_part:
  638|  10.8k|{
  639|  10.8k|    pjsip_multipart_part *part = pjsip_multipart_create_part(pool);
  640|  10.8k|    char *p = start, *end = start+len, *end_hdr = NULL, *start_body;
  641|  10.8k|    pjsip_ctype_hdr *ctype_hdr = NULL;
  642|       |
  643|  10.8k|    TRACE_((THIS_FILE, "Parsing part: begin--\n%.*s\n--end",
  644|  10.8k|            (int)len, start));
  645|       |
  646|       |    /* Find the end of header area, by looking at an empty line */
  647|  23.8k|    for (;;) {
  648|   251k|        while (p!=end && *p!='\n') ++p;
  ------------------
  |  Branch (648:16): [True: 246k, False: 4.93k]
  |  Branch (648:26): [True: 227k, False: 18.9k]
  ------------------
  649|  23.8k|        if (p==end) {
  ------------------
  |  Branch (649:13): [True: 4.93k, False: 18.9k]
  ------------------
  650|  4.93k|            start_body = end;
  651|  4.93k|            break;
  652|  4.93k|        }
  653|  18.9k|        if ((p==start) || (p==start+1 && *(p-1)=='\r')) {
  ------------------
  |  Branch (653:13): [True: 410, False: 18.4k]
  |  Branch (653:28): [True: 1.74k, False: 16.7k]
  |  Branch (653:42): [True: 332, False: 1.41k]
  ------------------
  654|       |            /* Empty header section */
  655|    742|            end_hdr = start;
  656|    742|            start_body = ++p;
  657|    742|            break;
  658|  18.1k|        } else if (p==end-1) {
  ------------------
  |  Branch (658:20): [True: 4.20k, False: 13.9k]
  ------------------
  659|       |            /* Empty body section */
  660|  4.20k|            end_hdr = end;
  661|  4.20k|            start_body = ++p;
  662|  4.20k|            break;
  663|  13.9k|        } else if ((p>=start+1 && *(p-1)=='\n') ||
  ------------------
  |  Branch (663:21): [True: 13.9k, False: 0]
  |  Branch (663:35): [True: 718, False: 13.2k]
  ------------------
  664|  13.2k|                   (p>=start+2 && *(p-1)=='\r' && *(p-2)=='\n'))
  ------------------
  |  Branch (664:21): [True: 12.5k, False: 673]
  |  Branch (664:35): [True: 912, False: 11.6k]
  |  Branch (664:51): [True: 276, False: 636]
  ------------------
  665|    994|        {
  666|       |            /* Found it */
  667|    994|            end_hdr = (*(p-1)=='\r') ? (p-1) : p;
  ------------------
  |  Branch (667:23): [True: 276, False: 718]
  ------------------
  668|    994|            start_body = ++p;
  669|    994|            break;
  670|  12.9k|        } else {
  671|  12.9k|            ++p;
  672|  12.9k|        }
  673|  18.9k|    }
  674|       |
  675|       |    /* Parse the headers */
  676|  10.8k|    if (end_hdr-start > 0) {
  ------------------
  |  Branch (676:9): [True: 5.20k, False: 5.68k]
  ------------------
  677|  5.20k|        pjsip_hdr *hdr;
  678|  5.20k|        pj_status_t status;
  679|       |
  680|  5.20k|        status = pjsip_parse_headers(pool, start, end_hdr-start, 
  681|  5.20k|                                     &part->hdr, 0);
  682|  5.20k|        if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (682:13): [True: 0, False: 5.20k]
  ------------------
  683|      0|            PJ_PERROR(2,(THIS_FILE, status, "Warning: error parsing multipart"
  ------------------
  |  |  189|      0|#define PJ_PERROR(level,arg)    do { \
  |  |  190|      0|                                    pj_perror_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  579|      0|    #define pj_perror_wrapper_2(arg)    pj_perror_2 arg
  |  |  ------------------
  |  |  191|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (191:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  684|      0|                                            " header"));
  685|      0|        }
  686|       |
  687|       |        /* Find Content-Type header */
  688|  5.20k|        hdr = part->hdr.next;
  689|  10.1k|        while (hdr != &part->hdr) {
  ------------------
  |  Branch (689:16): [True: 4.99k, False: 5.20k]
  ------------------
  690|  4.99k|            TRACE_((THIS_FILE, "Header parsed: %.*s", (int)hdr->name.slen,
  691|  4.99k|                    hdr->name.ptr));
  692|  4.99k|            if (hdr->type == PJSIP_H_CONTENT_TYPE) {
  ------------------
  |  Branch (692:17): [True: 556, False: 4.43k]
  ------------------
  693|    556|                ctype_hdr = (pjsip_ctype_hdr*)hdr;
  694|    556|            }
  695|  4.99k|            hdr = hdr->next;
  696|  4.99k|        }
  697|  5.20k|    }
  698|       |
  699|       |    /* Assign the body */
  700|  10.8k|    part->body = PJ_POOL_ZALLOC_T(pool, pjsip_msg_body);
  ------------------
  |  |  583|  10.8k|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  701|  10.8k|    if (ctype_hdr) {
  ------------------
  |  Branch (701:9): [True: 327, False: 10.5k]
  ------------------
  702|    327|        pjsip_media_type_cp(pool, &part->body->content_type, &ctype_hdr->media);
  703|  10.5k|    } else if (pct && pj_stricmp2(&pct->subtype, "digest")==0) {
  ------------------
  |  Branch (703:16): [True: 10.5k, False: 0]
  |  Branch (703:23): [True: 505, False: 10.0k]
  ------------------
  704|    505|        part->body->content_type.type = pj_str("message");
  705|    505|        part->body->content_type.subtype = pj_str("rfc822");
  706|  10.0k|    } else {
  707|  10.0k|        part->body->content_type.type = pj_str("text");
  708|  10.0k|        part->body->content_type.subtype = pj_str("plain");
  709|  10.0k|    }
  710|       |
  711|  10.8k|    if (start_body < end) {
  ------------------
  |  Branch (711:9): [True: 1.71k, False: 9.16k]
  ------------------
  712|  1.71k|        part->body->data = start_body;
  713|  1.71k|        part->body->len = (unsigned)(end - start_body);
  714|  9.16k|    } else {
  715|  9.16k|        part->body->data = (void*)"";
  716|  9.16k|        part->body->len = 0;
  717|  9.16k|    }
  718|  10.8k|    TRACE_((THIS_FILE, "Body parsed: \"%.*s\"", (int)part->body->len,
  719|  10.8k|            part->body->data));
  720|  10.8k|    part->body->print_body = &pjsip_print_text_body;
  721|  10.8k|    part->body->clone_data = &pjsip_clone_text_data;
  722|       |
  723|  10.8k|    return part;
  724|  10.8k|}

pjsip_parser_const:
  290|  8.32k|{
  291|  8.32k|    return &pconst;
  292|  8.32k|}
init_sip_parser:
  549|      2|{
  550|      2|    pj_enter_critical_section();
  551|      2|    if (++parser_is_initialized == 1) {
  ------------------
  |  Branch (551:9): [True: 2, False: 0]
  ------------------
  552|      2|        init_parser();
  553|      2|    }
  554|      2|    pj_leave_critical_section();
  555|      2|}
pjsip_register_hdr_parser:
  665|     46|{
  666|     46|    unsigned i;
  667|     46|    pj_size_t len;
  668|     46|    char hname_lcase[PJSIP_MAX_HNAME_LEN+1];
  669|     46|    pj_status_t status;
  670|       |
  671|       |    /* Check that name is not too long */
  672|     46|    len = pj_ansi_strlen(hname);
  ------------------
  |  |   69|     46|#define pj_ansi_strlen          strlen
  ------------------
  673|     46|    if (len > PJSIP_MAX_HNAME_LEN) {
  ------------------
  |  | 1145|     46|#define PJSIP_MAX_HNAME_LEN             64
  ------------------
  |  Branch (673:9): [True: 0, False: 46]
  ------------------
  674|      0|        pj_assert(!"Header name is too long!");
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (674:9): [Folded, False: 0]
  |  Branch (674:9): [Folded, False: 0]
  ------------------
  675|      0|        return PJ_ENAMETOOLONG;
  ------------------
  |  |  398|      0|#define PJ_ENAMETOOLONG     (PJ_ERRNO_START_STATUS + 5) /* 70005 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  676|      0|    }
  677|       |
  678|       |    /* Register the normal Mixed-Case name */
  679|     46|    status = int_register_parser(hname, fptr);
  680|     46|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (680:9): [True: 0, False: 46]
  ------------------
  681|      0|        return status;
  682|      0|    }
  683|       |
  684|       |    /* Get the lower-case name */
  685|    476|    for (i=0; i<len; ++i) {
  ------------------
  |  Branch (685:15): [True: 430, False: 46]
  ------------------
  686|    430|        hname_lcase[i] = (char)pj_tolower(hname[i]);
  687|    430|    }
  688|     46|    hname_lcase[len] = '\0';
  689|       |
  690|       |    /* Register the lower-case version of the name */
  691|     46|    status = int_register_parser(hname_lcase, fptr);
  692|     46|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (692:9): [True: 0, False: 46]
  ------------------
  693|      0|        return status;
  694|      0|    }
  695|       |    
  696|       |
  697|       |    /* Register the shortname version of the name */
  698|     46|    if (hshortname) {
  ------------------
  |  Branch (698:9): [True: 16, False: 30]
  ------------------
  699|     16|        status = int_register_parser(hshortname, fptr);
  700|     16|        if (status != PJ_SUCCESS) 
  ------------------
  |  Branch (700:13): [True: 0, False: 16]
  ------------------
  701|      0|            return status;
  702|     16|    }
  703|     46|    return PJ_SUCCESS;
  704|     46|}
pjsip_register_uri_parser:
  783|      6|{
  784|      6|    if (uri_handler_count >= PJ_ARRAY_SIZE(uri_handler))
  ------------------
  |  |  315|      6|#define PJ_ARRAY_SIZE(a)    (sizeof(a)/sizeof(a[0]))
  ------------------
  |  Branch (784:9): [True: 0, False: 6]
  ------------------
  785|      0|        return PJ_ETOOMANY;
  ------------------
  |  |  423|      0|#define PJ_ETOOMANY         (PJ_ERRNO_START_STATUS + 10)/* 70010 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  786|       |
  787|      6|    uri_handler[uri_handler_count].scheme = pj_str((char*)scheme);
  788|      6|    uri_handler[uri_handler_count].parse = func;
  789|      6|    ++uri_handler_count;
  790|       |
  791|      6|    return PJ_SUCCESS;
  792|      6|}
pjsip_parse_msg:
  798|  5.40k|{
  799|  5.40k|    pjsip_msg *msg = NULL;
  800|  5.40k|    pj_scanner scanner;
  801|  5.40k|    pjsip_parse_ctx context;
  802|       |
  803|  5.40k|    pj_scan_init(&scanner, buf, size, PJ_SCAN_AUTOSKIP_WS_HEADER, 
  804|  5.40k|                 &on_syntax_error);
  805|       |
  806|  5.40k|    context.scanner = &scanner;
  807|  5.40k|    context.pool = pool;
  808|  5.40k|    context.rdata = NULL;
  809|       |
  810|  5.40k|    msg = int_parse_msg(&context, err_list);
  811|       |
  812|  5.40k|    pj_scan_fini(&scanner);
  813|  5.40k|    return msg;
  814|  5.40k|}
pjsip_parse_uri:
  960|  6.06k|{
  961|  6.06k|    pj_scanner scanner;
  962|  6.06k|    pjsip_uri *uri = NULL;
  963|  6.06k|    PJ_USE_EXCEPTION;
  ------------------
  |  |  367|  6.06k|#define PJ_USE_EXCEPTION    struct pj_exception_state_t pj_x_except__; int pj_x_code__
  ------------------
  964|       |
  965|  6.06k|    pj_scan_init(&scanner, buf, size, 0, &on_syntax_error);
  966|       |
  967|       |    
  968|  6.06k|    PJ_TRY {
  ------------------
  |  |  373|  6.06k|#define PJ_TRY              if (1) { \
  |  |  ------------------
  |  |  |  Branch (373:33): [True: 6.06k, Folded]
  |  |  ------------------
  |  |  374|  6.06k|                                pj_push_exception_handler_(&pj_x_except__); \
  |  |  375|  6.06k|                                pj_x_code__ = pj_setjmp(pj_x_except__.state); \
  |  |  ------------------
  |  |  |  |   31|  6.06k|#    define pj_setjmp(buf)      setjmp(buf)
  |  |  ------------------
  |  |  376|  6.06k|                                if (pj_x_code__ == 0)
  |  |  ------------------
  |  |  |  Branch (376:37): [True: 6.06k, False: 0]
  |  |  ------------------
  ------------------
  969|  6.06k|        uri = int_parse_uri_or_name_addr(&scanner, pool, option);
  970|  6.06k|    }
  971|      0|    PJ_CATCH_ANY {
  972|      0|        uri = NULL;
  973|      0|    }
  974|  6.06k|    PJ_END;
  ------------------
  |  |  394|  6.06k|#define PJ_END                  pj_pop_exception_handler_(&pj_x_except__); \
  |  |  395|  6.06k|                            } else {}
  ------------------
  975|       |
  976|       |    /* Must have exhausted all inputs. */
  977|  6.06k|    if (pj_scan_is_eof(&scanner) || IS_NEWLINE(*scanner.curptr)) {
  ------------------
  |  |   62|  5.27k|#define IS_NEWLINE(c)   ((c)=='\r' || (c)=='\n')
  |  |  ------------------
  |  |  |  Branch (62:26): [True: 215, False: 5.06k]
  |  |  |  Branch (62:39): [True: 561, False: 4.50k]
  |  |  ------------------
  ------------------
  |  Branch (977:9): [True: 784, False: 5.27k]
  ------------------
  978|       |        /* Success. */
  979|  1.56k|        pj_scan_fini(&scanner);
  980|  1.56k|        return uri;
  981|  1.56k|    }
  982|       |
  983|       |    /* Still have some characters unparsed. */
  984|  4.50k|    pj_scan_fini(&scanner);
  985|       |    return NULL;
  986|  6.06k|}
pjsip_parse_param_imp:
 1268|  13.7k|{
 1269|  13.7k|    parse_param_imp(scanner, pool, pname, pvalue, &pconst.pjsip_TOKEN_SPEC,
 1270|       |                    // Token does not need to be unescaped.
 1271|       |                    // Refer to PR #2933.
 1272|       |                    // &pconst.pjsip_TOKEN_SPEC_ESC,
 1273|       |                    NULL, option);
 1274|  13.7k|}
pjsip_parse_uri_param_imp:
 1281|  18.9k|{
 1282|  18.9k|    parse_param_imp(scanner,pool, pname, pvalue, &pconst.pjsip_PARAM_CHAR_SPEC,
 1283|  18.9k|                    &pconst.pjsip_PARAM_CHAR_SPEC_ESC, option);
 1284|  18.9k|}
pjsip_parse_hdr:
 2417|    402|{
 2418|    402|    pj_scanner scanner;
 2419|    402|    pjsip_hdr *hdr = NULL;
 2420|    402|    pjsip_parse_ctx context;
 2421|    402|    PJ_USE_EXCEPTION;
  ------------------
  |  |  367|    402|#define PJ_USE_EXCEPTION    struct pj_exception_state_t pj_x_except__; int pj_x_code__
  ------------------
 2422|       |
 2423|    402|    pj_scan_init(&scanner, buf, size, PJ_SCAN_AUTOSKIP_WS_HEADER, 
 2424|    402|                 &on_syntax_error);
 2425|       |
 2426|    402|    context.scanner = &scanner;
 2427|    402|    context.pool = pool;
 2428|    402|    context.rdata = NULL;
 2429|       |
 2430|    402|    PJ_TRY {
  ------------------
  |  |  373|    402|#define PJ_TRY              if (1) { \
  |  |  ------------------
  |  |  |  Branch (373:33): [True: 402, Folded]
  |  |  ------------------
  |  |  374|    402|                                pj_push_exception_handler_(&pj_x_except__); \
  |  |  375|    402|                                pj_x_code__ = pj_setjmp(pj_x_except__.state); \
  |  |  ------------------
  |  |  |  |   31|    402|#    define pj_setjmp(buf)      setjmp(buf)
  |  |  ------------------
  |  |  376|    402|                                if (pj_x_code__ == 0)
  |  |  ------------------
  |  |  |  Branch (376:37): [True: 402, False: 0]
  |  |  ------------------
  ------------------
 2431|    402|        pjsip_parse_hdr_func *func = find_handler(hname);
 2432|    402|        if (func) {
  ------------------
  |  Branch (2432:13): [True: 368, False: 34]
  ------------------
 2433|    368|            hdr = (*func)(&context);
 2434|    368|        } else {
 2435|     34|            hdr = parse_hdr_generic_string(&context);
 2436|     34|            hdr->type = PJSIP_H_OTHER;
 2437|     34|            pj_strdup(pool, &hdr->name, hname);
 2438|     34|            hdr->sname = hdr->name;
 2439|     34|        }
 2440|       |
 2441|    402|    } 
 2442|      0|    PJ_CATCH_ANY {
 2443|      0|        hdr = NULL;
 2444|      0|    }
 2445|    402|    PJ_END
  ------------------
  |  |  394|    402|#define PJ_END                  pj_pop_exception_handler_(&pj_x_except__); \
  |  |  395|    402|                            } else {}
  ------------------
 2446|       |
 2447|    402|    if (parsed_len) {
  ------------------
  |  Branch (2447:9): [True: 0, False: 402]
  ------------------
 2448|      0|        *parsed_len = (unsigned)(scanner.curptr - scanner.begin);
 2449|      0|    }
 2450|       |
 2451|    402|    pj_scan_fini(&scanner);
 2452|       |
 2453|    402|    return hdr;
 2454|    402|}
pjsip_parse_headers:
 2460|  5.20k|{
 2461|  5.20k|    enum { STOP_ON_ERROR = 1 };
 2462|  5.20k|    pj_str_t hname = {0, 0};
 2463|  5.20k|    pj_scanner scanner;
 2464|  5.20k|    pjsip_parse_ctx ctx;
 2465|       |
 2466|  5.20k|    PJ_USE_EXCEPTION;
  ------------------
  |  |  367|  5.20k|#define PJ_USE_EXCEPTION    struct pj_exception_state_t pj_x_except__; int pj_x_code__
  ------------------
 2467|       |
 2468|  5.20k|    pj_scan_init(&scanner, input, size, PJ_SCAN_AUTOSKIP_WS_HEADER,
 2469|  5.20k|                 &on_syntax_error);
 2470|       |
 2471|  5.20k|    pj_bzero(&ctx, sizeof(ctx));
 2472|  5.20k|    ctx.scanner = &scanner;
 2473|  5.20k|    ctx.pool = pool;
 2474|       |
 2475|  9.62k|retry_parse:
 2476|  9.62k|    PJ_TRY
  ------------------
  |  |  373|  9.62k|#define PJ_TRY              if (1) { \
  |  |  ------------------
  |  |  |  Branch (373:33): [True: 9.62k, Folded]
  |  |  ------------------
  |  |  374|  9.62k|                                pj_push_exception_handler_(&pj_x_except__); \
  |  |  375|  9.62k|                                pj_x_code__ = pj_setjmp(pj_x_except__.state); \
  |  |  ------------------
  |  |  |  |   31|  9.62k|#    define pj_setjmp(buf)      setjmp(buf)
  |  |  ------------------
  |  |  376|  9.62k|                                if (pj_x_code__ == 0)
  |  |  ------------------
  |  |  |  Branch (376:37): [True: 9.62k, False: 0]
  |  |  ------------------
  ------------------
 2477|  9.62k|    {
 2478|       |        /* Parse headers. */
 2479|  13.0k|        do {
 2480|  13.0k|            pjsip_parse_hdr_func * func;
 2481|  13.0k|            pjsip_hdr *hdr = NULL;
 2482|       |
 2483|       |            /* Init hname just in case parsing fails.
 2484|       |             * Ref: PROTOS #2412
 2485|       |             */
 2486|  13.0k|            hname.slen = 0;
 2487|       |
 2488|       |            /* Get hname. */            
 2489|  13.0k|            pj_scan_get( &scanner, &pconst.pjsip_TOKEN_SPEC, &hname);
 2490|  13.0k|            if (pj_scan_get_char( &scanner ) != ':') {
  ------------------
  |  Branch (2490:17): [True: 4.02k, False: 9.04k]
  ------------------
 2491|  4.02k|                PJ_THROW(PJSIP_SYN_ERR_EXCEPTION);
  ------------------
  |  |  402|  4.02k|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
 2492|  4.02k|            }
 2493|       |
 2494|       |            /* Find handler. */
 2495|  9.04k|            func = find_handler(&hname);
 2496|       |
 2497|       |            /* Call the handler if found.
 2498|       |             * If no handler is found, then treat the header as generic
 2499|       |             * hname/hvalue pair.
 2500|       |             */
 2501|  9.04k|            if (func) {
  ------------------
  |  Branch (2501:17): [True: 5.99k, False: 3.04k]
  ------------------
 2502|  5.99k|                hdr = (*func)(&ctx);
 2503|  5.99k|            } else {
 2504|  3.04k|                hdr = parse_hdr_generic_string(&ctx);
 2505|  3.04k|                hdr->name = hdr->sname = hname;
 2506|  3.04k|            }
 2507|       |
 2508|       |            /* Single parse of header line can produce multiple headers.
 2509|       |             * For example, if one Contact: header contains Contact list
 2510|       |             * separated by comma, then these Contacts will be split into
 2511|       |             * different Contact headers.
 2512|       |             * So here we must insert list instead of just insert one header.
 2513|       |             */
 2514|  9.04k|            if (hdr)
  ------------------
  |  Branch (2514:17): [True: 4.99k, False: 4.04k]
  ------------------
 2515|  4.99k|                pj_list_insert_nodes_before(hlist, hdr);
 2516|       |
 2517|       |            /* Parse until EOF or an empty line is found. */
 2518|  9.04k|        } while (!pj_scan_is_eof(&scanner) && !IS_NEWLINE(*scanner.curptr));
  ------------------
  |  |   62|  4.00k|#define IS_NEWLINE(c)   ((c)=='\r' || (c)=='\n')
  |  |  ------------------
  |  |  |  Branch (62:26): [True: 275, False: 3.73k]
  |  |  |  Branch (62:39): [True: 293, False: 3.43k]
  |  |  ------------------
  ------------------
  |  Branch (2518:18): [True: 4.00k, False: 5.03k]
  ------------------
 2519|       |
 2520|       |        /* If empty line is found, eat it. */
 2521|  5.60k|        if (!pj_scan_is_eof(&scanner)) {
  ------------------
  |  Branch (2521:13): [True: 568, False: 5.03k]
  ------------------
 2522|    568|            if (IS_NEWLINE(*scanner.curptr)) {
  ------------------
  |  |   62|    568|#define IS_NEWLINE(c)   ((c)=='\r' || (c)=='\n')
  |  |  ------------------
  |  |  |  Branch (62:26): [True: 275, False: 293]
  |  |  |  Branch (62:39): [True: 293, False: 0]
  |  |  ------------------
  ------------------
 2523|    568|                pj_scan_get_newline(&scanner);
 2524|    568|            }
 2525|    568|        }
 2526|  5.60k|    }
 2527|      0|    PJ_CATCH_ANY
 2528|      0|    {
 2529|      0|        PJ_LOG(4,(THIS_FILE, "Error parsing header: '%.*s' line %d col %d",
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|  8.06k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 8.06k, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 8.06k]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2530|      0|                  (int)hname.slen, hname.ptr, scanner.line,
 2531|      0|                  pj_scan_get_col(&scanner)));
 2532|       |
 2533|       |        /* Exception was thrown during parsing. */
 2534|      0|        if ((options & STOP_ON_ERROR) == STOP_ON_ERROR) {
  ------------------
  |  Branch (2534:13): [True: 0, False: 0]
  ------------------
 2535|      0|            pj_scan_fini(&scanner);
 2536|      0|            return PJSIP_EINVALIDHDR;
  ------------------
  |  |  175|      0|#define PJSIP_EINVALIDHDR       (PJSIP_ERRNO_START_PJSIP + 51)  /* 171051 */
  |  |  ------------------
  |  |  |  |   73|      0|#define PJSIP_ERRNO_START_PJSIP (PJSIP_ERRNO_START + 1000)
  |  |  |  |  ------------------
  |  |  |  |  |  |   47|      0|#define PJSIP_ERRNO_START       (PJ_ERRNO_START_USER)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  535|      0|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2537|      0|        }
 2538|       |
 2539|       |        /* Skip until newline, and parse next header. */
 2540|  6.07k|        if (!pj_scan_is_eof(&scanner)) {
  ------------------
  |  Branch (2540:13): [True: 6.07k, False: 18.4E]
  ------------------
 2541|       |            /* Skip until next line.
 2542|       |             * Watch for header continuation.
 2543|       |             */
 2544|  6.40k|            do {
 2545|  6.40k|                pj_scan_skip_line(&scanner);
 2546|  6.40k|            } while (IS_SPACE(*scanner.curptr));
  ------------------
  |  |   63|  6.40k|#define IS_SPACE(c)     ((c)==' ' || (c)=='\t')
  |  |  ------------------
  |  |  |  Branch (63:26): [True: 287, False: 6.11k]
  |  |  |  Branch (63:38): [True: 38, False: 6.07k]
  |  |  ------------------
  ------------------
 2547|  6.07k|        }
 2548|       |
 2549|       |        /* Restore flag. Flag may be set in int_parse_sip_url() */
 2550|      0|        scanner.skip_ws = PJ_SCAN_AUTOSKIP_WS_HEADER;
 2551|       |
 2552|       |        /* Continue parse next header, if any. */
 2553|  5.01k|        if (!pj_scan_is_eof(&scanner) && !IS_NEWLINE(*scanner.curptr)) {
  ------------------
  |  |   62|  5.01k|#define IS_NEWLINE(c)   ((c)=='\r' || (c)=='\n')
  |  |  ------------------
  |  |  |  Branch (62:26): [True: 350, False: 4.66k]
  |  |  |  Branch (62:39): [True: 246, False: 4.42k]
  |  |  ------------------
  ------------------
  |  Branch (2553:13): [True: 5.01k, False: 18.4E]
  ------------------
 2554|  4.42k|            goto retry_parse;
 2555|  4.42k|        }
 2556|       |
 2557|      0|    }
 2558|  1.17k|    PJ_END;
  ------------------
  |  |  394|  1.17k|#define PJ_END                  pj_pop_exception_handler_(&pj_x_except__); \
  |  |  395|  1.17k|                            } else {}
  ------------------
 2559|       |
 2560|  1.17k|    return PJ_SUCCESS;
 2561|  9.62k|}
sip_parser.c:init_parser:
  329|      2|{
  330|      2|    pj_status_t status;
  331|       |
  332|       |    /*
  333|       |     * Syntax error exception number.
  334|       |     */
  335|      2|    pj_assert (PJSIP_SYN_ERR_EXCEPTION == -1);
  ------------------
  |  |   65|      2|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (335:5): [True: 0, False: 2]
  |  Branch (335:5): [True: 2, False: 0]
  ------------------
  336|      2|    status = pj_exception_id_alloc("PJSIP syntax error", 
  337|      2|                                   &PJSIP_SYN_ERR_EXCEPTION);
  338|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (338:5): [True: 0, False: 0]
  |  Branch (338:5): [True: 0, False: 0]
  ------------------
  339|       |
  340|       |    /*
  341|       |     * Invalid value exception.
  342|       |     */
  343|      2|    pj_assert (PJSIP_EINVAL_ERR_EXCEPTION == -2);
  ------------------
  |  |   65|      2|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (343:5): [True: 0, False: 2]
  |  Branch (343:5): [True: 2, False: 0]
  ------------------
  344|      2|    status = pj_exception_id_alloc("PJSIP invalid value error", 
  345|      2|                                   &PJSIP_EINVAL_ERR_EXCEPTION);
  346|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (346:5): [True: 0, False: 0]
  |  Branch (346:5): [True: 0, False: 0]
  ------------------
  347|       |
  348|       |    /*
  349|       |     * Init character input spec (cis)
  350|       |     */
  351|       |
  352|      2|    pj_cis_buf_init(&cis_buf);
  353|       |
  354|      2|    status = pj_cis_init(&cis_buf, &pconst.pjsip_DIGIT_SPEC);
  355|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (355:5): [True: 0, False: 0]
  |  Branch (355:5): [True: 0, False: 0]
  ------------------
  356|      2|    pj_cis_add_num(&pconst.pjsip_DIGIT_SPEC);
  357|       |    
  358|      2|    status = pj_cis_init(&cis_buf, &pconst.pjsip_ALPHA_SPEC);
  359|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (359:5): [True: 0, False: 0]
  |  Branch (359:5): [True: 0, False: 0]
  ------------------
  360|      2|    pj_cis_add_alpha( &pconst.pjsip_ALPHA_SPEC );
  361|       |    
  362|      2|    status = pj_cis_init(&cis_buf, &pconst.pjsip_ALNUM_SPEC);
  363|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (363:5): [True: 0, False: 0]
  |  Branch (363:5): [True: 0, False: 0]
  ------------------
  364|      2|    pj_cis_add_alpha( &pconst.pjsip_ALNUM_SPEC );
  365|      2|    pj_cis_add_num( &pconst.pjsip_ALNUM_SPEC );
  366|       |
  367|      2|    status = pj_cis_init(&cis_buf, &pconst.pjsip_NOT_NEWLINE);
  368|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (368:5): [True: 0, False: 0]
  |  Branch (368:5): [True: 0, False: 0]
  ------------------
  369|      2|    pj_cis_add_str(&pconst.pjsip_NOT_NEWLINE, "\r\n");
  370|      2|    pj_cis_invert(&pconst.pjsip_NOT_NEWLINE);
  371|       |
  372|      2|    status = pj_cis_init(&cis_buf, &pconst.pjsip_NOT_COMMA_OR_NEWLINE);
  373|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (373:5): [True: 0, False: 0]
  |  Branch (373:5): [True: 0, False: 0]
  ------------------
  374|      2|    pj_cis_add_str( &pconst.pjsip_NOT_COMMA_OR_NEWLINE, ",\r\n");
  375|      2|    pj_cis_invert(&pconst.pjsip_NOT_COMMA_OR_NEWLINE);
  376|       |
  377|      2|    status = pj_cis_dup(&pconst.pjsip_TOKEN_SPEC, &pconst.pjsip_ALNUM_SPEC);
  378|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (378:5): [True: 0, False: 0]
  |  Branch (378:5): [True: 0, False: 0]
  ------------------
  379|      2|    pj_cis_add_str( &pconst.pjsip_TOKEN_SPEC, TOKEN);
  ------------------
  |  |   47|      2|#define TOKEN               "-.!%*_`'~+"   /* '=' was removed for parsing 
  ------------------
  380|       |
  381|       |    /* Token is allowed to have '%' so we do not need this. */
  382|       |    /*
  383|       |    status = pj_cis_dup(&pconst.pjsip_TOKEN_SPEC_ESC, &pconst.pjsip_TOKEN_SPEC);
  384|       |    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  385|       |    pj_cis_del_str(&pconst.pjsip_TOKEN_SPEC_ESC, "%");
  386|       |    */
  387|       |
  388|      2|    status = pj_cis_dup(&pconst.pjsip_VIA_PARAM_SPEC, &pconst.pjsip_TOKEN_SPEC);
  389|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (389:5): [True: 0, False: 0]
  |  Branch (389:5): [True: 0, False: 0]
  ------------------
  390|      2|    pj_cis_add_str(&pconst.pjsip_VIA_PARAM_SPEC, "[:]");
  391|       |
  392|       |    /* Token is allowed to have '%' */
  393|       |    /*
  394|       |    status = pj_cis_dup(&pconst.pjsip_VIA_PARAM_SPEC_ESC, &pconst.pjsip_TOKEN_SPEC_ESC);
  395|       |    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  396|       |    pj_cis_add_str(&pconst.pjsip_VIA_PARAM_SPEC_ESC, "[:]");
  397|       |    */
  398|       |
  399|      2|    status = pj_cis_dup(&pconst.pjsip_HOST_SPEC, &pconst.pjsip_ALNUM_SPEC);
  400|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (400:5): [True: 0, False: 0]
  |  Branch (400:5): [True: 0, False: 0]
  ------------------
  401|      2|    pj_cis_add_str( &pconst.pjsip_HOST_SPEC, HOST);
  ------------------
  |  |   49|      2|#define HOST                "_-."
  ------------------
  402|       |
  403|      2|    status = pj_cis_dup(&pconst.pjsip_HEX_SPEC, &pconst.pjsip_DIGIT_SPEC);
  404|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (404:5): [True: 0, False: 0]
  |  Branch (404:5): [True: 0, False: 0]
  ------------------
  405|      2|    pj_cis_add_str( &pconst.pjsip_HEX_SPEC, HEX_DIGIT);
  ------------------
  |  |   50|      2|#define HEX_DIGIT           "abcdefABCDEF"
  ------------------
  406|       |
  407|      2|    status = pj_cis_dup(&pconst.pjsip_PARAM_CHAR_SPEC, &pconst.pjsip_ALNUM_SPEC);
  408|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (408:5): [True: 0, False: 0]
  |  Branch (408:5): [True: 0, False: 0]
  ------------------
  409|      2|    pj_cis_add_str(&pconst.pjsip_PARAM_CHAR_SPEC, PARAM_CHAR);
  ------------------
  |  |   51|      2|#define PARAM_CHAR          "[]/:&+$" UNRESERVED ESCAPED
  |  |  ------------------
  |  |  |  |   44|      2|#define ESCAPED             "%"
  |  |  ------------------
  ------------------
  410|       |
  411|      2|    status = pj_cis_dup(&pconst.pjsip_PARAM_CHAR_SPEC_ESC, &pconst.pjsip_PARAM_CHAR_SPEC);
  412|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (412:5): [True: 0, False: 0]
  |  Branch (412:5): [True: 0, False: 0]
  ------------------
  413|      2|    pj_cis_del_str(&pconst.pjsip_PARAM_CHAR_SPEC_ESC, ESCAPED);
  ------------------
  |  |   44|      2|#define ESCAPED             "%"
  ------------------
  414|       |
  415|      2|    status = pj_cis_dup(&pconst.pjsip_HDR_CHAR_SPEC, &pconst.pjsip_ALNUM_SPEC);
  416|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (416:5): [True: 0, False: 0]
  |  Branch (416:5): [True: 0, False: 0]
  ------------------
  417|      2|    pj_cis_add_str(&pconst.pjsip_HDR_CHAR_SPEC, HDR_CHAR);
  ------------------
  |  |   53|      2|#define HDR_CHAR            HNV_UNRESERVED UNRESERVED ESCAPED
  |  |  ------------------
  |  |  |  |   52|      2|#define HNV_UNRESERVED      "[]/?:+$"
  |  |  ------------------
  |  |               #define HDR_CHAR            HNV_UNRESERVED UNRESERVED ESCAPED
  |  |  ------------------
  |  |  |  |   44|      2|#define ESCAPED             "%"
  |  |  ------------------
  ------------------
  418|       |
  419|      2|    status = pj_cis_dup(&pconst.pjsip_HDR_CHAR_SPEC_ESC, &pconst.pjsip_HDR_CHAR_SPEC);
  420|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (420:5): [True: 0, False: 0]
  |  Branch (420:5): [True: 0, False: 0]
  ------------------
  421|      2|    pj_cis_del_str(&pconst.pjsip_HDR_CHAR_SPEC_ESC, ESCAPED);
  ------------------
  |  |   44|      2|#define ESCAPED             "%"
  ------------------
  422|       |
  423|      2|    status = pj_cis_dup(&pconst.pjsip_USER_SPEC, &pconst.pjsip_ALNUM_SPEC);
  424|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (424:5): [True: 0, False: 0]
  |  Branch (424:5): [True: 0, False: 0]
  ------------------
  425|      2|    pj_cis_add_str( &pconst.pjsip_USER_SPEC, UNRESERVED ESCAPED USER_UNRESERVED );
  ------------------
  |  |   43|      2|#define UNRESERVED          ALNUM MARK
  |  |  ------------------
  |  |  |  |   42|      2|#define MARK                "-_.!~*'()"
  |  |  ------------------
  ------------------
                  pj_cis_add_str( &pconst.pjsip_USER_SPEC, UNRESERVED ESCAPED USER_UNRESERVED );
  ------------------
  |  |   45|      2|#define USER_UNRESERVED     "&=+$,;?/"
  ------------------
  426|       |
  427|      2|    status = pj_cis_dup(&pconst.pjsip_USER_SPEC_ESC, &pconst.pjsip_USER_SPEC);
  428|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (428:5): [True: 0, False: 0]
  |  Branch (428:5): [True: 0, False: 0]
  ------------------
  429|      2|    pj_cis_del_str( &pconst.pjsip_USER_SPEC_ESC, ESCAPED);
  ------------------
  |  |   44|      2|#define ESCAPED             "%"
  ------------------
  430|       |
  431|      2|    status = pj_cis_dup(&pconst.pjsip_USER_SPEC_LENIENT, &pconst.pjsip_USER_SPEC);
  432|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (432:5): [True: 0, False: 0]
  |  Branch (432:5): [True: 0, False: 0]
  ------------------
  433|      2|    pj_cis_add_str(&pconst.pjsip_USER_SPEC_LENIENT, "#");
  434|       |
  435|      2|    status = pj_cis_dup(&pconst.pjsip_USER_SPEC_LENIENT_ESC, &pconst.pjsip_USER_SPEC_ESC);
  436|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (436:5): [True: 0, False: 0]
  |  Branch (436:5): [True: 0, False: 0]
  ------------------
  437|      2|    pj_cis_add_str(&pconst.pjsip_USER_SPEC_LENIENT_ESC, "#");
  438|       |
  439|      2|    status = pj_cis_dup(&pconst.pjsip_PASSWD_SPEC, &pconst.pjsip_ALNUM_SPEC);
  440|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (440:5): [True: 0, False: 0]
  |  Branch (440:5): [True: 0, False: 0]
  ------------------
  441|      2|    pj_cis_add_str( &pconst.pjsip_PASSWD_SPEC, UNRESERVED ESCAPED PASS);
  ------------------
  |  |   43|      2|#define UNRESERVED          ALNUM MARK
  |  |  ------------------
  |  |  |  |   42|      2|#define MARK                "-_.!~*'()"
  |  |  ------------------
  ------------------
                  pj_cis_add_str( &pconst.pjsip_PASSWD_SPEC, UNRESERVED ESCAPED PASS);
  ------------------
  |  |   46|      2|#define PASS                "&=+$,"
  ------------------
  442|       |
  443|      2|    status = pj_cis_dup(&pconst.pjsip_PASSWD_SPEC_ESC, &pconst.pjsip_PASSWD_SPEC);
  444|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (444:5): [True: 0, False: 0]
  |  Branch (444:5): [True: 0, False: 0]
  ------------------
  445|      2|    pj_cis_del_str( &pconst.pjsip_PASSWD_SPEC_ESC, ESCAPED);
  ------------------
  |  |   44|      2|#define ESCAPED             "%"
  ------------------
  446|       |
  447|      2|    status = pj_cis_init(&cis_buf, &pconst.pjsip_PROBE_USER_HOST_SPEC);
  448|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (448:5): [True: 0, False: 0]
  |  Branch (448:5): [True: 0, False: 0]
  ------------------
  449|      2|    pj_cis_add_str( &pconst.pjsip_PROBE_USER_HOST_SPEC, "@ \n>");
  450|      2|    pj_cis_invert( &pconst.pjsip_PROBE_USER_HOST_SPEC );
  451|       |
  452|      2|    status = pj_cis_init(&cis_buf, &pconst.pjsip_DISPLAY_SPEC);
  453|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (453:5): [True: 0, False: 0]
  |  Branch (453:5): [True: 0, False: 0]
  ------------------
  454|      2|    pj_cis_add_str( &pconst.pjsip_DISPLAY_SPEC, ":\r\n<");
  455|      2|    pj_cis_invert(&pconst.pjsip_DISPLAY_SPEC);
  456|       |
  457|      2|    status = pj_cis_dup(&pconst.pjsip_OTHER_URI_CONTENT, &pconst.pjsip_ALNUM_SPEC);
  458|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (458:5): [True: 0, False: 0]
  |  Branch (458:5): [True: 0, False: 0]
  ------------------
  459|      2|    pj_cis_add_str( &pconst.pjsip_OTHER_URI_CONTENT, GENERIC_URI_CHARS);
  ------------------
  |  |   58|      2|#define GENERIC_URI_CHARS   "#?;:@&=+-_.!~*'()%$,/" "%"
  ------------------
  460|       |
  461|       |    /*
  462|       |     * Register URI parsers.
  463|       |     */
  464|       |
  465|      2|    status = pjsip_register_uri_parser("sip", &int_parse_sip_url);
  466|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (466:5): [True: 0, False: 0]
  |  Branch (466:5): [True: 0, False: 0]
  ------------------
  467|       |
  468|      2|    status = pjsip_register_uri_parser("sips", &int_parse_sip_url);
  469|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (469:5): [True: 0, False: 0]
  |  Branch (469:5): [True: 0, False: 0]
  ------------------
  470|       |
  471|       |    /*
  472|       |     * Register header parsers.
  473|       |     */
  474|       |
  475|      2|    status = pjsip_register_hdr_parser( "Accept", NULL, &parse_hdr_accept);
  476|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (476:5): [True: 0, False: 0]
  |  Branch (476:5): [True: 0, False: 0]
  ------------------
  477|       |
  478|      2|    status = pjsip_register_hdr_parser( "Allow", NULL, &parse_hdr_allow);
  479|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (479:5): [True: 0, False: 0]
  |  Branch (479:5): [True: 0, False: 0]
  ------------------
  480|       |
  481|      2|    status = pjsip_register_hdr_parser( "Call-ID", "i", &parse_hdr_call_id);
  482|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (482:5): [True: 0, False: 0]
  |  Branch (482:5): [True: 0, False: 0]
  ------------------
  483|       |
  484|      2|    status = pjsip_register_hdr_parser( "Contact", "m", &parse_hdr_contact);
  485|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (485:5): [True: 0, False: 0]
  |  Branch (485:5): [True: 0, False: 0]
  ------------------
  486|       |
  487|      2|    status = pjsip_register_hdr_parser( "Content-Length", "l", 
  488|      2|                                        &parse_hdr_content_len);
  489|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (489:5): [True: 0, False: 0]
  |  Branch (489:5): [True: 0, False: 0]
  ------------------
  490|       |
  491|      2|    status = pjsip_register_hdr_parser( "Content-Type", "c", 
  492|      2|                                        &parse_hdr_content_type);
  493|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (493:5): [True: 0, False: 0]
  |  Branch (493:5): [True: 0, False: 0]
  ------------------
  494|       |
  495|      2|    status = pjsip_register_hdr_parser( "CSeq", NULL, &parse_hdr_cseq);
  496|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (496:5): [True: 0, False: 0]
  |  Branch (496:5): [True: 0, False: 0]
  ------------------
  497|       |
  498|      2|    status = pjsip_register_hdr_parser( "Expires", NULL, &parse_hdr_expires);
  499|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (499:5): [True: 0, False: 0]
  |  Branch (499:5): [True: 0, False: 0]
  ------------------
  500|       |
  501|      2|    status = pjsip_register_hdr_parser( "From", "f", &parse_hdr_from);
  502|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (502:5): [True: 0, False: 0]
  |  Branch (502:5): [True: 0, False: 0]
  ------------------
  503|       |
  504|      2|    status = pjsip_register_hdr_parser( "Max-Forwards", NULL, 
  505|      2|                                        &parse_hdr_max_forwards);
  506|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (506:5): [True: 0, False: 0]
  |  Branch (506:5): [True: 0, False: 0]
  ------------------
  507|       |
  508|      2|    status = pjsip_register_hdr_parser( "Min-Expires", NULL, 
  509|      2|                                        &parse_hdr_min_expires);
  510|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (510:5): [True: 0, False: 0]
  |  Branch (510:5): [True: 0, False: 0]
  ------------------
  511|       |
  512|      2|    status = pjsip_register_hdr_parser( "Record-Route", NULL, &parse_hdr_rr);
  513|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (513:5): [True: 0, False: 0]
  |  Branch (513:5): [True: 0, False: 0]
  ------------------
  514|       |
  515|      2|    status = pjsip_register_hdr_parser( "Route", NULL, &parse_hdr_route);
  516|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (516:5): [True: 0, False: 0]
  |  Branch (516:5): [True: 0, False: 0]
  ------------------
  517|       |
  518|      2|    status = pjsip_register_hdr_parser( "Require", NULL, &parse_hdr_require);
  519|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (519:5): [True: 0, False: 0]
  |  Branch (519:5): [True: 0, False: 0]
  ------------------
  520|       |
  521|      2|    status = pjsip_register_hdr_parser( "Retry-After", NULL, 
  522|      2|                                        &parse_hdr_retry_after);
  523|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (523:5): [True: 0, False: 0]
  |  Branch (523:5): [True: 0, False: 0]
  ------------------
  524|       |
  525|      2|    status = pjsip_register_hdr_parser( "Supported", "k", 
  526|      2|                                        &parse_hdr_supported);
  527|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (527:5): [True: 0, False: 0]
  |  Branch (527:5): [True: 0, False: 0]
  ------------------
  528|       |
  529|      2|    status = pjsip_register_hdr_parser( "To", "t", &parse_hdr_to);
  530|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (530:5): [True: 0, False: 0]
  |  Branch (530:5): [True: 0, False: 0]
  ------------------
  531|       |
  532|      2|    status = pjsip_register_hdr_parser( "Unsupported", NULL, 
  533|      2|                                        &parse_hdr_unsupported);
  534|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (534:5): [True: 0, False: 0]
  |  Branch (534:5): [True: 0, False: 0]
  ------------------
  535|       |
  536|      2|    status = pjsip_register_hdr_parser( "Via", "v", &parse_hdr_via);
  537|      2|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (537:5): [True: 0, False: 0]
  |  Branch (537:5): [True: 0, False: 0]
  ------------------
  538|       |
  539|       |    /* 
  540|       |     * Register auth parser. 
  541|       |     */
  542|       |
  543|      2|    status = pjsip_auth_init_parser();
  544|       |
  545|      2|    return status;
  546|      2|}
sip_parser.c:int_parse_sip_url:
 1508|  10.8k|{
 1509|  10.8k|    pj_str_t scheme;
 1510|  10.8k|    pjsip_sip_uri *url = NULL;
 1511|  10.8k|    int colon;
 1512|  10.8k|    int skip_ws = scanner->skip_ws;
 1513|  10.8k|    scanner->skip_ws = 0;
 1514|       |
 1515|  10.8k|    pj_scan_get(scanner, &pconst.pjsip_TOKEN_SPEC, &scheme);
 1516|  10.8k|    colon = pj_scan_get_char(scanner);
 1517|  10.8k|    if (colon != ':') {
  ------------------
  |  Branch (1517:9): [True: 0, False: 10.8k]
  ------------------
 1518|      0|        PJ_THROW(PJSIP_SYN_ERR_EXCEPTION);
  ------------------
  |  |  402|      0|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
 1519|      0|    }
 1520|       |
 1521|  10.8k|    if (parser_stricmp(scheme, pconst.pjsip_SIP_STR)==0) {
  ------------------
  |  |  207|  10.8k|#define parser_stricmp(s1, s2)  (s1.slen!=s2.slen || pj_stricmp_alnum(&s1, &s2))
  |  |  ------------------
  |  |  |  |  408|  10.3k|#define pj_stricmp_alnum    pj_stricmp
  |  |  ------------------
  |  |  |  Branch (207:34): [True: 482, False: 10.3k]
  |  |  |  Branch (207:54): [True: 0, False: 10.3k]
  |  |  ------------------
  ------------------
  |  Branch (1521:9): [True: 10.3k, False: 482]
  ------------------
 1522|  10.3k|        url = pjsip_sip_uri_create(pool, 0);
 1523|       |
 1524|  10.3k|    } else if (parser_stricmp(scheme, pconst.pjsip_SIPS_STR)==0) {
  ------------------
  |  |  207|    482|#define parser_stricmp(s1, s2)  (s1.slen!=s2.slen || pj_stricmp_alnum(&s1, &s2))
  |  |  ------------------
  |  |  |  |  408|    482|#define pj_stricmp_alnum    pj_stricmp
  |  |  ------------------
  |  |  |  Branch (207:34): [True: 0, False: 482]
  |  |  |  Branch (207:54): [True: 0, False: 482]
  |  |  ------------------
  ------------------
  |  Branch (1524:16): [True: 482, False: 0]
  ------------------
 1525|    482|        url = pjsip_sip_uri_create(pool, 1);
 1526|       |
 1527|    482|    } else {
 1528|      0|        PJ_THROW(PJSIP_SYN_ERR_EXCEPTION);
  ------------------
  |  |  402|      0|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
 1529|       |        /* should not reach here */
 1530|      0|        UNREACHED({
 1531|      0|            pj_assert(0);
 1532|      0|            return 0;
 1533|      0|        })
 1534|      0|    }
 1535|       |
 1536|  10.8k|    if (int_is_next_user(scanner)) {
  ------------------
  |  Branch (1536:9): [True: 2.18k, False: 8.62k]
  ------------------
 1537|       |#if defined (PJSIP_URI_USE_ORIG_USERPASS) && (PJSIP_URI_USE_ORIG_USERPASS)
 1538|       |        char *start = scanner->curptr;
 1539|       |        pj_str_t orig;
 1540|       |#endif
 1541|       |
 1542|  2.18k|        int_parse_user_pass(scanner, pool, &url->user, &url->passwd);
 1543|       |
 1544|       |#if defined (PJSIP_URI_USE_ORIG_USERPASS) && (PJSIP_URI_USE_ORIG_USERPASS)
 1545|       |        pj_strset3(&orig, start, scanner->curptr - 1);
 1546|       |        pj_strdup(pool, &url->orig_userpass, &orig);
 1547|       |#endif
 1548|  2.18k|    }
 1549|       |
 1550|       |    /* Get host:port */
 1551|  10.8k|    int_parse_uri_host_port(scanner, &url->host, &url->port);
 1552|       |
 1553|       |    /* Get URL parameters. */
 1554|  10.8k|    if (parse_params) {
  ------------------
  |  Branch (1554:9): [True: 5.55k, False: 5.25k]
  ------------------
 1555|  24.4k|      while (*scanner->curptr == ';' ) {
  ------------------
  |  Branch (1555:14): [True: 18.9k, False: 5.55k]
  ------------------
 1556|  18.9k|        pj_str_t pname, pvalue;
 1557|       |
 1558|  18.9k|        int_parse_uri_param( scanner, pool, &pname, &pvalue, 0);
 1559|       |
 1560|  18.9k|        if (!parser_stricmp(pname, pconst.pjsip_USER_STR) && pvalue.slen) {
  ------------------
  |  |  207|  37.8k|#define parser_stricmp(s1, s2)  (s1.slen!=s2.slen || pj_stricmp_alnum(&s1, &s2))
  |  |  ------------------
  |  |  |  |  408|  2.94k|#define pj_stricmp_alnum    pj_stricmp
  |  |  ------------------
  |  |  |  Branch (207:34): [True: 15.9k, False: 2.94k]
  |  |  |  Branch (207:54): [True: 2.42k, False: 525]
  |  |  ------------------
  ------------------
  |  Branch (1560:62): [True: 255, False: 270]
  ------------------
 1561|    255|            url->user_param = pvalue;
 1562|       |
 1563|  18.6k|        } else if (!parser_stricmp(pname, pconst.pjsip_METHOD_STR) && pvalue.slen) {
  ------------------
  |  |  207|  37.3k|#define parser_stricmp(s1, s2)  (s1.slen!=s2.slen || pj_stricmp_alnum(&s1, &s2))
  |  |  ------------------
  |  |  |  |  408|  1.57k|#define pj_stricmp_alnum    pj_stricmp
  |  |  ------------------
  |  |  |  Branch (207:34): [True: 17.0k, False: 1.57k]
  |  |  |  Branch (207:54): [True: 1.12k, False: 452]
  |  |  ------------------
  ------------------
  |  Branch (1563:71): [True: 246, False: 206]
  ------------------
 1564|    246|            url->method_param = pvalue;
 1565|       |
 1566|  18.4k|        } else if (!parser_stricmp(pname, pconst.pjsip_TRANSPORT_STR) && pvalue.slen) {
  ------------------
  |  |  207|  36.8k|#define parser_stricmp(s1, s2)  (s1.slen!=s2.slen || pj_stricmp_alnum(&s1, &s2))
  |  |  ------------------
  |  |  |  |  408|  1.20k|#define pj_stricmp_alnum    pj_stricmp
  |  |  ------------------
  |  |  |  Branch (207:34): [True: 17.2k, False: 1.20k]
  |  |  |  Branch (207:54): [True: 607, False: 602]
  |  |  ------------------
  ------------------
  |  Branch (1566:74): [True: 246, False: 356]
  ------------------
 1567|    246|            url->transport_param = pvalue;
 1568|       |
 1569|  18.1k|        } else if (!parser_stricmp(pname, pconst.pjsip_TTL_STR) && pvalue.slen) {
  ------------------
  |  |  207|  36.3k|#define parser_stricmp(s1, s2)  (s1.slen!=s2.slen || pj_stricmp_alnum(&s1, &s2))
  |  |  ------------------
  |  |  |  |  408|  4.27k|#define pj_stricmp_alnum    pj_stricmp
  |  |  ------------------
  |  |  |  Branch (207:34): [True: 13.9k, False: 4.27k]
  |  |  |  Branch (207:54): [True: 2.11k, False: 2.16k]
  |  |  ------------------
  ------------------
  |  Branch (1569:68): [True: 1.56k, False: 601]
  ------------------
 1570|  1.56k|            strtoi_validate(&pvalue, PJSIP_MIN_TTL, PJSIP_MAX_TTL,
  ------------------
  |  |   47|  1.56k|#define PJSIP_MIN_TTL               0           /**< For limit checks */
  ------------------
                          strtoi_validate(&pvalue, PJSIP_MIN_TTL, PJSIP_MAX_TTL,
  ------------------
  |  |   48|  1.56k|#define PJSIP_MAX_TTL               PJ_MAXUINT8 /**< For limit checks */
  |  |  ------------------
  |  |  |  |   39|  1.56k|#define PJ_MAXUINT8     0xff
  |  |  ------------------
  ------------------
 1571|  1.56k|                            &url->ttl_param);
 1572|  16.6k|        } else if (!parser_stricmp(pname, pconst.pjsip_MADDR_STR) && pvalue.slen) {
  ------------------
  |  |  207|  33.2k|#define parser_stricmp(s1, s2)  (s1.slen!=s2.slen || pj_stricmp_alnum(&s1, &s2))
  |  |  ------------------
  |  |  |  |  408|  1.94k|#define pj_stricmp_alnum    pj_stricmp
  |  |  ------------------
  |  |  |  Branch (207:34): [True: 14.6k, False: 1.94k]
  |  |  |  Branch (207:54): [True: 1.52k, False: 423]
  |  |  ------------------
  ------------------
  |  Branch (1572:70): [True: 206, False: 217]
  ------------------
 1573|    206|            url->maddr_param = pvalue;
 1574|       |
 1575|  16.4k|        } else if (!parser_stricmp(pname, pconst.pjsip_LR_STR)) {
  ------------------
  |  |  207|  16.4k|#define parser_stricmp(s1, s2)  (s1.slen!=s2.slen || pj_stricmp_alnum(&s1, &s2))
  |  |  ------------------
  |  |  |  |  408|  2.51k|#define pj_stricmp_alnum    pj_stricmp
  |  |  ------------------
  |  |  |  Branch (207:34): [True: 13.8k, False: 2.51k]
  |  |  |  Branch (207:54): [True: 2.18k, False: 324]
  |  |  ------------------
  ------------------
 1576|    324|            url->lr_param = 1;
 1577|       |
 1578|  16.0k|        } else {
 1579|  16.0k|            pjsip_param *p = PJ_POOL_ALLOC_T(pool, pjsip_param);
  ------------------
  |  |  569|  16.0k|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
 1580|  16.0k|            p->name = pname;
 1581|  16.0k|            p->value = pvalue;
 1582|  16.0k|            pj_list_insert_before(&url->other_param, p);
 1583|  16.0k|        }
 1584|  18.9k|      }
 1585|  5.55k|    }
 1586|       |
 1587|       |    /* Get header params. */
 1588|  10.8k|    if (parse_params && *scanner->curptr == '?') {
  ------------------
  |  Branch (1588:9): [True: 5.05k, False: 5.74k]
  |  Branch (1588:25): [True: 475, False: 4.58k]
  ------------------
 1589|  1.66k|      do {
 1590|  1.66k|        pjsip_param *param;
 1591|  1.66k|        param = PJ_POOL_ALLOC_T(pool, pjsip_param);
  ------------------
  |  |  569|  1.66k|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
 1592|  1.66k|        int_parse_hparam(scanner, pool, &param->name, &param->value);
 1593|  1.66k|        pj_list_insert_before(&url->header_param, param);
 1594|  1.66k|      } while (*scanner->curptr == '&');
  ------------------
  |  Branch (1594:16): [True: 1.18k, False: 475]
  ------------------
 1595|    475|    }
 1596|       |
 1597|  10.8k|    scanner->skip_ws = skip_ws;
 1598|  10.8k|    pj_scan_skip_whitespace(scanner);
 1599|  10.8k|    return url;
 1600|  10.8k|}
sip_parser.c:int_is_next_user:
 1377|  10.8k|{
 1378|  10.8k|    pj_str_t dummy;
 1379|  10.8k|    int is_user;
 1380|       |
 1381|       |    /* Find character '@'. If this character exist, then the token
 1382|       |     * must be a username.
 1383|       |     */
 1384|  10.8k|    if (pj_scan_peek( scanner, &pconst.pjsip_PROBE_USER_HOST_SPEC, &dummy) == '@')
  ------------------
  |  Branch (1384:9): [True: 2.18k, False: 8.62k]
  ------------------
 1385|  2.18k|        is_user = 1;
 1386|  8.62k|    else
 1387|  8.62k|        is_user = 0;
 1388|       |
 1389|  10.8k|    return is_user;
 1390|  10.8k|}
sip_parser.c:int_parse_user_pass:
 1395|  2.18k|{
 1396|  2.18k|    parser_get_and_unescape(scanner, pool, &pconst.pjsip_USER_SPEC_LENIENT, 
 1397|  2.18k|                            &pconst.pjsip_USER_SPEC_LENIENT_ESC, user);
 1398|       |
 1399|  2.18k|    if ( *scanner->curptr == ':') {
  ------------------
  |  Branch (1399:10): [True: 231, False: 1.95k]
  ------------------
 1400|    231|        pj_scan_get_char( scanner );
 1401|    231|        parser_get_and_unescape(scanner, pool, &pconst.pjsip_PASSWD_SPEC,
 1402|    231|                                &pconst.pjsip_PASSWD_SPEC_ESC, pass);
 1403|  1.95k|    } else {
 1404|  1.95k|        pass->ptr = NULL;
 1405|  1.95k|        pass->slen = 0;
 1406|  1.95k|    }
 1407|       |
 1408|       |    /* Get the '@' */
 1409|  2.18k|    pj_scan_get_char( scanner );
 1410|  2.18k|}
sip_parser.c:parser_get_and_unescape:
  214|  26.9k|{
  215|       |#if defined(PJSIP_UNESCAPE_IN_PLACE) && PJSIP_UNESCAPE_IN_PLACE!=0
  216|       |    PJ_UNUSED_ARG(pool);
  217|       |    PJ_UNUSED_ARG(spec);
  218|       |    pj_scan_get_unescape(scanner, unesc_spec, token);
  219|       |#else
  220|  26.9k|    PJ_UNUSED_ARG(unesc_spec);
  ------------------
  |  | 1537|  26.9k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  221|  26.9k|    pj_scan_get(scanner, spec, token);
  222|  26.9k|    *token = pj_str_unescape(pool, token);
  223|  26.9k|#endif
  224|  26.9k|}
sip_parser.c:int_parse_uri_host_port:
 1361|  10.7k|{
 1362|  10.7k|    int_parse_host(scanner, host);
 1363|       |
 1364|       |    /* RFC3261 section 19.1.2: host don't need to be unescaped */
 1365|  10.7k|    if (*scanner->curptr == ':') {
  ------------------
  |  Branch (1365:9): [True: 372, False: 10.4k]
  ------------------
 1366|    372|        pj_str_t port;
 1367|    372|        pj_scan_get_char(scanner);
 1368|    372|        pj_scan_get(scanner, &pconst.pjsip_DIGIT_SPEC, &port);
 1369|    372|        strtoi_validate(&port, PJSIP_MIN_PORT, PJSIP_MAX_PORT, p_port);
  ------------------
  |  |   45|    372|#define PJSIP_MIN_PORT              0           /**< For limit checks */
  ------------------
                      strtoi_validate(&port, PJSIP_MIN_PORT, PJSIP_MAX_PORT, p_port);
  ------------------
  |  |   46|    372|#define PJSIP_MAX_PORT              PJ_MAXUINT16/**< For limit checks */
  |  |  ------------------
  |  |  |  |   36|    372|#define PJ_MAXUINT16    0xffff
  |  |  ------------------
  ------------------
 1370|  10.4k|    } else {
 1371|  10.4k|        *p_port = 0;
 1372|  10.4k|    }
 1373|  10.7k|}
sip_parser.c:int_parse_host:
 1344|  16.2k|{
 1345|  16.2k|    if (*scanner->curptr == '[') {
  ------------------
  |  Branch (1345:9): [True: 1.06k, False: 15.1k]
  ------------------
 1346|       |        /* Note: the '[' and ']' characters are removed from the host */
 1347|  1.06k|        pj_scan_get_char(scanner);
 1348|  1.06k|        pj_scan_get_until_ch(scanner, ']', host);
 1349|  1.06k|        pj_scan_get_char(scanner);
 1350|       |        /* Empty IPv6 address (e.g. "sip:[]") is invalid */
 1351|  1.06k|        if (host->slen == 0)
  ------------------
  |  Branch (1351:13): [True: 411, False: 656]
  ------------------
 1352|    411|            on_syntax_error(scanner);
 1353|  15.1k|    } else {
 1354|  15.1k|        pj_scan_get( scanner, &pconst.pjsip_HOST_SPEC, host);
 1355|  15.1k|    }
 1356|  16.2k|}
sip_parser.c:int_parse_uri_param:
 1303|  18.9k|{
 1304|       |    /* Get ';' character */
 1305|  18.9k|    pj_scan_get_char(scanner);
 1306|       |
 1307|       |    /* Get pname and optionally pvalue */
 1308|  18.9k|    pjsip_parse_uri_param_imp(scanner, pool, pname, pvalue, 
 1309|  18.9k|                              option);
 1310|  18.9k|}
sip_parser.c:int_parse_hparam:
 1316|  1.66k|{
 1317|       |    /* Get '?' or '&' character. */
 1318|  1.66k|    pj_scan_get_char(scanner);
 1319|       |
 1320|       |    /* hname */
 1321|  1.66k|    parser_get_and_unescape(scanner, pool, &pconst.pjsip_HDR_CHAR_SPEC, 
 1322|  1.66k|                            &pconst.pjsip_HDR_CHAR_SPEC_ESC, hname);
 1323|       |
 1324|       |    /* Init hvalue */
 1325|  1.66k|    hvalue->ptr = NULL;
 1326|  1.66k|    hvalue->slen = 0;
 1327|       |
 1328|       |    /* pvalue, if any */
 1329|  1.66k|    if (*scanner->curptr == '=') {
  ------------------
  |  Branch (1329:9): [True: 609, False: 1.05k]
  ------------------
 1330|    609|        pj_scan_get_char(scanner);
 1331|    609|        if (!pj_scan_is_eof(scanner) && 
  ------------------
  |  Branch (1331:13): [True: 604, False: 5]
  ------------------
 1332|    604|            pj_cis_match(&pconst.pjsip_HDR_CHAR_SPEC, *scanner->curptr))
  ------------------
  |  Branch (1332:13): [True: 406, False: 198]
  ------------------
 1333|    406|        {
 1334|    406|            parser_get_and_unescape(scanner, pool, &pconst.pjsip_HDR_CHAR_SPEC,
 1335|    406|                                    &pconst.pjsip_HDR_CHAR_SPEC_ESC, hvalue);
 1336|    406|        }
 1337|    609|    }
 1338|  1.66k|}
sip_parser.c:parse_hdr_call_id:
 1889|  1.67k|{
 1890|  1.67k|    pjsip_cid_hdr *hdr = pjsip_cid_hdr_create(ctx->pool);
 1891|  1.67k|    pj_scan_get( ctx->scanner, &pconst.pjsip_NOT_NEWLINE, &hdr->id);
 1892|  1.67k|    parse_hdr_end(ctx->scanner);
 1893|       |
 1894|  1.67k|    if (ctx->rdata)
  ------------------
  |  Branch (1894:9): [True: 0, False: 1.67k]
  ------------------
 1895|      0|        ctx->rdata->msg_info.cid = hdr;
 1896|       |
 1897|  1.67k|    return (pjsip_hdr*)hdr;
 1898|  1.67k|}
sip_parser.c:parse_hdr_contact:
 1958|  7.77k|{
 1959|  7.77k|    pjsip_contact_hdr *first = NULL;
 1960|  7.77k|    pj_scanner *scanner = ctx->scanner;
 1961|       |    
 1962|  7.99k|    do {
 1963|  7.99k|        pjsip_contact_hdr *hdr = pjsip_contact_hdr_create(ctx->pool);
 1964|  7.99k|        if (first == NULL)
  ------------------
  |  Branch (1964:13): [True: 7.77k, False: 224]
  ------------------
 1965|  7.77k|            first = hdr;
 1966|    224|        else
 1967|    224|            pj_list_insert_before(first, hdr);
 1968|       |
 1969|  7.99k|        if (*scanner->curptr == '*') {
  ------------------
  |  Branch (1969:13): [True: 1.06k, False: 6.92k]
  ------------------
 1970|  1.06k|            pj_scan_get_char(scanner);
 1971|  1.06k|            hdr->star = 1;
 1972|       |
 1973|  6.92k|        } else {
 1974|  6.92k|            hdr->star = 0;
 1975|  6.92k|            hdr->uri = int_parse_uri_or_name_addr(scanner, ctx->pool, 
 1976|  6.92k|                                                  PJSIP_PARSE_URI_AS_NAMEADDR |
 1977|  6.92k|                                                  PJSIP_PARSE_URI_IN_FROM_TO_HDR);
 1978|       |
 1979|  6.92k|            int_parse_contact_param(hdr, scanner, ctx->pool);
 1980|  6.92k|        }
 1981|       |
 1982|  7.99k|        if (*scanner->curptr != ',')
  ------------------
  |  Branch (1982:13): [True: 4.50k, False: 3.49k]
  ------------------
 1983|  4.50k|            break;
 1984|       |
 1985|  3.49k|        pj_scan_get_char(scanner);
 1986|       |
 1987|  3.49k|    } while (1);
  ------------------
  |  Branch (1987:14): [True: 224, Folded]
  ------------------
 1988|       |
 1989|  7.77k|    parse_hdr_end(scanner);
 1990|       |
 1991|  7.77k|    return (pjsip_hdr*)first;
 1992|  7.77k|}
sip_parser.c:int_parse_contact_param:
 1904|  5.27k|{
 1905|  14.2k|    while ( *scanner->curptr == ';' ) {
  ------------------
  |  Branch (1905:13): [True: 9.20k, False: 5.07k]
  ------------------
 1906|  9.20k|        pj_str_t pname, pvalue;
 1907|       |
 1908|  9.20k|        int_parse_param( scanner, pool, &pname, &pvalue, 0);
 1909|  9.20k|        if (!parser_stricmp(pname, pconst.pjsip_Q_STR) && pvalue.slen) {
  ------------------
  |  |  207|  18.4k|#define parser_stricmp(s1, s2)  (s1.slen!=s2.slen || pj_stricmp_alnum(&s1, &s2))
  |  |  ------------------
  |  |  |  |  408|  4.36k|#define pj_stricmp_alnum    pj_stricmp
  |  |  ------------------
  |  |  |  Branch (207:34): [True: 4.83k, False: 4.36k]
  |  |  |  Branch (207:54): [True: 1.20k, False: 3.15k]
  |  |  ------------------
  ------------------
  |  Branch (1909:59): [True: 2.91k, False: 246]
  ------------------
 1910|  2.91k|            char *dot_pos = (char*) pj_memchr(pvalue.ptr, '.', pvalue.slen);
 1911|  2.91k|            if (!dot_pos) {
  ------------------
  |  Branch (1911:17): [True: 1.26k, False: 1.65k]
  ------------------
 1912|  1.26k|                strtoi_validate(&pvalue, PJSIP_MIN_Q1000, PJSIP_MAX_Q1000,
  ------------------
  |  |   51|  1.26k|#define PJSIP_MIN_Q1000             0           /**< For limit checks */
  ------------------
                              strtoi_validate(&pvalue, PJSIP_MIN_Q1000, PJSIP_MAX_Q1000,
  ------------------
  |  |   52|  1.26k|#define PJSIP_MAX_Q1000             PJ_MAXINT32 / 1000/**< For limit checks */
  |  |  ------------------
  |  |  |  |   30|  1.26k|#define PJ_MAXINT32     0x7fffffff
  |  |  ------------------
  ------------------
 1913|  1.26k|                                &hdr->q1000);
 1914|  1.26k|                hdr->q1000 *= 1000;
 1915|  1.65k|            } else {
 1916|  1.65k|                pj_str_t tmp = pvalue;
 1917|  1.65k|                unsigned long qval_frac;
 1918|       |
 1919|  1.65k|                tmp.slen = dot_pos - pvalue.ptr;
 1920|  1.65k|                strtoi_validate(&tmp, PJSIP_MIN_Q1000, PJSIP_MAX_Q1000,
  ------------------
  |  |   51|  1.65k|#define PJSIP_MIN_Q1000             0           /**< For limit checks */
  ------------------
                              strtoi_validate(&tmp, PJSIP_MIN_Q1000, PJSIP_MAX_Q1000,
  ------------------
  |  |   52|  1.65k|#define PJSIP_MAX_Q1000             PJ_MAXINT32 / 1000/**< For limit checks */
  |  |  ------------------
  |  |  |  |   30|  1.65k|#define PJ_MAXINT32     0x7fffffff
  |  |  ------------------
  ------------------
 1921|  1.65k|                                &hdr->q1000);
 1922|  1.65k|                hdr->q1000 *= 1000;
 1923|       |
 1924|  1.65k|                pvalue.slen = (pvalue.ptr+pvalue.slen) - (dot_pos+1);
 1925|  1.65k|                pvalue.ptr = dot_pos + 1;
 1926|  1.65k|                if (pvalue.slen > 3) {
  ------------------
  |  Branch (1926:21): [True: 411, False: 1.24k]
  ------------------
 1927|    411|                    pvalue.slen = 3;
 1928|    411|                }
 1929|  1.65k|                qval_frac = pj_strtoul_mindigit(&pvalue, 3);
 1930|  1.65k|                if ((unsigned)hdr->q1000 > (PJ_MAXINT32 - qval_frac)) {
  ------------------
  |  |   30|  1.65k|#define PJ_MAXINT32     0x7fffffff
  ------------------
  |  Branch (1930:21): [True: 198, False: 1.45k]
  ------------------
 1931|    198|                    PJ_THROW(PJSIP_SYN_ERR_EXCEPTION);
  ------------------
  |  |  402|    198|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
 1932|    198|                }
 1933|  1.45k|                hdr->q1000 += qval_frac;
 1934|  1.45k|            }    
 1935|  6.28k|        } else if (!parser_stricmp(pname, pconst.pjsip_EXPIRES_STR) && 
  ------------------
  |  |  207|  12.5k|#define parser_stricmp(s1, s2)  (s1.slen!=s2.slen || pj_stricmp_alnum(&s1, &s2))
  |  |  ------------------
  |  |  |  |  408|  1.01k|#define pj_stricmp_alnum    pj_stricmp
  |  |  ------------------
  |  |  |  Branch (207:34): [True: 5.27k, False: 1.01k]
  |  |  |  Branch (207:54): [True: 280, False: 736]
  |  |  ------------------
  ------------------
 1936|    736|                   pvalue.slen) 
  ------------------
  |  Branch (1936:20): [True: 529, False: 207]
  ------------------
 1937|    529|        {
 1938|    529|            hdr->expires = pj_strtoul(&pvalue);
 1939|    529|            if (hdr->expires == PJSIP_EXPIRES_NOT_SPECIFIED)
  ------------------
  |  | 1427|    529|#define PJSIP_EXPIRES_NOT_SPECIFIED     ((pj_uint32_t)0xFFFFFFFFUL)
  ------------------
  |  Branch (1939:17): [True: 194, False: 335]
  ------------------
 1940|    194|                hdr->expires--;
 1941|       |            //if (hdr->expires > PJSIP_MAX_EXPIRES)
 1942|       |            //    hdr->expires = PJSIP_MAX_EXPIRES;
 1943|       |#if PJSIP_MIN_EXPIRES > 0
 1944|       |            if (hdr->expires < PJSIP_MIN_EXPIRES)
 1945|       |                hdr->expires = PJSIP_MIN_EXPIRES;
 1946|       |#endif
 1947|  5.75k|        } else {
 1948|  5.75k|            pjsip_param *p = PJ_POOL_ALLOC_T(pool, pjsip_param);
  ------------------
  |  |  569|  5.75k|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
 1949|  5.75k|            p->name = pname;
 1950|  5.75k|            p->value = pvalue;
 1951|  5.75k|            pj_list_insert_before(&hdr->other_param, p);
 1952|  5.75k|        }
 1953|  9.20k|    }
 1954|  5.27k|}
sip_parser.c:int_parse_param:
 1291|  13.7k|{
 1292|       |    /* Get ';' character */
 1293|  13.7k|    pj_scan_get_char(scanner);
 1294|       |
 1295|       |    /* Get pname and optionally pvalue */
 1296|  13.7k|    pjsip_parse_param_imp(scanner, pool, pname, pvalue, option);
 1297|  13.7k|}
sip_parser.c:pj_strtoul_mindigit:
  192|  1.42k|{
  193|  1.42k|    unsigned long value;
  194|  1.42k|    unsigned i;
  195|       |
  196|  1.42k|    value = 0;
  197|  3.74k|    for (i=0; i<(unsigned)str->slen; ++i) {
  ------------------
  |  Branch (197:15): [True: 2.32k, False: 1.42k]
  ------------------
  198|  2.32k|        value = value * 10 + (str->ptr[i] - '0');
  199|  2.32k|    }
  200|  3.36k|    for (; i<mindig; ++i) {
  ------------------
  |  Branch (200:12): [True: 1.94k, False: 1.42k]
  ------------------
  201|  1.94k|        value = value * 10;
  202|  1.94k|    }
  203|  1.42k|    return value;
  204|  1.42k|}
sip_parser.c:parse_hdr_content_len:
 1996|    950|{
 1997|    950|    pj_str_t digit;
 1998|    950|    pjsip_clen_hdr *hdr;
 1999|       |
 2000|    950|    hdr = pjsip_clen_hdr_create(ctx->pool);
 2001|    950|    pj_scan_get(ctx->scanner, &pconst.pjsip_DIGIT_SPEC, &digit);
 2002|    950|    strtoi_validate(&digit, PJSIP_MIN_CONTENT_LENGTH,
  ------------------
  |  |   43|    950|#define PJSIP_MIN_CONTENT_LENGTH    0           /**< For limit checks */
  ------------------
 2003|    950|                    PJSIP_MAX_CONTENT_LENGTH, &hdr->len);
  ------------------
  |  |   44|    950|#define PJSIP_MAX_CONTENT_LENGTH    PJ_MAXINT32 /**< For limit checks */
  |  |  ------------------
  |  |  |  |   30|    950|#define PJ_MAXINT32     0x7fffffff
  |  |  ------------------
  ------------------
 2004|    950|    parse_hdr_end(ctx->scanner);
 2005|       |
 2006|    950|    if (ctx->rdata)
  ------------------
  |  Branch (2006:9): [True: 0, False: 950]
  ------------------
 2007|      0|        ctx->rdata->msg_info.clen = hdr;
 2008|       |
 2009|    950|    return (pjsip_hdr*)hdr;
 2010|    950|}
sip_parser.c:parse_hdr_content_type:
 2014|  2.97k|{
 2015|  2.97k|    pjsip_ctype_hdr *hdr;
 2016|  2.97k|    pj_scanner *scanner = ctx->scanner;
 2017|       |
 2018|  2.97k|    hdr = pjsip_ctype_hdr_create(ctx->pool);
 2019|       |    
 2020|       |    /* Parse media type and subtype. */
 2021|  2.97k|    pj_scan_get(scanner, &pconst.pjsip_TOKEN_SPEC, &hdr->media.type);
 2022|  2.97k|    pj_scan_get_char(scanner);
 2023|  2.97k|    pj_scan_get(scanner, &pconst.pjsip_TOKEN_SPEC, &hdr->media.subtype);
 2024|       |
 2025|       |    /* Parse media parameters */
 2026|  4.12k|    while (*scanner->curptr == ';') {
  ------------------
  |  Branch (2026:12): [True: 1.15k, False: 2.97k]
  ------------------
 2027|  1.15k|        pjsip_param *param = PJ_POOL_ALLOC_T(ctx->pool, pjsip_param);
  ------------------
  |  |  569|  1.15k|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
 2028|  1.15k|        int_parse_param(scanner, ctx->pool, &param->name, &param->value, 0);
 2029|  1.15k|        pj_list_push_back(&hdr->media.param, param);
 2030|  1.15k|    }
 2031|       |
 2032|  2.97k|    parse_hdr_end(ctx->scanner);
 2033|       |
 2034|  2.97k|    if (ctx->rdata)
  ------------------
  |  Branch (2034:9): [True: 0, False: 2.97k]
  ------------------
 2035|      0|        ctx->rdata->msg_info.ctype = hdr;
 2036|       |
 2037|  2.97k|    return (pjsip_hdr*)hdr;
 2038|  2.97k|}
sip_parser.c:parse_hdr_cseq:
 2042|  1.87k|{
 2043|  1.87k|    pj_str_t cseq, method;
 2044|  1.87k|    pjsip_cseq_hdr *hdr = NULL;
 2045|  1.87k|    int cseq_val = 0;
 2046|       |
 2047|  1.87k|    pj_scan_get( ctx->scanner, &pconst.pjsip_DIGIT_SPEC, &cseq);
 2048|  1.87k|    strtoi_validate(&cseq, PJSIP_MIN_CSEQ, PJSIP_MAX_CSEQ, &cseq_val);
  ------------------
  |  |   55|  1.87k|#define PJSIP_MIN_CSEQ              0           /**< For limit checks */
  ------------------
                  strtoi_validate(&cseq, PJSIP_MIN_CSEQ, PJSIP_MAX_CSEQ, &cseq_val);
  ------------------
  |  |   56|  1.87k|#define PJSIP_MAX_CSEQ              PJ_MAXINT32 /**< For limit checks */
  |  |  ------------------
  |  |  |  |   30|  1.87k|#define PJ_MAXINT32     0x7fffffff
  |  |  ------------------
  ------------------
 2049|       |
 2050|  1.87k|    hdr = pjsip_cseq_hdr_create(ctx->pool);
 2051|  1.87k|    hdr->cseq = cseq_val;
 2052|       |
 2053|  1.87k|    pj_scan_get( ctx->scanner, &pconst.pjsip_TOKEN_SPEC, &method);
 2054|  1.87k|    parse_hdr_end( ctx->scanner );
 2055|       |
 2056|  1.87k|    pjsip_method_init_np(&hdr->method, &method);
 2057|  1.87k|    if (ctx->rdata) {
  ------------------
  |  Branch (2057:9): [True: 0, False: 1.87k]
  ------------------
 2058|      0|        ctx->rdata->msg_info.cseq = hdr;
 2059|      0|    }
 2060|       |
 2061|  1.87k|    return (pjsip_hdr*)hdr;
 2062|  1.87k|}
sip_parser.c:parse_hdr_expires:
 2066|    415|{
 2067|    415|    pjsip_expires_hdr *hdr = pjsip_expires_hdr_create(ctx->pool, 0);
 2068|    415|    parse_generic_int_hdr(hdr, ctx->scanner);
 2069|    415|    return (pjsip_hdr*)hdr;
 2070|    415|}
sip_parser.c:parse_generic_int_hdr:
 1863|    988|{
 1864|    988|    pj_str_t tmp;
 1865|    988|    pj_scan_get( scanner, &pconst.pjsip_DIGIT_SPEC, &tmp);
 1866|    988|    hdr->ivalue = pj_strtoul(&tmp);
 1867|    988|    parse_hdr_end(scanner);
 1868|    988|}
sip_parser.c:parse_hdr_from:
 2102|  2.50k|{
 2103|  2.50k|    pjsip_from_hdr *hdr = pjsip_from_hdr_create(ctx->pool);
 2104|  2.50k|    parse_hdr_fromto(ctx->scanner, ctx->pool, hdr);
 2105|  2.50k|    if (ctx->rdata)
  ------------------
  |  Branch (2105:9): [True: 0, False: 2.50k]
  ------------------
 2106|      0|        ctx->rdata->msg_info.from = hdr;
 2107|       |
 2108|  2.50k|    return (pjsip_hdr*)hdr;
 2109|  2.50k|}
sip_parser.c:parse_hdr_fromto:
 2076|  7.08k|{
 2077|  7.08k|    hdr->uri = int_parse_uri_or_name_addr(scanner, pool, 
 2078|  7.08k|                                          PJSIP_PARSE_URI_AS_NAMEADDR |
 2079|  7.08k|                                          PJSIP_PARSE_URI_IN_FROM_TO_HDR);
 2080|       |
 2081|  9.74k|    while ( *scanner->curptr == ';' ) {
  ------------------
  |  Branch (2081:13): [True: 2.65k, False: 7.08k]
  ------------------
 2082|  2.65k|        pj_str_t pname, pvalue;
 2083|       |
 2084|  2.65k|        int_parse_param( scanner, pool, &pname, &pvalue, 0);
 2085|       |
 2086|  2.65k|        if (!parser_stricmp(pname, pconst.pjsip_TAG_STR)) {
  ------------------
  |  |  207|  2.65k|#define parser_stricmp(s1, s2)  (s1.slen!=s2.slen || pj_stricmp_alnum(&s1, &s2))
  |  |  ------------------
  |  |  |  |  408|  1.03k|#define pj_stricmp_alnum    pj_stricmp
  |  |  ------------------
  |  |  |  Branch (207:34): [True: 1.62k, False: 1.03k]
  |  |  |  Branch (207:54): [True: 451, False: 580]
  |  |  ------------------
  ------------------
 2087|    580|            hdr->tag = pvalue;
 2088|       |            
 2089|  2.07k|        } else {
 2090|  2.07k|            pjsip_param *p = PJ_POOL_ALLOC_T(pool, pjsip_param);
  ------------------
  |  |  569|  2.07k|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
 2091|  2.07k|            p->name = pname;
 2092|  2.07k|            p->value = pvalue;
 2093|  2.07k|            pj_list_insert_before(&hdr->other_param, p);
 2094|  2.07k|        }
 2095|  2.65k|    }
 2096|       |
 2097|  7.08k|    parse_hdr_end(scanner);
 2098|  7.08k|}
sip_parser.c:parse_hdr_max_forwards:
 2260|    573|{
 2261|    573|    pjsip_max_fwd_hdr *hdr;
 2262|    573|    hdr = pjsip_max_fwd_hdr_create(ctx->pool, 0);
 2263|    573|    parse_generic_int_hdr(hdr, ctx->scanner);
 2264|       |
 2265|    573|    if (ctx->rdata)
  ------------------
  |  Branch (2265:9): [True: 0, False: 573]
  ------------------
 2266|      0|        ctx->rdata->msg_info.max_fwd = hdr;
 2267|       |
 2268|    573|    return (pjsip_hdr*)hdr;
 2269|    573|}
sip_parser.c:parse_hdr_rr_route:
 2284|  1.61k|{
 2285|  1.61k|    pjsip_name_addr *temp=int_parse_name_addr(scanner, pool);
 2286|       |
 2287|  1.61k|    pj_memcpy(&hdr->name_addr, temp, sizeof(*temp));
 2288|       |
 2289|  2.33k|    while (*scanner->curptr == ';') {
  ------------------
  |  Branch (2289:12): [True: 724, False: 1.61k]
  ------------------
 2290|    724|        pjsip_param *p = PJ_POOL_ALLOC_T(pool, pjsip_param);
  ------------------
  |  |  569|    724|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
 2291|    724|        int_parse_param(scanner, pool, &p->name, &p->value, 0);
 2292|    724|        pj_list_insert_before(&hdr->other_param, p);
 2293|    724|    }
 2294|  1.61k|}
sip_parser.c:int_parse_name_addr:
 1605|  13.0k|{
 1606|  13.0k|    int has_bracket;
 1607|  13.0k|    pjsip_name_addr *name_addr;
 1608|       |
 1609|  13.0k|    name_addr = pjsip_name_addr_create(pool);
 1610|       |
 1611|  13.0k|    if (*scanner->curptr == '"') {
  ------------------
  |  Branch (1611:9): [True: 826, False: 12.1k]
  ------------------
 1612|    826|        pj_scan_get_quote( scanner, '"', '"', &name_addr->display);
 1613|       |        /* Trim the leading and ending quote */
 1614|    826|        name_addr->display.ptr++;
 1615|    826|        name_addr->display.slen -= 2;
 1616|       |
 1617|  12.1k|    } else if (*scanner->curptr != '<') {
  ------------------
  |  Branch (1617:16): [True: 7.39k, False: 4.79k]
  ------------------
 1618|  7.39k|        int next;
 1619|  7.39k|        pj_str_t dummy;
 1620|       |
 1621|       |        /* This can be either the start of display name,
 1622|       |         * the start of URL ("sip:", "sips:", "tel:", etc.), or '<' char.
 1623|       |         * We're only interested in display name, because SIP URL
 1624|       |         * will be parser later.
 1625|       |         */
 1626|  7.39k|        next = pj_scan_peek(scanner, &pconst.pjsip_DISPLAY_SPEC, &dummy);
 1627|  7.39k|        if (next == '<') {
  ------------------
  |  Branch (1627:13): [True: 1.76k, False: 5.63k]
  ------------------
 1628|       |            /* Ok, this is what we're looking for, a display name. */
 1629|  1.76k|            pj_scan_get_until_ch( scanner, '<', &name_addr->display);
 1630|  1.76k|            pj_strtrim(&name_addr->display);
 1631|  1.76k|        }
 1632|  7.39k|    }
 1633|       |
 1634|       |    /* Manually skip whitespace. */
 1635|  13.0k|    pj_scan_skip_whitespace(scanner);
 1636|       |
 1637|       |    /* Get the SIP-URL */
 1638|  13.0k|    has_bracket = (*scanner->curptr == '<');
 1639|  13.0k|    if (has_bracket) {
  ------------------
  |  Branch (1639:9): [True: 6.55k, False: 6.45k]
  ------------------
 1640|  6.55k|        pj_scan_get_char(scanner);
 1641|  6.55k|    } else if (name_addr->display.slen) {
  ------------------
  |  Branch (1641:16): [True: 417, False: 6.03k]
  ------------------
 1642|       |        /* Must have bracket now (2012-10-26).
 1643|       |         * Allowing (invalid) name-addr to pass URI verification will
 1644|       |         * cause us to send invalid URI to the wire.
 1645|       |         */
 1646|    417|        PJ_THROW( PJSIP_SYN_ERR_EXCEPTION);
  ------------------
  |  |  402|    417|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
 1647|    417|    }
 1648|  12.5k|    name_addr->uri = int_parse_uri( scanner, pool, PJ_TRUE );
 1649|  12.5k|    if (has_bracket) {
  ------------------
  |  Branch (1649:9): [True: 5.17k, False: 7.41k]
  ------------------
 1650|  5.17k|        if (pj_scan_get_char(scanner) != '>')
  ------------------
  |  Branch (1650:13): [True: 1.74k, False: 3.43k]
  ------------------
 1651|  1.74k|            PJ_THROW( PJSIP_SYN_ERR_EXCEPTION);
  ------------------
  |  |  402|  1.74k|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
 1652|  5.17k|    }
 1653|       |
 1654|  10.8k|    return name_addr;
 1655|  12.5k|}
sip_parser.c:int_parse_uri:
 1468|  15.1k|{
 1469|       |    /* Bug:
 1470|       |     * This function should not call back int_parse_name_addr() because
 1471|       |     * it is called by that function. This would cause stack overflow
 1472|       |     * with PROTOS test #1223.
 1473|       |    if (*scanner->curptr=='"' || *scanner->curptr=='<') {
 1474|       |        return (pjsip_uri*)int_parse_name_addr( scanner, pool );
 1475|       |    } else {
 1476|       |    */
 1477|  15.1k|        pj_str_t scheme;
 1478|  15.1k|        int colon;
 1479|  15.1k|        pjsip_parse_uri_func *func;
 1480|       |
 1481|       |        /* Get scheme. */
 1482|  15.1k|        colon = pj_scan_peek(scanner, &pconst.pjsip_TOKEN_SPEC, &scheme);
 1483|  15.1k|        if (colon != ':') {
  ------------------
  |  Branch (1483:13): [True: 5.70k, False: 9.41k]
  ------------------
 1484|  5.70k|            PJ_THROW(PJSIP_SYN_ERR_EXCEPTION);
  ------------------
  |  |  402|  5.70k|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
 1485|  5.70k|        }
 1486|       |
 1487|  9.41k|        func = find_uri_handler(&scheme);
 1488|  9.41k|        if (func)  {
  ------------------
  |  Branch (1488:13): [True: 9.26k, False: 154]
  ------------------
 1489|  9.26k|            return (pjsip_uri*)(*func)(scanner, pool, parse_params);
 1490|       |
 1491|  9.26k|        } else {
 1492|       |            /* Unsupported URI scheme */
 1493|    154|            PJ_THROW(PJSIP_SYN_ERR_EXCEPTION);
  ------------------
  |  |  402|    154|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
 1494|    154|            UNREACHED({ return NULL; /* Not reached. */ })
 1495|    154|        }
 1496|       |
 1497|       |    /*
 1498|       |    }
 1499|       |    */
 1500|  9.41k|}
sip_parser.c:find_uri_handler:
  771|  17.8k|{
  772|  17.8k|    unsigned i;
  773|  38.3k|    for (i=0; i<uri_handler_count; ++i) {
  ------------------
  |  Branch (773:15): [True: 32.5k, False: 5.79k]
  ------------------
  774|  32.5k|        if (parser_stricmp(uri_handler[i].scheme, (*scheme))==0)
  ------------------
  |  |  207|  32.5k|#define parser_stricmp(s1, s2)  (s1.slen!=s2.slen || pj_stricmp_alnum(&s1, &s2))
  |  |  ------------------
  |  |  |  |  408|  15.6k|#define pj_stricmp_alnum    pj_stricmp
  |  |  ------------------
  |  |  |  Branch (207:34): [True: 16.8k, False: 15.6k]
  |  |  |  Branch (207:54): [True: 3.56k, False: 12.1k]
  |  |  ------------------
  ------------------
  |  Branch (774:13): [True: 12.1k, False: 20.4k]
  ------------------
  775|  12.1k|            return uri_handler[i].parse;
  776|  32.5k|    }
  777|  5.79k|    return &int_parse_other_uri;
  778|  17.8k|}
sip_parser.c:int_parse_other_uri:
 1662|  5.79k|{
 1663|  5.79k|    pjsip_other_uri *uri = 0;
 1664|  5.79k|    const pjsip_parser_const_t *pc = pjsip_parser_const();
 1665|  5.79k|    int skip_ws = scanner->skip_ws;
 1666|       |
 1667|  5.79k|    PJ_UNUSED_ARG(parse_params);
  ------------------
  |  | 1537|  5.79k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1668|       |
 1669|  5.79k|    scanner->skip_ws = 0;
 1670|       |    
 1671|  5.79k|    uri = pjsip_other_uri_create(pool); 
 1672|       |    
 1673|  5.79k|    pj_scan_get(scanner, &pc->pjsip_TOKEN_SPEC, &uri->scheme);
 1674|  5.79k|    if (pj_scan_get_char(scanner) != ':') {
  ------------------
  |  Branch (1674:9): [True: 604, False: 5.18k]
  ------------------
 1675|    604|        PJ_THROW(PJSIP_SYN_ERR_EXCEPTION);
  ------------------
  |  |  402|    604|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
 1676|    604|    }
 1677|       |    
 1678|  5.18k|    pj_scan_get(scanner, &pc->pjsip_OTHER_URI_CONTENT, &uri->content);
 1679|  5.18k|    scanner->skip_ws = skip_ws;
 1680|       |    
 1681|  5.18k|    return uri;
 1682|  5.79k|}
sip_parser.c:parse_hdr_route:
 2326|  1.30k|{
 2327|  1.30k|    pjsip_route_hdr *first = NULL;
 2328|  1.30k|    pj_scanner *scanner = ctx->scanner;
 2329|       |
 2330|  1.61k|    do {
 2331|  1.61k|        pjsip_route_hdr *hdr = pjsip_route_hdr_create(ctx->pool);
 2332|  1.61k|        if (!first) {
  ------------------
  |  Branch (2332:13): [True: 1.30k, False: 307]
  ------------------
 2333|  1.30k|            first = hdr;
 2334|  1.30k|        } else {
 2335|    307|            pj_list_insert_before(first, hdr);
 2336|    307|        }
 2337|  1.61k|        parse_hdr_rr_route(scanner, ctx->pool, hdr);
 2338|  1.61k|        if (*scanner->curptr == ',') {
  ------------------
  |  Branch (2338:13): [True: 307, False: 1.30k]
  ------------------
 2339|    307|            pj_scan_get_char(scanner);
 2340|  1.30k|        } else {
 2341|  1.30k|            break;
 2342|  1.30k|        }
 2343|  1.61k|    } while (1);
  ------------------
  |  Branch (2343:14): [True: 307, Folded]
  ------------------
 2344|  1.30k|    parse_hdr_end(scanner);
 2345|       |
 2346|  1.30k|    if (ctx->rdata && ctx->rdata->msg_info.route==NULL)
  ------------------
  |  Branch (2346:9): [True: 0, False: 1.30k]
  |  Branch (2346:23): [True: 0, False: 0]
  ------------------
 2347|      0|        ctx->rdata->msg_info.route = first;
 2348|       |
 2349|  1.30k|    return (pjsip_hdr*)first;
 2350|  1.30k|}
sip_parser.c:parse_hdr_supported:
 2167|  12.1k|{
 2168|  12.1k|    pjsip_supported_hdr *hdr;
 2169|  12.1k|    pj_bool_t new_hdr = (ctx->rdata==NULL || 
  ------------------
  |  Branch (2169:26): [True: 12.1k, False: 0]
  ------------------
 2170|      0|                         ctx->rdata->msg_info.supported == NULL);
  ------------------
  |  Branch (2170:26): [True: 0, False: 0]
  ------------------
 2171|       |
 2172|  12.1k|    if (ctx->rdata && ctx->rdata->msg_info.supported) {
  ------------------
  |  Branch (2172:9): [True: 0, False: 12.1k]
  |  Branch (2172:23): [True: 0, False: 0]
  ------------------
 2173|      0|        hdr = ctx->rdata->msg_info.supported;
 2174|  12.1k|    } else {
 2175|  12.1k|        hdr = pjsip_supported_hdr_create(ctx->pool);
 2176|  12.1k|        if (ctx->rdata)
  ------------------
  |  Branch (2176:13): [True: 0, False: 12.1k]
  ------------------
 2177|      0|            ctx->rdata->msg_info.supported = hdr;
 2178|  12.1k|    }
 2179|       |
 2180|  12.1k|    parse_generic_array_hdr(hdr, ctx->scanner);
 2181|  12.1k|    return new_hdr ? (pjsip_hdr*)hdr : NULL;
  ------------------
  |  Branch (2181:12): [True: 11.8k, False: 281]
  ------------------
 2182|  12.1k|}
sip_parser.c:parse_hdr_to:
 2186|  4.58k|{
 2187|  4.58k|    pjsip_to_hdr *hdr = pjsip_to_hdr_create(ctx->pool);
 2188|  4.58k|    parse_hdr_fromto(ctx->scanner, ctx->pool, hdr);
 2189|       |
 2190|  4.58k|    if (ctx->rdata)
  ------------------
  |  Branch (2190:9): [True: 0, False: 4.58k]
  ------------------
 2191|      0|        ctx->rdata->msg_info.to = hdr;
 2192|       |
 2193|  4.58k|    return (pjsip_hdr*)hdr;
 2194|  4.58k|}
sip_parser.c:parse_hdr_via:
 2354|  19.7k|{
 2355|  19.7k|    pjsip_via_hdr *first = NULL;
 2356|  19.7k|    pj_scanner *scanner = ctx->scanner;
 2357|       |
 2358|  20.0k|    do {
 2359|  20.0k|        pjsip_via_hdr *hdr = pjsip_via_hdr_create(ctx->pool);
 2360|  20.0k|        if (!first)
  ------------------
  |  Branch (2360:13): [True: 19.7k, False: 266]
  ------------------
 2361|  19.7k|            first = hdr;
 2362|    266|        else
 2363|    266|            pj_list_insert_before(first, hdr);
 2364|       |
 2365|  20.0k|        parse_sip_version(scanner);
 2366|  20.0k|        if (pj_scan_get_char(scanner) != '/')
  ------------------
  |  Branch (2366:13): [True: 286, False: 19.7k]
  ------------------
 2367|    286|            on_syntax_error(scanner);
 2368|       |
 2369|  20.0k|        pj_scan_get( scanner, &pconst.pjsip_TOKEN_SPEC, &hdr->transport);
 2370|  20.0k|        int_parse_host(scanner, &hdr->sent_by.host);
 2371|       |
 2372|  20.0k|        if (*scanner->curptr==':') {
  ------------------
  |  Branch (2372:13): [True: 354, False: 19.6k]
  ------------------
 2373|    354|            pj_str_t digit;
 2374|    354|            pj_scan_get_char(scanner);
 2375|    354|            pj_scan_get(scanner, &pconst.pjsip_DIGIT_SPEC, &digit);
 2376|    354|            strtoi_validate(&digit, PJSIP_MIN_PORT, PJSIP_MAX_PORT,
  ------------------
  |  |   45|    354|#define PJSIP_MIN_PORT              0           /**< For limit checks */
  ------------------
                          strtoi_validate(&digit, PJSIP_MIN_PORT, PJSIP_MAX_PORT,
  ------------------
  |  |   46|    354|#define PJSIP_MAX_PORT              PJ_MAXUINT16/**< For limit checks */
  |  |  ------------------
  |  |  |  |   36|    354|#define PJ_MAXUINT16    0xffff
  |  |  ------------------
  ------------------
 2377|    354|                            &hdr->sent_by.port);
 2378|    354|        }
 2379|       |        
 2380|  20.0k|        int_parse_via_param(hdr, scanner, ctx->pool);
 2381|       |
 2382|  20.0k|        if (*scanner->curptr == '(') {
  ------------------
  |  Branch (2382:13): [True: 387, False: 19.6k]
  ------------------
 2383|    387|            pj_scan_get_char(scanner);
 2384|    387|            pj_scan_get_until_ch( scanner, ')', &hdr->comment);
 2385|    387|            pj_scan_get_char( scanner );
 2386|    387|        }
 2387|       |
 2388|  20.0k|        if (*scanner->curptr != ',')
  ------------------
  |  Branch (2388:13): [True: 3.54k, False: 16.4k]
  ------------------
 2389|  3.54k|            break;
 2390|       |
 2391|  16.4k|        pj_scan_get_char(scanner);
 2392|       |
 2393|  16.4k|    } while (1);
  ------------------
  |  Branch (2393:14): [True: 266, Folded]
  ------------------
 2394|       |
 2395|  19.7k|    parse_hdr_end(scanner);
 2396|       |
 2397|  19.7k|    if (ctx->rdata && ctx->rdata->msg_info.via == NULL)
  ------------------
  |  Branch (2397:9): [True: 0, False: 19.7k]
  |  Branch (2397:23): [True: 0, False: 0]
  ------------------
 2398|      0|        ctx->rdata->msg_info.via = first;
 2399|       |
 2400|  19.7k|    return (pjsip_hdr*)first;
 2401|  19.7k|}
sip_parser.c:parse_sip_version:
  990|  24.3k|{
  991|  24.3k|    pj_str_t SIP = { "SIP", 3 };
  992|  24.3k|    pj_str_t V2 = { "2.0", 3 };
  993|  24.3k|    pj_str_t sip, version;
  994|       |
  995|  24.3k|    pj_scan_get( scanner, &pconst.pjsip_ALPHA_SPEC, &sip);
  996|  24.3k|    if (pj_scan_get_char(scanner) != '/')
  ------------------
  |  Branch (996:9): [True: 892, False: 23.4k]
  ------------------
  997|    892|        on_syntax_error(scanner);
  998|  24.3k|    pj_scan_get_n( scanner, 3, &version);
  999|  24.3k|    if (pj_stricmp(&sip, &SIP) || pj_stricmp(&version, &V2))
  ------------------
  |  Branch (999:9): [True: 14.1k, False: 10.1k]
  |  Branch (999:35): [True: 820, False: 9.37k]
  ------------------
 1000|  1.53k|        on_syntax_error(scanner);
 1001|  24.3k|}
sip_parser.c:int_parse_via_param:
 2207|  4.42k|{
 2208|  16.2k|    while ( *scanner->curptr == ';' ) {
  ------------------
  |  Branch (2208:13): [True: 11.7k, False: 4.42k]
  ------------------
 2209|  11.7k|        pj_str_t pname, pvalue;
 2210|       |
 2211|       |        //Parse with PARAM_CHAR instead, to allow IPv6
 2212|       |        //No, back to using int_parse_param() for the "`" character!
 2213|       |        //int_parse_param( scanner, pool, &pname, &pvalue, 0);
 2214|       |        //parse_param_imp(scanner, pool, &pname, &pvalue, 
 2215|       |        //              &pconst.pjsip_TOKEN_SPEC,
 2216|       |        //              &pconst.pjsip_TOKEN_SPEC_ESC, 0);
 2217|       |        //int_parse_param(scanner, pool, &pname, &pvalue, 0);
 2218|       |        // This should be the correct one:
 2219|       |        //  added special spec for Via parameter, basically token plus
 2220|       |        //  ":" to allow IPv6 address in the received param.
 2221|  11.7k|        pj_scan_get_char(scanner);
 2222|  11.7k|        parse_param_imp(scanner, pool, &pname, &pvalue,
 2223|  11.7k|                        &pconst.pjsip_VIA_PARAM_SPEC,
 2224|       |                        // Token does not need to be unescaped.
 2225|       |                        // Refer to PR #2933.
 2226|       |                        // &pconst.pjsip_VIA_PARAM_SPEC_ESC,
 2227|  11.7k|                        NULL,
 2228|  11.7k|                        0);
 2229|       |
 2230|  11.7k|        if (!parser_stricmp(pname, pconst.pjsip_BRANCH_STR) && pvalue.slen) {
  ------------------
  |  |  207|  23.5k|#define parser_stricmp(s1, s2)  (s1.slen!=s2.slen || pj_stricmp_alnum(&s1, &s2))
  |  |  ------------------
  |  |  |  |  408|  1.31k|#define pj_stricmp_alnum    pj_stricmp
  |  |  ------------------
  |  |  |  Branch (207:34): [True: 10.4k, False: 1.31k]
  |  |  |  Branch (207:54): [True: 615, False: 703]
  |  |  ------------------
  ------------------
  |  Branch (2230:64): [True: 429, False: 274]
  ------------------
 2231|    429|            hdr->branch_param = pvalue;
 2232|       |
 2233|  11.3k|        } else if (!parser_stricmp(pname, pconst.pjsip_TTL_STR) && pvalue.slen) {
  ------------------
  |  |  207|  22.7k|#define parser_stricmp(s1, s2)  (s1.slen!=s2.slen || pj_stricmp_alnum(&s1, &s2))
  |  |  ------------------
  |  |  |  |  408|  2.51k|#define pj_stricmp_alnum    pj_stricmp
  |  |  ------------------
  |  |  |  Branch (207:34): [True: 8.84k, False: 2.51k]
  |  |  |  Branch (207:54): [True: 1.53k, False: 979]
  |  |  ------------------
  ------------------
  |  Branch (2233:68): [True: 636, False: 343]
  ------------------
 2234|    636|            strtoi_validate(&pvalue, PJSIP_MIN_TTL, PJSIP_MAX_TTL,
  ------------------
  |  |   47|    636|#define PJSIP_MIN_TTL               0           /**< For limit checks */
  ------------------
                          strtoi_validate(&pvalue, PJSIP_MIN_TTL, PJSIP_MAX_TTL,
  ------------------
  |  |   48|    636|#define PJSIP_MAX_TTL               PJ_MAXUINT8 /**< For limit checks */
  |  |  ------------------
  |  |  |  |   39|    636|#define PJ_MAXUINT8     0xff
  |  |  ------------------
  ------------------
 2235|    636|                            &hdr->ttl_param);
 2236|       |            
 2237|  10.7k|        } else if (!parser_stricmp(pname, pconst.pjsip_MADDR_STR) && pvalue.slen) {
  ------------------
  |  |  207|  21.4k|#define parser_stricmp(s1, s2)  (s1.slen!=s2.slen || pj_stricmp_alnum(&s1, &s2))
  |  |  ------------------
  |  |  |  |  408|  2.00k|#define pj_stricmp_alnum    pj_stricmp
  |  |  ------------------
  |  |  |  Branch (207:34): [True: 8.71k, False: 2.00k]
  |  |  |  Branch (207:54): [True: 1.55k, False: 454]
  |  |  ------------------
  ------------------
  |  Branch (2237:70): [True: 248, False: 206]
  ------------------
 2238|    248|            hdr->maddr_param = pvalue;
 2239|       |
 2240|  10.4k|        } else if (!parser_stricmp(pname, pconst.pjsip_RECEIVED_STR) && pvalue.slen) {
  ------------------
  |  |  207|  20.9k|#define parser_stricmp(s1, s2)  (s1.slen!=s2.slen || pj_stricmp_alnum(&s1, &s2))
  |  |  ------------------
  |  |  |  |  408|    897|#define pj_stricmp_alnum    pj_stricmp
  |  |  ------------------
  |  |  |  Branch (207:34): [True: 9.57k, False: 897]
  |  |  |  Branch (207:54): [True: 357, False: 540]
  |  |  ------------------
  ------------------
  |  Branch (2240:73): [True: 232, False: 308]
  ------------------
 2241|    232|            hdr->recvd_param = pvalue;
 2242|       |
 2243|  10.2k|        } else if (!parser_stricmp(pname, pconst.pjsip_RPORT_STR)) {
  ------------------
  |  |  207|  10.2k|#define parser_stricmp(s1, s2)  (s1.slen!=s2.slen || pj_stricmp_alnum(&s1, &s2))
  |  |  ------------------
  |  |  |  |  408|  1.76k|#define pj_stricmp_alnum    pj_stricmp
  |  |  ------------------
  |  |  |  Branch (207:34): [True: 8.47k, False: 1.76k]
  |  |  |  Branch (207:54): [True: 1.18k, False: 575]
  |  |  ------------------
  ------------------
 2244|    575|            if (pvalue.slen) {
  ------------------
  |  Branch (2244:17): [True: 327, False: 248]
  ------------------
 2245|    327|                strtoi_validate(&pvalue, PJSIP_MIN_PORT, PJSIP_MAX_PORT,
  ------------------
  |  |   45|    327|#define PJSIP_MIN_PORT              0           /**< For limit checks */
  ------------------
                              strtoi_validate(&pvalue, PJSIP_MIN_PORT, PJSIP_MAX_PORT,
  ------------------
  |  |   46|    327|#define PJSIP_MAX_PORT              PJ_MAXUINT16/**< For limit checks */
  |  |  ------------------
  |  |  |  |   36|    327|#define PJ_MAXUINT16    0xffff
  |  |  ------------------
  ------------------
 2246|    327|                                &hdr->rport_param);
 2247|    327|            } else
 2248|    248|                hdr->rport_param = 0;
 2249|  9.66k|        } else {
 2250|  9.66k|            pjsip_param *p = PJ_POOL_ALLOC_T(pool, pjsip_param);
  ------------------
  |  |  569|  9.66k|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
 2251|  9.66k|            p->name = pname;
 2252|  9.66k|            p->value = pvalue;
 2253|  9.66k|            pj_list_insert_before(&hdr->other_param, p);
 2254|  9.66k|        }
 2255|  11.7k|    }
 2256|  4.42k|}
sip_parser.c:int_register_parser:
  610|    108|{
  611|    108|    unsigned    pos;
  612|    108|    handler_rec rec;
  613|       |
  614|    108|    if (handler_count >= PJ_ARRAY_SIZE(handler)) {
  ------------------
  |  |  315|    108|#define PJ_ARRAY_SIZE(a)    (sizeof(a)/sizeof(a[0]))
  ------------------
  |  Branch (614:9): [True: 0, False: 108]
  ------------------
  615|      0|        pj_assert(!"Too many handlers!");
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (615:9): [Folded, False: 0]
  |  Branch (615:9): [Folded, False: 0]
  ------------------
  616|      0|        return PJ_ETOOMANY;
  ------------------
  |  |  423|      0|#define PJ_ETOOMANY         (PJ_ERRNO_START_STATUS + 10)/* 70010 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  617|      0|    }
  618|       |
  619|       |    /* Initialize temporary handler. */
  620|    108|    rec.handler = fptr;
  621|    108|    rec.hname_len = strlen(name);
  622|    108|    if (rec.hname_len >= sizeof(rec.hname)) {
  ------------------
  |  Branch (622:9): [True: 0, False: 108]
  ------------------
  623|      0|        pj_assert(!"Header name is too long!");
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (623:9): [Folded, False: 0]
  |  Branch (623:9): [Folded, False: 0]
  ------------------
  624|      0|        return PJ_ENAMETOOLONG;
  ------------------
  |  |  398|      0|#define PJ_ENAMETOOLONG     (PJ_ERRNO_START_STATUS + 5) /* 70005 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  625|      0|    }
  626|       |    /* Copy name. */
  627|    108|    pj_memcpy(rec.hname, name, rec.hname_len);
  628|    108|    rec.hname[rec.hname_len] = '\0';
  629|       |
  630|       |    /* Calculate hash value. */
  631|    108|    rec.hname_hash = pj_hash_calc(0, rec.hname, (unsigned)rec.hname_len);
  632|       |
  633|       |    /* Get the pos to insert the new handler. */
  634|  1.54k|    for (pos=0; pos < handler_count; ++pos) {
  ------------------
  |  Branch (634:17): [True: 1.54k, False: 6]
  ------------------
  635|  1.54k|        int d;
  636|  1.54k|        d = compare_handler(&handler[pos], rec.hname, rec.hname_len, 
  637|  1.54k|                            rec.hname_hash);
  638|  1.54k|        if (d == 0) {
  ------------------
  |  Branch (638:13): [True: 0, False: 1.54k]
  ------------------
  639|      0|            pj_assert(0);
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (639:13): [Folded, False: 0]
  |  Branch (639:13): [Folded, False: 0]
  ------------------
  640|      0|            return PJ_EEXISTS;
  ------------------
  |  |  448|      0|#define PJ_EEXISTS          (PJ_ERRNO_START_STATUS + 15)/* 70015 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  641|      0|        }
  642|  1.54k|        if (d > 0) {
  ------------------
  |  Branch (642:13): [True: 102, False: 1.43k]
  ------------------
  643|    102|            break;
  644|    102|        }
  645|  1.54k|    }
  646|       |
  647|       |    /* Shift handlers. */
  648|    108|    if (pos != handler_count) {
  ------------------
  |  Branch (648:9): [True: 102, False: 6]
  ------------------
  649|    102|        pj_memmove( &handler[pos+1], &handler[pos], 
  650|    102|                    (handler_count-pos)*sizeof(handler_rec));
  651|    102|    }
  652|       |    /* Add new handler. */
  653|    108|    pj_memcpy( &handler[pos], &rec, sizeof(handler_rec));
  654|    108|    ++handler_count;
  655|       |
  656|    108|    return PJ_SUCCESS;
  657|    108|}
sip_parser.c:compare_handler:
  588|   506k|{
  589|   506k|    PJ_UNUSED_ARG(name_len);
  ------------------
  |  | 1537|   506k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  590|       |
  591|       |    /* Compare hashed value. */
  592|   506k|    if (r1->hname_hash < hash)
  ------------------
  |  Branch (592:9): [True: 66.2k, False: 440k]
  ------------------
  593|  66.2k|        return -1;
  594|   440k|    if (r1->hname_hash > hash)
  ------------------
  |  Branch (594:9): [True: 383k, False: 56.5k]
  ------------------
  595|   383k|        return 1;
  596|       |
  597|       |    /* Compare length. */
  598|  56.5k|    if (r1->hname_len < name_len)
  ------------------
  |  Branch (598:9): [True: 3, False: 56.5k]
  ------------------
  599|      3|        return -1;
  600|  56.5k|    if (r1->hname_len > name_len)
  ------------------
  |  Branch (600:9): [True: 0, False: 56.5k]
  ------------------
  601|      0|        return 1;
  602|       |
  603|       |    /* Equal length and equal hash. compare the strings. */
  604|  56.5k|    return pj_memcmp(r1->hname, name, name_len);
  605|  56.5k|}
sip_parser.c:on_syntax_error:
  228|  32.1k|{
  229|  32.1k|    PJ_UNUSED_ARG(scanner);
  ------------------
  |  | 1537|  32.1k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  230|  32.1k|    PJ_THROW(PJSIP_SYN_ERR_EXCEPTION);
  ------------------
  |  |  402|  32.1k|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
  231|  32.1k|}
sip_parser.c:strtoi_validate:
  264|  10.6k|{ 
  265|  10.6k|    long retval;
  266|  10.6k|    pj_status_t status;
  267|       |
  268|  10.6k|    if (!str || !value) {
  ------------------
  |  Branch (268:9): [True: 0, False: 10.6k]
  |  Branch (268:17): [True: 0, False: 10.6k]
  ------------------
  269|      0|        on_str_parse_error(str, PJ_EINVAL);
  ------------------
  |  |  393|      0|#define PJ_EINVAL           (PJ_ERRNO_START_STATUS + 4) /* 70004 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  270|      0|        return;
  271|      0|    }
  272|  10.6k|    status = pj_strtol2(str, &retval);
  273|  10.6k|    if (status != PJ_EINVAL) {
  ------------------
  |  |  393|  10.6k|#define PJ_EINVAL           (PJ_ERRNO_START_STATUS + 4) /* 70004 */
  |  |  ------------------
  |  |  |  |  521|  10.6k|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|  10.6k|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|  10.6k|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (273:9): [True: 9.69k, False: 960]
  ------------------
  274|  9.69k|        if (min_val > retval) {
  ------------------
  |  Branch (274:13): [True: 486, False: 9.20k]
  ------------------
  275|    486|            *value = min_val;
  276|    486|            status = PJ_ETOOSMALL;
  ------------------
  |  |  469|    486|#define PJ_ETOOSMALL        (PJ_ERRNO_START_STATUS + 19)/* 70019 */
  |  |  ------------------
  |  |  |  |  521|    486|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|    486|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|    486|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  277|  9.20k|        } else if (retval > max_val) {
  ------------------
  |  Branch (277:20): [True: 879, False: 8.32k]
  ------------------
  278|    879|            *value = max_val;
  279|    879|            status = PJ_ETOOBIG;
  ------------------
  |  |  458|    879|#define PJ_ETOOBIG          (PJ_ERRNO_START_STATUS + 17)/* 70017 */
  |  |  ------------------
  |  |  |  |  521|    879|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|    879|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|    879|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  280|    879|        } else
  281|  8.32k|            *value = (int)retval;
  282|  9.69k|    }
  283|       |
  284|  10.6k|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (284:9): [True: 2.32k, False: 8.32k]
  ------------------
  285|  2.32k|        on_str_parse_error(str, status);
  286|  10.6k|}
sip_parser.c:on_str_parse_error:
  235|  2.32k|{
  236|  2.32k|    char *s;
  237|       |
  238|  2.32k|    switch(rc) {
  239|    960|    case PJ_EINVAL:
  ------------------
  |  |  393|    960|#define PJ_EINVAL           (PJ_ERRNO_START_STATUS + 4) /* 70004 */
  |  |  ------------------
  |  |  |  |  521|    960|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|    960|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|    960|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (239:5): [True: 960, False: 1.36k]
  ------------------
  240|    960|        s = "NULL input string, invalid input string, or NULL return "\
  241|    960|            "value pointer";
  242|    960|        break;
  243|    486|    case PJ_ETOOSMALL:
  ------------------
  |  |  469|    486|#define PJ_ETOOSMALL        (PJ_ERRNO_START_STATUS + 19)/* 70019 */
  |  |  ------------------
  |  |  |  |  521|    486|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|    486|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|    486|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (243:5): [True: 486, False: 1.83k]
  ------------------
  244|    486|        s = "String value was less than the minimum allowed value.";
  245|    486|        break;
  246|    879|    case PJ_ETOOBIG:
  ------------------
  |  |  458|    879|#define PJ_ETOOBIG          (PJ_ERRNO_START_STATUS + 17)/* 70017 */
  |  |  ------------------
  |  |  |  |  521|    879|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|    879|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|    879|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (246:5): [True: 879, False: 1.44k]
  ------------------
  247|    879|        s = "String value was greater than the maximum allowed value.";
  248|    879|        break;
  249|      0|    default:
  ------------------
  |  Branch (249:5): [True: 0, False: 2.32k]
  ------------------
  250|      0|        s = "Unknown error";
  251|  2.32k|    }
  252|       |
  253|  2.32k|    if (str) {
  ------------------
  |  Branch (253:9): [True: 2.32k, False: 0]
  ------------------
  254|  2.32k|        PJ_LOG(1, (THIS_FILE, "Error parsing '%.*s': %s",
  ------------------
  |  |  106|  2.32k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  2.32k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  4.65k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 2.32k, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 2.32k]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  432|      0|    #define pj_log_wrapper_1(arg)       pj_log_1 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|  2.32k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 2.32k]
  |  |  ------------------
  ------------------
  255|  2.32k|                   (int)str->slen, str->ptr, s));
  256|  2.32k|    } else {
  257|      0|        PJ_LOG(1, (THIS_FILE, "Can't parse input string: %s", s));
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  432|      0|    #define pj_log_wrapper_1(arg)       pj_log_1 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  258|      0|    }
  259|  2.32k|    PJ_THROW(PJSIP_EINVAL_ERR_EXCEPTION);
  ------------------
  |  |  402|  2.32k|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
  260|  2.32k|}
sip_parser.c:int_parse_msg:
 1021|  5.40k|{
 1022|       |    /* These variables require "volatile" so their values get
 1023|       |     * preserved when re-entering the PJ_TRY block after an error.
 1024|       |     */
 1025|  5.40k|    volatile pj_bool_t parsing_headers;
 1026|  5.40k|    pjsip_msg *volatile msg = NULL;
 1027|  5.40k|    pjsip_ctype_hdr *volatile ctype_hdr = NULL;
 1028|       |
 1029|  5.40k|    pj_str_t hname;
 1030|  5.40k|    pj_scanner *scanner = ctx->scanner;
 1031|  5.40k|    pj_pool_t *pool = ctx->pool;
 1032|  5.40k|    PJ_USE_EXCEPTION;
  ------------------
  |  |  367|  5.40k|#define PJ_USE_EXCEPTION    struct pj_exception_state_t pj_x_except__; int pj_x_code__
  ------------------
 1033|       |
 1034|  5.40k|    parsing_headers = PJ_FALSE;
 1035|       |
 1036|  41.3k|retry_parse:
 1037|  41.3k|    PJ_TRY 
  ------------------
  |  |  373|  41.3k|#define PJ_TRY              if (1) { \
  |  |  ------------------
  |  |  |  Branch (373:33): [True: 41.3k, Folded]
  |  |  ------------------
  |  |  374|  41.3k|                                pj_push_exception_handler_(&pj_x_except__); \
  |  |  375|  41.3k|                                pj_x_code__ = pj_setjmp(pj_x_except__.state); \
  |  |  ------------------
  |  |  |  |   31|  41.3k|#    define pj_setjmp(buf)      setjmp(buf)
  |  |  ------------------
  |  |  376|  41.3k|                                if (pj_x_code__ == 0)
  |  |  ------------------
  |  |  |  Branch (376:37): [True: 41.3k, False: 0]
  |  |  ------------------
  ------------------
 1038|  41.3k|    {
 1039|  41.3k|        if (parsing_headers)
  ------------------
  |  Branch (1039:13): [True: 35.9k, False: 5.40k]
  ------------------
 1040|  35.9k|            goto parse_headers;
 1041|       |
 1042|       |        /* Skip leading newlines. */
 1043|  6.43k|        while (IS_NEWLINE(*scanner->curptr)) {
  ------------------
  |  |   62|  6.43k|#define IS_NEWLINE(c)   ((c)=='\r' || (c)=='\n')
  |  |  ------------------
  |  |  |  Branch (62:26): [True: 576, False: 5.85k]
  |  |  |  Branch (62:39): [True: 453, False: 5.40k]
  |  |  ------------------
  ------------------
 1044|  1.02k|            pj_scan_get_newline(scanner);
 1045|  1.02k|        }
 1046|       |
 1047|       |        /* Check if we still have valid packet.
 1048|       |         * Sometimes endpoints just send blank (CRLF) packets just to keep
 1049|       |         * NAT bindings open.
 1050|       |         */
 1051|  5.40k|        if (pj_scan_is_eof(scanner))
  ------------------
  |  Branch (1051:13): [True: 44, False: 5.35k]
  ------------------
 1052|     44|            return NULL;
 1053|       |
 1054|       |        /* Parse request or status line */
 1055|  5.35k|        if (is_next_sip_version(scanner)) {
  ------------------
  |  Branch (1055:13): [True: 2.33k, False: 3.02k]
  ------------------
 1056|  2.33k|            msg = pjsip_msg_create(pool, PJSIP_RESPONSE_MSG);
 1057|  2.33k|            int_parse_status_line( scanner, &msg->line.status );
 1058|  3.02k|        } else {
 1059|  3.02k|            msg = pjsip_msg_create(pool, PJSIP_REQUEST_MSG);
 1060|  3.02k|            int_parse_req_line(scanner, pool, &msg->line.req );
 1061|  3.02k|        }
 1062|       |
 1063|  5.35k|        parsing_headers = PJ_TRUE;
 1064|       |
 1065|  39.3k|parse_headers:
 1066|       |        /* Parse headers. */
 1067|  64.1k|        do {
 1068|  64.1k|            pjsip_parse_hdr_func * func;
 1069|  64.1k|            pjsip_hdr *hdr = NULL;
 1070|       |
 1071|       |            /* Init hname just in case parsing fails.
 1072|       |             * Ref: PROTOS #2412
 1073|       |             */
 1074|  64.1k|            hname.slen = 0;
 1075|       |            
 1076|       |            /* Get hname. */
 1077|  64.1k|            pj_scan_get( scanner, &pconst.pjsip_TOKEN_SPEC, &hname);
 1078|  64.1k|            if (pj_scan_get_char( scanner ) != ':') {
  ------------------
  |  Branch (1078:17): [True: 4.95k, False: 59.2k]
  ------------------
 1079|  4.95k|                PJ_THROW(PJSIP_SYN_ERR_EXCEPTION);
  ------------------
  |  |  402|  4.95k|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
 1080|  4.95k|            }
 1081|       |            
 1082|       |            /* Find handler. */
 1083|  59.2k|            func = find_handler(&hname);
 1084|       |            
 1085|       |            /* Call the handler if found.
 1086|       |             * If no handler is found, then treat the header as generic
 1087|       |             * hname/hvalue pair.
 1088|       |             */
 1089|  59.2k|            if (func) {
  ------------------
  |  Branch (1089:17): [True: 50.1k, False: 9.10k]
  ------------------
 1090|  50.1k|                hdr = (*func)(ctx);
 1091|       |
 1092|       |                /* Note:
 1093|       |                 *  hdr MAY BE NULL, if parsing does not yield a new header
 1094|       |                 *  instance, e.g. the values have been added to existing
 1095|       |                 *  header. See https://github.com/pjsip/pjproject/issues/940
 1096|       |                 */
 1097|       |
 1098|       |                /* Check if we've just parsed a Content-Type header. 
 1099|       |                 * We will check for a message body if we've got Content-Type 
 1100|       |                 * header.
 1101|       |                 */
 1102|  50.1k|                if (hdr && hdr->type == PJSIP_H_CONTENT_TYPE) {
  ------------------
  |  Branch (1102:21): [True: 23.0k, False: 27.0k]
  |  Branch (1102:28): [True: 1.48k, False: 21.5k]
  ------------------
 1103|  1.48k|                    ctype_hdr = (pjsip_ctype_hdr*)hdr;
 1104|  1.48k|                }
 1105|       |
 1106|  50.1k|            } else {
 1107|  9.10k|                hdr = parse_hdr_generic_string(ctx);
 1108|  9.10k|                hdr->name = hdr->sname = hname;
 1109|  9.10k|            }
 1110|       |            
 1111|       |            /* Single parse of header line can produce multiple headers.
 1112|       |             * For example, if one Contact: header contains Contact list
 1113|       |             * separated by comma, then these Contacts will be split into
 1114|       |             * different Contact headers.
 1115|       |             * So here we must insert list instead of just insert one header.
 1116|       |             */
 1117|  59.2k|            if (hdr)
  ------------------
  |  Branch (1117:17): [True: 27.0k, False: 32.1k]
  ------------------
 1118|  27.0k|                pj_list_insert_nodes_before(&msg->hdr, hdr);
 1119|       |            
 1120|       |            /* Parse until EOF or an empty line is found. */
 1121|  59.2k|        } while (!pj_scan_is_eof(scanner) && !IS_NEWLINE(*scanner->curptr));
  ------------------
  |  |   62|  25.5k|#define IS_NEWLINE(c)   ((c)=='\r' || (c)=='\n')
  |  |  ------------------
  |  |  |  Branch (62:26): [True: 597, False: 25.0k]
  |  |  |  Branch (62:39): [True: 159, False: 24.8k]
  |  |  ------------------
  ------------------
  |  Branch (1121:18): [True: 25.5k, False: 33.6k]
  ------------------
 1122|       |        
 1123|  34.3k|        parsing_headers = PJ_FALSE;
 1124|       |
 1125|       |        /* If empty line is found, eat it. */
 1126|  34.3k|        if (!pj_scan_is_eof(scanner)) {
  ------------------
  |  Branch (1126:13): [True: 756, False: 33.6k]
  ------------------
 1127|    756|            if (IS_NEWLINE(*scanner->curptr)) {
  ------------------
  |  |   62|    756|#define IS_NEWLINE(c)   ((c)=='\r' || (c)=='\n')
  |  |  ------------------
  |  |  |  Branch (62:26): [True: 597, False: 159]
  |  |  |  Branch (62:39): [True: 159, False: 0]
  |  |  ------------------
  ------------------
 1128|    756|                pj_scan_get_newline(scanner);
 1129|    756|            }
 1130|    756|        }
 1131|       |
 1132|       |        /* If we have Content-Type header, treat the rest of the message 
 1133|       |         * as body.
 1134|       |         */
 1135|  34.3k|        if (ctype_hdr && scanner->curptr!=scanner->end) {
  ------------------
  |  Branch (1135:13): [True: 744, False: 33.6k]
  |  Branch (1135:26): [True: 719, False: 25]
  ------------------
 1136|       |            /* New: if Content-Type indicates that this is a multipart
 1137|       |             * message body, parse it.
 1138|       |             */
 1139|    719|            const pj_str_t STR_MULTIPART = { "multipart", 9 };
 1140|    719|            pjsip_msg_body *body;
 1141|       |
 1142|    719|            if (pj_stricmp(&ctype_hdr->media.type, &STR_MULTIPART)==0) {
  ------------------
  |  Branch (1142:17): [True: 701, False: 18]
  ------------------
 1143|    701|                body = pjsip_multipart_parse(pool, scanner->curptr,
 1144|    701|                                             scanner->end - scanner->curptr,
 1145|    701|                                             &ctype_hdr->media, 0);
 1146|    701|            } else {
 1147|     18|                body = PJ_POOL_ALLOC_T(pool, pjsip_msg_body);
  ------------------
  |  |  569|     18|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
 1148|     18|                pjsip_media_type_cp(pool, &body->content_type,
 1149|     18|                                    &ctype_hdr->media);
 1150|       |
 1151|     18|                body->data = scanner->curptr;
 1152|     18|                body->len = (unsigned)(scanner->end - scanner->curptr);
 1153|     18|                body->print_body = &pjsip_print_text_body;
 1154|     18|                body->clone_data = &pjsip_clone_text_data;
 1155|     18|            }
 1156|       |
 1157|    719|            msg->body = body;
 1158|    719|        }
 1159|  34.3k|    }
 1160|      0|    PJ_CATCH_ANY 
 1161|      0|    {
 1162|       |        /* Exception was thrown during parsing. 
 1163|       |         * Skip until newline, and parse next header. 
 1164|       |         */
 1165|  39.1k|        if (err_list) {
  ------------------
  |  Branch (1165:13): [True: 39.1k, False: 18.4E]
  ------------------
 1166|  39.1k|            pjsip_parser_err_report *err_info;
 1167|       |            
 1168|  39.1k|            err_info = PJ_POOL_ALLOC_T(pool, pjsip_parser_err_report);
  ------------------
  |  |  569|  39.1k|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
 1169|  39.1k|            err_info->except_code = PJ_GET_EXCEPTION();
  ------------------
  |  |  409|  39.1k|#define PJ_GET_EXCEPTION()      (pj_x_code__)
  ------------------
 1170|  39.1k|            err_info->line = scanner->line;
 1171|       |            /* Scanner's column is zero based, so add 1 */
 1172|  39.1k|            err_info->col = pj_scan_get_col(scanner) + 1;
 1173|  39.1k|            if (parsing_headers)
  ------------------
  |  Branch (1173:17): [True: 37.1k, False: 1.95k]
  ------------------
 1174|  37.1k|                err_info->hname = hname;
 1175|  1.95k|            else if (msg && msg->type == PJSIP_REQUEST_MSG)
  ------------------
  |  Branch (1175:22): [True: 1.95k, False: 0]
  |  Branch (1175:29): [True: 1.72k, False: 226]
  ------------------
 1176|  1.72k|                err_info->hname = pj_str("Request Line");
 1177|    226|            else if (msg && msg->type == PJSIP_RESPONSE_MSG)
  ------------------
  |  Branch (1177:22): [True: 226, False: 0]
  |  Branch (1177:29): [True: 226, False: 0]
  ------------------
 1178|    226|                err_info->hname = pj_str("Status Line");
 1179|      0|            else
 1180|      0|                err_info->hname.slen = 0;
 1181|       |            
 1182|  39.1k|            pj_list_insert_before(err_list, err_info);
 1183|  39.1k|        }
 1184|       |        
 1185|  37.1k|        if (parsing_headers) {
  ------------------
  |  Branch (1185:13): [True: 37.1k, False: 18.4E]
  ------------------
 1186|  37.1k|            if (!pj_scan_is_eof(scanner)) {
  ------------------
  |  Branch (1186:17): [True: 36.8k, False: 276]
  ------------------
 1187|       |                /* Skip until next line.
 1188|       |                 * Watch for header continuation.
 1189|       |                 */
 1190|  37.2k|                do {
 1191|  37.2k|                    pj_scan_skip_line(scanner);
 1192|  37.2k|                } while (IS_SPACE(*scanner->curptr));
  ------------------
  |  |   63|  37.2k|#define IS_SPACE(c)     ((c)==' ' || (c)=='\t')
  |  |  ------------------
  |  |  |  Branch (63:26): [True: 362, False: 36.9k]
  |  |  |  Branch (63:38): [True: 48, False: 36.8k]
  |  |  ------------------
  ------------------
 1193|  36.8k|            }
 1194|       |
 1195|       |            /* Restore flag. Flag may be set in int_parse_sip_url() */
 1196|  37.1k|            scanner->skip_ws = PJ_SCAN_AUTOSKIP_WS_HEADER;
 1197|       |
 1198|       |            /* Continue parse next header, if any. */
 1199|  37.1k|            if (!pj_scan_is_eof(scanner) && !IS_NEWLINE(*scanner->curptr)) {
  ------------------
  |  |   62|  35.9k|#define IS_NEWLINE(c)   ((c)=='\r' || (c)=='\n')
  |  |  ------------------
  |  |  |  Branch (62:26): [True: 8, False: 35.9k]
  |  |  |  Branch (62:39): [True: 2, False: 35.9k]
  |  |  ------------------
  ------------------
  |  Branch (1199:17): [True: 35.9k, False: 1.19k]
  ------------------
 1200|  35.9k|                goto retry_parse;
 1201|  35.9k|            }
 1202|  37.1k|        }
 1203|       |
 1204|  18.4E|        msg = NULL;
 1205|  18.4E|    }
 1206|  18.4E|    PJ_END;
  ------------------
  |  |  394|  18.4E|#define PJ_END                  pj_pop_exception_handler_(&pj_x_except__); \
  |  |  395|  18.4E|                            } else {}
  ------------------
 1207|       |
 1208|  18.4E|    return msg;
 1209|  41.3k|}
sip_parser.c:is_next_sip_version:
 1004|  5.35k|{
 1005|  5.35k|    pj_str_t SIP = { "SIP", 3 };
 1006|  5.35k|    pj_str_t sip;
 1007|  5.35k|    int c;
 1008|       |
 1009|  5.35k|    c = pj_scan_peek(scanner, &pconst.pjsip_ALPHA_SPEC, &sip);
 1010|       |    /* return TRUE if it is "SIP" followed by "/" or space.
 1011|       |     * we include space since the "/" may be separated by space,
 1012|       |     * although this would mean it would return TRUE if it is a
 1013|       |     * request and the method is "SIP"!
 1014|       |     */
 1015|  5.35k|    return c && (c=='/' || c==' ' || c=='\t') && pj_stricmp(&sip, &SIP)==0;
  ------------------
  |  Branch (1015:12): [True: 5.29k, False: 66]
  |  Branch (1015:18): [True: 2.34k, False: 2.94k]
  |  Branch (1015:28): [True: 1.58k, False: 1.36k]
  |  Branch (1015:38): [True: 286, False: 1.07k]
  |  Branch (1015:50): [True: 2.33k, False: 1.88k]
  ------------------
 1016|  5.35k|}
sip_parser.c:int_parse_req_line:
 1688|  3.02k|{
 1689|  3.02k|    pj_str_t token;
 1690|       |
 1691|  3.02k|    pj_scan_get( scanner, &pconst.pjsip_TOKEN_SPEC, &token);
 1692|  3.02k|    pjsip_method_init_np( &req_line->method, &token);
 1693|       |
 1694|  3.02k|    req_line->uri = int_parse_uri(scanner, pool, PJ_TRUE);
 1695|  3.02k|    parse_sip_version(scanner);
 1696|  3.02k|    pj_scan_get_newline( scanner );
 1697|  3.02k|}
sip_parser.c:parse_param_imp:
 1217|  44.4k|{
 1218|       |    /* pname */
 1219|  44.4k|    if (!esc_spec) {
  ------------------
  |  Branch (1219:9): [True: 25.5k, False: 18.9k]
  ------------------
 1220|  25.5k|        pj_scan_get(scanner, spec, pname);
 1221|  25.5k|    } else {
 1222|  18.9k|        parser_get_and_unescape(scanner, pool, spec, esc_spec, pname);
 1223|  18.9k|    }
 1224|       |
 1225|       |    /* init pvalue */
 1226|  44.4k|    pvalue->ptr = NULL;
 1227|  44.4k|    pvalue->slen = 0;
 1228|       |
 1229|       |    /* pvalue, if any */
 1230|  44.4k|    if (*scanner->curptr == '=') {
  ------------------
  |  Branch (1230:9): [True: 15.6k, False: 28.8k]
  ------------------
 1231|  15.6k|        pj_scan_get_char(scanner);
 1232|  15.6k|        if (!pj_scan_is_eof(scanner)) {
  ------------------
  |  Branch (1232:13): [True: 15.5k, False: 26]
  ------------------
 1233|       |            /* pvalue can be a quoted string. */
 1234|  15.5k|            if (*scanner->curptr == '"') {
  ------------------
  |  Branch (1234:17): [True: 2.10k, False: 13.4k]
  ------------------
 1235|  2.10k|                pj_scan_get_quote( scanner, '"', '"', pvalue);
 1236|  2.10k|                if (option & PJSIP_PARSE_REMOVE_QUOTE) {
  ------------------
  |  Branch (1236:21): [True: 0, False: 2.10k]
  ------------------
 1237|      0|                    pvalue->ptr++;
 1238|      0|                    pvalue->slen -= 2;
 1239|      0|                }
 1240|       |            // } else if (*scanner->curptr == '[') {
 1241|       |                /* pvalue can be a quoted IPv6; in this case, the
 1242|       |                 * '[' and ']' quote characters are to be removed
 1243|       |                 * from the pvalue.
 1244|       |                 *
 1245|       |                 * Update: this seems to be unnecessary and may cause
 1246|       |                 * parsing error for cases such as IPv6 reference with
 1247|       |                 * port number.
 1248|       |                 */
 1249|       |                // pj_scan_get_char(scanner);
 1250|       |                // pj_scan_get_until_ch(scanner, ']', pvalue);
 1251|       |                // pj_scan_get_char(scanner);
 1252|  13.4k|            } else if(pj_cis_match(spec, *scanner->curptr)) {
  ------------------
  |  Branch (1252:23): [True: 11.0k, False: 2.41k]
  ------------------
 1253|  11.0k|                if (!esc_spec) {
  ------------------
  |  Branch (1253:21): [True: 7.51k, False: 3.55k]
  ------------------
 1254|  7.51k|                    pj_scan_get(scanner, spec, pvalue);
 1255|  7.51k|                } else {
 1256|  3.55k|                    parser_get_and_unescape(scanner, pool, spec, esc_spec,
 1257|  3.55k|                                            pvalue);
 1258|  3.55k|                }
 1259|  11.0k|            }
 1260|  15.5k|        }
 1261|  15.6k|    }
 1262|  44.4k|}
sip_parser.c:int_parse_uri_or_name_addr:
 1415|  20.0k|{
 1416|  20.0k|    pjsip_uri *uri;
 1417|  20.0k|    int is_name_addr = 0;
 1418|       |
 1419|       |    /* Exhaust any whitespaces. */
 1420|  20.0k|    pj_scan_skip_whitespace(scanner);
 1421|       |
 1422|  20.0k|    if (*scanner->curptr=='"' || *scanner->curptr=='<') {
  ------------------
  |  Branch (1422:9): [True: 826, False: 19.2k]
  |  Branch (1422:34): [True: 4.20k, False: 15.0k]
  ------------------
 1423|  5.03k|        uri = (pjsip_uri*)int_parse_name_addr( scanner, pool );
 1424|  5.03k|        is_name_addr = 1;
 1425|  15.0k|    } else {
 1426|  15.0k|        pj_str_t scheme;
 1427|  15.0k|        int next_ch;
 1428|       |
 1429|  15.0k|        next_ch = pj_scan_peek( scanner, &pconst.pjsip_DISPLAY_SPEC, &scheme);
 1430|       |
 1431|  15.0k|        if (next_ch==':') {
  ------------------
  |  Branch (1431:13): [True: 8.62k, False: 6.41k]
  ------------------
 1432|  8.62k|            pjsip_parse_uri_func *func = find_uri_handler(&scheme);
 1433|       |
 1434|  8.62k|            if (func == NULL) {
  ------------------
  |  Branch (1434:17): [True: 0, False: 8.62k]
  ------------------
 1435|       |                /* Unsupported URI scheme */
 1436|      0|                PJ_THROW(PJSIP_SYN_ERR_EXCEPTION);
  ------------------
  |  |  402|      0|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
 1437|      0|            }
 1438|       |
 1439|  8.62k|            uri = (pjsip_uri*)
 1440|  8.62k|                  (*func)(scanner, pool, 
 1441|  8.62k|                          (opt & PJSIP_PARSE_URI_IN_FROM_TO_HDR)==0);
 1442|       |
 1443|       |
 1444|  8.62k|        } else {
 1445|  6.41k|            uri = (pjsip_uri*)int_parse_name_addr( scanner, pool );
 1446|  6.41k|            is_name_addr = 1;
 1447|  6.41k|        }
 1448|  15.0k|    }
 1449|       |
 1450|       |    /* Should we return the URI object as name address? */
 1451|  20.0k|    if (opt & PJSIP_PARSE_URI_AS_NAMEADDR) {
  ------------------
  |  Branch (1451:9): [True: 8.67k, False: 11.4k]
  ------------------
 1452|  8.67k|        if (is_name_addr == 0) {
  ------------------
  |  Branch (1452:13): [True: 5.77k, False: 2.90k]
  ------------------
 1453|  5.77k|            pjsip_name_addr *name_addr;
 1454|       |
 1455|  5.77k|            name_addr = pjsip_name_addr_create(pool);
 1456|  5.77k|            name_addr->uri = uri;
 1457|       |
 1458|  5.77k|            uri = (pjsip_uri*)name_addr;
 1459|  5.77k|        }
 1460|  8.67k|    }
 1461|       |
 1462|  20.0k|    return uri;
 1463|  20.0k|}
sip_parser.c:int_parse_status_line:
 1702|  2.33k|{
 1703|  2.33k|    pj_str_t token;
 1704|       |
 1705|  2.33k|    parse_sip_version(scanner);
 1706|  2.33k|    pj_scan_get( scanner, &pconst.pjsip_DIGIT_SPEC, &token);
 1707|  2.33k|    strtoi_validate(&token, PJSIP_MIN_STATUS_CODE, PJSIP_MAX_STATUS_CODE,
  ------------------
  |  |   49|  2.33k|#define PJSIP_MIN_STATUS_CODE       100         /**< For limit checks */
  ------------------
                  strtoi_validate(&token, PJSIP_MIN_STATUS_CODE, PJSIP_MAX_STATUS_CODE,
  ------------------
  |  |   50|  2.33k|#define PJSIP_MAX_STATUS_CODE       999         /**< For limit checks */
  ------------------
 1708|  2.33k|                    &status_line->code);
 1709|  2.33k|    if (*scanner->curptr != '\r' && *scanner->curptr != '\n')
  ------------------
  |  Branch (1709:9): [True: 1.83k, False: 507]
  |  Branch (1709:37): [True: 1.43k, False: 392]
  ------------------
 1710|  1.43k|        pj_scan_get( scanner, &pconst.pjsip_NOT_NEWLINE, &status_line->reason);
 1711|    899|    else
 1712|    899|        status_line->reason.slen=0, status_line->reason.ptr=NULL;
 1713|  2.33k|    pj_scan_get_newline( scanner );
 1714|  2.33k|}
sip_parser.c:parse_hdr_end:
 1749|  37.4k|{
 1750|  37.4k|    if (pj_scan_is_eof(scanner)) {
  ------------------
  |  Branch (1750:9): [True: 1.27k, False: 36.1k]
  ------------------
 1751|  1.27k|        ;   /* Do nothing. */
 1752|  36.1k|    } else if (*scanner->curptr == '&') {
  ------------------
  |  Branch (1752:16): [True: 2.60k, False: 33.5k]
  ------------------
 1753|  2.60k|        pj_scan_get_char(scanner);
 1754|  33.5k|    } else {
 1755|  33.5k|        pj_scan_get_newline(scanner);
 1756|  33.5k|    }
 1757|  37.4k|}
sip_parser.c:parse_generic_array_hdr:
 1768|  12.1k|{
 1769|  12.1k|    pj_str_t elem;
 1770|       |
 1771|       |    /* Some header fields allow empty elements in the value:
 1772|       |     *   Accept, Allow, Supported
 1773|       |     */
 1774|  12.1k|    if (pj_scan_is_eof(scanner) || 
  ------------------
  |  Branch (1774:9): [True: 8, False: 12.1k]
  ------------------
 1775|  12.1k|        *scanner->curptr == '\r' || *scanner->curptr == '\n') 
  ------------------
  |  Branch (1775:9): [True: 691, False: 11.4k]
  |  Branch (1775:37): [True: 1.09k, False: 10.3k]
  ------------------
 1776|  1.79k|    {
 1777|  1.79k|        goto end;
 1778|  1.79k|    }
 1779|       |
 1780|  10.3k|    if (hdr->count >= PJ_ARRAY_SIZE(hdr->values)) {
  ------------------
  |  |  315|  10.3k|#define PJ_ARRAY_SIZE(a)    (sizeof(a)/sizeof(a[0]))
  ------------------
  |  Branch (1780:9): [True: 0, False: 10.3k]
  ------------------
 1781|       |        /* Too many elements */
 1782|      0|        on_syntax_error(scanner);
 1783|      0|        return;
 1784|      0|    }
 1785|       |
 1786|       |    /* Parse array elements, skipping any empty elements (for buggy clients).
 1787|       |     * Scanner is configured with PJ_SCAN_AUTOSKIP_WS_HEADER, so whitespace
 1788|       |     * is automatically skipped after getting comma or element.
 1789|       |     */
 1790|  13.6k|    while (hdr->count < PJ_ARRAY_SIZE(hdr->values))
  ------------------
  |  |  315|  13.6k|#define PJ_ARRAY_SIZE(a)    (sizeof(a)/sizeof(a[0]))
  ------------------
  |  Branch (1790:12): [True: 13.5k, False: 96]
  ------------------
 1791|  13.5k|    {
 1792|       |        /* Skip any leading/consecutive commas */
 1793|  32.3k|        while (*scanner->curptr == ',') {
  ------------------
  |  Branch (1793:16): [True: 18.7k, False: 13.5k]
  ------------------
 1794|  18.7k|            pj_scan_get_char(scanner);
 1795|  18.7k|        }
 1796|       |        
 1797|       |        /* Check for end of header */
 1798|  13.5k|        if (pj_scan_is_eof(scanner) || 
  ------------------
  |  Branch (1798:13): [True: 18, False: 13.5k]
  ------------------
 1799|  13.5k|            *scanner->curptr == '\r' || *scanner->curptr == '\n') 
  ------------------
  |  Branch (1799:13): [True: 7, False: 13.5k]
  |  Branch (1799:41): [True: 353, False: 13.2k]
  ------------------
 1800|    378|        {
 1801|    378|            break;
 1802|    378|        }
 1803|       |        
 1804|       |        /* Get element */
 1805|  13.2k|        pj_scan_get( scanner, &pconst.pjsip_NOT_COMMA_OR_NEWLINE, &elem);
 1806|  13.2k|        if (elem.slen > 0) {
  ------------------
  |  Branch (1806:13): [True: 13.1k, False: 25]
  ------------------
 1807|  13.1k|            hdr->values[hdr->count++] = elem;
 1808|  13.1k|        }
 1809|       |        
 1810|       |        /* If not followed by comma, we're done */
 1811|  13.2k|        if (*scanner->curptr != ',') {
  ------------------
  |  Branch (1811:13): [True: 9.85k, False: 3.35k]
  ------------------
 1812|  9.85k|            break;
 1813|  9.85k|        }
 1814|  13.2k|    }
 1815|       |
 1816|  12.0k|end:
 1817|  12.0k|    parse_hdr_end(scanner);
 1818|  12.0k|}
sip_parser.c:find_handler:
  741|  62.0k|{
  742|  62.0k|    pj_uint32_t hash;
  743|  62.0k|    char hname_copy[PJSIP_MAX_HNAME_LEN];
  744|  62.0k|    pj_str_t tmp;
  745|  62.0k|    pjsip_parse_hdr_func *func;
  746|       |
  747|  62.0k|    if (hname->slen >= PJSIP_MAX_HNAME_LEN) {
  ------------------
  |  | 1145|  62.0k|#define PJSIP_MAX_HNAME_LEN             64
  ------------------
  |  Branch (747:9): [True: 73, False: 61.9k]
  ------------------
  748|       |        /* Guaranteed not to be able to find handler. */
  749|     73|        return NULL;
  750|     73|    }
  751|       |
  752|       |    /* First, common case, try to find handler with exact name */
  753|  61.9k|    hash = pj_hash_calc(0, hname->ptr, (unsigned)hname->slen);
  754|  61.9k|    func = find_handler_imp(hash, hname);
  755|  61.9k|    if (func)
  ------------------
  |  Branch (755:9): [True: 28.9k, False: 32.9k]
  ------------------
  756|  28.9k|        return func;
  757|       |
  758|       |
  759|       |    /* If not found, try converting the header name to lowercase and
  760|       |     * search again.
  761|       |     */
  762|  32.9k|    hash = pj_hash_calc_tolower(0, hname_copy, hname);
  763|  32.9k|    tmp.ptr = hname_copy;
  764|  32.9k|    tmp.slen = hname->slen;
  765|  32.9k|    return find_handler_imp(hash, &tmp);
  766|  61.9k|}
sip_parser.c:find_handler_imp:
  710|  94.9k|{
  711|  94.9k|    handler_rec *first;
  712|  94.9k|    int          comp;
  713|  94.9k|    unsigned     n;
  714|       |
  715|       |    /* Binary search for the handler. */
  716|  94.9k|    comp = -1;
  717|  94.9k|    first = &handler[0];
  718|  94.9k|    n = handler_count;
  719|   543k|    for (; n > 0; ) {
  ------------------
  |  Branch (719:12): [True: 504k, False: 38.4k]
  ------------------
  720|   504k|        unsigned half = n / 2;
  721|   504k|        handler_rec *mid = first + half;
  722|       |
  723|   504k|        comp = compare_handler(mid, hname->ptr, hname->slen, hash);
  724|   504k|        if (comp < 0) {
  ------------------
  |  Branch (724:13): [True: 64.7k, False: 440k]
  ------------------
  725|  64.7k|            first = ++mid;
  726|  64.7k|            n -= half + 1;
  727|   440k|        } else if (comp==0) {
  ------------------
  |  Branch (727:20): [True: 56.5k, False: 383k]
  ------------------
  728|  56.5k|            first = mid;
  729|  56.5k|            break;
  730|   383k|        } else {
  731|   383k|            n = half;
  732|   383k|        }
  733|   504k|    }
  734|       |
  735|  94.9k|    return comp==0 ? first->handler : NULL;
  ------------------
  |  Branch (735:12): [True: 56.5k, False: 38.4k]
  ------------------
  736|  94.9k|}
sip_parser.c:parse_hdr_generic_string:
 2405|  5.50k|{
 2406|  5.50k|    pjsip_generic_string_hdr *hdr;
 2407|       |
 2408|  5.50k|    hdr = pjsip_generic_string_hdr_create(ctx->pool, NULL, NULL);
 2409|  5.50k|    parse_generic_string_hdr(hdr, ctx);
 2410|  5.50k|    return (pjsip_hdr*)hdr;
 2411|       |
 2412|  5.50k|}
sip_parser.c:parse_generic_string_hdr:
 1831|  5.50k|{
 1832|  5.50k|    pj_scanner *scanner = ctx->scanner;
 1833|       |
 1834|  5.50k|    hdr->hvalue.slen = 0;
 1835|       |
 1836|       |    /* header may be mangled hence the loop */
 1837|  6.09k|    while (pj_cis_match(&pconst.pjsip_NOT_NEWLINE, *scanner->curptr)) {
  ------------------
  |  Branch (1837:12): [True: 5.11k, False: 976]
  ------------------
 1838|  5.11k|        pj_str_t next, tmp;
 1839|       |
 1840|  5.11k|        pj_scan_get( scanner, &pconst.pjsip_NOT_NEWLINE, &hdr->hvalue);
 1841|  5.11k|        if (pj_scan_is_eof(scanner) || IS_NEWLINE(*scanner->curptr))
  ------------------
  |  |   62|  4.94k|#define IS_NEWLINE(c)   ((c)=='\r' || (c)=='\n')
  |  |  ------------------
  |  |  |  Branch (62:26): [True: 2.25k, False: 2.68k]
  |  |  |  Branch (62:39): [True: 2.09k, False: 590]
  |  |  ------------------
  ------------------
  |  Branch (1841:13): [True: 173, False: 4.94k]
  ------------------
 1842|  4.52k|            break;
 1843|       |        /* mangled, get next fraction */
 1844|    590|        pj_scan_get( scanner, &pconst.pjsip_NOT_NEWLINE, &next);
 1845|       |        /* concatenate */
 1846|    590|        tmp.ptr = (char*)pj_pool_alloc(ctx->pool, 
 1847|    590|                                       hdr->hvalue.slen + next.slen + 2);
 1848|    590|        tmp.slen = 0;
 1849|    590|        pj_strcpy(&tmp, &hdr->hvalue);
 1850|    590|        pj_strcat2(&tmp, " ");
 1851|    590|        pj_strcat(&tmp, &next);
 1852|    590|        tmp.ptr[tmp.slen] = '\0';
 1853|       |
 1854|    590|        hdr->hvalue = tmp;
 1855|    590|    }
 1856|       |
 1857|  5.50k|    parse_hdr_end(scanner);
 1858|  5.50k|}

pjsip_resolver_create:
   96|      2|{
   97|      2|    pjsip_resolver_t *resolver;
   98|      2|    pj_status_t status;
   99|       |
  100|      2|    PJ_ASSERT_RETURN(pool && p_res, PJ_EINVAL);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      4|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 2, False: 0]
  |  |  |  Branch (98:23): [True: 2, False: 0]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (100:5): [True: 0, False: 0]
  |  Branch (100:5): [True: 0, False: 0]
  |  Branch (100:5): [True: 0, False: 0]
  |  Branch (100:5): [True: 0, False: 0]
  ------------------
  101|      2|    resolver = PJ_POOL_ZALLOC_T(pool, pjsip_resolver_t);
  ------------------
  |  |  583|      2|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  102|       |
  103|       |    /* Create group lock */
  104|      2|    status = pj_grp_lock_create(pool, NULL, &resolver->grp_lock);
  105|      2|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (105:9): [True: 0, False: 2]
  ------------------
  106|      0|        return status;
  107|       |
  108|      2|    pj_grp_lock_add_ref(resolver->grp_lock);
  109|       |
  110|      2|    *p_res = resolver;
  111|       |
  112|      2|    return PJ_SUCCESS;
  113|      2|}

pjsip_tel_uri_create:
   97|  1.43k|{
   98|  1.43k|    pjsip_tel_uri *uri = PJ_POOL_ZALLOC_T(pool, pjsip_tel_uri);
  ------------------
  |  |  583|  1.43k|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
   99|  1.43k|    uri->vptr = &tel_uri_vptr;
  100|  1.43k|    pj_list_init(&uri->other_param);
  101|  1.43k|    return uri;
  102|  1.43k|}
pjsip_tel_uri_subsys_init:
  118|      2|{
  119|      2|    pj_status_t status;
  120|       |
  121|      2|    pj_cis_buf_init(&cis_buf);
  122|       |
  123|      2|    status = pj_cis_init(&cis_buf, &pjsip_TEL_EXT_VALUE_SPEC);
  124|      2|    PJ_ASSERT_RETURN(status==PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (124:5): [True: 0, False: 0]
  |  Branch (124:5): [True: 0, False: 0]
  ------------------
  125|      2|    pj_cis_add_str(&pjsip_TEL_EXT_VALUE_SPEC, PHONE_DIGITS);
  ------------------
  |  |   36|      2|#define PHONE_DIGITS        DIGITS VISUAL_SEP
  |  |  ------------------
  |  |  |  |   32|      2|#define DIGITS              "0123456789"
  |  |  ------------------
  |  |               #define PHONE_DIGITS        DIGITS VISUAL_SEP
  |  |  ------------------
  |  |  |  |   35|      2|#define VISUAL_SEP          "-.()"
  |  |  ------------------
  ------------------
  126|       |
  127|      2|    status = pj_cis_init(&cis_buf, &pjsip_TEL_NUMBER_SPEC);
  128|      2|    PJ_ASSERT_RETURN(status==PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (128:5): [True: 0, False: 0]
  |  Branch (128:5): [True: 0, False: 0]
  ------------------
  129|      2|    pj_cis_add_str(&pjsip_TEL_NUMBER_SPEC, NUMBER_SPEC);
  ------------------
  |  |   39|      2|#define NUMBER_SPEC         LOCAL_DIGITS GLOBAL_DIGITS
  |  |  ------------------
  |  |  |  |   38|      2|#define LOCAL_DIGITS        HEX_DIGITS "*#" VISUAL_SEP
  |  |  |  |  ------------------
  |  |  |  |  |  |   34|      2|#define HEX_DIGITS          DIGITS HEX
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   32|      2|#define DIGITS              "0123456789"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define NUMBER_SPEC         LOCAL_DIGITS GLOBAL_DIGITS
  |  |  ------------------
  |  |  |  |   37|      2|#define GLOBAL_DIGITS       "+" PHONE_DIGITS
  |  |  |  |  ------------------
  |  |  |  |  |  |   36|      2|#define PHONE_DIGITS        DIGITS VISUAL_SEP
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   35|      2|#define VISUAL_SEP          "-.()"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  130|       |
  131|      2|    status = pj_cis_init(&cis_buf, &pjsip_TEL_VISUAL_SEP_SPEC);
  132|      2|    PJ_ASSERT_RETURN(status==PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (132:5): [True: 0, False: 0]
  |  Branch (132:5): [True: 0, False: 0]
  ------------------
  133|      2|    pj_cis_add_str(&pjsip_TEL_VISUAL_SEP_SPEC, VISUAL_SEP);
  ------------------
  |  |   35|      2|#define VISUAL_SEP          "-.()"
  ------------------
  134|       |
  135|      2|    status = pj_cis_init(&cis_buf, &pjsip_TEL_PHONE_CONTEXT_SPEC);
  136|      2|    PJ_ASSERT_RETURN(status==PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (136:5): [True: 0, False: 0]
  |  Branch (136:5): [True: 0, False: 0]
  ------------------
  137|      2|    pj_cis_add_alpha(&pjsip_TEL_PHONE_CONTEXT_SPEC);
  138|      2|    pj_cis_add_num(&pjsip_TEL_PHONE_CONTEXT_SPEC);
  139|      2|    pj_cis_add_str(&pjsip_TEL_PHONE_CONTEXT_SPEC, PHONE_CONTEXT);
  ------------------
  |  |   40|      2|#define PHONE_CONTEXT       ALPHA GLOBAL_DIGITS
  |  |  ------------------
  |  |  |  |   37|      2|#define GLOBAL_DIGITS       "+" PHONE_DIGITS
  |  |  |  |  ------------------
  |  |  |  |  |  |   36|      2|#define PHONE_DIGITS        DIGITS VISUAL_SEP
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   35|      2|#define VISUAL_SEP          "-.()"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  140|       |
  141|      2|    status = pj_cis_init(&cis_buf, &pjsip_TEL_URIC_SPEC);
  142|      2|    PJ_ASSERT_RETURN(status==PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (142:5): [True: 0, False: 0]
  |  Branch (142:5): [True: 0, False: 0]
  ------------------
  143|      2|    pj_cis_add_alpha(&pjsip_TEL_URIC_SPEC);
  144|      2|    pj_cis_add_num(&pjsip_TEL_URIC_SPEC);
  145|      2|    pj_cis_add_str(&pjsip_TEL_URIC_SPEC, URIC);
  ------------------
  |  |   46|      2|#define URIC                RESERVED UNRESERVED ESCAPED "[]+"
  |  |  ------------------
  |  |  |  |   42|      2|#define RESERVED            "/:@&$,+"
  |  |  ------------------
  ------------------
  146|       |
  147|      2|    status = pj_cis_init(&cis_buf, &pjsip_TEL_PNAME_SPEC);
  148|      2|    PJ_ASSERT_RETURN(status==PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (148:5): [True: 0, False: 0]
  |  Branch (148:5): [True: 0, False: 0]
  ------------------
  149|      2|    pj_cis_add_alpha(&pjsip_TEL_PNAME_SPEC);
  150|      2|    pj_cis_add_num(&pjsip_TEL_PNAME_SPEC);
  151|      2|    pj_cis_add_str(&pjsip_TEL_PNAME_SPEC, "-");
  152|       |
  153|      2|    status = pj_cis_init(&cis_buf, &pjsip_TEL_PVALUE_SPEC);
  154|      2|    PJ_ASSERT_RETURN(status==PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (154:5): [True: 0, False: 0]
  |  Branch (154:5): [True: 0, False: 0]
  ------------------
  155|      2|    pj_cis_add_alpha(&pjsip_TEL_PVALUE_SPEC);
  156|      2|    pj_cis_add_num(&pjsip_TEL_PVALUE_SPEC);
  157|      2|    pj_cis_add_str(&pjsip_TEL_PVALUE_SPEC, PARAM_CHAR);
  ------------------
  |  |   48|      2|#define PARAM_CHAR          PARAM_UNRESERVED UNRESERVED ESCAPED
  |  |  ------------------
  |  |  |  |   47|      2|#define PARAM_UNRESERVED    "[]/:&+$"
  |  |  ------------------
  |  |               #define PARAM_CHAR          PARAM_UNRESERVED UNRESERVED ESCAPED
  |  |  ------------------
  |  |  |  |   45|      2|#define ESCAPED             "%"
  |  |  ------------------
  ------------------
  158|       |
  159|      2|    status = pj_cis_dup(&pjsip_TEL_PVALUE_SPEC_ESC, &pjsip_TEL_PVALUE_SPEC);
  160|      2|    pj_cis_del_str(&pjsip_TEL_PVALUE_SPEC_ESC, "%");
  161|       |
  162|      2|    status = pj_cis_dup(&pjsip_TEL_PARSING_PVALUE_SPEC, &pjsip_TEL_URIC_SPEC);
  163|      2|    PJ_ASSERT_RETURN(status==PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (163:5): [True: 0, False: 0]
  |  Branch (163:5): [True: 0, False: 0]
  ------------------
  164|      2|    pj_cis_add_cis(&pjsip_TEL_PARSING_PVALUE_SPEC, &pjsip_TEL_PVALUE_SPEC);
  165|      2|    pj_cis_add_str(&pjsip_TEL_PARSING_PVALUE_SPEC, "=");
  166|       |
  167|      2|    status = pj_cis_dup(&pjsip_TEL_PARSING_PVALUE_SPEC_ESC, 
  168|      2|                        &pjsip_TEL_PARSING_PVALUE_SPEC);
  169|      2|    pj_cis_del_str(&pjsip_TEL_PARSING_PVALUE_SPEC_ESC, "%");
  170|       |
  171|      2|    status = pjsip_register_uri_parser("tel", &tel_uri_parse);
  172|      2|    PJ_ASSERT_RETURN(status==PJ_SUCCESS, status);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (172:5): [True: 0, False: 0]
  |  Branch (172:5): [True: 0, False: 0]
  ------------------
  173|       |
  174|      2|    return PJ_SUCCESS;
  175|      2|}
sip_tel_uri.c:tel_uri_get_scheme:
  106|    240|{
  107|    240|    PJ_UNUSED_ARG(uri);
  ------------------
  |  | 1537|    240|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  108|    240|    return &pjsip_parser_const()->pjsip_TEL_STR;
  109|    240|}
sip_tel_uri.c:tel_uri_get_uri:
  112|    102|{
  113|    102|    return uri;
  114|    102|}
sip_tel_uri.c:tel_uri_print:
  181|    100|{
  182|    100|    int printed;
  183|    100|    char *startbuf = buf;
  184|    100|    char *endbuf = buf+size-1; // Need to minus one for NULL terminator
  185|    100|    const pjsip_parser_const_t *pc = pjsip_parser_const();
  186|       |
  187|    100|    PJ_UNUSED_ARG(context);
  ------------------
  |  | 1537|    100|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  188|       |
  189|       |    /* Print scheme. */
  190|    100|    copy_advance(buf, pc->pjsip_TEL_STR);
  ------------------
  |  |  109|    100|#define copy_advance            copy_advance_check
  |  |  ------------------
  |  |  |  |   32|    100|        do { \
  |  |  |  |   33|    100|            if ((str).slen >= (endbuf-buf)) return -1;  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (33:17): [True: 3, False: 97]
  |  |  |  |  ------------------
  |  |  |  |   34|    100|            if ((str).slen) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (34:17): [True: 97, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   35|     97|                pj_memcpy(buf, (str).ptr, (str).slen); \
  |  |  |  |   36|     97|                buf += (str).slen; \
  |  |  |  |   37|     97|            } \
  |  |  |  |   38|     97|        } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (38:18): [Folded, False: 97]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  191|     97|    copy_advance_char_check(buf, ':');
  ------------------
  |  |   26|     97|        do { \
  |  |   27|     97|            if (1 >= (endbuf-buf)) return -1;   \
  |  |  ------------------
  |  |  |  Branch (27:17): [True: 3, False: 94]
  |  |  ------------------
  |  |   28|     97|            *buf++ = chr; \
  |  |   29|     94|        } while (0)
  |  |  ------------------
  |  |  |  Branch (29:18): [Folded, False: 94]
  |  |  ------------------
  ------------------
  192|       |
  193|       |    /* Print number. */
  194|     94|    copy_advance_escape(buf, uri->number, pjsip_TEL_NUMBER_SPEC);
  ------------------
  |  |   95|     94|        do { \
  |  |   96|     94|            printed = \
  |  |   97|     94|                (int)pj_strncpy2_escape(buf, &(str), (endbuf-buf), &(unres)); \
  |  |   98|     94|            if (printed < 0) return -1; \
  |  |  ------------------
  |  |  |  Branch (98:17): [True: 1, False: 93]
  |  |  ------------------
  |  |   99|     94|            buf += printed; \
  |  |  100|     93|        } while (0)
  |  |  ------------------
  |  |  |  Branch (100:18): [Folded, False: 93]
  |  |  ------------------
  ------------------
  195|       |
  196|       |    /* ISDN sub-address or extension must appear first. */
  197|       |
  198|       |    /* Extension param. */
  199|     93|    copy_advance_pair_escape(buf, ";ext=", 5, uri->ext_param, 
  ------------------
  |  |   76|     93|        do { \
  |  |   77|     93|          if (str2.slen) { \
  |  |  ------------------
  |  |  |  Branch (77:15): [True: 31, False: 62]
  |  |  ------------------
  |  |   78|     31|            if (len1+str2.slen >= (endbuf-buf)) return -1; \
  |  |  ------------------
  |  |  |  Branch (78:17): [True: 17, False: 14]
  |  |  ------------------
  |  |   79|     31|            pj_memcpy(buf,str1,len1); \
  |  |   80|     14|            printed=(int)pj_strncpy2_escape(buf+len1,&str2,(endbuf-buf-len1), \
  |  |   81|     14|                                            &unres);\
  |  |   82|     14|            if (printed < 0) return -1; \
  |  |  ------------------
  |  |  |  Branch (82:17): [True: 5, False: 9]
  |  |  ------------------
  |  |   83|     14|            buf += (printed+len1); \
  |  |   84|      9|          } \
  |  |   85|     93|        } while (0)
  |  |  ------------------
  |  |  |  Branch (85:18): [Folded, False: 71]
  |  |  ------------------
  ------------------
  200|     93|                             pjsip_TEL_EXT_VALUE_SPEC);
  201|       |
  202|       |    /* ISDN sub-address. */
  203|     71|    copy_advance_pair_escape(buf, ";isub=", 6, uri->isub_param, 
  ------------------
  |  |   76|     71|        do { \
  |  |   77|     71|          if (str2.slen) { \
  |  |  ------------------
  |  |  |  Branch (77:15): [True: 30, False: 41]
  |  |  ------------------
  |  |   78|     30|            if (len1+str2.slen >= (endbuf-buf)) return -1; \
  |  |  ------------------
  |  |  |  Branch (78:17): [True: 23, False: 7]
  |  |  ------------------
  |  |   79|     30|            pj_memcpy(buf,str1,len1); \
  |  |   80|      7|            printed=(int)pj_strncpy2_escape(buf+len1,&str2,(endbuf-buf-len1), \
  |  |   81|      7|                                            &unres);\
  |  |   82|      7|            if (printed < 0) return -1; \
  |  |  ------------------
  |  |  |  Branch (82:17): [True: 2, False: 5]
  |  |  ------------------
  |  |   83|      7|            buf += (printed+len1); \
  |  |   84|      5|          } \
  |  |   85|     71|        } while (0)
  |  |  ------------------
  |  |  |  Branch (85:18): [Folded, False: 46]
  |  |  ------------------
  ------------------
  204|     71|                             pjsip_TEL_URIC_SPEC);
  205|       |
  206|       |    /* Followed by phone context, if present. */
  207|     46|    copy_advance_pair_escape(buf, ";phone-context=", 15, uri->context, 
  ------------------
  |  |   76|     46|        do { \
  |  |   77|     46|          if (str2.slen) { \
  |  |  ------------------
  |  |  |  Branch (77:15): [True: 0, False: 46]
  |  |  ------------------
  |  |   78|      0|            if (len1+str2.slen >= (endbuf-buf)) return -1; \
  |  |  ------------------
  |  |  |  Branch (78:17): [True: 0, False: 0]
  |  |  ------------------
  |  |   79|      0|            pj_memcpy(buf,str1,len1); \
  |  |   80|      0|            printed=(int)pj_strncpy2_escape(buf+len1,&str2,(endbuf-buf-len1), \
  |  |   81|      0|                                            &unres);\
  |  |   82|      0|            if (printed < 0) return -1; \
  |  |  ------------------
  |  |  |  Branch (82:17): [True: 0, False: 0]
  |  |  ------------------
  |  |   83|      0|            buf += (printed+len1); \
  |  |   84|      0|          } \
  |  |   85|     46|        } while (0)
  |  |  ------------------
  |  |  |  Branch (85:18): [Folded, False: 46]
  |  |  ------------------
  ------------------
  208|     46|                             pjsip_TEL_PHONE_CONTEXT_SPEC);
  209|       |
  210|       |
  211|       |    /* Print other parameters. */
  212|     46|    printed = (int)pjsip_param_print_on(&uri->other_param, buf, (endbuf-buf), 
  213|     46|                                        &pjsip_TEL_PNAME_SPEC, 
  214|     46|                                        &pjsip_TEL_PVALUE_SPEC, ';');
  215|     46|    if (printed < 0)
  ------------------
  |  Branch (215:9): [True: 8, False: 38]
  ------------------
  216|      8|        return -1;
  217|     38|    buf += printed;
  218|       |
  219|     38|    *buf = '\0';
  220|       |
  221|     38|    return (buf-startbuf);
  222|     46|}
sip_tel_uri.c:tel_uri_clone:
  355|    136|{
  356|    136|    pjsip_tel_uri *uri = pjsip_tel_uri_create(pool);
  357|       |
  358|    136|    pj_strdup(pool, &uri->number, &rhs->number);
  359|    136|    pj_strdup(pool, &uri->context, &rhs->context);
  360|    136|    pj_strdup(pool, &uri->ext_param, &rhs->ext_param);
  361|    136|    pj_strdup(pool, &uri->isub_param, &rhs->isub_param);
  362|    136|    pjsip_param_clone(pool, &uri->other_param, &rhs->other_param);
  363|       |
  364|    136|    return uri;
  365|    136|}
sip_tel_uri.c:tel_uri_parse:
  372|  1.29k|{
  373|  1.29k|    pjsip_tel_uri *uri;
  374|  1.29k|    pj_str_t token;
  375|  1.29k|    int skip_ws = scanner->skip_ws;
  376|  1.29k|    const pjsip_parser_const_t *pc = pjsip_parser_const();
  377|       |
  378|  1.29k|    scanner->skip_ws = 0;
  379|       |
  380|       |    /* Parse scheme. */
  381|  1.29k|    pj_scan_get(scanner, &pc->pjsip_TOKEN_SPEC, &token);
  382|  1.29k|    if (pj_scan_get_char(scanner) != ':')
  ------------------
  |  Branch (382:9): [True: 0, False: 1.29k]
  ------------------
  383|      0|        PJ_THROW(PJSIP_SYN_ERR_EXCEPTION);
  ------------------
  |  |  402|      0|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
  384|  1.29k|    if (pj_stricmp_alnum(&token, &pc->pjsip_TEL_STR) != 0)
  ------------------
  |  |  408|  1.29k|#define pj_stricmp_alnum    pj_stricmp
  ------------------
  |  Branch (384:9): [True: 0, False: 1.29k]
  ------------------
  385|      0|        PJ_THROW(PJSIP_SYN_ERR_EXCEPTION);
  ------------------
  |  |  402|      0|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
  386|       |
  387|       |    /* Create URI */
  388|  1.29k|    uri = pjsip_tel_uri_create(pool);
  389|       |
  390|       |    /* Get the phone number. */
  391|       |#if defined(PJSIP_UNESCAPE_IN_PLACE) && PJSIP_UNESCAPE_IN_PLACE!=0
  392|       |    pj_scan_get_unescape(scanner, &pjsip_TEL_NUMBER_SPEC, &uri->number);
  393|       |#else
  394|  1.29k|    pj_scan_get(scanner, &pjsip_TEL_NUMBER_SPEC, &uri->number);
  395|  1.29k|    uri->number = pj_str_unescape(pool, &uri->number);
  396|  1.29k|#endif
  397|       |
  398|       |    /* Get all parameters. */
  399|  1.29k|    if (parse_params && *scanner->curptr==';') {
  ------------------
  |  Branch (399:9): [True: 910, False: 384]
  |  Branch (399:25): [True: 529, False: 381]
  ------------------
  400|    529|        pj_str_t pname, pvalue;
  401|       |
  402|  2.81k|        do {
  403|       |            /* Eat the ';' separator. */
  404|  2.81k|            pj_scan_get_char(scanner);
  405|       |
  406|       |            /* Get pname. */
  407|  2.81k|            pj_scan_get(scanner, &pc->pjsip_PARAM_CHAR_SPEC, &pname);
  408|       |
  409|  2.81k|            if (*scanner->curptr == '=') {
  ------------------
  |  Branch (409:17): [True: 409, False: 2.40k]
  ------------------
  410|    409|                pj_scan_get_char(scanner);
  411|       |
  412|       |#               if defined(PJSIP_UNESCAPE_IN_PLACE) && PJSIP_UNESCAPE_IN_PLACE!=0
  413|       |                    pj_scan_get_unescape(scanner, 
  414|       |                                         &pjsip_TEL_PARSING_PVALUE_SPEC_ESC,
  415|       |                                         &pvalue);
  416|       |#               else
  417|    409|                    pj_scan_get(scanner, &pjsip_TEL_PARSING_PVALUE_SPEC, 
  418|    409|                                &pvalue);
  419|    409|                    pvalue = pj_str_unescape(pool, &pvalue);
  420|    409|#               endif
  421|       |
  422|  2.40k|            } else {
  423|  2.40k|                pvalue.slen = 0;
  424|  2.40k|                pvalue.ptr = NULL;
  425|  2.40k|            }
  426|       |
  427|       |            /* Save the parameters. */
  428|  2.81k|            if (pj_stricmp_alnum(&pname, &pjsip_ISUB_STR)==0) {
  ------------------
  |  |  408|  2.81k|#define pj_stricmp_alnum    pj_stricmp
  ------------------
  |  Branch (428:17): [True: 234, False: 2.58k]
  ------------------
  429|    234|                uri->isub_param = pvalue;
  430|  2.58k|            } else if (pj_stricmp_alnum(&pname, &pjsip_EXT_STR)==0) {
  ------------------
  |  |  408|  2.58k|#define pj_stricmp_alnum    pj_stricmp
  ------------------
  |  Branch (430:24): [True: 261, False: 2.32k]
  ------------------
  431|    261|                uri->ext_param = pvalue;
  432|  2.32k|            } else if (pj_stricmp_alnum(&pname, &pjsip_PH_CTX_STR)==0) {
  ------------------
  |  |  408|  2.32k|#define pj_stricmp_alnum    pj_stricmp
  ------------------
  |  Branch (432:24): [True: 205, False: 2.11k]
  ------------------
  433|    205|                uri->context = pvalue;
  434|  2.11k|            } else {
  435|  2.11k|                pjsip_param *param = PJ_POOL_ALLOC_T(pool, pjsip_param);
  ------------------
  |  |  569|  2.11k|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
  436|  2.11k|                param->name = pname;
  437|  2.11k|                param->value = pvalue;
  438|  2.11k|                pj_list_insert_before(&uri->other_param, param);
  439|  2.11k|            }
  440|       |
  441|  2.81k|        } while (*scanner->curptr==';');
  ------------------
  |  Branch (441:18): [True: 2.28k, False: 529]
  ------------------
  442|    529|    }
  443|       |
  444|  1.29k|    scanner->skip_ws = skip_ws;
  445|  1.29k|    pj_scan_skip_whitespace(scanner);
  446|  1.29k|    return uri;
  447|  1.29k|}

pjsip_tsx_create_key:
  406|    281|{
  407|    281|    pj_str_t rfc3261_branch = {PJSIP_RFC3261_BRANCH_ID, 
  ------------------
  |  | 1065|    281|#define PJSIP_RFC3261_BRANCH_ID         "z9hG4bK"
  ------------------
  408|    281|                               PJSIP_RFC3261_BRANCH_LEN};
  ------------------
  |  | 1070|    281|#define PJSIP_RFC3261_BRANCH_LEN        7
  ------------------
  409|       |
  410|       |
  411|       |    /* Get the branch parameter in the top-most Via.
  412|       |     * If branch parameter is started with "z9hG4bK", then the message was
  413|       |     * generated by agent compliant with RFC3261. Otherwise, it will be
  414|       |     * handled as RFC2543.
  415|       |     */
  416|    281|    const pj_str_t *branch = &rdata->msg_info.via->branch_param;
  417|       |
  418|    281|    if (pj_strnicmp(branch,&rfc3261_branch,PJSIP_RFC3261_BRANCH_LEN)==0) {
  ------------------
  |  | 1070|    281|#define PJSIP_RFC3261_BRANCH_LEN        7
  ------------------
  |  Branch (418:9): [True: 8, False: 273]
  ------------------
  419|       |
  420|       |        /* Create transaction key. */
  421|      8|        return create_tsx_key_3261(pool, key, role, method, branch);
  422|       |
  423|    273|    } else {
  424|       |        /* Create the key for the message. This key will be matched up 
  425|       |         * with the transaction key. For RFC2563 transactions, the 
  426|       |         * transaction key was created by the same function, so it will 
  427|       |         * match the message.
  428|       |         */
  429|    273|        return create_tsx_key_2543( pool, key, role, method, rdata, PJ_TRUE );
  430|    273|    }
  431|    281|}
pjsip_tsx_initialize_timer_values:
  473|      2|{
  474|      2|    t1_timer_val.sec  = pjsip_cfg()->tsx.t1 / 1000;
  475|      2|    t1_timer_val.msec = pjsip_cfg()->tsx.t1 % 1000;
  476|      2|    t2_timer_val.sec  = pjsip_cfg()->tsx.t2 / 1000;
  477|      2|    t2_timer_val.msec = pjsip_cfg()->tsx.t2 % 1000;
  478|      2|    t4_timer_val.sec  = pjsip_cfg()->tsx.t4 / 1000;
  479|      2|    t4_timer_val.msec = pjsip_cfg()->tsx.t4 % 1000;
  480|      2|    td_timer_val.sec  = pjsip_cfg()->tsx.td / 1000;
  481|      2|    td_timer_val.msec = pjsip_cfg()->tsx.td % 1000;
  482|      2|    timeout_timer_val = td_timer_val;
  483|      2|}
pjsip_tsx_layer_init_module:
  502|      2|{
  503|      2|    pj_pool_t *pool;
  504|      2|    pj_status_t status;
  505|       |
  506|       |
  507|      2|    PJ_ASSERT_RETURN(mod_tsx_layer.endpt==NULL, PJ_EINVALIDOP);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (507:5): [True: 0, False: 0]
  |  Branch (507:5): [True: 0, False: 0]
  ------------------
  508|       |
  509|       |    /* Initialize timer values */
  510|      2|    pjsip_tsx_initialize_timer_values();
  511|       |
  512|       |    /* Reset max retrans count (for library restart scenario) */
  513|      2|    max_retrans_count = -1;
  514|       |
  515|       |    /*
  516|       |     * Initialize transaction layer structure.
  517|       |     */
  518|       |
  519|       |    /* Create pool for the module. */
  520|      2|    pool = pjsip_endpt_create_pool(endpt, "tsxlayer", 
  521|      2|                                   PJSIP_POOL_TSX_LAYER_LEN,
  ------------------
  |  | 1081|      2|#   define PJSIP_POOL_TSX_LAYER_LEN     512
  ------------------
  522|      2|                                   PJSIP_POOL_TSX_LAYER_INC );
  ------------------
  |  | 1091|      2|#   define PJSIP_POOL_TSX_LAYER_INC     512
  ------------------
  523|      2|    if (!pool)
  ------------------
  |  Branch (523:9): [True: 0, False: 2]
  ------------------
  524|      0|        return PJ_ENOMEM;
  ------------------
  |  |  408|      0|#define PJ_ENOMEM           (PJ_ERRNO_START_STATUS + 7) /* 70007 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  525|       |
  526|       |    
  527|       |    /* Initialize some attributes. */
  528|      2|    mod_tsx_layer.pool = pool;
  529|      2|    mod_tsx_layer.endpt = endpt;
  530|       |
  531|       |
  532|       |    /* Create hash table. */
  533|      2|    mod_tsx_layer.htable = pj_hash_create( pool, pjsip_cfg()->tsx.max_count );
  534|      2|    mod_tsx_layer.htable2 = pj_hash_create(pool, pjsip_cfg()->tsx.max_count);
  535|      2|    if (!mod_tsx_layer.htable || !mod_tsx_layer.htable2) {
  ------------------
  |  Branch (535:9): [True: 0, False: 2]
  |  Branch (535:34): [True: 0, False: 2]
  ------------------
  536|      0|        pjsip_endpt_release_pool(endpt, pool);
  537|      0|        return PJ_ENOMEM;
  ------------------
  |  |  408|      0|#define PJ_ENOMEM           (PJ_ERRNO_START_STATUS + 7) /* 70007 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  538|      0|    }
  539|       |
  540|       |    /* Create group lock. */
  541|      2|    status = pj_mutex_create_recursive(pool, "tsxlayer", &mod_tsx_layer.mutex);
  542|      2|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (542:9): [True: 0, False: 2]
  ------------------
  543|      0|        pjsip_endpt_release_pool(endpt, pool);
  544|      0|        return status;
  545|      0|    }
  546|       |
  547|       |    /*
  548|       |     * Register transaction layer module to endpoint.
  549|       |     */
  550|      2|    status = pjsip_endpt_register_module( endpt, &mod_tsx_layer.mod );
  551|      2|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (551:9): [True: 0, False: 2]
  ------------------
  552|      0|        pj_mutex_destroy(mod_tsx_layer.mutex);
  553|      0|        pjsip_endpt_release_pool(endpt, pool);
  554|      0|        return status;
  555|      0|    }
  556|       |
  557|       |    /* Register mod_stateful_util module (sip_util_statefull.c) */
  558|      2|    status = pjsip_endpt_register_module(endpt, &mod_stateful_util);
  559|      2|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (559:9): [True: 0, False: 2]
  ------------------
  560|      0|        return status;
  561|      0|    }
  562|       |
  563|      2|    return PJ_SUCCESS;
  564|      2|}
pjsip_rdata_get_tsx:
 1079|    281|{
 1080|    281|    return (pjsip_transaction*) 
 1081|    281|           rdata->endpt_info.mod_data[mod_tsx_layer.mod.id];
 1082|    281|}
pjsip_tsx_create_uas2:
 1714|    347|{
 1715|    347|    pjsip_transaction *tsx;
 1716|    347|    pjsip_msg *msg;
 1717|    347|    pj_str_t *branch;
 1718|    347|    pjsip_cseq_hdr *cseq;
 1719|    347|    pj_status_t status;
 1720|       |
 1721|       |    /* Validate arguments. */
 1722|    347|    PJ_ASSERT_RETURN(rdata && rdata->msg_info.msg && p_tsx, PJ_EINVAL);
  ------------------
  |  |   97|    347|            do { \
  |  |   98|  1.38k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 347, False: 0]
  |  |  |  Branch (98:23): [True: 347, False: 0]
  |  |  |  Branch (98:23): [True: 347, False: 0]
  |  |  ------------------
  |  |   99|    347|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 347]
  |  |  ------------------
  ------------------
  |  Branch (1722:5): [True: 0, False: 0]
  |  Branch (1722:5): [True: 0, False: 0]
  |  Branch (1722:5): [True: 0, False: 0]
  |  Branch (1722:5): [True: 0, False: 0]
  |  Branch (1722:5): [True: 0, False: 0]
  |  Branch (1722:5): [True: 0, False: 0]
  ------------------
 1723|       |
 1724|       |    /* Keep shortcut to message */
 1725|    347|    msg = rdata->msg_info.msg;
 1726|       |    
 1727|       |    /* Make sure this is a request message. */
 1728|    347|    PJ_ASSERT_RETURN(msg->type == PJSIP_REQUEST_MSG, PJSIP_ENOTREQUESTMSG);
  ------------------
  |  |   97|    347|            do { \
  |  |   98|    347|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 347]
  |  |  ------------------
  |  |   99|    347|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 347]
  |  |  ------------------
  ------------------
  |  Branch (1728:5): [True: 0, False: 0]
  |  Branch (1728:5): [True: 0, False: 0]
  ------------------
 1729|       |
 1730|       |    /* Make sure method is not ACK */
 1731|    347|    PJ_ASSERT_RETURN(msg->line.req.method.id != PJSIP_ACK_METHOD,
  ------------------
  |  |   97|    347|            do { \
  |  |   98|    347|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 347]
  |  |  ------------------
  |  |   99|    347|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 347]
  |  |  ------------------
  ------------------
  |  Branch (1731:5): [True: 0, False: 0]
  |  Branch (1731:5): [True: 0, False: 0]
  ------------------
 1732|    347|                     PJ_EINVALIDOP);
 1733|       |
 1734|       |    /* Make sure CSeq header is present. */
 1735|    347|    cseq = rdata->msg_info.cseq;
 1736|    347|    if (!cseq)
  ------------------
  |  Branch (1736:9): [True: 0, False: 347]
  ------------------
 1737|      0|        return PJSIP_EMISSINGHDR;
  ------------------
  |  |  170|      0|#define PJSIP_EMISSINGHDR       (PJSIP_ERRNO_START_PJSIP + 50)  /* 171050 */
  |  |  ------------------
  |  |  |  |   73|      0|#define PJSIP_ERRNO_START_PJSIP (PJSIP_ERRNO_START + 1000)
  |  |  |  |  ------------------
  |  |  |  |  |  |   47|      0|#define PJSIP_ERRNO_START       (PJ_ERRNO_START_USER)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  535|      0|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1738|       |
 1739|       |    /* Make sure Via header is present. */
 1740|    347|    if (rdata->msg_info.via == NULL)
  ------------------
  |  Branch (1740:9): [True: 0, False: 347]
  ------------------
 1741|      0|        return PJSIP_EMISSINGHDR;
  ------------------
  |  |  170|      0|#define PJSIP_EMISSINGHDR       (PJSIP_ERRNO_START_PJSIP + 50)  /* 171050 */
  |  |  ------------------
  |  |  |  |   73|      0|#define PJSIP_ERRNO_START_PJSIP (PJSIP_ERRNO_START + 1000)
  |  |  |  |  ------------------
  |  |  |  |  |  |   47|      0|#define PJSIP_ERRNO_START       (PJ_ERRNO_START_USER)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  535|      0|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1742|       |
 1743|       |    /* Check that method in CSeq header match request method.
 1744|       |     * Reference: PROTOS #1922
 1745|       |     */
 1746|    347|    if (pjsip_method_cmp(&msg->line.req.method, 
  ------------------
  |  Branch (1746:9): [True: 66, False: 281]
  ------------------
 1747|    347|                         &rdata->msg_info.cseq->method) != 0)
 1748|     66|    {
 1749|     66|        PJ_LOG(4,(THIS_FILE, "Error: CSeq header contains different "
  ------------------
  |  |  106|     66|#define PJ_LOG(level,arg)       do { \
  |  |  107|     66|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|    132|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 66, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 66]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|     66|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 66]
  |  |  ------------------
  ------------------
 1750|     66|                             "method than the request line"));
 1751|     66|        return PJSIP_EINVALIDHDR;
  ------------------
  |  |  175|     66|#define PJSIP_EINVALIDHDR       (PJSIP_ERRNO_START_PJSIP + 51)  /* 171051 */
  |  |  ------------------
  |  |  |  |   73|     66|#define PJSIP_ERRNO_START_PJSIP (PJSIP_ERRNO_START + 1000)
  |  |  |  |  ------------------
  |  |  |  |  |  |   47|     66|#define PJSIP_ERRNO_START       (PJ_ERRNO_START_USER)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  535|     66|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  528|     66|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  521|     66|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  509|     66|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  515|     66|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|     66|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|     66|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1752|     66|    }
 1753|       |
 1754|       |    /* 
 1755|       |     * Create transaction instance. 
 1756|       |     */
 1757|    281|    status = tsx_create( tsx_user, grp_lock, &tsx);
 1758|    281|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (1758:9): [True: 0, False: 281]
  ------------------
 1759|      0|        return status;
 1760|       |
 1761|       |
 1762|       |    /* Lock transaction. */
 1763|    281|    pj_grp_lock_acquire(tsx->grp_lock);
 1764|       |
 1765|       |    /* Role is UAS */
 1766|    281|    tsx->role = PJSIP_ROLE_UAS;
 1767|       |
 1768|       |    /* Save method. */
 1769|    281|    pjsip_method_copy( tsx->pool, &tsx->method, &msg->line.req.method);
 1770|       |
 1771|       |    /* Save CSeq */
 1772|    281|    tsx->cseq = cseq->cseq;
 1773|       |
 1774|       |    /* Get transaction key either from branch for RFC3261 message, or
 1775|       |     * create transaction key.
 1776|       |     */
 1777|    281|    status = pjsip_tsx_create_key(tsx->pool, &tsx->transaction_key, 
 1778|    281|                                  PJSIP_ROLE_UAS, &tsx->method, rdata);
 1779|    281|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (1779:9): [True: 0, False: 281]
  ------------------
 1780|      0|        pj_grp_lock_release(tsx->grp_lock);
 1781|      0|        tsx_shutdown(tsx);
 1782|      0|        return status;
 1783|      0|    }
 1784|       |
 1785|       |    /* Create transaction key to detect merged requests, with the key
 1786|       |     * consisting of From tag, CSeq, and Call-ID.
 1787|       |     */
 1788|    281|    status = create_tsx_key_2543(tsx->pool, &tsx->transaction_key2,
 1789|    281|                                 PJSIP_ROLE_UAS, &tsx->method, rdata,
 1790|    281|                                 PJ_FALSE );
 1791|    281|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (1791:9): [True: 0, False: 281]
  ------------------
 1792|      0|        pj_grp_lock_release(tsx->grp_lock);
 1793|      0|        tsx_shutdown(tsx);
 1794|      0|        return status;
 1795|      0|    }
 1796|       |
 1797|       |    /* Calculate hashed key value. */
 1798|    281|#ifdef PRECALC_HASH
 1799|    281|    tsx->hashed_key = pj_hash_calc_tolower(0, NULL, &tsx->transaction_key);
 1800|    281|    tsx->hashed_key2 = pj_hash_calc_tolower(0, NULL, &tsx->transaction_key2);
 1801|    281|#endif
 1802|       |
 1803|       |    /* Duplicate branch parameter for transaction. */
 1804|    281|    branch = &rdata->msg_info.via->branch_param;
 1805|    281|    pj_strdup(tsx->pool, &tsx->branch, branch);
 1806|       |
 1807|    281|    PJ_LOG(6, (tsx->obj_name, "tsx_key=%.*s", (int)tsx->transaction_key.slen,
  ------------------
  |  |  106|    281|#define PJ_LOG(level,arg)       do { \
  |  |  107|    281|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|    562|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 281]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|    281|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 281]
  |  |  ------------------
  ------------------
 1808|    281|               tsx->transaction_key.ptr));
 1809|       |
 1810|       |
 1811|       |    /* Begin with state NULL.
 1812|       |     * Manually set-up the state becase we don't want to call the callback.
 1813|       |     */
 1814|    281|    tsx->state = PJSIP_TSX_STATE_NULL; 
 1815|    281|    tsx->state_handler = &tsx_on_state_null;
 1816|       |
 1817|       |    /* Get response address. */
 1818|    281|    status = pjsip_get_response_addr( tsx->pool, rdata, &tsx->res_addr );
 1819|    281|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (1819:9): [True: 0, False: 281]
  ------------------
 1820|      0|        pj_grp_lock_release(tsx->grp_lock);
 1821|      0|        tsx_shutdown(tsx);
 1822|      0|        return status;
 1823|      0|    }
 1824|       |
 1825|       |    /* If it's decided that we should use current transport, keep the
 1826|       |     * transport.
 1827|       |     */
 1828|    281|    if (tsx->res_addr.transport) {
  ------------------
  |  Branch (1828:9): [True: 21, False: 260]
  ------------------
 1829|     21|        tsx_update_transport(tsx, tsx->res_addr.transport);
 1830|     21|        pj_memcpy(&tsx->addr, &tsx->res_addr.addr, tsx->res_addr.addr_len);
 1831|     21|        tsx->addr_len = tsx->res_addr.addr_len;
 1832|     21|        tsx->is_reliable = PJSIP_TRANSPORT_IS_RELIABLE(tsx->transport);
  ------------------
  |  |   82|     21|            ((tp)->flag & PJSIP_TRANSPORT_RELIABLE)
  ------------------
 1833|    260|    } else {
 1834|    260|        tsx->is_reliable = 
 1835|    260|            (tsx->res_addr.dst_host.flag & PJSIP_TRANSPORT_RELIABLE);
 1836|    260|    }
 1837|       |
 1838|       |
 1839|       |    /* Register the transaction. */
 1840|    281|    status = mod_tsx_layer_register_tsx(tsx);
 1841|    281|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (1841:9): [True: 0, False: 281]
  ------------------
 1842|      0|        pj_grp_lock_release(tsx->grp_lock);
 1843|      0|        tsx_shutdown(tsx);
 1844|      0|        return status;
 1845|      0|    }
 1846|       |
 1847|       |    /* Put this transaction in rdata's mod_data. */
 1848|    281|    rdata->endpt_info.mod_data[mod_tsx_layer.mod.id] = tsx;
 1849|       |
 1850|       |    /* Unlock transaction and return. */
 1851|    281|    pj_grp_lock_release(tsx->grp_lock);
 1852|       |
 1853|    281|    pj_log_push_indent();
 1854|    281|    PJ_LOG(5,(tsx->obj_name, "Transaction created for %s",
  ------------------
  |  |  106|    281|#define PJ_LOG(level,arg)       do { \
  |  |  107|    281|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|    562|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 281, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 281]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|    281|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 281]
  |  |  ------------------
  ------------------
 1855|    281|              pjsip_rx_data_get_info(rdata)));
 1856|    281|    pj_log_pop_indent();
 1857|       |
 1858|       |
 1859|    281|    *p_tsx = tsx;
 1860|    281|    return PJ_SUCCESS;
 1861|    281|}
pjsip_tsx_terminate:
 1910|    281|{
 1911|    281|    PJ_ASSERT_RETURN(tsx != NULL, PJ_EINVAL);
  ------------------
  |  |   97|    281|            do { \
  |  |   98|    281|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 281]
  |  |  ------------------
  |  |   99|    281|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 281]
  |  |  ------------------
  ------------------
  |  Branch (1911:5): [True: 0, False: 0]
  |  Branch (1911:5): [True: 0, False: 0]
  ------------------
 1912|       |
 1913|    281|    PJ_LOG(5,(tsx->obj_name, "Request to terminate transaction"));
  ------------------
  |  |  106|    281|#define PJ_LOG(level,arg)       do { \
  |  |  107|    281|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|    562|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 281, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 281]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|    281|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 281]
  |  |  ------------------
  ------------------
 1914|       |
 1915|    281|    PJ_ASSERT_RETURN(code >= 200, PJ_EINVAL);
  ------------------
  |  |   97|    281|            do { \
  |  |   98|    281|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 281]
  |  |  ------------------
  |  |   99|    281|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 281]
  |  |  ------------------
  ------------------
  |  Branch (1915:5): [True: 0, False: 0]
  |  Branch (1915:5): [True: 0, False: 0]
  ------------------
 1916|       |
 1917|    281|    pj_log_push_indent();
 1918|       |
 1919|    281|    pj_grp_lock_acquire(tsx->grp_lock);
 1920|       |
 1921|    281|    if (tsx->state < PJSIP_TSX_STATE_TERMINATED) {
  ------------------
  |  Branch (1921:9): [True: 281, False: 0]
  ------------------
 1922|    281|        tsx_set_status_code(tsx, code, NULL);
 1923|    281|        tsx_set_state( tsx, PJSIP_TSX_STATE_TERMINATED, PJSIP_EVENT_USER,
 1924|    281|                       NULL, 0);
 1925|    281|    }
 1926|    281|    pj_grp_lock_release(tsx->grp_lock);
 1927|       |
 1928|    281|    pj_log_pop_indent();
 1929|       |
 1930|    281|    return PJ_SUCCESS;
 1931|    281|}
pjsip_tsx_recv_msg:
 2104|    281|{
 2105|    281|    pjsip_event event;
 2106|       |
 2107|    281|    PJ_LOG(5,(tsx->obj_name, "Incoming %s in state %s", 
  ------------------
  |  |  106|    281|#define PJ_LOG(level,arg)       do { \
  |  |  107|    281|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|    562|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 281, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 281]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|    281|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 281]
  |  |  ------------------
  ------------------
 2108|    281|              pjsip_rx_data_get_info(rdata), state_str[tsx->state]));
 2109|    281|    pj_log_push_indent();
 2110|       |
 2111|       |    /* Put the transaction in the rdata's mod_data. */
 2112|    281|    rdata->endpt_info.mod_data[mod_tsx_layer.mod.id] = tsx;
 2113|       |
 2114|       |    /* Init event. */
 2115|    281|    PJSIP_EVENT_INIT_RX_MSG(event, rdata);
  ------------------
  |  |  190|    281|        do { \
  |  |  191|    281|            (event).type = PJSIP_EVENT_RX_MSG;          \
  |  |  192|    281|            (event).body.rx_msg.rdata = prdata;         \
  |  |  193|    281|        } while (0)
  |  |  ------------------
  |  |  |  Branch (193:18): [Folded, False: 281]
  |  |  ------------------
  ------------------
 2116|       |
 2117|       |    /* Dispatch to transaction. */
 2118|    281|    pj_grp_lock_acquire(tsx->grp_lock);
 2119|    281|    (*tsx->state_handler)(tsx, &event);
 2120|    281|    pj_grp_lock_release(tsx->grp_lock);
 2121|       |
 2122|    281|    pj_log_pop_indent();
 2123|    281|}
sip_transaction.c:create_tsx_key_3261:
  369|      8|{
  370|      8|    char *p;
  371|       |
  372|      8|    PJ_ASSERT_RETURN(pool && key && method && branch, PJ_EINVAL);
  ------------------
  |  |   97|      8|            do { \
  |  |   98|     48|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 8, False: 0]
  |  |  |  Branch (98:23): [True: 8, False: 0]
  |  |  |  Branch (98:23): [True: 8, False: 0]
  |  |  |  Branch (98:23): [True: 8, False: 0]
  |  |  ------------------
  |  |   99|      8|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 8]
  |  |  ------------------
  ------------------
  |  Branch (372:5): [True: 0, False: 0]
  |  Branch (372:5): [True: 0, False: 0]
  |  Branch (372:5): [True: 0, False: 0]
  |  Branch (372:5): [True: 0, False: 0]
  |  Branch (372:5): [True: 0, False: 0]
  |  Branch (372:5): [True: 0, False: 0]
  |  Branch (372:5): [True: 0, False: 0]
  |  Branch (372:5): [True: 0, False: 0]
  ------------------
  373|       |
  374|      8|    p = key->ptr = (char*) 
  375|      8|                   pj_pool_alloc(pool, branch->slen + method->name.slen + 4 );
  376|       |    
  377|       |    /* Add role. */
  378|      8|    *p++ = (char)(role==PJSIP_ROLE_UAC ? 'c' : 's');
  ------------------
  |  Branch (378:19): [True: 0, False: 8]
  ------------------
  379|      8|    *p++ = SEPARATOR;
  ------------------
  |  |  282|      8|#define SEPARATOR   '$'
  ------------------
  380|       |
  381|       |    /* Add method, except when method is INVITE or ACK. */
  382|      8|    if (method->id != PJSIP_INVITE_METHOD && method->id != PJSIP_ACK_METHOD) {
  ------------------
  |  Branch (382:9): [True: 1, False: 7]
  |  Branch (382:46): [True: 1, False: 0]
  ------------------
  383|      1|        pj_memcpy(p, method->name.ptr, method->name.slen);
  384|      1|        p += method->name.slen;
  385|      1|        *p++ = '$';
  386|      1|    }
  387|       |
  388|       |    /* Add branch ID. */
  389|      8|    pj_memcpy(p, branch->ptr, branch->slen);
  390|      8|    p += branch->slen;
  391|       |
  392|       |    /* Set length */
  393|      8|    key->slen = p - key->ptr;
  394|       |
  395|      8|    return PJ_SUCCESS;
  396|      8|}
sip_transaction.c:create_tsx_key_2543:
  281|    554|{
  282|    554|#define SEPARATOR   '$'
  283|    554|    char *key, *p;
  284|    554|    pj_ssize_t len;
  285|    554|    pj_size_t len_required;
  286|    554|    pj_str_t *host;
  287|       |
  288|    554|    PJ_ASSERT_RETURN(pool && str && method && rdata, PJ_EINVAL);
  ------------------
  |  |   97|    554|            do { \
  |  |   98|  3.32k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 554, False: 0]
  |  |  |  Branch (98:23): [True: 554, False: 0]
  |  |  |  Branch (98:23): [True: 554, False: 0]
  |  |  |  Branch (98:23): [True: 554, False: 0]
  |  |  ------------------
  |  |   99|    554|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 554]
  |  |  ------------------
  ------------------
  |  Branch (288:5): [True: 0, False: 0]
  |  Branch (288:5): [True: 0, False: 0]
  |  Branch (288:5): [True: 0, False: 0]
  |  Branch (288:5): [True: 0, False: 0]
  |  Branch (288:5): [True: 0, False: 0]
  |  Branch (288:5): [True: 0, False: 0]
  |  Branch (288:5): [True: 0, False: 0]
  |  Branch (288:5): [True: 0, False: 0]
  ------------------
  289|    554|    PJ_ASSERT_RETURN(rdata->msg_info.msg, PJ_EINVAL);
  ------------------
  |  |   97|    554|            do { \
  |  |   98|    554|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 554]
  |  |  ------------------
  |  |   99|    554|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 554]
  |  |  ------------------
  ------------------
  |  Branch (289:5): [True: 0, False: 0]
  |  Branch (289:5): [True: 0, False: 0]
  ------------------
  290|    554|    PJ_ASSERT_RETURN(rdata->msg_info.via, PJSIP_EMISSINGHDR);
  ------------------
  |  |   97|    554|            do { \
  |  |   98|    554|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 554]
  |  |  ------------------
  |  |   99|    554|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 554]
  |  |  ------------------
  ------------------
  |  Branch (290:5): [True: 0, False: 0]
  |  Branch (290:5): [True: 0, False: 0]
  ------------------
  291|    554|    PJ_ASSERT_RETURN(rdata->msg_info.cseq, PJSIP_EMISSINGHDR);
  ------------------
  |  |   97|    554|            do { \
  |  |   98|    554|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 554]
  |  |  ------------------
  |  |   99|    554|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 554]
  |  |  ------------------
  ------------------
  |  Branch (291:5): [True: 0, False: 0]
  |  Branch (291:5): [True: 0, False: 0]
  ------------------
  292|    554|    PJ_ASSERT_RETURN(rdata->msg_info.from, PJSIP_EMISSINGHDR);
  ------------------
  |  |   97|    554|            do { \
  |  |   98|    554|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 554]
  |  |  ------------------
  |  |   99|    554|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 554]
  |  |  ------------------
  ------------------
  |  Branch (292:5): [True: 0, False: 0]
  |  Branch (292:5): [True: 0, False: 0]
  ------------------
  293|       |
  294|    554|    host = &rdata->msg_info.via->sent_by.host;
  295|       |
  296|       |    /* Calculate length required. */
  297|    554|    len_required = method->name.slen +      /* Method */
  298|    554|                   11 +                     /* CSeq number */
  299|    554|                   rdata->msg_info.from->tag.slen +   /* From tag. */
  300|    554|                   rdata->msg_info.cid->id.slen +    /* Call-ID */
  301|    554|                   16;                      /* Separator+Allowance. */
  302|    554|    if (include_via) {
  ------------------
  |  Branch (302:9): [True: 273, False: 281]
  ------------------
  303|    273|        len_required += host->slen +        /* Via host. */
  304|    273|                        11;                 /* Via port. */
  305|    273|    }
  306|    554|    key = p = (char*) pj_pool_alloc(pool, len_required);
  307|       |
  308|       |    /* Add role. */
  309|    554|    *p++ = (char)(role==PJSIP_ROLE_UAC ? 'c' : 's');
  ------------------
  |  Branch (309:19): [True: 0, False: 554]
  ------------------
  310|    554|    *p++ = SEPARATOR;
  ------------------
  |  |  282|    554|#define SEPARATOR   '$'
  ------------------
  311|       |
  312|       |    /* Add method, except when method is INVITE or ACK. */
  313|    554|    if (method->id != PJSIP_INVITE_METHOD && method->id != PJSIP_ACK_METHOD) {
  ------------------
  |  Branch (313:9): [True: 3, False: 551]
  |  Branch (313:46): [True: 3, False: 0]
  ------------------
  314|      3|        pj_memcpy(p, method->name.ptr, method->name.slen);
  315|      3|        p += method->name.slen;
  316|      3|        *p++ = '$';
  317|      3|    }
  318|       |
  319|       |    /* Add CSeq (only the number). */
  320|    554|    len = pj_utoa(rdata->msg_info.cseq->cseq, p);
  321|    554|    p += len;
  322|    554|    *p++ = SEPARATOR;
  ------------------
  |  |  282|    554|#define SEPARATOR   '$'
  ------------------
  323|       |
  324|       |    /* Add From tag. */
  325|    554|    len = rdata->msg_info.from->tag.slen;
  326|    554|    pj_memcpy( p, rdata->msg_info.from->tag.ptr, len);
  327|    554|    p += len;
  328|    554|    *p++ = SEPARATOR;
  ------------------
  |  |  282|    554|#define SEPARATOR   '$'
  ------------------
  329|       |
  330|       |    /* Add Call-ID. */
  331|    554|    len = rdata->msg_info.cid->id.slen;
  332|    554|    pj_memcpy( p, rdata->msg_info.cid->id.ptr, len );
  333|    554|    p += len;
  334|    554|    *p++ = SEPARATOR;
  ------------------
  |  |  282|    554|#define SEPARATOR   '$'
  ------------------
  335|       |
  336|       |    /* Add top Via header. 
  337|       |     * We don't really care whether the port contains the real port (because
  338|       |     * it can be omited if default port is used). Anyway this function is 
  339|       |     * only used to match request retransmission, and we expect that the 
  340|       |     * request retransmissions will contain the same port.
  341|       |     */
  342|    554|    if (include_via) {
  ------------------
  |  Branch (342:9): [True: 273, False: 281]
  ------------------
  343|    273|        pj_memcpy(p, host->ptr, host->slen);
  344|    273|        p += host->slen;
  345|    273|        *p++ = ':';
  346|       |
  347|    273|        len = pj_utoa(rdata->msg_info.via->sent_by.port, p);
  348|    273|        p += len;
  349|    273|        *p++ = SEPARATOR;
  ------------------
  |  |  282|    273|#define SEPARATOR   '$'
  ------------------
  350|    273|    }
  351|       |
  352|    554|    *p++ = '\0';
  353|       |
  354|       |    /* Done. */
  355|    554|    str->ptr = key;
  356|    554|    str->slen = p-key;
  357|       |
  358|    554|    return PJ_SUCCESS;
  359|    554|}
sip_transaction.c:mod_tsx_layer_load:
  785|      2|{
  786|      2|    PJ_UNUSED_ARG(endpt);
  ------------------
  |  | 1537|      2|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  787|      2|    return PJ_SUCCESS;
  788|      2|}
sip_transaction.c:mod_tsx_layer_start:
  795|      2|{
  796|      2|    return PJ_SUCCESS;
  797|      2|}
sip_transaction.c:mod_tsx_layer_unregister_tsx:
  661|    281|{
  662|    281|    if (mod_tsx_layer.mod.id == -1) {
  ------------------
  |  Branch (662:9): [True: 0, False: 281]
  ------------------
  663|       |        /* The transaction layer has been unregistered. This could happen
  664|       |         * if the transaction was pending on transport and the application
  665|       |         * is shutdown. See https://github.com/pjsip/pjproject/issues/1033. In
  666|       |         * this case just do nothing.
  667|       |         */
  668|      0|        return;
  669|      0|    }
  670|       |
  671|    281|    pj_assert(tsx->transaction_key.slen != 0);
  ------------------
  |  |   65|    281|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (671:5): [True: 0, False: 281]
  |  Branch (671:5): [True: 281, False: 0]
  ------------------
  672|       |    //pj_assert(tsx->state != PJSIP_TSX_STATE_NULL);
  673|       |
  674|       |    /* Lock hash table mutex. */
  675|    281|    pj_mutex_lock(mod_tsx_layer.mutex);
  676|       |
  677|       |    /* Unregister the transaction from the hash tables. */
  678|    281|#ifdef PRECALC_HASH
  679|    281|    pj_hash_set_lower( NULL, mod_tsx_layer.htable, tsx->transaction_key.ptr,
  680|    281|                       (unsigned)tsx->transaction_key.slen, tsx->hashed_key,
  681|    281|                       NULL);
  682|    281|    if (tsx->role == PJSIP_ROLE_UAS) {
  ------------------
  |  Branch (682:9): [True: 281, False: 0]
  ------------------
  683|    281|        pj_hash_set_lower(NULL, mod_tsx_layer.htable2,
  684|    281|                          tsx->transaction_key2.ptr,
  685|    281|                          (unsigned)tsx->transaction_key2.slen,
  686|    281|                          tsx->hashed_key2, NULL);
  687|    281|    }
  688|       |#else
  689|       |    pj_hash_set_lower( NULL, mod_tsx_layer.htable, tsx->transaction_key.ptr,
  690|       |                       tsx->transaction_key.slen, 0, NULL);
  691|       |    if (tsx->role == PJSIP_ROLE_UAS) {
  692|       |        pj_hash_set_lower(NULL, mod_tsx_layer.htable2,
  693|       |                          tsx->transaction_key2.ptr,
  694|       |                          tsx->transaction_key2.slen, 0, NULL);
  695|       |    }
  696|       |#endif
  697|       |
  698|    281|    TSX_TRACE_((THIS_FILE, 
  699|    281|                "Transaction %p unregistered, hkey=0x%p and key=%.*s",
  700|    281|                tsx, tsx->hashed_key, tsx->transaction_key.slen,
  701|    281|                tsx->transaction_key.ptr));
  702|       |
  703|       |    /* Unlock mutex. */
  704|    281|    pj_mutex_unlock(mod_tsx_layer.mutex);
  705|    281|}
sip_transaction.c:tsx_create:
 1176|    281|{
 1177|    281|    pj_pool_t *pool;
 1178|    281|    pjsip_transaction *tsx;
 1179|    281|    pj_status_t status;
 1180|       |
 1181|    281|    pool = pjsip_endpt_create_pool( mod_tsx_layer.endpt, "tsx", 
 1182|    281|                                    PJSIP_POOL_TSX_LEN, PJSIP_POOL_TSX_INC );
  ------------------
  |  | 1098|    281|#   define PJSIP_POOL_TSX_LEN           1536 /* 768 */
  ------------------
                                                  PJSIP_POOL_TSX_LEN, PJSIP_POOL_TSX_INC );
  ------------------
  |  | 1105|    281|#   define PJSIP_POOL_TSX_INC           256
  ------------------
 1183|    281|    if (!pool)
  ------------------
  |  Branch (1183:9): [True: 0, False: 281]
  ------------------
 1184|      0|        return PJ_ENOMEM;
  ------------------
  |  |  408|      0|#define PJ_ENOMEM           (PJ_ERRNO_START_STATUS + 7) /* 70007 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1185|       |
 1186|    281|    tsx = PJ_POOL_ZALLOC_T(pool, pjsip_transaction);
  ------------------
  |  |  583|    281|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
 1187|    281|    tsx->pool = pool;
 1188|    281|    tsx->tsx_user = tsx_user;
 1189|    281|    tsx->endpt = mod_tsx_layer.endpt;
 1190|       |
 1191|    281|    pj_ansi_snprintf(tsx->obj_name, sizeof(tsx->obj_name), 
  ------------------
  |  |  114|    281|#define pj_ansi_snprintf        snprintf
  ------------------
 1192|    281|                     "tsx%p", tsx);
 1193|    281|    pj_memcpy(pool->obj_name, tsx->obj_name, sizeof(pool->obj_name));
 1194|       |
 1195|    281|    tsx->handle_200resp = 1;
 1196|    281|    tsx->retransmit_timer.id = TIMER_INACTIVE;
  ------------------
  |  |  137|    281|#define TIMER_INACTIVE          0
  ------------------
 1197|    281|    tsx->retransmit_timer.user_data = tsx;
 1198|    281|    tsx->retransmit_timer.cb = &tsx_timer_callback;
 1199|    281|    tsx->timeout_timer.id = TIMER_INACTIVE;
  ------------------
  |  |  137|    281|#define TIMER_INACTIVE          0
  ------------------
 1200|    281|    tsx->timeout_timer.user_data = tsx;
 1201|    281|    tsx->timeout_timer.cb = &tsx_timer_callback;
 1202|    281|    tsx->chained_lock = NULL;
 1203|       |    
 1204|    281|    if (grp_lock) {
  ------------------
  |  Branch (1204:9): [True: 281, False: 0]
  ------------------
 1205|    281|        tsx->grp_lock = grp_lock;
 1206|       |        
 1207|    281|        pj_grp_lock_add_ref(tsx->grp_lock);
 1208|    281|        pj_grp_lock_add_handler(tsx->grp_lock, tsx->pool, tsx, &tsx_on_destroy);
 1209|    281|    } else {
 1210|      0|        status = pj_grp_lock_create_w_handler(pool, NULL, tsx, &tsx_on_destroy,
 1211|      0|                                              &tsx->grp_lock);
 1212|      0|        if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (1212:13): [True: 0, False: 0]
  ------------------
 1213|      0|            pjsip_endpt_release_pool(mod_tsx_layer.endpt, pool);
 1214|      0|            return status;
 1215|      0|        }
 1216|       |        
 1217|      0|        pj_grp_lock_add_ref(tsx->grp_lock);
 1218|      0|    }
 1219|       |
 1220|    281|    status = pj_mutex_create_simple(pool, tsx->obj_name, &tsx->mutex_b);
 1221|    281|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (1221:9): [True: 0, False: 281]
  ------------------
 1222|      0|        tsx_shutdown(tsx);
 1223|      0|        return status;
 1224|      0|    }
 1225|       |
 1226|    281|    *p_tsx = tsx;
 1227|    281|    return PJ_SUCCESS;
 1228|    281|}
sip_transaction.c:tsx_timer_callback:
 1303|    281|{
 1304|    281|    pjsip_transaction *tsx = (pjsip_transaction*) entry->user_data;
 1305|       |
 1306|    281|    PJ_UNUSED_ARG(theap);
  ------------------
  |  | 1537|    281|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1307|       |
 1308|       |    /* Just return if transaction is already destroyed (see also #2102). */
 1309|    281|    if (tsx->state >= PJSIP_TSX_STATE_DESTROYED) {
  ------------------
  |  Branch (1309:9): [True: 0, False: 281]
  ------------------
 1310|      0|        return;
 1311|      0|    }
 1312|       |
 1313|       |
 1314|    281|    if (entry->id == TERMINATE_TIMER) {
  ------------------
  |  |  142|    281|#define TERMINATE_TIMER         5
  ------------------
  |  Branch (1314:9): [True: 0, False: 281]
  ------------------
 1315|      0|        if (tsx->state < PJSIP_TSX_STATE_TERMINATED) {
  ------------------
  |  Branch (1315:13): [True: 0, False: 0]
  ------------------
 1316|      0|            pjsip_tsx_terminate(tsx, tsx->status_code);
 1317|      0|        }
 1318|    281|    } else if (entry->id == TRANSPORT_ERR_TIMER ||
  ------------------
  |  |  140|    562|#define TRANSPORT_ERR_TIMER     3
  ------------------
  |  Branch (1318:16): [True: 0, False: 281]
  ------------------
 1319|    281|               entry->id == TRANSPORT_DISC_TIMER)
  ------------------
  |  |  141|    281|#define TRANSPORT_DISC_TIMER    4
  ------------------
  |  Branch (1319:16): [True: 0, False: 281]
  ------------------
 1320|      0|    {
 1321|       |        /* Posted transport error/disconnection event */
 1322|      0|        pj_bool_t tp_disc = (entry->id == TRANSPORT_DISC_TIMER);
  ------------------
  |  |  141|      0|#define TRANSPORT_DISC_TIMER    4
  ------------------
 1323|       |
 1324|      0|        entry->id = 0;
 1325|      0|        if (tsx->state < PJSIP_TSX_STATE_TERMINATED) {
  ------------------
  |  Branch (1325:13): [True: 0, False: 0]
  ------------------
 1326|      0|            pjsip_tsx_state_e prev_state;
 1327|      0|            pj_time_val timeout = { 0, 0 };
 1328|       |
 1329|      0|            pj_grp_lock_acquire(tsx->grp_lock);
 1330|      0|            prev_state = tsx->state;
 1331|       |
 1332|       |            /* Release transport as it's no longer working. */
 1333|      0|            tsx_update_transport(tsx, NULL);
 1334|       |
 1335|      0|#if PJSIP_TSX_UAS_CONTINUE_ON_TP_ERROR
 1336|      0|            if (tp_disc && tsx->method.id == PJSIP_INVITE_METHOD &&
  ------------------
  |  Branch (1336:17): [True: 0, False: 0]
  |  Branch (1336:28): [True: 0, False: 0]
  ------------------
 1337|      0|                tsx->role == PJSIP_ROLE_UAS && tsx->status_code < 200 &&
  ------------------
  |  Branch (1337:17): [True: 0, False: 0]
  |  Branch (1337:48): [True: 0, False: 0]
  ------------------
 1338|      0|                !(tsx->transport_flag & TSX_HAS_PENDING_TRANSPORT) &&
  ------------------
  |  Branch (1338:17): [True: 0, False: 0]
  ------------------
 1339|      0|                !(tsx->transport_flag & TSX_HAS_PENDING_DESTROY))
  ------------------
  |  Branch (1339:17): [True: 0, False: 0]
  ------------------
 1340|       |#else
 1341|       |            PJ_UNUSED_ARG(tp_disc);
 1342|       |            if (0)
 1343|       |#endif
 1344|      0|            {
 1345|       |                /* Upon transport disconnection event, if we receive
 1346|       |                 * incoming INVITE and haven't responded with a final answer,
 1347|       |                 * just return here and don't terminate the transaction,
 1348|       |                 * in case that the library can switch to another working
 1349|       |                 * transport.
 1350|       |                 */
 1351|      0|                tsx->transport_flag = 0;
 1352|      0|                tsx->addr_len = 0;
 1353|      0|                tsx->res_addr.transport = NULL;
 1354|      0|                tsx->res_addr.addr_len = 0;
 1355|       |                
 1356|      0|                pj_grp_lock_release(tsx->grp_lock);
 1357|      0|                return;
 1358|      0|            }
 1359|       |
 1360|      0|            if (tsx->status_code < 200) {
  ------------------
  |  Branch (1360:17): [True: 0, False: 0]
  ------------------
 1361|      0|                pj_str_t err;
 1362|      0|                char errmsg[PJ_ERR_MSG_SIZE];
 1363|       |
 1364|      0|                err = pj_strerror(tsx->transport_err, errmsg, sizeof(errmsg));
 1365|      0|                tsx_set_status_code(tsx, PJSIP_SC_TSX_TRANSPORT_ERROR, &err);
 1366|      0|            }
 1367|       |
 1368|       |            /* Set transaction state etc, but don't notify TU now,
 1369|       |             * otherwise we'll get a deadlock. See:
 1370|       |             * https://github.com/pjsip/pjproject/issues/1646
 1371|       |             */
 1372|       |            /* Also don't schedule tsx handler, otherwise we'll get race
 1373|       |             * condition of TU notifications due to delayed TERMINATED
 1374|       |             * state TU notification. It happened in multiple worker threads
 1375|       |             * environment between TERMINATED & DESTROYED! See:
 1376|       |             * https://github.com/pjsip/pjproject/issues/1902
 1377|       |             */
 1378|      0|            tsx_set_state( tsx, PJSIP_TSX_STATE_TERMINATED,
 1379|      0|                           PJSIP_EVENT_TRANSPORT_ERROR, NULL,
 1380|      0|                           NO_NOTIFY | NO_SCHEDULE_HANDLER);
 1381|      0|            pj_grp_lock_release(tsx->grp_lock);
 1382|       |
 1383|       |            /* Now notify TU about state change, WITHOUT holding the
 1384|       |             * group lock. It should be safe to do so; transaction will
 1385|       |             * not get destroyed because group lock reference counter
 1386|       |             * has been incremented by the timer heap.
 1387|       |             */
 1388|      0|            if (tsx->tsx_user && tsx->tsx_user->on_tsx_state) {
  ------------------
  |  Branch (1388:17): [True: 0, False: 0]
  |  Branch (1388:34): [True: 0, False: 0]
  ------------------
 1389|      0|                pjsip_event e;
 1390|      0|                PJSIP_EVENT_INIT_TSX_STATE(e, tsx,
  ------------------
  |  |  169|      0|        do { \
  |  |  170|      0|            (event).type = PJSIP_EVENT_TSX_STATE;           \
  |  |  171|      0|            (event).body.tsx_state.tsx = ptsx;              \
  |  |  172|      0|            (event).body.tsx_state.type = ptype;            \
  |  |  173|      0|            (event).body.tsx_state.src.data = pdata;        \
  |  |  174|      0|            (event).body.tsx_state.prev_state = prev;       \
  |  |  175|      0|        } while (0)
  |  |  ------------------
  |  |  |  Branch (175:18): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1391|      0|                                           PJSIP_EVENT_TRANSPORT_ERROR, NULL,
 1392|      0|                                           prev_state);
 1393|      0|                (*tsx->tsx_user->on_tsx_state)(tsx, &e);
 1394|      0|            }
 1395|       |
 1396|       |            /* Now let's schedule the tsx handler */
 1397|      0|            tsx_schedule_timer(tsx, &tsx->timeout_timer, &timeout,
 1398|      0|                               TIMEOUT_TIMER);
  ------------------
  |  |  139|      0|#define TIMEOUT_TIMER           2
  ------------------
 1399|      0|        }
 1400|    281|    } else {
 1401|    281|        pjsip_event event;
 1402|       |
 1403|    281|        entry->id = 0;
 1404|       |
 1405|    281|        PJ_LOG(5,(tsx->obj_name, "%s timer event",
  ------------------
  |  |  106|    281|#define PJ_LOG(level,arg)       do { \
  |  |  107|    281|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|    562|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 281, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 281]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (496:50): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|    281|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 281]
  |  |  ------------------
  ------------------
 1406|    281|                 (entry==&tsx->retransmit_timer ? "Retransmit":"Timeout")));
 1407|    281|        pj_log_push_indent();
 1408|       |
 1409|       |
 1410|    281|        PJSIP_EVENT_INIT_TIMER(event, entry);
  ------------------
  |  |  160|    281|        do { \
  |  |  161|    281|            (event).type = PJSIP_EVENT_TIMER;           \
  |  |  162|    281|            (event).body.timer.entry = pentry;          \
  |  |  163|    281|        } while (0)
  |  |  ------------------
  |  |  |  Branch (163:18): [Folded, False: 281]
  |  |  ------------------
  ------------------
 1411|       |
 1412|       |        /* Dispatch event to transaction. */
 1413|    281|        pj_grp_lock_acquire(tsx->grp_lock);
 1414|    281|        (*tsx->state_handler)(tsx, &event);
 1415|    281|        pj_grp_lock_release(tsx->grp_lock);
 1416|       |
 1417|    281|        pj_log_pop_indent();
 1418|    281|    }
 1419|    281|}
sip_transaction.c:tsx_on_destroy:
 1232|    281|{
 1233|    281|    pjsip_transaction *tsx = (pjsip_transaction*)arg;
 1234|       |
 1235|    281|    PJ_LOG(5,(tsx->obj_name, "Transaction destroyed!"));
  ------------------
  |  |  106|    281|#define PJ_LOG(level,arg)       do { \
  |  |  107|    281|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|    562|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 281, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 281]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|    281|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 281]
  |  |  ------------------
  ------------------
 1236|       |
 1237|    281|    pj_mutex_destroy(tsx->mutex_b);
 1238|    281|    pjsip_endpt_release_pool(tsx->endpt, tsx->pool);
 1239|    281|}
sip_transaction.c:tsx_shutdown:
 1243|    281|{
 1244|       |    /* Release the transport */
 1245|    281|    tsx_update_transport(tsx, NULL);
 1246|       |
 1247|       |    /* Decrement reference counter in transport selector, only if
 1248|       |     * we haven't been called before */
 1249|    281|    if (!tsx->terminating) {
  ------------------
  |  Branch (1249:9): [True: 281, False: 0]
  ------------------
 1250|    281|        pjsip_tpselector_dec_ref(&tsx->tp_sel);
 1251|       |        
 1252|       |        /* Unchain and dec ref the chained lock (e.g., dialog lock) if it was set.
 1253|       |         * This must be done before the group lock is destroyed.
 1254|       |         * The chained_lock is stored when pj_grp_lock_chain_lock() is called
 1255|       |         * in sip_dialog.c to prevent lock-order-inversion.
 1256|       |         */
 1257|    281|        if (tsx->chained_lock) {
  ------------------
  |  Branch (1257:13): [True: 281, False: 0]
  ------------------
 1258|    281|            pj_grp_lock_unchain_lock(tsx->grp_lock, (pj_lock_t *)tsx->chained_lock);
 1259|    281|            pj_grp_lock_dec_ref(tsx->chained_lock);
 1260|    281|            tsx->chained_lock = NULL;
 1261|    281|        }
 1262|    281|    }
 1263|       |
 1264|       |    /* Free last transmitted message. */
 1265|    281|    if (tsx->last_tx) {
  ------------------
  |  Branch (1265:9): [True: 0, False: 281]
  ------------------
 1266|      0|        pjsip_tx_data_dec_ref( tsx->last_tx );
 1267|      0|        tsx->last_tx = NULL;
 1268|      0|    }
 1269|       |    /* Cancel timeout timer. */
 1270|    281|    tsx_cancel_timer(tsx, &tsx->timeout_timer);
 1271|       |
 1272|       |    /* Cancel retransmission timer. */
 1273|    281|    tsx_cancel_timer(tsx, &tsx->retransmit_timer);
 1274|       |
 1275|       |    /* Clear some pending flags. */
 1276|    281|    tsx->transport_flag &= ~(TSX_HAS_PENDING_RESCHED | TSX_HAS_PENDING_SEND);
 1277|       |
 1278|       |
 1279|       |    /* Refuse to destroy transaction if it has pending resolving. */
 1280|    281|    if (tsx->transport_flag & TSX_HAS_PENDING_TRANSPORT) {
  ------------------
  |  Branch (1280:9): [True: 0, False: 281]
  ------------------
 1281|      0|        tsx->transport_flag |= TSX_HAS_PENDING_DESTROY;
 1282|      0|        tsx->tsx_user = NULL;
 1283|      0|        PJ_LOG(4,(tsx->obj_name, "Will destroy later because transport is "
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1284|      0|                                 "in progress"));
 1285|      0|    }
 1286|       |
 1287|    281|    if (!tsx->terminating) {
  ------------------
  |  Branch (1287:9): [True: 281, False: 0]
  ------------------
 1288|    281|        tsx->terminating = PJ_TRUE;
 1289|    281|        pj_grp_lock_dec_ref(tsx->grp_lock);
 1290|    281|    }
 1291|       |
 1292|       |    /* No acccess to tsx after this, it may have been destroyed */
 1293|       |
 1294|    281|    return PJ_SUCCESS;
 1295|    281|}
sip_transaction.c:mod_tsx_layer_register_tsx:
  596|    281|{
  597|    281|    pj_assert(tsx->transaction_key.slen != 0);
  ------------------
  |  |   65|    281|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (597:5): [True: 0, False: 281]
  |  Branch (597:5): [True: 281, False: 0]
  ------------------
  598|       |
  599|       |    /* Lock hash table mutex. */
  600|    281|    pj_mutex_lock(mod_tsx_layer.mutex);
  601|       |
  602|       |    /* Check if no transaction with the same key exists. 
  603|       |     * Do not use PJ_ASSERT_RETURN since it evaluates the expression
  604|       |     * twice!
  605|       |     */
  606|    281|    if(pj_hash_get_lower(mod_tsx_layer.htable, 
  ------------------
  |  Branch (606:8): [True: 0, False: 281]
  ------------------
  607|    281|                         tsx->transaction_key.ptr,
  608|    281|                         (unsigned)tsx->transaction_key.slen, 
  609|    281|                         NULL))
  610|      0|    {
  611|      0|        pj_mutex_unlock(mod_tsx_layer.mutex);
  612|      0|        PJ_LOG(2,(THIS_FILE, 
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  448|      0|    #define pj_log_wrapper_2(arg)       pj_log_2 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
  613|      0|                  "Unable to register %.*s transaction (key exists)",
  614|      0|                  (int)tsx->method.name.slen,
  615|      0|                  tsx->method.name.ptr));
  616|      0|        return PJ_EEXISTS;
  ------------------
  |  |  448|      0|#define PJ_EEXISTS          (PJ_ERRNO_START_STATUS + 15)/* 70015 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  617|      0|    }
  618|       |
  619|    281|    TSX_TRACE_((THIS_FILE, 
  620|    281|                "Transaction %p registered with hkey=0x%p and key=%.*s",
  621|    281|                tsx, tsx->hashed_key, tsx->transaction_key.slen,
  622|    281|                tsx->transaction_key.ptr));
  623|       |
  624|       |    /* Register the transaction to the hash tables. We register the tsx
  625|       |     * to the secondary hash table only if it's UAS, for the purpose of
  626|       |     * detecting merged requests.
  627|       |     */
  628|    281|#ifdef PRECALC_HASH
  629|    281|    pj_hash_set_lower( tsx->pool, mod_tsx_layer.htable,
  630|    281|                       tsx->transaction_key.ptr,
  631|    281|                       (unsigned)tsx->transaction_key.slen, 
  632|    281|                       tsx->hashed_key, tsx);
  633|    281|    if (tsx->role == PJSIP_ROLE_UAS) {
  ------------------
  |  Branch (633:9): [True: 281, False: 0]
  ------------------
  634|    281|        pj_hash_set_lower( tsx->pool, mod_tsx_layer.htable2,
  635|    281|                           tsx->transaction_key2.ptr,
  636|    281|                           (unsigned)tsx->transaction_key2.slen,
  637|    281|                           tsx->hashed_key2, tsx);
  638|    281|    }
  639|       |#else
  640|       |    pj_hash_set_lower( tsx->pool, mod_tsx_layer.htable,
  641|       |                       tsx->transaction_key.ptr,
  642|       |                       tsx->transaction_key.slen, 0, tsx);
  643|       |    if (tsx->role == PJSIP_ROLE_UAS) {
  644|       |        pj_hash_set_lower( tsx->pool, mod_tsx_layer.htable2,
  645|       |                           tsx->transaction_key2.ptr,
  646|       |                           tsx->transaction_key2.slen, 0, tsx);
  647|       |    }
  648|       |#endif
  649|       |
  650|       |    /* Unlock mutex. */
  651|    281|    pj_mutex_unlock(mod_tsx_layer.mutex);
  652|       |
  653|    281|    return PJ_SUCCESS;
  654|    281|}
sip_transaction.c:tsx_set_status_code:
 1897|    281|{
 1898|    281|    tsx->status_code = code;
 1899|    281|    if (reason)
  ------------------
  |  Branch (1899:9): [True: 0, False: 281]
  ------------------
 1900|      0|        pj_strdup(tsx->pool, &tsx->status_text, reason);
 1901|    281|    else
 1902|    281|        tsx->status_text = *pjsip_get_status_text(code);
 1903|    281|}
sip_transaction.c:tsx_set_state:
 1430|    843|{
 1431|    843|    pjsip_tsx_state_e prev_state = tsx->state;
 1432|       |
 1433|       |    /* New state must be greater than previous state */
 1434|    843|    pj_assert(state >= tsx->state);
  ------------------
  |  |   65|    843|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (1434:5): [True: 0, False: 843]
  |  Branch (1434:5): [True: 843, False: 0]
  ------------------
 1435|       |
 1436|    843|    PJ_LOG(5, (tsx->obj_name, "State changed from %s to %s, event=%s",
  ------------------
  |  |  106|    843|#define PJ_LOG(level,arg)       do { \
  |  |  107|    843|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  1.68k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 843, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 843]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|    843|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 843]
  |  |  ------------------
  ------------------
 1437|    843|               state_str[tsx->state], state_str[state], 
 1438|    843|               pjsip_event_str(event_src_type)));
 1439|    843|    pj_log_push_indent();
 1440|       |
 1441|       |    /* Change state. */
 1442|    843|    tsx->state = state;
 1443|       |
 1444|       |    /* Update the state handlers. */
 1445|    843|    if (tsx->role == PJSIP_ROLE_UAC) {
  ------------------
  |  Branch (1445:9): [True: 0, False: 843]
  ------------------
 1446|      0|        tsx->state_handler = tsx_state_handler_uac[state];
 1447|    843|    } else {
 1448|    843|        tsx->state_handler = tsx_state_handler_uas[state];
 1449|    843|    }
 1450|       |
 1451|       |    /* Before informing TU about state changed, inform TU about
 1452|       |     * rx event.
 1453|       |     */
 1454|    843|    if (event_src_type==PJSIP_EVENT_RX_MSG && tsx->tsx_user &&
  ------------------
  |  Branch (1454:9): [True: 281, False: 562]
  |  Branch (1454:47): [True: 281, False: 0]
  ------------------
 1455|    281|        (flag & NO_NOTIFY)==0)
  ------------------
  |  Branch (1455:9): [True: 281, False: 0]
  ------------------
 1456|    281|    {
 1457|    281|        pjsip_rx_data *rdata = (pjsip_rx_data*) event_src;
 1458|       |
 1459|    281|        pj_assert(rdata != NULL);
  ------------------
  |  |   65|    281|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (1459:9): [True: 0, False: 281]
  |  Branch (1459:9): [True: 281, False: 0]
  ------------------
 1460|       |
 1461|    281|        if (rdata->msg_info.msg->type == PJSIP_RESPONSE_MSG &&
  ------------------
  |  Branch (1461:13): [True: 0, False: 281]
  ------------------
 1462|      0|                   tsx->tsx_user->on_rx_response)
  ------------------
  |  Branch (1462:20): [True: 0, False: 0]
  ------------------
 1463|      0|        {
 1464|      0|            (*tsx->tsx_user->on_rx_response)(rdata);
 1465|      0|        }
 1466|       |
 1467|    281|    }
 1468|       |
 1469|       |    /* Inform TU about state changed. */
 1470|    843|    if (tsx->tsx_user && tsx->tsx_user->on_tsx_state &&
  ------------------
  |  Branch (1470:9): [True: 843, False: 0]
  |  Branch (1470:26): [True: 843, False: 0]
  ------------------
 1471|    843|        (flag & NO_NOTIFY) == 0)
  ------------------
  |  Branch (1471:9): [True: 843, False: 0]
  ------------------
 1472|    843|    {
 1473|    843|        pjsip_event e;
 1474|    843|        PJSIP_EVENT_INIT_TSX_STATE(e, tsx, event_src_type, event_src,
  ------------------
  |  |  169|    843|        do { \
  |  |  170|    843|            (event).type = PJSIP_EVENT_TSX_STATE;           \
  |  |  171|    843|            (event).body.tsx_state.tsx = ptsx;              \
  |  |  172|    843|            (event).body.tsx_state.type = ptype;            \
  |  |  173|    843|            (event).body.tsx_state.src.data = pdata;        \
  |  |  174|    843|            (event).body.tsx_state.prev_state = prev;       \
  |  |  175|    843|        } while (0)
  |  |  ------------------
  |  |  |  Branch (175:18): [Folded, False: 843]
  |  |  ------------------
  ------------------
 1475|    843|                                   prev_state);
 1476|       |
 1477|       |        /* For timer event, release lock to avoid deadlock.
 1478|       |         * This should be safe because:
 1479|       |         * 1. The tsx state just switches to TERMINATED or DESTROYED.
 1480|       |         * 2. There should be no other processing taking place. All other
 1481|       |         *    events, such as the ones handled by tsx_on_state_terminated()
 1482|       |         *    should be ignored.
 1483|       |         * 3. tsx_shutdown() hasn't been called.
 1484|       |         * Refer to ticket #2001 (https://github.com/pjsip/pjproject/issues/2001).
 1485|       |         */
 1486|    843|        if ((flag & RELEASE_LOCK) != 0 ||
  ------------------
  |  Branch (1486:13): [True: 0, False: 843]
  ------------------
 1487|    843|            (event_src_type == PJSIP_EVENT_TIMER &&
  ------------------
  |  Branch (1487:14): [True: 281, False: 562]
  ------------------
 1488|    281|             (pj_timer_entry *)event_src == &tsx->timeout_timer))
  ------------------
  |  Branch (1488:14): [True: 281, False: 0]
  ------------------
 1489|    281|        {
 1490|    281|            pj_grp_lock_release(tsx->grp_lock);
 1491|    281|        }
 1492|       |
 1493|    843|        (*tsx->tsx_user->on_tsx_state)(tsx, &e);
 1494|       |
 1495|    843|        if ((flag & RELEASE_LOCK) != 0 ||
  ------------------
  |  Branch (1495:13): [True: 0, False: 843]
  ------------------
 1496|    843|            (event_src_type == PJSIP_EVENT_TIMER &&
  ------------------
  |  Branch (1496:14): [True: 281, False: 562]
  ------------------
 1497|    281|             (pj_timer_entry *)event_src == &tsx->timeout_timer))
  ------------------
  |  Branch (1497:14): [True: 281, False: 0]
  ------------------
 1498|    281|        {
 1499|    281|            pj_grp_lock_acquire(tsx->grp_lock);
 1500|    281|        }
 1501|    843|    }
 1502|       |    
 1503|       |
 1504|       |    /* When the transaction is terminated, release transport, and free the
 1505|       |     * saved last transmitted message.
 1506|       |     */
 1507|    843|    if (state == PJSIP_TSX_STATE_TERMINATED) {
  ------------------
  |  Branch (1507:9): [True: 281, False: 562]
  ------------------
 1508|    281|        pj_time_val timeout = { 0, 0 };
 1509|       |
 1510|       |        /* If we're still waiting for a message to be sent.. */
 1511|    281|        if (tsx->transport_flag & TSX_HAS_PENDING_TRANSPORT) {
  ------------------
  |  Branch (1511:13): [True: 0, False: 281]
  ------------------
 1512|       |            /* Disassociate ourselves from the outstanding transmit data
 1513|       |             * so that when the send callback is called we will be able
 1514|       |             * to ignore that (otherwise we'll get assertion, see
 1515|       |             * https://github.com/pjsip/pjproject/issues/1033)
 1516|       |             */
 1517|      0|            if (tsx->pending_tx) {
  ------------------
  |  Branch (1517:17): [True: 0, False: 0]
  ------------------
 1518|      0|                tsx->pending_tx->mod_data[mod_tsx_layer.mod.id] = NULL;
 1519|      0|                tsx->pending_tx = NULL;
 1520|       |
 1521|       |                /* Decrease pending send counter */
 1522|      0|                pj_grp_lock_dec_ref(tsx->grp_lock);
 1523|      0|            }
 1524|      0|            tsx->transport_flag &= ~(TSX_HAS_PENDING_TRANSPORT);
 1525|      0|        }
 1526|       |
 1527|    281|        lock_timer(tsx);
 1528|    281|        tsx_cancel_timer(tsx, &tsx->timeout_timer);
 1529|    281|        if ((flag & NO_SCHEDULE_HANDLER) == 0) {
  ------------------
  |  Branch (1529:13): [True: 281, False: 0]
  ------------------
 1530|    281|            tsx_schedule_timer(tsx, &tsx->timeout_timer, &timeout,
 1531|    281|                               TIMEOUT_TIMER);
  ------------------
  |  |  139|    281|#define TIMEOUT_TIMER           2
  ------------------
 1532|    281|        }
 1533|    281|        unlock_timer(tsx);
 1534|       |
 1535|    562|    } else if (state == PJSIP_TSX_STATE_DESTROYED) {
  ------------------
  |  Branch (1535:16): [True: 281, False: 281]
  ------------------
 1536|       |
 1537|       |        /* Unregister transaction. */
 1538|    281|        mod_tsx_layer_unregister_tsx(tsx);
 1539|       |
 1540|       |        /* Destroy transaction. */
 1541|    281|        tsx_shutdown(tsx);
 1542|    281|    }
 1543|       |
 1544|    843|    pj_log_pop_indent();
 1545|    843|}
sip_transaction.c:tsx_on_state_terminated:
 3884|    281|{
 3885|    281|    pj_assert(tsx->state == PJSIP_TSX_STATE_TERMINATED);
  ------------------
  |  |   65|    281|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (3885:5): [True: 0, False: 281]
  |  Branch (3885:5): [True: 281, False: 0]
  ------------------
 3886|       |
 3887|       |    /* Ignore events other than timer. This used to be an assertion but
 3888|       |     * events may genuinely arrive at this state.
 3889|       |     */
 3890|    281|    if (event->type != PJSIP_EVENT_TIMER) {
  ------------------
  |  Branch (3890:9): [True: 0, False: 281]
  ------------------
 3891|      0|        return PJ_EIGNORED;
  ------------------
  |  |  474|      0|#define PJ_EIGNORED         (PJ_ERRNO_START_STATUS + 20)/* 70020 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3892|      0|    }
 3893|       |
 3894|       |    /* Destroy this transaction */
 3895|    281|    tsx_set_state(tsx, PJSIP_TSX_STATE_DESTROYED, 
 3896|    281|                  event->type, event->body.user.user1, 0 );
 3897|       |
 3898|    281|    return PJ_SUCCESS;
 3899|    281|}
sip_transaction.c:lock_timer:
 1135|    281|{
 1136|    281|    pj_mutex_lock(tsx->mutex_b);
 1137|    281|}
sip_transaction.c:tsx_cancel_timer:
 1165|    843|{
 1166|    843|    pj_timer_heap_t *timer_heap = pjsip_endpt_get_timer_heap(tsx->endpt);
 1167|    843|    return pj_timer_heap_cancel_if_active(timer_heap, entry, TIMER_INACTIVE);
  ------------------
  |  |  137|    843|#define TIMER_INACTIVE          0
  ------------------
 1168|    843|}
sip_transaction.c:tsx_schedule_timer:
 1150|    281|{
 1151|    281|    pj_timer_heap_t *timer_heap = pjsip_endpt_get_timer_heap(tsx->endpt);
 1152|    281|    pj_status_t status;
 1153|       |
 1154|    281|    pj_assert(active_id != 0);
  ------------------
  |  |   65|    281|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (1154:5): [True: 0, False: 281]
  |  Branch (1154:5): [True: 281, False: 0]
  ------------------
 1155|    281|    status = pj_timer_heap_schedule_w_grp_lock(timer_heap, entry,
  ------------------
  |  |  280|    281|        pj_timer_heap_schedule_w_grp_lock_dbg(ht,e,d,id,g,__FILE__,__LINE__)
  ------------------
 1156|    281|                                               delay, active_id,
 1157|    281|                                               tsx->grp_lock);
 1158|       |
 1159|    281|    return status;
 1160|    281|}
sip_transaction.c:unlock_timer:
 1141|    281|{
 1142|    281|    pj_mutex_unlock(tsx->mutex_b);
 1143|    281|}
sip_transaction.c:tsx_update_transport:
 2858|    302|{
 2859|    302|    pj_assert(tsx);
  ------------------
  |  |   65|    302|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (2859:5): [True: 0, False: 302]
  |  Branch (2859:5): [True: 302, False: 0]
  ------------------
 2860|       |
 2861|    302|    if (tsx->transport) {
  ------------------
  |  Branch (2861:9): [True: 21, False: 281]
  ------------------
 2862|     21|        if (tsx->tp_st_key) {
  ------------------
  |  Branch (2862:13): [True: 21, False: 0]
  ------------------
 2863|     21|            pjsip_transport_remove_state_listener(tsx->transport,
 2864|     21|                                                  tsx->tp_st_key, tsx);
 2865|     21|        }
 2866|     21|        pjsip_transport_dec_ref( tsx->transport );
 2867|     21|        tsx->transport = NULL;
 2868|     21|    }
 2869|       |
 2870|    302|    if (tp) {
  ------------------
  |  Branch (2870:9): [True: 21, False: 281]
  ------------------
 2871|     21|        tsx->transport = tp;
 2872|     21|        pjsip_transport_add_ref(tp);
 2873|     21|        pjsip_transport_add_state_listener(tp, &tsx_tp_state_callback, tsx,
 2874|     21|                                            &tsx->tp_st_key);
 2875|     21|        if (tp->is_shutdown || tp->is_destroying) {
  ------------------
  |  Branch (2875:13): [True: 0, False: 21]
  |  Branch (2875:32): [True: 0, False: 21]
  ------------------
 2876|      0|            pjsip_transport_state_info info;
 2877|       |
 2878|      0|            pj_bzero(&info, sizeof(info));
 2879|      0|            info.user_data = tsx;
 2880|      0|            info.status = PJSIP_SC_TSX_TRANSPORT_ERROR;
 2881|      0|            tsx_tp_state_callback(tp, PJSIP_TP_STATE_DISCONNECTED, &info);
 2882|      0|        }
 2883|     21|    }
 2884|    302|}
sip_transaction.c:tsx_on_state_null:
 2891|    281|{
 2892|    281|    pj_status_t status;
 2893|       |
 2894|    281|    pj_assert(tsx->state == PJSIP_TSX_STATE_NULL);
  ------------------
  |  |   65|    281|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (2894:5): [True: 0, False: 281]
  |  Branch (2894:5): [True: 281, False: 0]
  ------------------
 2895|       |
 2896|    281|    if (tsx->role == PJSIP_ROLE_UAS) {
  ------------------
  |  Branch (2896:9): [True: 281, False: 0]
  ------------------
 2897|       |
 2898|       |        /* Set state to Trying. */
 2899|    281|        pj_assert(event->type == PJSIP_EVENT_RX_MSG &&
  ------------------
  |  |   65|    281|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (2899:9): [True: 0, False: 281]
  |  Branch (2899:9): [True: 0, False: 0]
  |  Branch (2899:9): [True: 281, False: 0]
  |  Branch (2899:9): [True: 281, False: 0]
  ------------------
 2900|    281|                  event->body.rx_msg.rdata->msg_info.msg->type == 
 2901|    281|                    PJSIP_REQUEST_MSG);
 2902|    281|        tsx_set_state( tsx, PJSIP_TSX_STATE_TRYING, PJSIP_EVENT_RX_MSG,
 2903|    281|                       event->body.rx_msg.rdata, 0);
 2904|       |
 2905|    281|    } else {
 2906|      0|        pjsip_tx_data *tdata;
 2907|       |
 2908|       |        /* Must be transmit event. 
 2909|       |         * You may got this assertion when using loop transport with delay 
 2910|       |         * set to zero. That would cause on_rx_response() callback to be 
 2911|       |         * called before tsx_send_msg() has completed.
 2912|       |         */
 2913|      0|        PJ_ASSERT_RETURN(event->type == PJSIP_EVENT_TX_MSG, PJ_EBUG);
  ------------------
  |  |   97|      0|            do { \
  |  |   98|      0|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 0]
  |  |  ------------------
  |  |   99|      0|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (2913:9): [True: 0, False: 0]
  |  Branch (2913:9): [True: 0, False: 0]
  ------------------
 2914|       |
 2915|       |        /* Get the txdata */
 2916|      0|        tdata = event->body.tx_msg.tdata;
 2917|       |
 2918|       |        /* Save the message for retransmission. */
 2919|      0|        if (tsx->last_tx && tsx->last_tx != tdata) {
  ------------------
  |  Branch (2919:13): [True: 0, False: 0]
  |  Branch (2919:29): [True: 0, False: 0]
  ------------------
 2920|      0|            pjsip_tx_data_dec_ref(tsx->last_tx);
 2921|      0|            tsx->last_tx = NULL;
 2922|      0|        }
 2923|      0|        if (tsx->last_tx != tdata) {
  ------------------
  |  Branch (2923:13): [True: 0, False: 0]
  ------------------
 2924|      0|            tsx->last_tx = tdata;
 2925|      0|            pjsip_tx_data_add_ref(tdata);
 2926|      0|        }
 2927|       |
 2928|       |        /* Send the message. */
 2929|      0|        status = tsx_send_msg( tsx, tdata);
 2930|      0|        if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (2930:13): [True: 0, False: 0]
  ------------------
 2931|      0|            return status;
 2932|      0|        }
 2933|       |
 2934|       |        /* Start Timer B (or called timer F for non-INVITE) for transaction 
 2935|       |         * timeout.
 2936|       |         */
 2937|      0|        lock_timer(tsx);
 2938|      0|        tsx_cancel_timer( tsx, &tsx->timeout_timer );
 2939|      0|        tsx_schedule_timer( tsx, &tsx->timeout_timer, &timeout_timer_val,
 2940|      0|                            TIMEOUT_TIMER);
  ------------------
  |  |  139|      0|#define TIMEOUT_TIMER           2
  ------------------
 2941|      0|        unlock_timer(tsx);
 2942|       |
 2943|       |        /* Start Timer A (or timer E) for retransmission only if unreliable 
 2944|       |         * transport is being used.
 2945|       |         */
 2946|      0|        if (!tsx->is_reliable)  {
  ------------------
  |  Branch (2946:13): [True: 0, False: 0]
  ------------------
 2947|      0|            tsx->retransmit_count = 0;
 2948|      0|            if (tsx->transport_flag & TSX_HAS_PENDING_TRANSPORT) {
  ------------------
  |  Branch (2948:17): [True: 0, False: 0]
  ------------------
 2949|      0|                tsx->transport_flag |= TSX_HAS_PENDING_RESCHED;
 2950|      0|            } else {
 2951|      0|                tsx_schedule_timer(tsx, &tsx->retransmit_timer,
 2952|      0|                                   &t1_timer_val, RETRANSMIT_TIMER);
  ------------------
  |  |  138|      0|#define RETRANSMIT_TIMER        1
  ------------------
 2953|      0|            }
 2954|      0|        }
 2955|       |
 2956|       |        /* Move state. */
 2957|      0|        tsx_set_state( tsx, PJSIP_TSX_STATE_CALLING, 
 2958|      0|                       PJSIP_EVENT_TX_MSG, tdata, 0);
 2959|      0|    }
 2960|       |
 2961|    281|    return PJ_SUCCESS;
 2962|    281|}

pjsip_transport_get_default_port_for_type:
  423|    264|{
  424|       |    /* Return the port. */
  425|    264|    return get_tpname(type)->port;
  426|    264|}
pjsip_tpselector_dec_ref:
  470|    730|{
  471|    730|    if (sel->type == PJSIP_TPSELECTOR_TRANSPORT && sel->u.transport != NULL)
  ------------------
  |  Branch (471:9): [True: 0, False: 730]
  |  Branch (471:52): [True: 0, False: 0]
  ------------------
  472|      0|        pjsip_transport_dec_ref(sel->u.transport);
  473|    730|    else if (sel->type == PJSIP_TPSELECTOR_LISTENER && sel->u.listener != NULL) {
  ------------------
  |  Branch (473:14): [True: 0, False: 730]
  |  Branch (473:56): [True: 0, False: 0]
  ------------------
  474|      0|        ; /* Hmm.. looks like we don't have reference counter for listener */
  475|      0|    }
  476|    730|}
pjsip_tx_data_create:
  490|    449|{
  491|    449|    pj_pool_t *pool;
  492|    449|    pjsip_tx_data *tdata;
  493|    449|    pj_status_t status;
  494|       |
  495|    449|    PJ_ASSERT_RETURN(mgr && p_tdata, PJ_EINVAL);
  ------------------
  |  |   97|    449|            do { \
  |  |   98|    898|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 449, False: 0]
  |  |  |  Branch (98:23): [True: 449, False: 0]
  |  |  ------------------
  |  |   99|    449|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 449]
  |  |  ------------------
  ------------------
  |  Branch (495:5): [True: 0, False: 0]
  |  Branch (495:5): [True: 0, False: 0]
  |  Branch (495:5): [True: 0, False: 0]
  |  Branch (495:5): [True: 0, False: 0]
  ------------------
  496|       |
  497|    449|    pool = pjsip_endpt_create_pool( mgr->endpt, "tdta%p",
  498|    449|                                    PJSIP_POOL_LEN_TDATA,
  ------------------
  |  | 1019|    449|#   define PJSIP_POOL_LEN_TDATA         4000
  ------------------
  499|    449|                                    PJSIP_POOL_INC_TDATA );
  ------------------
  |  | 1026|    449|#   define PJSIP_POOL_INC_TDATA         4000
  ------------------
  500|    449|    if (!pool)
  ------------------
  |  Branch (500:9): [True: 0, False: 449]
  ------------------
  501|      0|        return PJ_ENOMEM;
  ------------------
  |  |  408|      0|#define PJ_ENOMEM           (PJ_ERRNO_START_STATUS + 7) /* 70007 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  502|       |
  503|    449|    tdata = PJ_POOL_ZALLOC_T(pool, pjsip_tx_data);
  ------------------
  |  |  583|    449|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  504|    449|    tdata->pool = pool;
  505|    449|    tdata->mgr = mgr;
  506|    449|    pj_ansi_snprintf(tdata->obj_name, sizeof(tdata->obj_name), "tdta%p", tdata);
  ------------------
  |  |  114|    449|#define pj_ansi_snprintf        snprintf
  ------------------
  507|    449|    pj_memcpy(pool->obj_name, tdata->obj_name, sizeof(pool->obj_name));
  508|       |
  509|    449|    status = pj_atomic_create(tdata->pool, 0, &tdata->ref_cnt);
  510|    449|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (510:9): [True: 0, False: 449]
  ------------------
  511|      0|        pjsip_endpt_release_pool( mgr->endpt, tdata->pool );
  512|      0|        return status;
  513|      0|    }
  514|       |    
  515|       |    //status = pj_lock_create_simple_mutex(pool, "tdta%p", &tdata->lock);
  516|    449|    status = pj_lock_create_null_mutex(pool, "tdta%p", &tdata->lock);
  517|    449|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (517:9): [True: 0, False: 449]
  ------------------
  518|      0|        pjsip_endpt_release_pool( mgr->endpt, tdata->pool );
  519|      0|        return status;
  520|      0|    }
  521|       |
  522|    449|    pj_ioqueue_op_key_init(&tdata->op_key.key, sizeof(tdata->op_key.key));
  523|    449|    pj_list_init(tdata);
  524|       |
  525|       |#if defined(PJSIP_HAS_TX_DATA_LIST) && PJSIP_HAS_TX_DATA_LIST!=0
  526|       |    /* Append this just created tdata to transmit buffer list */
  527|       |    pj_lock_acquire(mgr->lock);
  528|       |    pj_list_push_back(&mgr->tdata_list, tdata);
  529|       |    pj_lock_release(mgr->lock);
  530|       |#endif
  531|       |
  532|    449|#if defined(PJ_DEBUG) && PJ_DEBUG!=0
  533|    449|    pj_atomic_inc( tdata->mgr->tdata_counter );
  534|    449|#endif
  535|       |
  536|    449|    *p_tdata = tdata;
  537|    449|    return PJ_SUCCESS;
  538|    449|}
pjsip_tx_data_add_ref:
  545|    449|{
  546|    449|    pj_atomic_inc(tdata->ref_cnt);
  547|    449|}
pjsip_tx_data_dec_ref:
  575|    449|{
  576|    449|    pj_atomic_value_t ref_cnt;
  577|       |    
  578|    449|    PJ_ASSERT_RETURN(tdata && tdata->ref_cnt, PJ_EINVAL);
  ------------------
  |  |   97|    449|            do { \
  |  |   98|    898|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 449, False: 0]
  |  |  |  Branch (98:23): [True: 449, False: 0]
  |  |  ------------------
  |  |   99|    449|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 449]
  |  |  ------------------
  ------------------
  |  Branch (578:5): [True: 0, False: 0]
  |  Branch (578:5): [True: 0, False: 0]
  |  Branch (578:5): [True: 0, False: 0]
  |  Branch (578:5): [True: 0, False: 0]
  ------------------
  579|       |
  580|    449|    ref_cnt = pj_atomic_dec_and_get(tdata->ref_cnt);
  581|    449|    pj_assert( ref_cnt >= 0);
  ------------------
  |  |   65|    449|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (581:5): [True: 0, False: 449]
  |  Branch (581:5): [True: 449, False: 0]
  ------------------
  582|    449|    if (ref_cnt == 0) {
  ------------------
  |  Branch (582:9): [True: 449, False: 0]
  ------------------
  583|    449|        tx_data_destroy(tdata);
  584|    449|        return PJSIP_EBUFDESTROYED;
  ------------------
  |  |  221|    449|#define PJSIP_EBUFDESTROYED     (PJSIP_ERRNO_START_PJSIP + 63)  /* 171063 */
  |  |  ------------------
  |  |  |  |   73|    449|#define PJSIP_ERRNO_START_PJSIP (PJSIP_ERRNO_START + 1000)
  |  |  |  |  ------------------
  |  |  |  |  |  |   47|    449|#define PJSIP_ERRNO_START       (PJ_ERRNO_START_USER)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  535|    449|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  528|    449|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  521|    449|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  509|    449|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  515|    449|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  515|    449|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|    449|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  585|    449|    } else {
  586|      0|        return PJ_SUCCESS;
  587|      0|    }
  588|    449|}
pjsip_transport_add_ref:
 1215|     21|{
 1216|     21|    pjsip_tpmgr *tpmgr;
 1217|     21|    pjsip_transport_key key;
 1218|     21|    int key_len;
 1219|       |
 1220|     21|    PJ_ASSERT_RETURN(tp != NULL, PJ_EINVAL);
  ------------------
  |  |   97|     21|            do { \
  |  |   98|     21|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 21]
  |  |  ------------------
  |  |   99|     21|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 21]
  |  |  ------------------
  ------------------
  |  Branch (1220:5): [True: 0, False: 0]
  |  Branch (1220:5): [True: 0, False: 0]
  ------------------
 1221|       |
 1222|       |    /* Add ref transport group lock, if any */
 1223|     21|    if (tp->grp_lock)
  ------------------
  |  Branch (1223:9): [True: 0, False: 21]
  ------------------
 1224|      0|        pj_grp_lock_add_ref(tp->grp_lock);
 1225|       |
 1226|       |    /* Cache some vars for checking transport validity later */
 1227|     21|    tpmgr = tp->tpmgr;
 1228|     21|    key_len = sizeof(tp->key.type) + tp->addr_len;
 1229|     21|    pj_memcpy(&key, &tp->key, key_len);
 1230|       |
 1231|     21|    if (pj_atomic_inc_and_get(tp->ref_cnt) == 1) {
  ------------------
  |  Branch (1231:9): [True: 21, False: 0]
  ------------------
 1232|     21|        pj_lock_acquire(tpmgr->lock);
 1233|       |        /* Verify again. But first, make sure transport is still valid
 1234|       |         * (see #1883).
 1235|       |         */
 1236|     21|        if (is_transport_valid(tp, tpmgr, &key, key_len) &&
  ------------------
  |  Branch (1236:13): [True: 21, False: 0]
  ------------------
 1237|     21|            pj_atomic_get(tp->ref_cnt) == 1)
  ------------------
  |  Branch (1237:13): [True: 21, False: 0]
  ------------------
 1238|     21|        {
 1239|     21|            if (tp->idle_timer.id != PJ_FALSE) {
  ------------------
  |  Branch (1239:17): [True: 20, False: 1]
  ------------------
 1240|     20|                tp->idle_timer.id = PJ_FALSE;
 1241|     20|                pjsip_endpt_cancel_timer(tp->tpmgr->endpt, &tp->idle_timer);
 1242|     20|            }
 1243|     21|        }
 1244|     21|        pj_lock_release(tpmgr->lock);
 1245|     21|    }
 1246|       |
 1247|     21|    return PJ_SUCCESS;
 1248|     21|}
pjsip_transport_dec_ref:
 1254|     21|{
 1255|     21|    pjsip_tpmgr *tpmgr;
 1256|     21|    pjsip_transport_key key;
 1257|     21|    int key_len;
 1258|       |
 1259|     21|    PJ_ASSERT_RETURN(tp != NULL, PJ_EINVAL);
  ------------------
  |  |   97|     21|            do { \
  |  |   98|     21|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 21]
  |  |  ------------------
  |  |   99|     21|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 21]
  |  |  ------------------
  ------------------
  |  Branch (1259:5): [True: 0, False: 0]
  |  Branch (1259:5): [True: 0, False: 0]
  ------------------
 1260|     21|    pj_assert(pj_atomic_get(tp->ref_cnt) > 0);
  ------------------
  |  |   65|     21|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (1260:5): [True: 0, False: 21]
  |  Branch (1260:5): [True: 21, False: 0]
  ------------------
 1261|       |
 1262|       |    /* Cache some vars for checking transport validity later */
 1263|     21|    tpmgr = tp->tpmgr;
 1264|     21|    key_len = sizeof(tp->key.type) + tp->addr_len;
 1265|     21|    pj_memcpy(&key, &tp->key, key_len);
 1266|       |
 1267|     21|    if (pj_atomic_dec_and_get(tp->ref_cnt) == 0) {
  ------------------
  |  Branch (1267:9): [True: 21, False: 0]
  ------------------
 1268|     21|        pj_lock_acquire(tpmgr->lock);
 1269|       |        /* Verify again. Do not register timer if the transport is
 1270|       |         * being destroyed. But first, make sure transport is still valid
 1271|       |         * (see #1883).
 1272|       |         */
 1273|     21|        if (is_transport_valid(tp, tpmgr, &key, key_len) &&
  ------------------
  |  Branch (1273:13): [True: 21, False: 0]
  ------------------
 1274|     21|            !tp->is_destroying && pj_atomic_get(tp->ref_cnt) == 0)
  ------------------
  |  Branch (1274:13): [True: 21, False: 0]
  |  Branch (1274:35): [True: 21, False: 0]
  ------------------
 1275|     21|        {
 1276|     21|            pj_time_val delay;
 1277|       |            
 1278|     21|            int timer_id = IDLE_TIMER_ID;
 1279|       |
 1280|       |            /* If transport is in graceful shutdown, then this is the
 1281|       |             * last user who uses the transport. Schedule to destroy the
 1282|       |             * transport immediately. Otherwise schedule idle timer.
 1283|       |             */
 1284|     21|            if (tp->is_shutdown) {
  ------------------
  |  Branch (1284:17): [True: 0, False: 21]
  ------------------
 1285|      0|                delay.sec = delay.msec = 0;
 1286|     21|            } else {
 1287|     21|                if (tp->dir == PJSIP_TP_DIR_OUTGOING) {
  ------------------
  |  Branch (1287:21): [True: 0, False: 21]
  ------------------
 1288|      0|                    delay.sec = PJSIP_TRANSPORT_IDLE_TIME;
  ------------------
  |  |  676|      0|#   define PJSIP_TRANSPORT_IDLE_TIME    33
  ------------------
 1289|     21|                } else {
 1290|     21|                    delay.sec = PJSIP_TRANSPORT_SERVER_IDLE_TIME;
  ------------------
  |  |  689|     21|#   define PJSIP_TRANSPORT_SERVER_IDLE_TIME     600
  ------------------
 1291|     21|                    if (tp->last_recv_ts.u64 == 0 && tp->initial_timeout) {
  ------------------
  |  Branch (1291:25): [True: 21, False: 0]
  |  Branch (1291:54): [True: 0, False: 21]
  ------------------
 1292|      0|                        PJ_LOG(4, (THIS_FILE, 
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      0|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1293|      0|                                   "Starting transport %s initial timer",
 1294|      0|                                   tp->obj_name));
 1295|      0|                        timer_id = INITIAL_IDLE_TIMER_ID;
 1296|      0|                        delay.sec = tp->initial_timeout;
 1297|      0|                    }
 1298|     21|                }
 1299|     21|                delay.msec = 0;
 1300|     21|            }
 1301|       |
 1302|       |            /* Avoid double timer entry scheduling */
 1303|     21|            if (pj_timer_entry_running(&tp->idle_timer))
  ------------------
  |  Branch (1303:17): [True: 0, False: 21]
  ------------------
 1304|      0|                pjsip_endpt_cancel_timer(tp->tpmgr->endpt, &tp->idle_timer);
 1305|       |
 1306|     21|            pjsip_endpt_schedule_timer_w_grp_lock(tp->tpmgr->endpt,
  ------------------
  |  |  187|     21|                pjsip_endpt_schedule_timer_w_grp_lock_dbg(ept,ent,d,id,gl,\
  |  |  188|     21|                                                          __FILE__, __LINE__)
  ------------------
 1307|     21|                                                  &tp->idle_timer,
 1308|     21|                                                  &delay,
 1309|     21|                                                  timer_id,
 1310|     21|                                                  tp->grp_lock);
 1311|     21|        }
 1312|     21|        pj_lock_release(tpmgr->lock);
 1313|     21|    }
 1314|       |
 1315|       |    /* Dec ref transport group lock, if any */
 1316|     21|    if (tp->grp_lock) {
  ------------------
  |  Branch (1316:9): [True: 0, False: 21]
  ------------------
 1317|      0|        pj_grp_lock_dec_ref(tp->grp_lock);
 1318|      0|    }
 1319|       |
 1320|     21|    return PJ_SUCCESS;
 1321|     21|}
pjsip_transport_register:
 1329|      2|{
 1330|      2|    int key_len;
 1331|      2|    pj_uint32_t hval;
 1332|      2|    transport *tp_ref = NULL;
 1333|      2|    transport *tp_add = NULL;
 1334|       |
 1335|       |    /* Init. */
 1336|      2|    tp->tpmgr = mgr;
 1337|      2|    pj_bzero(&tp->idle_timer, sizeof(tp->idle_timer));
 1338|      2|    tp->idle_timer.user_data = tp;
 1339|      2|    tp->idle_timer.cb = &transport_idle_callback;
 1340|       |
 1341|       |    /*
 1342|       |     * Register to hash table (see Trac ticket #42).
 1343|       |     */
 1344|      2|    key_len = sizeof(tp->key.type) + tp->addr_len;
 1345|      2|    pj_lock_acquire(mgr->lock);
 1346|       |
 1347|      2|    hval = 0;
 1348|      2|    tp_ref = (transport *)pj_hash_get(mgr->table, &tp->key, key_len, &hval);
 1349|       |
 1350|       |    /* Get an empty entry from the freelist. */
 1351|      2|    if (pj_list_empty(&mgr->tp_entry_freelist)) {
  ------------------
  |  Branch (1351:9): [True: 0, False: 2]
  ------------------
 1352|      0|        unsigned i = 0;
 1353|       |
 1354|      0|        TRACE_((THIS_FILE, "Transport list is full, allocate new entry"));
 1355|       |        /* Allocate new entry for the freelist. */
 1356|      0|        for (; i < PJSIP_TRANSPORT_ENTRY_ALLOC_CNT; ++i) {
  ------------------
  |  |  100|      0|#   define PJSIP_TRANSPORT_ENTRY_ALLOC_CNT  16
  ------------------
  |  Branch (1356:16): [True: 0, False: 0]
  ------------------
 1357|      0|            tp_add = PJ_POOL_ZALLOC_T(mgr->pool, transport);
  ------------------
  |  |  583|      0|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
 1358|      0|            if (!tp_add){
  ------------------
  |  Branch (1358:17): [True: 0, False: 0]
  ------------------
 1359|      0|                pj_lock_release(mgr->lock);
 1360|      0|                return PJ_ENOMEM;
  ------------------
  |  |  408|      0|#define PJ_ENOMEM           (PJ_ERRNO_START_STATUS + 7) /* 70007 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1361|      0|            }  
 1362|      0|            pj_list_init(tp_add);
 1363|      0|            pj_list_push_back(&mgr->tp_entry_freelist, tp_add);
 1364|      0|        }
 1365|      0|    }
 1366|      2|    tp_add = mgr->tp_entry_freelist.next;
 1367|      2|    tp_add->tp = tp;
 1368|      2|    pj_list_erase(tp_add);
 1369|       |
 1370|      2|    if (tp_ref) {
  ------------------
  |  Branch (1370:9): [True: 0, False: 2]
  ------------------
 1371|       |        /* There'a already a transport list from the hash table. Add the 
 1372|       |         * new transport to the list.
 1373|       |         */
 1374|      0|        pj_list_push_back(tp_ref, tp_add);
 1375|      0|        TRACE_((THIS_FILE, "Remote address already registered, "
 1376|      0|                           "appended the transport to the list"));
 1377|      2|    } else {
 1378|       |        /* Transport list not found, add it to the hash table. */
 1379|      2|        pj_hash_set_np(mgr->table, &tp->key, key_len, hval, tp_add->tp_buf,
 1380|      2|                       tp_add);
 1381|      2|        TRACE_((THIS_FILE, "Remote address not registered, "
 1382|      2|                           "added the transport to the hash"));
 1383|      2|    }
 1384|       |
 1385|       |    /* Add ref transport group lock, if any */
 1386|      2|    if (tp->grp_lock)
  ------------------
  |  Branch (1386:9): [True: 0, False: 2]
  ------------------
 1387|      0|        pj_grp_lock_add_ref(tp->grp_lock);
 1388|       |
 1389|      2|    pj_lock_release(mgr->lock);
 1390|       |
 1391|      2|    TRACE_((THIS_FILE, "Transport %s registered: type=%s, remote=%s:%d",
 1392|      2|            tp->obj_name,
 1393|      2|            pjsip_transport_get_type_name(tp->key.type),
 1394|      2|            pj_sockaddr_has_addr(&tp->key.rem_addr)?
 1395|      2|                                addr_string(&tp->key.rem_addr):"",
 1396|      2|            pj_sockaddr_has_addr(&tp->key.rem_addr)?
 1397|      2|                                pj_sockaddr_get_port(&tp->key.rem_addr):0));
 1398|       |
 1399|      2|    return PJ_SUCCESS;
 1400|      2|}
pjsip_tpmgr_create:
 1674|      2|{
 1675|      2|    pjsip_tpmgr *mgr;
 1676|      2|    pj_status_t status;
 1677|      2|    unsigned i = 0;
 1678|      2|    pj_pool_t *mgr_pool;
 1679|       |
 1680|      2|    PJ_ASSERT_RETURN(pool && endpt && rx_cb && p_mgr, PJ_EINVAL);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|     12|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 2, False: 0]
  |  |  |  Branch (98:23): [True: 2, False: 0]
  |  |  |  Branch (98:23): [True: 2, False: 0]
  |  |  |  Branch (98:23): [True: 2, False: 0]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (1680:5): [True: 0, False: 0]
  |  Branch (1680:5): [True: 0, False: 0]
  |  Branch (1680:5): [True: 0, False: 0]
  |  Branch (1680:5): [True: 0, False: 0]
  |  Branch (1680:5): [True: 0, False: 0]
  |  Branch (1680:5): [True: 0, False: 0]
  |  Branch (1680:5): [True: 0, False: 0]
  |  Branch (1680:5): [True: 0, False: 0]
  ------------------
 1681|       |
 1682|       |    /* Register mod_msg_print module. */
 1683|      2|    status = pjsip_endpt_register_module(endpt, &mod_msg_print);
 1684|      2|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (1684:9): [True: 0, False: 2]
  ------------------
 1685|      0|        return status;
 1686|       |
 1687|       |    /* Create and initialize transport manager. */
 1688|      2|    mgr_pool = pjsip_endpt_create_pool(endpt, "tpmgr",
 1689|      2|                                       TPMGR_POOL_INIT_SIZE,
  ------------------
  |  |   86|      2|#   define TPMGR_POOL_INIT_SIZE 1000
  ------------------
 1690|      2|                                       TPMGR_POOL_INC_SIZE);
  ------------------
  |  |   91|      2|    #define TPMGR_POOL_INC_SIZE 1000
  ------------------
 1691|      2|    mgr = PJ_POOL_ZALLOC_T(mgr_pool, pjsip_tpmgr);
  ------------------
  |  |  583|      2|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
 1692|      2|    mgr->endpt = endpt;
 1693|      2|    mgr->on_rx_msg = rx_cb;
 1694|      2|    mgr->on_tx_msg = tx_cb;
 1695|      2|    mgr->pool = mgr_pool;
 1696|       |
 1697|      2|    if (!mgr->pool)
  ------------------
  |  Branch (1697:9): [True: 0, False: 2]
  ------------------
 1698|      0|        return PJ_ENOMEM;
  ------------------
  |  |  408|      0|#define PJ_ENOMEM           (PJ_ERRNO_START_STATUS + 7) /* 70007 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1699|       |
 1700|      2|    pj_list_init(&mgr->factory_list);
 1701|      2|    pj_list_init(&mgr->tdata_list);
 1702|      2|    pj_list_init(&mgr->tp_entry_freelist);
 1703|       |
 1704|      2|    mgr->table = pj_hash_create(mgr->pool, PJSIP_TPMGR_HTABLE_SIZE);
  ------------------
  |  |  346|      2|#   define PJSIP_TPMGR_HTABLE_SIZE      31
  ------------------
 1705|      2|    if (!mgr->table)
  ------------------
  |  Branch (1705:9): [True: 0, False: 2]
  ------------------
 1706|      0|        return PJ_ENOMEM;
  ------------------
  |  |  408|      0|#define PJ_ENOMEM           (PJ_ERRNO_START_STATUS + 7) /* 70007 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1707|       |
 1708|      2|    status = pj_lock_create_recursive_mutex(mgr->pool, "tmgr%p", &mgr->lock);
 1709|      2|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (1709:9): [True: 0, False: 2]
  ------------------
 1710|      0|        return status;
 1711|       |
 1712|     34|    for (; i < PJSIP_TRANSPORT_ENTRY_ALLOC_CNT; ++i) {
  ------------------
  |  |  100|     34|#   define PJSIP_TRANSPORT_ENTRY_ALLOC_CNT  16
  ------------------
  |  Branch (1712:12): [True: 32, False: 2]
  ------------------
 1713|     32|        transport *tp_add = NULL;
 1714|       |
 1715|     32|        tp_add = PJ_POOL_ZALLOC_T(mgr->pool, transport);
  ------------------
  |  |  583|     32|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
 1716|     32|        if (!tp_add)
  ------------------
  |  Branch (1716:13): [True: 0, False: 32]
  ------------------
 1717|      0|            return PJ_ENOMEM;
  ------------------
  |  |  408|      0|#define PJ_ENOMEM           (PJ_ERRNO_START_STATUS + 7) /* 70007 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1718|     32|        pj_list_init(tp_add);
 1719|     32|        pj_list_push_back(&mgr->tp_entry_freelist, tp_add);
 1720|     32|    }
 1721|       |
 1722|      2|#if defined(PJ_DEBUG) && PJ_DEBUG!=0
 1723|      2|    status = pj_atomic_create(mgr->pool, 0, &mgr->tdata_counter);
 1724|      2|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (1724:9): [True: 0, False: 2]
  ------------------
 1725|      0|        pj_lock_destroy(mgr->lock);
 1726|      0|        return status;
 1727|      0|    }
 1728|      2|#endif
 1729|       |
 1730|       |    /* Set transport state callback */
 1731|      2|    pjsip_tpmgr_set_state_cb(mgr, &tp_state_callback);
 1732|       |
 1733|      2|    PJ_LOG(5, (THIS_FILE, "Transport manager created."));
  ------------------
  |  |  106|      2|#define PJ_LOG(level,arg)       do { \
  |  |  107|      2|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      4|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 2, Folded]
  |  |  |  Branch (107:70): [True: 2, False: 0]
  |  |  ------------------
  |  |  108|      2|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  496|      2|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  ------------------
  |  |  109|      2|                                    } \
  |  |  110|      2|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 2]
  |  |  ------------------
  ------------------
 1734|       |
 1735|      2|    *p_mgr = mgr;
 1736|      2|    return PJ_SUCCESS;
 1737|      2|}
pjsip_tpmgr_set_state_cb:
 2882|      2|{
 2883|      2|    PJ_ASSERT_RETURN(mgr, PJ_EINVAL);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (2883:5): [True: 0, False: 0]
  |  Branch (2883:5): [True: 0, False: 0]
  ------------------
 2884|       |
 2885|      2|    mgr->tp_state_cb = cb;
 2886|       |
 2887|      2|    return PJ_SUCCESS;
 2888|      2|}
pjsip_transport_add_state_listener:
 2960|     21|{
 2961|     21|    transport_data *tp_data;
 2962|     21|    tp_state_listener *entry;
 2963|       |
 2964|     21|    PJ_ASSERT_RETURN(tp && cb && key, PJ_EINVAL);
  ------------------
  |  |   97|     21|            do { \
  |  |   98|     84|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 21, False: 0]
  |  |  |  Branch (98:23): [True: 21, False: 0]
  |  |  |  Branch (98:23): [True: 21, False: 0]
  |  |  ------------------
  |  |   99|     21|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 21]
  |  |  ------------------
  ------------------
  |  Branch (2964:5): [True: 0, False: 0]
  |  Branch (2964:5): [True: 0, False: 0]
  |  Branch (2964:5): [True: 0, False: 0]
  |  Branch (2964:5): [True: 0, False: 0]
  |  Branch (2964:5): [True: 0, False: 0]
  |  Branch (2964:5): [True: 0, False: 0]
  ------------------
 2965|       |
 2966|     21|    if (tp->is_shutdown || tp->is_destroying) {
  ------------------
  |  Branch (2966:9): [True: 0, False: 21]
  |  Branch (2966:28): [True: 0, False: 21]
  ------------------
 2967|      0|        *key = NULL;
 2968|      0|        return PJ_EINVALIDOP;
  ------------------
  |  |  438|      0|#define PJ_EINVALIDOP       (PJ_ERRNO_START_STATUS + 13)/* 70013 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2969|      0|    }
 2970|       |
 2971|     21|    pj_lock_acquire(tp->lock);
 2972|       |
 2973|       |    /* Init transport data, if it hasn't */
 2974|     21|    if (!tp->data)
  ------------------
  |  Branch (2974:9): [True: 1, False: 20]
  ------------------
 2975|      1|        init_tp_data(tp);
 2976|       |
 2977|     21|    tp_data = (transport_data*)tp->data;
 2978|       |
 2979|       |    /* Init the new listener entry. Use available empty slot, if any,
 2980|       |     * otherwise allocate it using the transport pool.
 2981|       |     */
 2982|     21|    if (!pj_list_empty(&tp_data->st_listeners_empty)) {
  ------------------
  |  Branch (2982:9): [True: 20, False: 1]
  ------------------
 2983|     20|        entry = tp_data->st_listeners_empty.next;
 2984|     20|        pj_list_erase(entry);
 2985|     20|    } else {
 2986|      1|        entry = PJ_POOL_ZALLOC_T(tp->pool, tp_state_listener);
  ------------------
  |  |  583|      1|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
 2987|      1|    }
 2988|     21|    entry->cb = cb;
 2989|     21|    entry->user_data = user_data;
 2990|       |
 2991|       |    /* Add the new listener entry to the listeners list */
 2992|     21|    pj_list_push_back(&tp_data->st_listeners, entry);
 2993|       |
 2994|     21|    *key = entry;
 2995|       |
 2996|     21|    pj_lock_release(tp->lock);
 2997|       |
 2998|     21|    return PJ_SUCCESS;
 2999|     21|}
pjsip_transport_remove_state_listener:
 3009|     21|{
 3010|     21|    transport_data *tp_data;
 3011|     21|    tp_state_listener *entry;
 3012|       |
 3013|     21|    PJ_ASSERT_RETURN(tp && key, PJ_EINVAL);
  ------------------
  |  |   97|     21|            do { \
  |  |   98|     42|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 21, False: 0]
  |  |  |  Branch (98:23): [True: 21, False: 0]
  |  |  ------------------
  |  |   99|     21|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 21]
  |  |  ------------------
  ------------------
  |  Branch (3013:5): [True: 0, False: 0]
  |  Branch (3013:5): [True: 0, False: 0]
  |  Branch (3013:5): [True: 0, False: 0]
  |  Branch (3013:5): [True: 0, False: 0]
  ------------------
 3014|       |
 3015|     21|    pj_lock_acquire(tp->lock);
 3016|       |
 3017|     21|    tp_data = (transport_data*)tp->data;
 3018|       |
 3019|       |    /* Transport data is NULL or no registered listener? */
 3020|     21|    if (!tp_data || pj_list_empty(&tp_data->st_listeners)) {
  ------------------
  |  Branch (3020:9): [True: 0, False: 21]
  |  Branch (3020:21): [True: 0, False: 21]
  ------------------
 3021|      0|        pj_lock_release(tp->lock);
 3022|      0|        return PJ_ENOTFOUND;
  ------------------
  |  |  403|      0|#define PJ_ENOTFOUND        (PJ_ERRNO_START_STATUS + 6) /* 70006 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3023|      0|    }
 3024|       |
 3025|     21|    entry = (tp_state_listener*)key;
 3026|       |
 3027|       |    /* Validate the user data */
 3028|     21|    if (entry->user_data != user_data) {
  ------------------
  |  Branch (3028:9): [True: 0, False: 21]
  ------------------
 3029|      0|        pj_assert(!"Invalid transport state listener key");
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (3029:9): [Folded, False: 0]
  |  Branch (3029:9): [Folded, False: 0]
  ------------------
 3030|      0|        pj_lock_release(tp->lock);
 3031|      0|        return PJ_EBUG;
  ------------------
  |  |  413|      0|#define PJ_EBUG             (PJ_ERRNO_START_STATUS + 8) /* 70008 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3032|      0|    }
 3033|       |
 3034|       |    /* Reset the entry and move it to the empty list */
 3035|     21|    entry->cb = NULL;
 3036|     21|    entry->user_data = NULL;
 3037|     21|    pj_list_erase(entry);
 3038|     21|    pj_list_push_back(&tp_data->st_listeners_empty, entry);
 3039|       |
 3040|     21|    pj_lock_release(tp->lock);
 3041|       |
 3042|     21|    return PJ_SUCCESS;
 3043|     21|}
sip_transport.c:get_tpname:
  301|    264|{
  302|    264|    unsigned i;
  303|  2.11k|    for (i=0; i<PJ_ARRAY_SIZE(transport_names); ++i) {
  ------------------
  |  |  315|  2.11k|#define PJ_ARRAY_SIZE(a)    (sizeof(a)/sizeof(a[0]))
  ------------------
  |  Branch (303:15): [True: 2.11k, False: 0]
  ------------------
  304|  2.11k|        if (transport_names[i].type == type)
  ------------------
  |  Branch (304:13): [True: 264, False: 1.84k]
  ------------------
  305|    264|            return &transport_names[i];
  306|  2.11k|    }
  307|      0|    pj_assert(!"Invalid transport type!");
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (307:5): [Folded, False: 0]
  |  Branch (307:5): [Folded, False: 0]
  ------------------
  308|      0|    return NULL;
  309|      0|}
sip_transport.c:tx_data_destroy:
  550|    449|{
  551|    449|    PJ_LOG(5,(tdata->obj_name, "Destroying txdata %s",
  ------------------
  |  |  106|    449|#define PJ_LOG(level,arg)       do { \
  |  |  107|    449|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|    898|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 449, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 449]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|    449|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 449]
  |  |  ------------------
  ------------------
  552|    449|              pjsip_tx_data_get_info(tdata)));
  553|    449|    pjsip_tpselector_dec_ref(&tdata->tp_sel);
  554|    449|#if defined(PJ_DEBUG) && PJ_DEBUG!=0
  555|    449|    pj_atomic_dec( tdata->mgr->tdata_counter );
  556|    449|#endif
  557|       |
  558|       |#if defined(PJSIP_HAS_TX_DATA_LIST) && PJSIP_HAS_TX_DATA_LIST!=0
  559|       |    /* Remove this tdata from transmit buffer list */
  560|       |    pj_lock_acquire(tdata->mgr->lock);
  561|       |    pj_list_erase(tdata);
  562|       |    pj_lock_release(tdata->mgr->lock);
  563|       |#endif
  564|       |
  565|    449|    pj_atomic_destroy( tdata->ref_cnt );
  566|    449|    pj_lock_destroy( tdata->lock );
  567|    449|    pjsip_endpt_release_pool( tdata->mgr->endpt, tdata->pool );
  568|    449|}
sip_transport.c:is_transport_valid:
 1193|     42|{
 1194|     42|    transport *tp_entry;
 1195|       |
 1196|     42|    tp_entry = (transport *)pj_hash_get(tpmgr->table, key, key_len, NULL);
 1197|     42|    if (tp_entry != NULL) {
  ------------------
  |  Branch (1197:9): [True: 42, False: 0]
  ------------------
 1198|       |
 1199|     42|        transport *tp_iter = tp_entry;
 1200|     42|        do {
 1201|     42|            if (tp_iter->tp == tp) {
  ------------------
  |  Branch (1201:17): [True: 42, False: 0]
  ------------------
 1202|     42|                return PJ_TRUE;
 1203|     42|            }
 1204|      0|            tp_iter = tp_iter->next;
 1205|      0|        } while (tp_iter != tp_entry);
  ------------------
  |  Branch (1205:18): [True: 0, False: 0]
  ------------------
 1206|     42|    }
 1207|       |
 1208|      0|    return PJ_FALSE;
 1209|     42|}
sip_transport.c:init_tp_data:
 2906|      1|{
 2907|      1|    transport_data *tp_data;
 2908|       |
 2909|      1|    pj_assert(tp && !tp->data);
  ------------------
  |  |   65|      1|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (2909:5): [True: 0, False: 1]
  |  Branch (2909:5): [True: 0, False: 0]
  |  Branch (2909:5): [True: 1, False: 0]
  |  Branch (2909:5): [True: 1, False: 0]
  ------------------
 2910|       |
 2911|      1|    tp_data = PJ_POOL_ZALLOC_T(tp->pool, transport_data);
  ------------------
  |  |  583|      1|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
 2912|      1|    pj_list_init(&tp_data->st_listeners);
 2913|      1|    pj_list_init(&tp_data->st_listeners_empty);
 2914|      1|    tp->data = tp_data;
 2915|      1|}

pjsip_loop_start:
  356|      2|{
  357|      2|    pj_pool_t *pool;
  358|      2|    struct loop_transport *loop;
  359|      2|    pj_status_t status;
  360|       |
  361|       |    /* Create pool. */
  362|      2|    pool = pjsip_endpt_create_pool(endpt, "loop", 4000, 4000);
  363|      2|    if (!pool)
  ------------------
  |  Branch (363:9): [True: 0, False: 2]
  ------------------
  364|      0|        return PJ_ENOMEM;
  ------------------
  |  |  408|      0|#define PJ_ENOMEM           (PJ_ERRNO_START_STATUS + 7) /* 70007 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  365|       |
  366|       |    /* Create the loop structure. */
  367|      2|    loop = PJ_POOL_ZALLOC_T(pool, struct loop_transport);
  ------------------
  |  |  583|      2|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  368|       |    
  369|       |    /* Initialize transport properties. */
  370|      2|    pj_ansi_snprintf(loop->base.obj_name, sizeof(loop->base.obj_name), 
  ------------------
  |  |  114|      2|#define pj_ansi_snprintf        snprintf
  ------------------
  371|      2|                     "loop%p", loop);
  372|      2|    loop->base.pool = pool;
  373|      2|    status = pj_atomic_create(pool, 0, &loop->base.ref_cnt);
  374|      2|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (374:9): [True: 0, False: 2]
  ------------------
  375|      0|        goto on_error;
  376|      2|    status = pj_lock_create_recursive_mutex(pool, "loop", &loop->base.lock);
  377|      2|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (377:9): [True: 0, False: 2]
  ------------------
  378|      0|        goto on_error;
  379|      2|    loop->base.key.type = PJSIP_TRANSPORT_LOOP_DGRAM;
  380|       |    //loop->base.key.rem_addr.addr.sa_family = pj_AF_INET();
  381|      2|    loop->base.type_name = "LOOP-DGRAM";
  382|      2|    loop->base.info = "LOOP-DGRAM";
  383|      2|    loop->base.flag = PJSIP_TRANSPORT_DATAGRAM;
  384|      2|    loop->base.local_name.host = pj_str(ADDR_LOOP_DGRAM);
  ------------------
  |  |   31|      2|#define ADDR_LOOP_DGRAM "129.0.0.1"
  ------------------
  385|      2|    loop->base.local_name.port = 
  386|      2|        pjsip_transport_get_default_port_for_type((pjsip_transport_type_e)
  387|      2|                                                  loop->base.key.type);
  388|      2|    loop->base.addr_len = sizeof(pj_sockaddr_in);
  389|      2|    loop->base.dir = PJSIP_TP_DIR_NONE;
  390|      2|    loop->base.endpt = endpt;
  391|      2|    loop->base.tpmgr = pjsip_endpt_get_tpmgr(endpt);
  392|      2|    loop->base.send_msg = &loop_send_msg;
  393|      2|    loop->base.destroy = &loop_destroy;
  394|       |
  395|      2|    pj_list_init(&loop->recv_list);
  396|      2|    pj_list_init(&loop->send_list);
  397|       |
  398|       |    /* Create worker thread. */
  399|      2|    status = pj_thread_create(pool, "loop", 
  400|      2|                              &loop_transport_worker_thread, loop, 0, 
  401|      2|                              PJ_THREAD_SUSPENDED, &loop->thread);
  402|      2|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (402:9): [True: 0, False: 2]
  ------------------
  403|      0|        goto on_error;
  404|       |
  405|       |    /* Register to transport manager. */
  406|      2|    status = pjsip_transport_register( loop->base.tpmgr, &loop->base);
  407|      2|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (407:9): [True: 0, False: 2]
  ------------------
  408|      0|        goto on_error;
  409|       |
  410|       |    /* Start the thread. */
  411|      2|    status = pj_thread_resume(loop->thread);
  412|      2|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (412:9): [True: 0, False: 2]
  ------------------
  413|      0|        goto on_error;
  414|       |
  415|       |    /*
  416|       |     * Done.
  417|       |     */
  418|       |
  419|      2|    if (transport)
  ------------------
  |  Branch (419:9): [True: 2, False: 0]
  ------------------
  420|      2|        *transport = &loop->base;
  421|       |
  422|      2|    return PJ_SUCCESS;
  423|       |
  424|      0|on_error:
  425|      0|    if (loop->base.lock)
  ------------------
  |  Branch (425:9): [True: 0, False: 0]
  ------------------
  426|      0|        pj_lock_destroy(loop->base.lock);
  427|      0|    if (loop->thread)
  ------------------
  |  Branch (427:9): [True: 0, False: 0]
  ------------------
  428|      0|        pj_thread_destroy(loop->thread);
  429|      0|    if (loop->base.ref_cnt)
  ------------------
  |  Branch (429:9): [True: 0, False: 0]
  ------------------
  430|      0|        pj_atomic_destroy(loop->base.ref_cnt);
  431|      0|    pjsip_endpt_release_pool(endpt, loop->pool);
  432|      0|    return status;
  433|      2|}
sip_transport_loop.c:loop_transport_worker_thread:
  262|      2|{
  263|      2|    struct loop_transport *loop = (struct loop_transport*) arg;
  264|      2|    struct recv_list r;
  265|      2|    struct send_list s;
  266|       |
  267|      2|    pj_list_init(&r);
  268|      2|    pj_list_init(&s);
  269|       |
  270|  1.08k|    while (!loop->thread_quit_flag) {
  ------------------
  |  Branch (270:12): [True: 1.08k, False: 2]
  ------------------
  271|  1.08k|        pj_time_val now;
  272|       |
  273|  1.08k|        pj_thread_sleep(1);
  274|  1.08k|        pj_gettimeofday(&now);
  275|       |
  276|  1.08k|        pj_lock_acquire(loop->base.lock);
  277|       |
  278|       |        /* Move expired send notification to local list. */
  279|  1.08k|        while (!pj_list_empty(&loop->send_list)) {
  ------------------
  |  Branch (279:16): [True: 0, False: 1.08k]
  ------------------
  280|      0|            struct send_list *node = loop->send_list.next;
  281|       |
  282|       |            /* Break when next node time is greater than now. */
  283|      0|            if (PJ_TIME_VAL_GTE(node->sent_time, now))
  ------------------
  |  |  508|      0|#define PJ_TIME_VAL_GTE(t1, t2) (PJ_TIME_VAL_GT(t1,t2) || \
  |  |  ------------------
  |  |  |  |  497|      0|#define PJ_TIME_VAL_GT(t1, t2)  ((t1).sec>(t2).sec || \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (497:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  498|      0|                                ((t1).sec==(t2).sec && (t1).msec>(t2).msec))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (498:34): [True: 0, False: 0]
  |  |  |  |  |  Branch (498:56): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  509|      0|                                 PJ_TIME_VAL_EQ(t1,t2))
  |  |  ------------------
  |  |  |  |  487|      0|#define PJ_TIME_VAL_EQ(t1, t2)  ((t1).sec==(t2).sec && (t1).msec==(t2).msec)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (487:34): [True: 0, False: 0]
  |  |  |  |  |  Branch (487:56): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  284|      0|                break;
  285|       |
  286|       |            /* Delete this from the list. */
  287|      0|            pj_list_erase(node);
  288|       |
  289|       |            /* Add to local list. */
  290|      0|            pj_list_push_back(&s, node);
  291|      0|        }
  292|       |
  293|       |        /* Move expired "incoming" packet to local list. */
  294|  1.08k|        while (!pj_list_empty(&loop->recv_list)) {
  ------------------
  |  Branch (294:16): [True: 0, False: 1.08k]
  ------------------
  295|      0|            struct recv_list *node = loop->recv_list.next;
  296|       |
  297|       |            /* Break when next node time is greater than now. */
  298|      0|            if (PJ_TIME_VAL_GTE(node->rdata.pkt_info.timestamp, now))
  ------------------
  |  |  508|      0|#define PJ_TIME_VAL_GTE(t1, t2) (PJ_TIME_VAL_GT(t1,t2) || \
  |  |  ------------------
  |  |  |  |  497|      0|#define PJ_TIME_VAL_GT(t1, t2)  ((t1).sec>(t2).sec || \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (497:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  498|      0|                                ((t1).sec==(t2).sec && (t1).msec>(t2).msec))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (498:34): [True: 0, False: 0]
  |  |  |  |  |  Branch (498:56): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  509|      0|                                 PJ_TIME_VAL_EQ(t1,t2))
  |  |  ------------------
  |  |  |  |  487|      0|#define PJ_TIME_VAL_EQ(t1, t2)  ((t1).sec==(t2).sec && (t1).msec==(t2).msec)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (487:34): [True: 0, False: 0]
  |  |  |  |  |  Branch (487:56): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  299|      0|                break;
  300|       |
  301|       |            /* Delete this from the list. */
  302|      0|            pj_list_erase(node);
  303|       |
  304|       |            /* Add to local list. */
  305|      0|            pj_list_push_back(&r, node);
  306|       |
  307|      0|        }
  308|       |
  309|  1.08k|        pj_lock_release(loop->base.lock);
  310|       |
  311|       |        /* Process send notification and incoming packet notification
  312|       |         * without holding down the loop's mutex.
  313|       |         */
  314|  1.08k|        while (!pj_list_empty(&s)) {
  ------------------
  |  Branch (314:16): [True: 0, False: 1.08k]
  ------------------
  315|      0|            struct send_list *node = s.next;
  316|       |
  317|      0|            pj_list_erase(node);
  318|       |
  319|       |            /* Notify callback. */
  320|      0|            if (node->callback) {
  ------------------
  |  Branch (320:17): [True: 0, False: 0]
  ------------------
  321|      0|                (*node->callback)(&loop->base, node->token, node->sent);
  322|      0|            }
  323|       |
  324|       |            /* Decrement tdata reference counter. */
  325|      0|            pjsip_tx_data_dec_ref(node->tdata);
  326|      0|        }
  327|       |
  328|       |        /* Process "incoming" packet. */
  329|  1.08k|        while (!pj_list_empty(&r)) {
  ------------------
  |  Branch (329:16): [True: 0, False: 1.08k]
  ------------------
  330|      0|            struct recv_list *node = r.next;
  331|      0|            pj_ssize_t size_eaten;
  332|       |
  333|      0|            pj_list_erase(node);
  334|       |
  335|       |            /* Notify transport manager about the "incoming packet" */
  336|      0|            size_eaten = pjsip_tpmgr_receive_packet(loop->base.tpmgr,
  337|      0|                                                    &node->rdata);
  338|       |
  339|       |            /* Must "eat" all the packets. */
  340|      0|            pj_assert(size_eaten == node->rdata.pkt_info.len);
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (340:13): [True: 0, False: 0]
  |  Branch (340:13): [True: 0, False: 0]
  ------------------
  341|      0|            PJ_UNUSED_ARG(size_eaten);
  ------------------
  |  | 1537|      0|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  342|       |
  343|       |            /* Done. */
  344|      0|            pjsip_endpt_release_pool(loop->base.endpt,
  345|      0|                                     node->rdata.tp_info.pool);
  346|      0|        }
  347|  1.08k|    }
  348|       |
  349|      2|    return 0;
  350|      2|}

pjsip_ua_init_module:
  195|      2|{
  196|      2|    pj_status_t status;
  197|       |
  198|       |    /* Check if module already registered. */
  199|      2|    PJ_ASSERT_RETURN(mod_ua.mod.id == -1, PJ_EINVALIDOP);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (199:5): [True: 0, False: 0]
  |  Branch (199:5): [True: 0, False: 0]
  ------------------
  200|       |
  201|       |    /* Copy param, if exists. */
  202|      2|    if (prm)
  ------------------
  |  Branch (202:9): [True: 0, False: 2]
  ------------------
  203|      0|        pj_memcpy(&mod_ua.param, prm, sizeof(pjsip_ua_init_param));
  204|       |
  205|       |    /* Register the module. */
  206|      2|    status = pjsip_endpt_register_module(endpt, &mod_ua.mod);
  207|       |
  208|      2|    return status;
  209|      2|}
pjsip_ua_instance:
  216|  5.99k|{
  217|  5.99k|    return &mod_ua.mod;
  218|  5.99k|}
pjsip_ua_get_endpt:
  225|  5.99k|{
  226|  5.99k|    PJ_UNUSED_ARG(ua);
  ------------------
  |  | 1537|  5.99k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  227|  5.99k|    pj_assert(ua == &mod_ua.mod);
  ------------------
  |  |   65|  5.99k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (227:5): [True: 0, False: 5.99k]
  |  Branch (227:5): [True: 5.99k, False: 0]
  ------------------
  228|  5.99k|    return mod_ua.endpt;
  229|  5.99k|}
pjsip_ua_register_dlg:
  292|    449|{
  293|       |    /* Sanity check. */
  294|    449|    PJ_ASSERT_RETURN(ua && dlg, PJ_EINVAL);
  ------------------
  |  |   97|    449|            do { \
  |  |   98|    898|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 449, False: 0]
  |  |  |  Branch (98:23): [True: 449, False: 0]
  |  |  ------------------
  |  |   99|    449|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 449]
  |  |  ------------------
  ------------------
  |  Branch (294:5): [True: 0, False: 0]
  |  Branch (294:5): [True: 0, False: 0]
  |  Branch (294:5): [True: 0, False: 0]
  |  Branch (294:5): [True: 0, False: 0]
  ------------------
  295|       |
  296|       |    /* For all dialogs, local tag (inc hash) must has been initialized. */
  297|    449|    PJ_ASSERT_RETURN(dlg->local.info && dlg->local.info->tag.slen &&
  ------------------
  |  |   97|    449|            do { \
  |  |   98|  1.79k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 449, False: 0]
  |  |  |  Branch (98:23): [True: 449, False: 0]
  |  |  |  Branch (98:23): [True: 449, False: 0]
  |  |  ------------------
  |  |   99|    449|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 449]
  |  |  ------------------
  ------------------
  |  Branch (297:5): [True: 0, False: 0]
  |  Branch (297:5): [True: 0, False: 0]
  |  Branch (297:5): [True: 0, False: 0]
  |  Branch (297:5): [True: 0, False: 0]
  |  Branch (297:5): [True: 0, False: 0]
  |  Branch (297:5): [True: 0, False: 0]
  ------------------
  298|    449|                     dlg->local.tag_hval != 0, PJ_EBUG);
  299|       |
  300|       |    /* For UAS dialog, remote tag (inc hash) must have been initialized. */
  301|       |    //PJ_ASSERT_RETURN(dlg->role==PJSIP_ROLE_UAC ||
  302|       |    //               (dlg->role==PJSIP_ROLE_UAS && dlg->remote.info->tag.slen
  303|       |    //                && dlg->remote.tag_hval != 0), PJ_EBUG);
  304|       |
  305|       |    /* Lock the user agent. */
  306|    449|    pj_mutex_lock(mod_ua.mutex);
  307|       |
  308|       |    /* For UAC, check if there is existing dialog in the same set. */
  309|    449|    if (dlg->role == PJSIP_ROLE_UAC) {
  ------------------
  |  Branch (309:9): [True: 168, False: 281]
  ------------------
  310|    168|        struct dlg_set *dlg_set;
  311|       |
  312|    168|        dlg_set = (struct dlg_set*)
  313|    168|                  pj_hash_get_lower( mod_ua.dlg_table,
  314|    168|                                     dlg->local.info->tag.ptr, 
  315|    168|                                     (unsigned)dlg->local.info->tag.slen,
  316|    168|                                     &dlg->local.tag_hval);
  317|       |
  318|    168|        if (dlg_set) {
  ------------------
  |  Branch (318:13): [True: 0, False: 168]
  ------------------
  319|       |            /* This is NOT the first dialog in the dialog set. 
  320|       |             * Just add this dialog in the list.
  321|       |             */
  322|      0|            pj_assert(dlg_set->dlg_list.next != (void*)&dlg_set->dlg_list);
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (322:13): [True: 0, False: 0]
  |  Branch (322:13): [True: 0, False: 0]
  ------------------
  323|      0|            pj_list_push_back(&dlg_set->dlg_list, dlg);
  324|       |
  325|      0|            dlg->dlg_set = dlg_set;
  326|       |
  327|    168|        } else {
  328|       |            /* This is the first dialog in the dialog set. 
  329|       |             * Create the dialog set and add this dialog to it.
  330|       |             */
  331|    168|            dlg_set = alloc_dlgset_node();
  332|    168|            dlg_set->ht_key = dlg->local.info->tag;
  333|    168|            pj_list_init(&dlg_set->dlg_list);
  334|    168|            pj_list_push_back(&dlg_set->dlg_list, dlg);
  335|       |
  336|    168|            dlg->dlg_set = dlg_set;
  337|       |
  338|       |            /* Register the dialog set in the hash table. */
  339|    168|            pj_hash_set_np_lower(mod_ua.dlg_table, 
  340|    168|                                 dlg_set->ht_key.ptr,
  341|    168|                                 (unsigned)dlg_set->ht_key.slen,
  342|    168|                                 dlg->local.tag_hval, dlg_set->ht_entry,
  343|    168|                                 dlg_set);
  344|    168|        }
  345|       |
  346|    281|    } else {
  347|       |        /* For UAS, create the dialog set with a single dialog as member. */
  348|    281|        struct dlg_set *dlg_set;
  349|       |
  350|    281|        dlg_set = alloc_dlgset_node();
  351|    281|        dlg_set->ht_key = dlg->local.info->tag;
  352|    281|        pj_list_init(&dlg_set->dlg_list);
  353|    281|        pj_list_push_back(&dlg_set->dlg_list, dlg);
  354|       |
  355|    281|        dlg->dlg_set = dlg_set;
  356|       |
  357|    281|        pj_hash_set_np_lower(mod_ua.dlg_table, 
  358|    281|                             dlg_set->ht_key.ptr,
  359|    281|                             (unsigned)dlg_set->ht_key.slen,
  360|    281|                             dlg->local.tag_hval, dlg_set->ht_entry, dlg_set);
  361|    281|    }
  362|       |
  363|       |    /* Unlock user agent. */
  364|    449|    pj_mutex_unlock(mod_ua.mutex);
  365|       |
  366|       |    /* Done. */
  367|    449|    return PJ_SUCCESS;
  368|    449|}
pjsip_ua_unregister_dlg:
  373|    449|{
  374|    449|    struct dlg_set *dlg_set;
  375|    449|    pjsip_dialog *d;
  376|       |
  377|       |    /* Sanity-check arguments. */
  378|    449|    PJ_ASSERT_RETURN(ua && dlg, PJ_EINVAL);
  ------------------
  |  |   97|    449|            do { \
  |  |   98|    898|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 449, False: 0]
  |  |  |  Branch (98:23): [True: 449, False: 0]
  |  |  ------------------
  |  |   99|    449|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 449]
  |  |  ------------------
  ------------------
  |  Branch (378:5): [True: 0, False: 0]
  |  Branch (378:5): [True: 0, False: 0]
  |  Branch (378:5): [True: 0, False: 0]
  |  Branch (378:5): [True: 0, False: 0]
  ------------------
  379|       |
  380|       |    /* Check that dialog has been registered. */
  381|    449|    PJ_ASSERT_RETURN(dlg->dlg_set, PJ_EINVALIDOP);
  ------------------
  |  |   97|    449|            do { \
  |  |   98|    449|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 449]
  |  |  ------------------
  |  |   99|    449|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 449]
  |  |  ------------------
  ------------------
  |  Branch (381:5): [True: 0, False: 0]
  |  Branch (381:5): [True: 0, False: 0]
  ------------------
  382|       |
  383|       |    /* Lock user agent. */
  384|    449|    pj_mutex_lock(mod_ua.mutex);
  385|       |
  386|       |    /* Find this dialog from the dialog set. */
  387|    449|    dlg_set = (struct dlg_set*) dlg->dlg_set;
  388|    449|    d = dlg_set->dlg_list.next;
  389|    449|    while (d != (pjsip_dialog*)&dlg_set->dlg_list && d != dlg) {
  ------------------
  |  Branch (389:12): [True: 449, False: 0]
  |  Branch (389:54): [True: 0, False: 449]
  ------------------
  390|      0|        d = d->next;
  391|      0|    }
  392|       |
  393|    449|    if (d != dlg) {
  ------------------
  |  Branch (393:9): [True: 0, False: 449]
  ------------------
  394|      0|        pj_assert(!"Dialog is not registered!");
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (394:9): [Folded, False: 0]
  |  Branch (394:9): [Folded, False: 0]
  ------------------
  395|      0|        pj_mutex_unlock(mod_ua.mutex);
  396|      0|        return PJ_EINVALIDOP;
  ------------------
  |  |  438|      0|#define PJ_EINVALIDOP       (PJ_ERRNO_START_STATUS + 13)/* 70013 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  397|      0|    }
  398|       |
  399|       |    /* Remove this dialog from the list. */
  400|    449|    pj_list_erase(dlg);
  401|       |
  402|       |    /* If dialog list is empty, remove the dialog set from the hash table. */
  403|    449|    if (pj_list_empty(&dlg_set->dlg_list)) {
  ------------------
  |  Branch (403:9): [True: 449, False: 0]
  ------------------
  404|       |
  405|       |        /* Verify that the dialog set is valid */
  406|    449|        pj_assert(pj_hash_get_lower(mod_ua.dlg_table, dlg_set->ht_key.ptr,
  ------------------
  |  |   65|    449|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (406:9): [True: 0, False: 449]
  |  Branch (406:9): [True: 449, False: 0]
  ------------------
  407|    449|                                    (unsigned)dlg_set->ht_key.slen,
  408|    449|                                    &dlg->local.tag_hval) == dlg_set);
  409|       |
  410|    449|        pj_hash_set_lower(NULL, mod_ua.dlg_table, dlg_set->ht_key.ptr,
  411|    449|                          (unsigned)dlg_set->ht_key.slen,
  412|    449|                          dlg->local.tag_hval, NULL);
  413|       |
  414|       |        /* Return dlg_set to free nodes. */
  415|    449|        pj_list_push_back(&mod_ua.free_dlgset_nodes, dlg_set);
  416|    449|    } else {
  417|       |        /* If the just unregistered dialog is being used as hash key,
  418|       |         * reset the dlg_set entry with a new key (i.e: from the first dialog
  419|       |         * in dlg_set).
  420|       |         */
  421|      0|        if (dlg_set->ht_key.ptr  == dlg->local.info->tag.ptr &&
  ------------------
  |  Branch (421:13): [True: 0, False: 0]
  ------------------
  422|      0|            dlg_set->ht_key.slen == dlg->local.info->tag.slen)
  ------------------
  |  Branch (422:13): [True: 0, False: 0]
  ------------------
  423|      0|        {
  424|      0|            pjsip_dialog* key_dlg = dlg_set->dlg_list.next;
  425|       |
  426|       |            /* Verify that the old & new keys share the hash value */
  427|      0|            pj_assert(key_dlg->local.tag_hval == dlg->local.tag_hval);
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (427:13): [True: 0, False: 0]
  |  Branch (427:13): [True: 0, False: 0]
  ------------------
  428|       |
  429|      0|            pj_hash_set_lower(NULL, mod_ua.dlg_table, dlg_set->ht_key.ptr,
  430|      0|                              (unsigned)dlg_set->ht_key.slen,
  431|      0|                              dlg->local.tag_hval, NULL);
  432|       |
  433|      0|            dlg_set->ht_key = key_dlg->local.info->tag;
  434|       |
  435|      0|            pj_hash_set_np_lower(mod_ua.dlg_table,
  436|      0|                                 dlg_set->ht_key.ptr,
  437|      0|                                 (unsigned)dlg_set->ht_key.slen,
  438|      0|                                 key_dlg->local.tag_hval, dlg_set->ht_entry,
  439|      0|                                 dlg_set);
  440|      0|        }
  441|      0|    }
  442|       |
  443|       |    /* Unlock user agent. */
  444|    449|    pj_mutex_unlock(mod_ua.mutex);
  445|       |
  446|       |    /* Done. */
  447|    449|    return PJ_SUCCESS;
  448|    449|}
sip_ua_layer.c:mod_ua_load:
  113|      2|{
  114|      2|    pj_status_t status;
  115|       |
  116|       |    /* Initialize the user agent. */
  117|      2|    mod_ua.endpt = endpt;
  118|      2|    mod_ua.pool = pjsip_endpt_create_pool( endpt, "ua%p", PJSIP_POOL_LEN_UA,
  ------------------
  |  | 1033|      2|#   define PJSIP_POOL_LEN_UA            512
  ------------------
  119|      2|                                           PJSIP_POOL_INC_UA);
  ------------------
  |  | 1040|      2|#   define PJSIP_POOL_INC_UA            512
  ------------------
  120|      2|    if (mod_ua.pool == NULL)
  ------------------
  |  Branch (120:9): [True: 0, False: 2]
  ------------------
  121|      0|        return PJ_ENOMEM;
  ------------------
  |  |  408|      0|#define PJ_ENOMEM           (PJ_ERRNO_START_STATUS + 7) /* 70007 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  122|       |
  123|      2|    status = pj_mutex_create_recursive(mod_ua.pool, " ua%p", &mod_ua.mutex);
  124|      2|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (124:9): [True: 0, False: 2]
  ------------------
  125|      0|        return status;
  126|       |
  127|      2|    mod_ua.dlg_table = pj_hash_create(mod_ua.pool, PJSIP_MAX_DIALOG_COUNT);
  ------------------
  |  |  327|      2|#   define PJSIP_MAX_DIALOG_COUNT       (512-1)
  ------------------
  128|      2|    if (mod_ua.dlg_table == NULL)
  ------------------
  |  Branch (128:9): [True: 0, False: 2]
  ------------------
  129|      0|        return PJ_ENOMEM;
  ------------------
  |  |  408|      0|#define PJ_ENOMEM           (PJ_ERRNO_START_STATUS + 7) /* 70007 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  130|       |
  131|      2|    pj_list_init(&mod_ua.free_dlgset_nodes);
  132|       |
  133|       |    /* Initialize dialog lock. */
  134|      2|    status = pj_thread_local_alloc(&pjsip_dlg_lock_tls_id);
  135|      2|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (135:9): [True: 0, False: 2]
  ------------------
  136|      0|        return status;
  137|       |
  138|      2|    pj_thread_local_set(pjsip_dlg_lock_tls_id, NULL);
  139|       |
  140|      2|    return PJ_SUCCESS;
  141|       |
  142|      2|}
sip_ua_layer.c:mod_ua_on_tsx_state:
  167|    843|{
  168|    843|    pjsip_dialog *dlg;
  169|       |
  170|       |    /* If the module id is -1, it could mean that the module has been
  171|       |     * destroyed.
  172|       |     */
  173|    843|    if (mod_ua.mod.id == -1)
  ------------------
  |  Branch (173:9): [True: 0, False: 843]
  ------------------
  174|      0|        return;
  175|       |
  176|       |    /* Get the dialog where this transaction belongs. */
  177|    843|    dlg = (pjsip_dialog*) tsx->mod_data[mod_ua.mod.id];
  178|       |    
  179|       |    /* If dialog instance has gone, it could mean that the dialog
  180|       |     * may has been destroyed.
  181|       |     */
  182|    843|    if (dlg == NULL)
  ------------------
  |  Branch (182:9): [True: 281, False: 562]
  ------------------
  183|    281|        return;
  184|       |
  185|       |    /* Hand over the event to the dialog. */
  186|    562|    pjsip_dlg_on_tsx_state(dlg, tsx, e);
  187|    562|}
sip_ua_layer.c:alloc_dlgset_node:
  273|    449|{
  274|    449|    struct dlg_set *set;
  275|       |
  276|    449|    if (!pj_list_empty(&mod_ua.free_dlgset_nodes)) {
  ------------------
  |  Branch (276:9): [True: 448, False: 1]
  ------------------
  277|    448|        set = mod_ua.free_dlgset_nodes.next;
  278|    448|        pj_list_erase(set);
  279|    448|        return set;
  280|    448|    } else {
  281|      1|        set = PJ_POOL_ALLOC_T(mod_ua.pool, struct dlg_set);
  ------------------
  |  |  569|      1|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
  282|      1|        return set;
  283|      1|    }
  284|    449|}

pjsip_param_find:
   34|  1.35k|{
   35|  1.35k|    pjsip_param *p = (pjsip_param*)param_list->next;
   36|  1.60k|    while (p != param_list) {
  ------------------
  |  Branch (36:12): [True: 255, False: 1.34k]
  ------------------
   37|    255|        if (pj_stricmp(&p->name, name)==0)
  ------------------
  |  Branch (37:13): [True: 7, False: 248]
  ------------------
   38|      7|            return p;
   39|    248|        p = p->next;
   40|    248|    }
   41|  1.34k|    return NULL;
   42|  1.35k|}
pjsip_param_clone:
   72|  8.60k|{
   73|  8.60k|    const pjsip_param *p = src_list->next;
   74|       |
   75|  8.60k|    pj_list_init(dst_list);
   76|  21.5k|    while (p && p != src_list) {
  ------------------
  |  Branch (76:12): [True: 21.5k, False: 0]
  |  Branch (76:17): [True: 12.9k, False: 8.60k]
  ------------------
   77|  12.9k|        pjsip_param *new_param = PJ_POOL_ALLOC_T(pool, pjsip_param);
  ------------------
  |  |  569|  12.9k|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
   78|  12.9k|        pj_strdup(pool, &new_param->name, &p->name);
   79|  12.9k|        pj_strdup(pool, &new_param->value, &p->value);
   80|  12.9k|        pj_list_insert_before(dst_list, new_param);
   81|  12.9k|        p = p->next;
   82|  12.9k|    }
   83|  8.60k|}
pjsip_param_shallow_clone:
   89|     27|{
   90|     27|    const pjsip_param *p = src_list->next;
   91|       |
   92|     27|    pj_list_init(dst_list);
   93|    360|    while (p != src_list) {
  ------------------
  |  Branch (93:12): [True: 333, False: 27]
  ------------------
   94|    333|        pjsip_param *new_param = PJ_POOL_ALLOC_T(pool, pjsip_param);
  ------------------
  |  |  569|    333|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
   95|    333|        new_param->name = p->name;
   96|    333|        new_param->value = p->value;
   97|    333|        pj_list_insert_before(dst_list, new_param);
   98|    333|        p = p->next;
   99|    333|    }
  100|     27|}
pjsip_param_print_on:
  107|    814|{
  108|    814|    const pjsip_param *p;
  109|    814|    char *startbuf;
  110|    814|    char *endbuf;
  111|    814|    int printed;
  112|       |
  113|    814|    p = param_list->next;
  114|    814|    if (p == NULL || p == param_list)
  ------------------
  |  Branch (114:9): [True: 0, False: 814]
  |  Branch (114:22): [True: 600, False: 214]
  ------------------
  115|    600|        return 0;
  116|       |
  117|    214|    startbuf = buf;
  118|    214|    endbuf = buf + size;
  119|       |
  120|    214|    PJ_UNUSED_ARG(pname_spec);
  ------------------
  |  | 1537|    214|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  121|       |
  122|  1.34k|    do {
  123|  1.34k|        copy_advance_char_check(buf, (char)sep);
  ------------------
  |  |   26|  1.34k|        do { \
  |  |   27|  1.34k|            if (1 >= (endbuf-buf)) return -1;   \
  |  |  ------------------
  |  |  |  Branch (27:17): [True: 7, False: 1.33k]
  |  |  ------------------
  |  |   28|  1.34k|            *buf++ = chr; \
  |  |   29|  1.33k|        } while (0)
  |  |  ------------------
  |  |  |  Branch (29:18): [Folded, False: 1.33k]
  |  |  ------------------
  ------------------
  124|  1.33k|        copy_advance_escape(buf, p->name, (*pname_spec));
  ------------------
  |  |   95|  1.33k|        do { \
  |  |   96|  1.33k|            printed = \
  |  |   97|  1.33k|                (int)pj_strncpy2_escape(buf, &(str), (endbuf-buf), &(unres)); \
  |  |   98|  1.33k|            if (printed < 0) return -1; \
  |  |  ------------------
  |  |  |  Branch (98:17): [True: 12, False: 1.32k]
  |  |  ------------------
  |  |   99|  1.33k|            buf += printed; \
  |  |  100|  1.32k|        } while (0)
  |  |  ------------------
  |  |  |  Branch (100:18): [Folded, False: 1.32k]
  |  |  ------------------
  ------------------
  125|  1.32k|        if (p->value.slen) {
  ------------------
  |  Branch (125:13): [True: 371, False: 955]
  ------------------
  126|    371|            copy_advance_char_check(buf, '=');
  ------------------
  |  |   26|    371|        do { \
  |  |   27|    371|            if (1 >= (endbuf-buf)) return -1;   \
  |  |  ------------------
  |  |  |  Branch (27:17): [True: 7, False: 364]
  |  |  ------------------
  |  |   28|    371|            *buf++ = chr; \
  |  |   29|    364|        } while (0)
  |  |  ------------------
  |  |  |  Branch (29:18): [Folded, False: 364]
  |  |  ------------------
  ------------------
  127|    364|            if (*p->value.ptr == '"')
  ------------------
  |  Branch (127:17): [True: 139, False: 225]
  ------------------
  128|    139|                copy_advance(buf, p->value);
  ------------------
  |  |  109|    139|#define copy_advance            copy_advance_check
  |  |  ------------------
  |  |  |  |   32|    139|        do { \
  |  |  |  |   33|    139|            if ((str).slen >= (endbuf-buf)) return -1;  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (33:17): [True: 18, False: 121]
  |  |  |  |  ------------------
  |  |  |  |   34|    139|            if ((str).slen) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (34:17): [True: 121, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   35|    121|                pj_memcpy(buf, (str).ptr, (str).slen); \
  |  |  |  |   36|    121|                buf += (str).slen; \
  |  |  |  |   37|    121|            } \
  |  |  |  |   38|    121|        } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (38:18): [Folded, False: 121]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  129|    225|            else
  130|    225|                copy_advance_escape(buf, p->value, (*pvalue_spec));
  ------------------
  |  |   95|    225|        do { \
  |  |   96|    225|            printed = \
  |  |   97|    225|                (int)pj_strncpy2_escape(buf, &(str), (endbuf-buf), &(unres)); \
  |  |   98|    225|            if (printed < 0) return -1; \
  |  |  ------------------
  |  |  |  Branch (98:17): [True: 4, False: 221]
  |  |  ------------------
  |  |   99|    225|            buf += printed; \
  |  |  100|    221|        } while (0)
  |  |  ------------------
  |  |  |  Branch (100:18): [Folded, False: 221]
  |  |  ------------------
  ------------------
  131|    364|        }
  132|  1.29k|        p = p->next;
  133|  1.29k|        if (sep == '?') sep = '&';
  ------------------
  |  Branch (133:13): [True: 0, False: 1.29k]
  ------------------
  134|  1.29k|    } while (p != param_list);
  ------------------
  |  Branch (134:14): [True: 1.13k, False: 166]
  ------------------
  135|       |
  136|    166|    return buf-startbuf;
  137|    214|}
pjsip_sip_uri_set_secure:
  231|  12.6k|{
  232|  12.6k|    url->vptr = secure ? &sips_url_vptr : &sip_url_vptr;
  ------------------
  |  Branch (232:17): [True: 523, False: 12.0k]
  ------------------
  233|  12.6k|}
pjsip_sip_uri_init:
  236|  12.6k|{
  237|  12.6k|    pj_bzero(url, sizeof(*url));
  238|  12.6k|    url->ttl_param = -1;
  239|  12.6k|    pjsip_sip_uri_set_secure(url, secure);
  240|  12.6k|    pj_list_init(&url->other_param);
  241|  12.6k|    pj_list_init(&url->header_param);
  242|  12.6k|}
pjsip_sip_uri_create:
  246|  10.8k|{
  247|  10.8k|    pjsip_sip_uri *url = PJ_POOL_ALLOC_T(pool, pjsip_sip_uri);
  ------------------
  |  |  569|  10.8k|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
  248|  10.8k|    pjsip_sip_uri_init(url, secure);
  249|  10.8k|    return url;
  250|  10.8k|}
pjsip_sip_uri_assign:
  516|  1.80k|{
  517|  1.80k|    pj_strdup( pool, &url->user, &rhs->user);
  518|  1.80k|    pj_strdup( pool, &url->passwd, &rhs->passwd);
  519|       |#if defined (PJSIP_URI_USE_ORIG_USERPASS) && (PJSIP_URI_USE_ORIG_USERPASS)
  520|       |    pj_strdup( pool, &url->orig_userpass, &rhs->orig_userpass);
  521|       |#endif
  522|  1.80k|    pj_strdup( pool, &url->host, &rhs->host);
  523|  1.80k|    url->port = rhs->port;
  524|  1.80k|    pj_strdup( pool, &url->user_param, &rhs->user_param);
  525|  1.80k|    pj_strdup( pool, &url->method_param, &rhs->method_param);
  526|  1.80k|    pj_strdup( pool, &url->transport_param, &rhs->transport_param);
  527|  1.80k|    url->ttl_param = rhs->ttl_param;
  528|  1.80k|    pj_strdup( pool, &url->maddr_param, &rhs->maddr_param);
  529|  1.80k|    pjsip_param_clone(pool, &url->other_param, &rhs->other_param);
  530|  1.80k|    pjsip_param_clone(pool, &url->header_param, &rhs->header_param);
  531|  1.80k|    url->lr_param = rhs->lr_param;
  532|  1.80k|}
pjsip_name_addr_init:
  552|  22.8k|{
  553|  22.8k|    name->vptr = &name_addr_vptr;
  554|  22.8k|    name->uri = NULL;
  555|  22.8k|    name->display.slen = 0;
  556|       |    name->display.ptr = NULL;
  557|  22.8k|}
pjsip_name_addr_create:
  560|  18.7k|{
  561|  18.7k|    pjsip_name_addr *name_addr = PJ_POOL_ALLOC_T(pool, pjsip_name_addr);
  ------------------
  |  |  569|  18.7k|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
  562|  18.7k|    pjsip_name_addr_init(name_addr);
  563|  18.7k|    return name_addr;
  564|  18.7k|}
pjsip_name_addr_assign:
  604|  2.44k|{
  605|  2.44k|    pj_strdup( pool, &dst->display, &src->display);
  606|  2.44k|    dst->uri = (pjsip_uri*) pjsip_uri_clone(pool, src->uri);
  607|  2.44k|}
pjsip_other_uri_create:
  671|  7.27k|{
  672|  7.27k|    pjsip_other_uri *uri = PJ_POOL_ZALLOC_T(pool, pjsip_other_uri);
  ------------------
  |  |  583|  7.27k|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  673|  7.27k|    uri->vptr = &other_uri_vptr;
  674|  7.27k|    return uri;
  675|  7.27k|}
sip_uri.c:pjsips_url_get_scheme:
  214|     82|{
  215|     82|    PJ_UNUSED_ARG(url);
  ------------------
  |  | 1537|     82|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  216|     82|    return &sips_str;
  217|     82|}
sip_uri.c:pjsip_get_uri:
  220|  1.09k|{
  221|  1.09k|    return uri;
  222|  1.09k|}
sip_uri.c:pjsip_url_print:
  255|    896|{
  256|    896|    int printed;
  257|    896|    char *startbuf = buf;
  258|    896|    char *endbuf = buf+size-1; // Need to minus one for NULL terminator
  259|    896|    const pj_str_t *scheme;
  260|    896|    const pjsip_parser_const_t *pc = pjsip_parser_const();
  261|       |
  262|    896|    if (endbuf < startbuf) return -1;
  ------------------
  |  Branch (262:9): [True: 0, False: 896]
  ------------------
  263|    896|    *buf = '\0';
  264|       |
  265|       |    /* Print scheme ("sip:" or "sips:") */
  266|    896|    scheme = pjsip_uri_get_scheme(url);
  267|    896|    copy_advance_check(buf, *scheme);
  ------------------
  |  |   32|    896|        do { \
  |  |   33|    896|            if ((str).slen >= (endbuf-buf)) return -1;  \
  |  |  ------------------
  |  |  |  Branch (33:17): [True: 4, False: 892]
  |  |  ------------------
  |  |   34|    896|            if ((str).slen) { \
  |  |  ------------------
  |  |  |  Branch (34:17): [True: 892, False: 0]
  |  |  ------------------
  |  |   35|    892|                pj_memcpy(buf, (str).ptr, (str).slen); \
  |  |   36|    892|                buf += (str).slen; \
  |  |   37|    892|            } \
  |  |   38|    892|        } while (0)
  |  |  ------------------
  |  |  |  Branch (38:18): [Folded, False: 892]
  |  |  ------------------
  ------------------
  268|    892|    copy_advance_char_check(buf, ':');
  ------------------
  |  |   26|    892|        do { \
  |  |   27|    892|            if (1 >= (endbuf-buf)) return -1;   \
  |  |  ------------------
  |  |  |  Branch (27:17): [True: 3, False: 889]
  |  |  ------------------
  |  |   28|    892|            *buf++ = chr; \
  |  |   29|    889|        } while (0)
  |  |  ------------------
  |  |  |  Branch (29:18): [Folded, False: 889]
  |  |  ------------------
  ------------------
  269|       |
  270|       |    /* Print "user:password@", if any. */
  271|    889|    if (url->user.slen) {
  ------------------
  |  Branch (271:9): [True: 483, False: 406]
  ------------------
  272|       |#if defined (PJSIP_URI_USE_ORIG_USERPASS) && (PJSIP_URI_USE_ORIG_USERPASS)
  273|       |        /* Use the URI's original username and password, if any. */
  274|       |        if (url->orig_userpass.slen) {
  275|       |            copy_advance_check(buf, url->orig_userpass);
  276|       |        } else {
  277|       |#endif
  278|    483|            const pj_cis_t *spec = pjsip_cfg()->endpt.allow_tx_hash_in_uri ?
  ------------------
  |  Branch (278:36): [True: 0, False: 483]
  ------------------
  279|      0|                                    &pc->pjsip_USER_SPEC_LENIENT :
  280|    483|                                    &pc->pjsip_USER_SPEC;
  281|    483|            copy_advance_escape(buf, url->user, *spec);
  ------------------
  |  |   95|    483|        do { \
  |  |   96|    483|            printed = \
  |  |   97|    483|                (int)pj_strncpy2_escape(buf, &(str), (endbuf-buf), &(unres)); \
  |  |   98|    483|            if (printed < 0) return -1; \
  |  |  ------------------
  |  |  |  Branch (98:17): [True: 13, False: 470]
  |  |  ------------------
  |  |   99|    483|            buf += printed; \
  |  |  100|    470|        } while (0)
  |  |  ------------------
  |  |  |  Branch (100:18): [Folded, False: 470]
  |  |  ------------------
  ------------------
  282|    470|            if (url->passwd.slen) {
  ------------------
  |  Branch (282:17): [True: 16, False: 454]
  ------------------
  283|     16|                copy_advance_char_check(buf, ':');
  ------------------
  |  |   26|     16|        do { \
  |  |   27|     16|            if (1 >= (endbuf-buf)) return -1;   \
  |  |  ------------------
  |  |  |  Branch (27:17): [True: 2, False: 14]
  |  |  ------------------
  |  |   28|     16|            *buf++ = chr; \
  |  |   29|     14|        } while (0)
  |  |  ------------------
  |  |  |  Branch (29:18): [Folded, False: 14]
  |  |  ------------------
  ------------------
  284|     14|                copy_advance_escape(buf, url->passwd, pc->pjsip_PASSWD_SPEC);
  ------------------
  |  |   95|     14|        do { \
  |  |   96|     14|            printed = \
  |  |   97|     14|                (int)pj_strncpy2_escape(buf, &(str), (endbuf-buf), &(unres)); \
  |  |   98|     14|            if (printed < 0) return -1; \
  |  |  ------------------
  |  |  |  Branch (98:17): [True: 2, False: 12]
  |  |  ------------------
  |  |   99|     14|            buf += printed; \
  |  |  100|     12|        } while (0)
  |  |  ------------------
  |  |  |  Branch (100:18): [Folded, False: 12]
  |  |  ------------------
  ------------------
  285|     14|            }
  286|       |#if defined (PJSIP_URI_USE_ORIG_USERPASS) && (PJSIP_URI_USE_ORIG_USERPASS)
  287|       |        }
  288|       |#endif
  289|    466|        copy_advance_char_check(buf, '@');
  ------------------
  |  |   26|    466|        do { \
  |  |   27|    466|            if (1 >= (endbuf-buf)) return -1;   \
  |  |  ------------------
  |  |  |  Branch (27:17): [True: 3, False: 463]
  |  |  ------------------
  |  |   28|    466|            *buf++ = chr; \
  |  |   29|    463|        } while (0)
  |  |  ------------------
  |  |  |  Branch (29:18): [Folded, False: 463]
  |  |  ------------------
  ------------------
  290|    466|    }
  291|       |
  292|       |    /* Print host. */
  293|    869|    pj_assert(url->host.slen != 0);
  ------------------
  |  |   65|    869|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (293:5): [True: 0, False: 869]
  |  Branch (293:5): [True: 869, False: 0]
  ------------------
  294|       |    /* Detect IPv6 IP address */
  295|    869|    if (pj_memchr(url->host.ptr, ':', url->host.slen)) {
  ------------------
  |  Branch (295:9): [True: 74, False: 795]
  ------------------
  296|     74|        copy_advance_pair_quote_cond(buf, "", 0, url->host, '[', ']');
  ------------------
  |  |  117|     74|        do {    \
  |  |  118|     74|          if (str2.slen && *str2.ptr!=quotebegin) \
  |  |  ------------------
  |  |  |  Branch (118:15): [True: 74, False: 0]
  |  |  |  Branch (118:28): [True: 44, False: 30]
  |  |  ------------------
  |  |  119|     74|            copy_advance_pair_quote(buf,str1,len1,str2,quotebegin,quoteend); \
  |  |  ------------------
  |  |  |  |   65|     44|        do { \
  |  |  |  |   66|     44|                printed = len1+(int)str2.slen+2; \
  |  |  |  |   67|     44|                if (printed >= (endbuf-buf)) return -1; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (67:21): [True: 26, False: 18]
  |  |  |  |  ------------------
  |  |  |  |   68|     44|                pj_memcpy(buf,str1,len1); \
  |  |  |  |   69|     18|                *(buf+len1)=quotebegin; \
  |  |  |  |   70|     18|                pj_memcpy(buf+len1+1, str2.ptr, str2.slen); \
  |  |  |  |   71|     18|                *(buf+printed-1) = quoteend; \
  |  |  |  |   72|     18|                buf += printed; \
  |  |  |  |   73|     18|        } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (73:18): [Folded, False: 18]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  120|     74|          else \
  |  |  121|     74|            copy_advance_pair(buf,str1,len1,str2); \
  |  |  ------------------
  |  |  |  |  110|     30|#define copy_advance_pair       copy_advance_pair_check
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|     30|        do { \
  |  |  |  |  |  |   42|     30|            if (str2.slen) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (42:17): [True: 30, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   43|     30|                printed = len1+(int)str2.slen; \
  |  |  |  |  |  |   44|     30|                if (printed >= (endbuf-buf)) return -1; \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (44:21): [True: 22, False: 8]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   45|     30|                pj_memcpy(buf,str1,len1); \
  |  |  |  |  |  |   46|      8|                pj_memcpy(buf+len1, str2.ptr, str2.slen); \
  |  |  |  |  |  |   47|      8|                buf += printed; \
  |  |  |  |  |  |   48|      8|            } \
  |  |  |  |  |  |   49|     30|        } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (49:18): [Folded, False: 8]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  122|     74|        } while (0)
  |  |  ------------------
  |  |  |  Branch (122:18): [Folded, False: 26]
  |  |  ------------------
  ------------------
  297|    795|    } else {
  298|    795|        copy_advance_check(buf, url->host);
  ------------------
  |  |   32|    795|        do { \
  |  |   33|    795|            if ((str).slen >= (endbuf-buf)) return -1;  \
  |  |  ------------------
  |  |  |  Branch (33:17): [True: 27, False: 768]
  |  |  ------------------
  |  |   34|    795|            if ((str).slen) { \
  |  |  ------------------
  |  |  |  Branch (34:17): [True: 768, False: 0]
  |  |  ------------------
  |  |   35|    768|                pj_memcpy(buf, (str).ptr, (str).slen); \
  |  |   36|    768|                buf += (str).slen; \
  |  |   37|    768|            } \
  |  |   38|    768|        } while (0)
  |  |  ------------------
  |  |  |  Branch (38:18): [Folded, False: 768]
  |  |  ------------------
  ------------------
  299|    795|    }
  300|       |
  301|       |    /* Only print port if it is explicitly specified. 
  302|       |     * Port is not allowed in To and From header, see Table 1 in
  303|       |     * RFC 3261 Section 19.1.1
  304|       |     */
  305|       |    /* Note: ticket #1141 adds run-time setting to allow port number to
  306|       |     * appear in From/To header. Default is still false.
  307|       |     */
  308|    794|    if (url->port &&
  ------------------
  |  Branch (308:9): [True: 16, False: 778]
  ------------------
  309|     16|        (context != PJSIP_URI_IN_FROMTO_HDR ||
  ------------------
  |  Branch (309:10): [True: 0, False: 16]
  ------------------
  310|     16|         pjsip_cfg()->endpt.allow_port_in_fromto_hdr))
  ------------------
  |  Branch (310:10): [True: 0, False: 16]
  ------------------
  311|      0|    {
  312|      0|        if (endbuf - buf < 10)
  ------------------
  |  Branch (312:13): [True: 0, False: 0]
  ------------------
  313|      0|            return -1;
  314|       |
  315|      0|        copy_advance_char_check(buf, ':');
  ------------------
  |  |   26|      0|        do { \
  |  |   27|      0|            if (1 >= (endbuf-buf)) return -1;   \
  |  |  ------------------
  |  |  |  Branch (27:17): [True: 0, False: 0]
  |  |  ------------------
  |  |   28|      0|            *buf++ = chr; \
  |  |   29|      0|        } while (0)
  |  |  ------------------
  |  |  |  Branch (29:18): [Folded, False: 0]
  |  |  ------------------
  ------------------
  316|      0|        printed = pj_utoa(url->port, buf);
  317|      0|        buf += printed;
  318|      0|    }
  319|       |
  320|       |    /* User param is allowed in all contexes */
  321|    794|    copy_advance_pair_check(buf, ";user=", 6, url->user_param);
  ------------------
  |  |   41|    794|        do { \
  |  |   42|    794|            if (str2.slen) { \
  |  |  ------------------
  |  |  |  Branch (42:17): [True: 53, False: 741]
  |  |  ------------------
  |  |   43|     53|                printed = len1+(int)str2.slen; \
  |  |   44|     53|                if (printed >= (endbuf-buf)) return -1; \
  |  |  ------------------
  |  |  |  Branch (44:21): [True: 26, False: 27]
  |  |  ------------------
  |  |   45|     53|                pj_memcpy(buf,str1,len1); \
  |  |   46|     27|                pj_memcpy(buf+len1, str2.ptr, str2.slen); \
  |  |   47|     27|                buf += printed; \
  |  |   48|     27|            } \
  |  |   49|    794|        } while (0)
  |  |  ------------------
  |  |  |  Branch (49:18): [Folded, False: 768]
  |  |  ------------------
  ------------------
  322|       |
  323|       |    /* Method param is only allowed in external/other context. */
  324|    768|    if (context == PJSIP_URI_IN_OTHER) {
  ------------------
  |  Branch (324:9): [True: 0, False: 768]
  ------------------
  325|      0|        copy_advance_pair_escape(buf, ";method=", 8, url->method_param, 
  ------------------
  |  |   76|      0|        do { \
  |  |   77|      0|          if (str2.slen) { \
  |  |  ------------------
  |  |  |  Branch (77:15): [True: 0, False: 0]
  |  |  ------------------
  |  |   78|      0|            if (len1+str2.slen >= (endbuf-buf)) return -1; \
  |  |  ------------------
  |  |  |  Branch (78:17): [True: 0, False: 0]
  |  |  ------------------
  |  |   79|      0|            pj_memcpy(buf,str1,len1); \
  |  |   80|      0|            printed=(int)pj_strncpy2_escape(buf+len1,&str2,(endbuf-buf-len1), \
  |  |   81|      0|                                            &unres);\
  |  |   82|      0|            if (printed < 0) return -1; \
  |  |  ------------------
  |  |  |  Branch (82:17): [True: 0, False: 0]
  |  |  ------------------
  |  |   83|      0|            buf += (printed+len1); \
  |  |   84|      0|          } \
  |  |   85|      0|        } while (0)
  |  |  ------------------
  |  |  |  Branch (85:18): [Folded, False: 0]
  |  |  ------------------
  ------------------
  326|      0|                                 pc->pjsip_PARAM_CHAR_SPEC);
  327|      0|    }
  328|       |
  329|       |    /* Transport is not allowed in From/To header. */
  330|    768|    if (context != PJSIP_URI_IN_FROMTO_HDR) {
  ------------------
  |  Branch (330:9): [True: 0, False: 768]
  ------------------
  331|      0|        copy_advance_pair_escape(buf, ";transport=", 11, url->transport_param,
  ------------------
  |  |   76|      0|        do { \
  |  |   77|      0|          if (str2.slen) { \
  |  |  ------------------
  |  |  |  Branch (77:15): [True: 0, False: 0]
  |  |  ------------------
  |  |   78|      0|            if (len1+str2.slen >= (endbuf-buf)) return -1; \
  |  |  ------------------
  |  |  |  Branch (78:17): [True: 0, False: 0]
  |  |  ------------------
  |  |   79|      0|            pj_memcpy(buf,str1,len1); \
  |  |   80|      0|            printed=(int)pj_strncpy2_escape(buf+len1,&str2,(endbuf-buf-len1), \
  |  |   81|      0|                                            &unres);\
  |  |   82|      0|            if (printed < 0) return -1; \
  |  |  ------------------
  |  |  |  Branch (82:17): [True: 0, False: 0]
  |  |  ------------------
  |  |   83|      0|            buf += (printed+len1); \
  |  |   84|      0|          } \
  |  |   85|      0|        } while (0)
  |  |  ------------------
  |  |  |  Branch (85:18): [Folded, False: 0]
  |  |  ------------------
  ------------------
  332|      0|                                 pc->pjsip_PARAM_CHAR_SPEC);
  333|      0|    }
  334|       |
  335|       |    /* TTL param is not allowed in From, To, Route, and Record-Route header. */
  336|    768|    if (url->ttl_param >= 0 && context != PJSIP_URI_IN_FROMTO_HDR &&
  ------------------
  |  Branch (336:9): [True: 5, False: 763]
  |  Branch (336:32): [True: 0, False: 5]
  ------------------
  337|      0|        context != PJSIP_URI_IN_ROUTING_HDR) 
  ------------------
  |  Branch (337:9): [True: 0, False: 0]
  ------------------
  338|      0|    {
  339|      0|        if (endbuf - buf < 15)
  ------------------
  |  Branch (339:13): [True: 0, False: 0]
  ------------------
  340|      0|            return -1;
  341|      0|        pj_memcpy(buf, ";ttl=", 5);
  342|      0|        printed = pj_utoa(url->ttl_param, buf+5);
  343|      0|        buf += printed + 5;
  344|      0|    }
  345|       |
  346|       |    /* maddr param is not allowed in From and To header. */
  347|    768|    if (context != PJSIP_URI_IN_FROMTO_HDR && url->maddr_param.slen) {
  ------------------
  |  Branch (347:9): [True: 0, False: 768]
  |  Branch (347:47): [True: 0, False: 0]
  ------------------
  348|       |        /* Detect IPv6 IP address */
  349|      0|        if (pj_memchr(url->maddr_param.ptr, ':', url->maddr_param.slen)) {
  ------------------
  |  Branch (349:13): [True: 0, False: 0]
  ------------------
  350|      0|            copy_advance_pair_quote_cond(buf, ";maddr=", 7, url->maddr_param,
  ------------------
  |  |  117|      0|        do {    \
  |  |  118|      0|          if (str2.slen && *str2.ptr!=quotebegin) \
  |  |  ------------------
  |  |  |  Branch (118:15): [True: 0, False: 0]
  |  |  |  Branch (118:28): [True: 0, False: 0]
  |  |  ------------------
  |  |  119|      0|            copy_advance_pair_quote(buf,str1,len1,str2,quotebegin,quoteend); \
  |  |  ------------------
  |  |  |  |   65|      0|        do { \
  |  |  |  |   66|      0|                printed = len1+(int)str2.slen+2; \
  |  |  |  |   67|      0|                if (printed >= (endbuf-buf)) return -1; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (67:21): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   68|      0|                pj_memcpy(buf,str1,len1); \
  |  |  |  |   69|      0|                *(buf+len1)=quotebegin; \
  |  |  |  |   70|      0|                pj_memcpy(buf+len1+1, str2.ptr, str2.slen); \
  |  |  |  |   71|      0|                *(buf+printed-1) = quoteend; \
  |  |  |  |   72|      0|                buf += printed; \
  |  |  |  |   73|      0|        } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (73:18): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  120|      0|          else \
  |  |  121|      0|            copy_advance_pair(buf,str1,len1,str2); \
  |  |  ------------------
  |  |  |  |  110|      0|#define copy_advance_pair       copy_advance_pair_check
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|      0|        do { \
  |  |  |  |  |  |   42|      0|            if (str2.slen) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (42:17): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   43|      0|                printed = len1+(int)str2.slen; \
  |  |  |  |  |  |   44|      0|                if (printed >= (endbuf-buf)) return -1; \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (44:21): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   45|      0|                pj_memcpy(buf,str1,len1); \
  |  |  |  |  |  |   46|      0|                pj_memcpy(buf+len1, str2.ptr, str2.slen); \
  |  |  |  |  |  |   47|      0|                buf += printed; \
  |  |  |  |  |  |   48|      0|            } \
  |  |  |  |  |  |   49|      0|        } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (49:18): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  122|      0|        } while (0)
  |  |  ------------------
  |  |  |  Branch (122:18): [Folded, False: 0]
  |  |  ------------------
  ------------------
  351|      0|                                         '[', ']');
  352|      0|        } else {
  353|      0|            copy_advance_pair_escape(buf, ";maddr=", 7, url->maddr_param,
  ------------------
  |  |   76|      0|        do { \
  |  |   77|      0|          if (str2.slen) { \
  |  |  ------------------
  |  |  |  Branch (77:15): [True: 0, False: 0]
  |  |  ------------------
  |  |   78|      0|            if (len1+str2.slen >= (endbuf-buf)) return -1; \
  |  |  ------------------
  |  |  |  Branch (78:17): [True: 0, False: 0]
  |  |  ------------------
  |  |   79|      0|            pj_memcpy(buf,str1,len1); \
  |  |   80|      0|            printed=(int)pj_strncpy2_escape(buf+len1,&str2,(endbuf-buf-len1), \
  |  |   81|      0|                                            &unres);\
  |  |   82|      0|            if (printed < 0) return -1; \
  |  |  ------------------
  |  |  |  Branch (82:17): [True: 0, False: 0]
  |  |  ------------------
  |  |   83|      0|            buf += (printed+len1); \
  |  |   84|      0|          } \
  |  |   85|      0|        } while (0)
  |  |  ------------------
  |  |  |  Branch (85:18): [Folded, False: 0]
  |  |  ------------------
  ------------------
  354|      0|                                     pc->pjsip_PARAM_CHAR_SPEC);
  355|      0|        }
  356|      0|    }
  357|       |
  358|       |    /* lr param is not allowed in From, To, and Contact header. */
  359|    768|    if (url->lr_param && context != PJSIP_URI_IN_FROMTO_HDR &&
  ------------------
  |  Branch (359:9): [True: 14, False: 754]
  |  Branch (359:26): [True: 0, False: 14]
  ------------------
  360|      0|        context != PJSIP_URI_IN_CONTACT_HDR) 
  ------------------
  |  Branch (360:9): [True: 0, False: 0]
  ------------------
  361|      0|    {
  362|      0|        pj_str_t lr = { ";lr", 3 };
  363|      0|        if (endbuf - buf < 3)
  ------------------
  |  Branch (363:13): [True: 0, False: 0]
  ------------------
  364|      0|            return -1;
  365|      0|        copy_advance_check(buf, lr);
  ------------------
  |  |   32|      0|        do { \
  |  |   33|      0|            if ((str).slen >= (endbuf-buf)) return -1;  \
  |  |  ------------------
  |  |  |  Branch (33:17): [True: 0, False: 0]
  |  |  ------------------
  |  |   34|      0|            if ((str).slen) { \
  |  |  ------------------
  |  |  |  Branch (34:17): [True: 0, False: 0]
  |  |  ------------------
  |  |   35|      0|                pj_memcpy(buf, (str).ptr, (str).slen); \
  |  |   36|      0|                buf += (str).slen; \
  |  |   37|      0|            } \
  |  |   38|      0|        } while (0)
  |  |  ------------------
  |  |  |  Branch (38:18): [Folded, False: 0]
  |  |  ------------------
  ------------------
  366|      0|    }
  367|       |
  368|       |    /* Other param. */
  369|    768|    printed = (int)pjsip_param_print_on(&url->other_param, buf, endbuf-buf, 
  370|    768|                                        &pc->pjsip_PARAM_CHAR_SPEC, 
  371|    768|                                        &pc->pjsip_PARAM_CHAR_SPEC, ';');
  372|    768|    if (printed < 0)
  ------------------
  |  Branch (372:9): [True: 40, False: 728]
  ------------------
  373|     40|        return -1;
  374|    728|    buf += printed;
  375|       |
  376|       |    /* Header param. 
  377|       |     * Header param is only allowed in these contexts:
  378|       |     *  - PJSIP_URI_IN_CONTACT_HDR
  379|       |     *  - PJSIP_URI_IN_OTHER
  380|       |     */
  381|    728|    if (context == PJSIP_URI_IN_CONTACT_HDR || context == PJSIP_URI_IN_OTHER) {
  ------------------
  |  Branch (381:9): [True: 0, False: 728]
  |  Branch (381:48): [True: 0, False: 728]
  ------------------
  382|      0|        printed = (int)pjsip_param_print_on(&url->header_param, buf, endbuf-buf,
  383|      0|                                            &pc->pjsip_HDR_CHAR_SPEC, 
  384|      0|                                            &pc->pjsip_HDR_CHAR_SPEC, '?');
  385|      0|        if (printed < 0)
  ------------------
  |  Branch (385:13): [True: 0, False: 0]
  ------------------
  386|      0|            return -1;
  387|      0|        buf += printed;
  388|      0|    }
  389|       |
  390|    728|    *buf = '\0';
  391|    728|    return buf-startbuf;
  392|    728|}
sip_uri.c:pjsip_url_clone:
  535|  1.80k|{
  536|  1.80k|    pjsip_sip_uri *url = PJ_POOL_ALLOC_T(pool, pjsip_sip_uri);
  ------------------
  |  |  569|  1.80k|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
  537|  1.80k|    if (!url)
  ------------------
  |  Branch (537:9): [True: 0, False: 1.80k]
  ------------------
  538|      0|        return NULL;
  539|       |
  540|  1.80k|    pjsip_sip_uri_init(url, IS_SIPS(rhs));
  ------------------
  |  |  143|  1.80k|#define IS_SIPS(url)    ((url)->vptr==&sips_url_vptr)
  ------------------
  541|  1.80k|    pjsip_sip_uri_assign(pool, url, rhs);
  542|  1.80k|    return url;
  543|  1.80k|}
sip_uri.c:pjsip_url_get_scheme:
  208|  1.48k|{
  209|  1.48k|    PJ_UNUSED_ARG(url);
  ------------------
  |  | 1537|  1.48k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  210|  1.48k|    return &sip_str;
  211|  1.48k|}
sip_uri.c:pjsip_name_addr_get_scheme:
  546|  1.22k|{
  547|  1.22k|    pj_assert(name->uri != NULL);
  ------------------
  |  |   65|  1.22k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (547:5): [True: 0, False: 1.22k]
  |  Branch (547:5): [True: 1.22k, False: 0]
  ------------------
  548|  1.22k|    return pjsip_uri_get_scheme(name->uri);
  549|  1.22k|}
sip_uri.c:pjsip_name_addr_get_uri:
  225|     27|{
  226|     27|    return pjsip_uri_get_uri(name->uri);
  227|     27|}
sip_uri.c:pjsip_name_addr_print:
  569|  1.41k|{
  570|  1.41k|    int printed;
  571|  1.41k|    char *startbuf = buf;
  572|  1.41k|    char *endbuf = buf + size - 1; // Need to minus one for NULL terminator
  573|  1.41k|    pjsip_uri *uri;
  574|       |
  575|  1.41k|    uri = (pjsip_uri*) pjsip_uri_get_uri(name->uri);
  576|  1.41k|    pj_assert(uri != NULL);
  ------------------
  |  |   65|  1.41k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (576:5): [True: 0, False: 1.41k]
  |  Branch (576:5): [True: 1.41k, False: 0]
  ------------------
  577|       |
  578|  1.41k|    if (context != PJSIP_URI_IN_REQ_URI) {
  ------------------
  |  Branch (578:9): [True: 1.41k, False: 0]
  ------------------
  579|  1.41k|        if (name->display.slen) {
  ------------------
  |  Branch (579:13): [True: 400, False: 1.01k]
  ------------------
  580|    400|            if (endbuf-buf < name->display.slen + 3) return -1;
  ------------------
  |  Branch (580:17): [True: 14, False: 386]
  ------------------
  581|    386|            copy_advance_char_check(buf, '"');
  ------------------
  |  |   26|    386|        do { \
  |  |   27|    386|            if (1 >= (endbuf-buf)) return -1;   \
  |  |  ------------------
  |  |  |  Branch (27:17): [True: 0, False: 386]
  |  |  ------------------
  |  |   28|    386|            *buf++ = chr; \
  |  |   29|    386|        } while (0)
  |  |  ------------------
  |  |  |  Branch (29:18): [Folded, False: 386]
  |  |  ------------------
  ------------------
  582|    386|            copy_advance(buf, name->display);
  ------------------
  |  |  109|    386|#define copy_advance            copy_advance_check
  |  |  ------------------
  |  |  |  |   32|    386|        do { \
  |  |  |  |   33|    386|            if ((str).slen >= (endbuf-buf)) return -1;  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (33:17): [True: 0, False: 386]
  |  |  |  |  ------------------
  |  |  |  |   34|    386|            if ((str).slen) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (34:17): [True: 386, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   35|    386|                pj_memcpy(buf, (str).ptr, (str).slen); \
  |  |  |  |   36|    386|                buf += (str).slen; \
  |  |  |  |   37|    386|            } \
  |  |  |  |   38|    386|        } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (38:18): [Folded, False: 386]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  583|    386|            copy_advance_char_check(buf, '"');
  ------------------
  |  |   26|    386|        do { \
  |  |   27|    386|            if (1 >= (endbuf-buf)) return -1;   \
  |  |  ------------------
  |  |  |  Branch (27:17): [True: 0, False: 386]
  |  |  ------------------
  |  |   28|    386|            *buf++ = chr; \
  |  |   29|    386|        } while (0)
  |  |  ------------------
  |  |  |  Branch (29:18): [Folded, False: 386]
  |  |  ------------------
  ------------------
  584|    386|            copy_advance_char_check(buf, ' ');
  ------------------
  |  |   26|    386|        do { \
  |  |   27|    386|            if (1 >= (endbuf-buf)) return -1;   \
  |  |  ------------------
  |  |  |  Branch (27:17): [True: 3, False: 383]
  |  |  ------------------
  |  |   28|    386|            *buf++ = chr; \
  |  |   29|    383|        } while (0)
  |  |  ------------------
  |  |  |  Branch (29:18): [Folded, False: 383]
  |  |  ------------------
  ------------------
  585|    386|        }
  586|  1.40k|        copy_advance_char_check(buf, '<');;
  ------------------
  |  |   26|  1.40k|        do { \
  |  |   27|  1.40k|            if (1 >= (endbuf-buf)) return -1;   \
  |  |  ------------------
  |  |  |  Branch (27:17): [True: 3, False: 1.39k]
  |  |  ------------------
  |  |   28|  1.40k|            *buf++ = chr; \
  |  |   29|  1.39k|        } while (0)
  |  |  ------------------
  |  |  |  Branch (29:18): [Folded, False: 1.39k]
  |  |  ------------------
  ------------------
  587|  1.39k|    }
  588|       |
  589|  1.39k|    printed = pjsip_uri_print(context,uri, buf, endbuf - buf);
  590|  1.39k|    if (printed < 1)
  ------------------
  |  Branch (590:9): [True: 250, False: 1.14k]
  ------------------
  591|    250|        return -1;
  592|  1.14k|    buf += printed;
  593|       |
  594|  1.14k|    if (context != PJSIP_URI_IN_REQ_URI) {
  ------------------
  |  Branch (594:9): [True: 1.14k, False: 0]
  ------------------
  595|  1.14k|        copy_advance_char_check(buf, '>');
  ------------------
  |  |   26|  1.14k|        do { \
  |  |   27|  1.14k|            if (1 >= (endbuf-buf)) return -1;   \
  |  |  ------------------
  |  |  |  Branch (27:17): [True: 6, False: 1.14k]
  |  |  ------------------
  |  |   28|  1.14k|            *buf++ = chr; \
  |  |   29|  1.14k|        } while (0)
  |  |  ------------------
  |  |  |  Branch (29:18): [Folded, False: 1.14k]
  |  |  ------------------
  ------------------
  596|  1.14k|    }
  597|       |
  598|  1.14k|    *buf = '\0';
  599|  1.14k|    return buf-startbuf;
  600|  1.14k|}
sip_uri.c:pjsip_name_addr_clone:
  611|  2.42k|{
  612|  2.42k|    pjsip_name_addr *addr = PJ_POOL_ALLOC_T(pool, pjsip_name_addr);
  ------------------
  |  |  569|  2.42k|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
  613|  2.42k|    if (!addr)
  ------------------
  |  Branch (613:9): [True: 0, False: 2.42k]
  ------------------
  614|      0|        return NULL;
  615|       |
  616|  2.42k|    pjsip_name_addr_init(addr);
  617|  2.42k|    pjsip_name_addr_assign(pool, addr, rhs);
  618|  2.42k|    return addr;
  619|  2.42k|}
sip_uri.c:other_uri_get_scheme:
  678|  1.97k|{
  679|  1.97k|        return &uri->scheme;
  680|  1.97k|}
sip_uri.c:other_uri_get_uri:
  683|    473|{
  684|    473|    return uri;
  685|    473|}
sip_uri.c:other_uri_print:
  690|    465|{
  691|    465|    char *startbuf = buf;
  692|    465|    char *endbuf = buf + size - 1; // Need to minus one for NULL terminator
  693|       |    
  694|    465|    PJ_UNUSED_ARG(context);
  ------------------
  |  | 1537|    465|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  695|       |    
  696|    465|    if (uri->scheme.slen + uri->content.slen + 1 > (int)size)
  ------------------
  |  Branch (696:9): [True: 20, False: 445]
  ------------------
  697|     20|        return -1;
  698|       |
  699|       |    /* Print scheme. */
  700|    445|    copy_advance(buf, uri->scheme);
  ------------------
  |  |  109|    445|#define copy_advance            copy_advance_check
  |  |  ------------------
  |  |  |  |   32|    445|        do { \
  |  |  |  |   33|    445|            if ((str).slen >= (endbuf-buf)) return -1;  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (33:17): [True: 0, False: 445]
  |  |  |  |  ------------------
  |  |  |  |   34|    445|            if ((str).slen) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (34:17): [True: 445, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   35|    445|                pj_memcpy(buf, (str).ptr, (str).slen); \
  |  |  |  |   36|    445|                buf += (str).slen; \
  |  |  |  |   37|    445|            } \
  |  |  |  |   38|    445|        } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (38:18): [Folded, False: 445]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  701|    445|    copy_advance_char_check(buf, ':');
  ------------------
  |  |   26|    445|        do { \
  |  |   27|    445|            if (1 >= (endbuf-buf)) return -1;   \
  |  |  ------------------
  |  |  |  Branch (27:17): [True: 1, False: 444]
  |  |  ------------------
  |  |   28|    445|            *buf++ = chr; \
  |  |   29|    444|        } while (0)
  |  |  ------------------
  |  |  |  Branch (29:18): [Folded, False: 444]
  |  |  ------------------
  ------------------
  702|       |    
  703|       |    /* Print content. */
  704|    444|    copy_advance(buf, uri->content);
  ------------------
  |  |  109|    444|#define copy_advance            copy_advance_check
  |  |  ------------------
  |  |  |  |   32|    444|        do { \
  |  |  |  |   33|    444|            if ((str).slen >= (endbuf-buf)) return -1;  \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (33:17): [True: 4, False: 440]
  |  |  |  |  ------------------
  |  |  |  |   34|    444|            if ((str).slen) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (34:17): [True: 440, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   35|    440|                pj_memcpy(buf, (str).ptr, (str).slen); \
  |  |  |  |   36|    440|                buf += (str).slen; \
  |  |  |  |   37|    440|            } \
  |  |  |  |   38|    440|        } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (38:18): [Folded, False: 440]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  705|       |    
  706|    440|    *buf = '\0';
  707|    440|    return (buf - startbuf);
  708|    444|}
sip_uri.c:other_uri_clone:
  737|  1.48k|{
  738|  1.48k|    pjsip_other_uri *uri = pjsip_other_uri_create(pool);
  739|  1.48k|    pj_strdup(pool, &uri->scheme, &rhs->scheme);
  740|  1.48k|    pj_strdup(pool, &uri->content, &rhs->content);
  741|       |
  742|  1.48k|    return uri;
  743|  1.48k|}

pjsip_target_set_add_uri:
   58|    566|{
   59|    566|    pjsip_target *t, *pos = NULL;
   60|       |
   61|    566|    PJ_ASSERT_RETURN(tset && pool && uri, PJ_EINVAL);
  ------------------
  |  |   97|    566|            do { \
  |  |   98|  2.26k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 566, False: 0]
  |  |  |  Branch (98:23): [True: 566, False: 0]
  |  |  |  Branch (98:23): [True: 566, False: 0]
  |  |  ------------------
  |  |   99|    566|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 566]
  |  |  ------------------
  ------------------
  |  Branch (61:5): [True: 0, False: 0]
  |  Branch (61:5): [True: 0, False: 0]
  |  Branch (61:5): [True: 0, False: 0]
  |  Branch (61:5): [True: 0, False: 0]
  |  Branch (61:5): [True: 0, False: 0]
  |  Branch (61:5): [True: 0, False: 0]
  ------------------
   62|       |
   63|       |    /* Set q-value to 1 if it is not set */
   64|    566|    if (q1000 <= 0)
  ------------------
  |  Branch (64:9): [True: 566, False: 0]
  ------------------
   65|    566|        q1000 = 1000;
   66|       |
   67|       |    /* Scan all the elements to see for duplicates, and at the same time
   68|       |     * get the position where the new element should be inserted to
   69|       |     * based on the q-value.
   70|       |     */
   71|    566|    t = tset->head.next;
   72|    566|    while (t != &tset->head) {
  ------------------
  |  Branch (72:12): [True: 0, False: 566]
  ------------------
   73|      0|        if (pjsip_uri_cmp(PJSIP_URI_IN_REQ_URI, t->uri, uri)==PJ_SUCCESS)
  ------------------
  |  Branch (73:13): [True: 0, False: 0]
  ------------------
   74|      0|            return PJ_EEXISTS;
  ------------------
  |  |  448|      0|#define PJ_EEXISTS          (PJ_ERRNO_START_STATUS + 15)/* 70015 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   75|      0|        if (pos==NULL && t->q1000 < q1000)
  ------------------
  |  Branch (75:13): [True: 0, False: 0]
  |  Branch (75:26): [True: 0, False: 0]
  ------------------
   76|      0|            pos = t;
   77|      0|        t = t->next;
   78|      0|    }
   79|       |
   80|       |    /* Create new element */
   81|    566|    t = PJ_POOL_ZALLOC_T(pool, pjsip_target);
  ------------------
  |  |  583|    566|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
   82|    566|    t->uri = (pjsip_uri*)pjsip_uri_clone(pool, uri);
   83|    566|    t->q1000 = q1000;
   84|       |
   85|       |    /* Insert */
   86|    566|    if (pos == NULL)
  ------------------
  |  Branch (86:9): [True: 566, False: 0]
  ------------------
   87|    566|        pj_list_push_back(&tset->head, t);
   88|      0|    else
   89|      0|        pj_list_insert_before(pos, t);
   90|       |
   91|       |    /* Set current target if this is the first URI */
   92|    566|    if (tset->current == NULL)
  ------------------
  |  Branch (92:9): [True: 566, False: 0]
  ------------------
   93|    566|        tset->current = t;
   94|       |
   95|    566|    return PJ_SUCCESS;
   96|    566|}
pjsip_endpt_create_request_from_hdr:
  409|    168|{
  410|    168|    pjsip_uri *target;
  411|    168|    pjsip_tx_data *tdata;
  412|    168|    pjsip_from_hdr *from;
  413|    168|    pjsip_to_hdr *to;
  414|    168|    pjsip_contact_hdr *contact;
  415|    168|    pjsip_cid_hdr *call_id;
  416|    168|    pjsip_cseq_hdr *cseq = NULL; /* The NULL because warning in VC6 */
  417|    168|    pj_status_t status;
  418|    168|    PJ_USE_EXCEPTION;
  ------------------
  |  |  367|    168|#define PJ_USE_EXCEPTION    struct pj_exception_state_t pj_x_except__; int pj_x_code__
  ------------------
  419|       |
  420|       |    /* Check arguments. */
  421|    168|    PJ_ASSERT_RETURN(endpt && method && param_target && param_from &&
  ------------------
  |  |   97|    168|            do { \
  |  |   98|  1.68k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 168, False: 0]
  |  |  |  Branch (98:23): [True: 168, False: 0]
  |  |  |  Branch (98:23): [True: 168, False: 0]
  |  |  |  Branch (98:23): [True: 168, False: 0]
  |  |  |  Branch (98:23): [True: 168, False: 0]
  |  |  |  Branch (98:23): [True: 168, False: 0]
  |  |  ------------------
  |  |   99|    168|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 168]
  |  |  ------------------
  ------------------
  |  Branch (421:5): [True: 0, False: 0]
  |  Branch (421:5): [True: 0, False: 0]
  |  Branch (421:5): [True: 0, False: 0]
  |  Branch (421:5): [True: 0, False: 0]
  |  Branch (421:5): [True: 0, False: 0]
  |  Branch (421:5): [True: 0, False: 0]
  |  Branch (421:5): [True: 0, False: 0]
  |  Branch (421:5): [True: 0, False: 0]
  |  Branch (421:5): [True: 0, False: 0]
  |  Branch (421:5): [True: 0, False: 0]
  |  Branch (421:5): [True: 0, False: 0]
  |  Branch (421:5): [True: 0, False: 0]
  ------------------
  422|    168|                     param_to && p_tdata, PJ_EINVAL);
  423|       |
  424|       |    /* Create new transmit data. */
  425|    168|    status = pjsip_endpt_create_tdata(endpt, &tdata);
  426|    168|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (426:9): [True: 0, False: 168]
  ------------------
  427|      0|        return status;
  428|       |
  429|       |    /* Set initial reference counter to 1. */
  430|    168|    pjsip_tx_data_add_ref(tdata);
  431|       |
  432|    168|    PJ_TRY {
  ------------------
  |  |  373|    168|#define PJ_TRY              if (1) { \
  |  |  ------------------
  |  |  |  Branch (373:33): [True: 168, Folded]
  |  |  ------------------
  |  |  374|    168|                                pj_push_exception_handler_(&pj_x_except__); \
  |  |  375|    168|                                pj_x_code__ = pj_setjmp(pj_x_except__.state); \
  |  |  ------------------
  |  |  |  |   31|    168|#    define pj_setjmp(buf)      setjmp(buf)
  |  |  ------------------
  |  |  376|    168|                                if (pj_x_code__ == 0)
  |  |  ------------------
  |  |  |  Branch (376:37): [True: 168, False: 0]
  |  |  ------------------
  ------------------
  433|       |        /* Duplicate target URI and headers. */
  434|    168|        target = (pjsip_uri*) pjsip_uri_clone(tdata->pool, param_target);
  435|    168|        from = (pjsip_from_hdr*) pjsip_hdr_clone(tdata->pool, param_from);
  436|    168|        pjsip_fromto_hdr_set_from(from);
  437|    168|        to = (pjsip_to_hdr*) pjsip_hdr_clone(tdata->pool, param_to);
  438|    168|        pjsip_fromto_hdr_set_to(to);
  439|    168|        if (param_contact) {
  ------------------
  |  Branch (439:13): [True: 0, False: 168]
  ------------------
  440|      0|            contact = (pjsip_contact_hdr*) 
  441|      0|                      pjsip_hdr_clone(tdata->pool, param_contact);
  442|    168|        } else {
  443|    168|            contact = NULL;
  444|    168|        }
  445|    168|        call_id = pjsip_cid_hdr_create(tdata->pool);
  446|    168|        if (param_call_id != NULL && param_call_id->id.slen)
  ------------------
  |  Branch (446:13): [True: 168, False: 0]
  |  Branch (446:38): [True: 168, False: 0]
  ------------------
  447|    168|            pj_strdup(tdata->pool, &call_id->id, &param_call_id->id);
  448|      0|        else
  449|      0|            pj_create_unique_string(tdata->pool, &call_id->id);
  450|       |
  451|    168|        cseq = pjsip_cseq_hdr_create(tdata->pool);
  452|    168|        if (param_cseq >= 0)
  ------------------
  |  Branch (452:13): [True: 168, False: 0]
  ------------------
  453|    168|            cseq->cseq = param_cseq;
  454|      0|        else
  455|      0|            cseq->cseq = pj_rand() % 0xFFFF;
  456|    168|        pjsip_method_copy(tdata->pool, &cseq->method, method);
  457|       |
  458|       |        /* Copy headers to the request. */
  459|    168|        init_request_throw(endpt, tdata, &cseq->method, target, from, to, 
  460|    168|                           contact, call_id, cseq, param_text);
  461|    168|    }
  462|      0|    PJ_CATCH_ANY {
  463|      0|        status = PJ_ENOMEM;
  ------------------
  |  |  408|      0|#define PJ_ENOMEM           (PJ_ERRNO_START_STATUS + 7) /* 70007 */
  |  |  ------------------
  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  464|      0|        goto on_error;
  465|      0|    }
  466|    168|    PJ_END;
  ------------------
  |  |  394|    168|#define PJ_END                  pj_pop_exception_handler_(&pj_x_except__); \
  |  |  395|    168|                            } else {}
  ------------------
  467|       |
  468|    168|    *p_tdata = tdata;
  469|    168|    return PJ_SUCCESS;
  470|       |
  471|      0|on_error:
  472|      0|    pjsip_tx_data_dec_ref(tdata);
  473|      0|    return status;
  474|    168|}
pjsip_endpt_create_response:
  484|    281|{
  485|    281|    pjsip_tx_data *tdata;
  486|    281|    pjsip_msg *msg, *req_msg;
  487|    281|    pjsip_hdr *hdr;
  488|    281|    pjsip_to_hdr *to_hdr;
  489|    281|    pjsip_via_hdr *top_via = NULL, *via;
  490|    281|    pjsip_rr_hdr *rr;
  491|    281|    pj_status_t status;
  492|       |
  493|       |    /* Check arguments. */
  494|    281|    PJ_ASSERT_RETURN(endpt && rdata && p_tdata, PJ_EINVAL);
  ------------------
  |  |   97|    281|            do { \
  |  |   98|  1.12k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 281, False: 0]
  |  |  |  Branch (98:23): [True: 281, False: 0]
  |  |  |  Branch (98:23): [True: 281, False: 0]
  |  |  ------------------
  |  |   99|    281|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 281]
  |  |  ------------------
  ------------------
  |  Branch (494:5): [True: 0, False: 0]
  |  Branch (494:5): [True: 0, False: 0]
  |  Branch (494:5): [True: 0, False: 0]
  |  Branch (494:5): [True: 0, False: 0]
  |  Branch (494:5): [True: 0, False: 0]
  |  Branch (494:5): [True: 0, False: 0]
  ------------------
  495|       |
  496|       |    /* Check status code. */
  497|    281|    PJ_ASSERT_RETURN(st_code >= 100 && st_code <= 699, PJ_EINVAL);
  ------------------
  |  |   97|    281|            do { \
  |  |   98|    562|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 281, False: 0]
  |  |  |  Branch (98:23): [True: 281, False: 0]
  |  |  ------------------
  |  |   99|    281|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 281]
  |  |  ------------------
  ------------------
  |  Branch (497:5): [True: 0, False: 0]
  |  Branch (497:5): [True: 0, False: 0]
  |  Branch (497:5): [True: 0, False: 0]
  |  Branch (497:5): [True: 0, False: 0]
  ------------------
  498|       |
  499|       |    /* rdata must be a request message. */
  500|    281|    req_msg = rdata->msg_info.msg;
  501|    281|    pj_assert(req_msg->type == PJSIP_REQUEST_MSG);
  ------------------
  |  |   65|    281|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (501:5): [True: 0, False: 281]
  |  Branch (501:5): [True: 281, False: 0]
  ------------------
  502|       |
  503|       |    /* Request MUST NOT be ACK request! */
  504|    281|    PJ_ASSERT_RETURN(req_msg->line.req.method.id != PJSIP_ACK_METHOD,
  ------------------
  |  |   97|    281|            do { \
  |  |   98|    281|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 281]
  |  |  ------------------
  |  |   99|    281|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 281]
  |  |  ------------------
  ------------------
  |  Branch (504:5): [True: 0, False: 0]
  |  Branch (504:5): [True: 0, False: 0]
  ------------------
  505|    281|                     PJ_EINVALIDOP);
  506|       |
  507|       |    /* Create a new transmit buffer. */
  508|    281|    status = pjsip_endpt_create_tdata( endpt, &tdata);
  509|    281|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (509:9): [True: 0, False: 281]
  ------------------
  510|      0|        return status;
  511|       |
  512|       |    /* Set initial reference count to 1. */
  513|    281|    pjsip_tx_data_add_ref(tdata);
  514|       |
  515|       |    /* Create new response message. */
  516|    281|    tdata->msg = msg = pjsip_msg_create(tdata->pool, PJSIP_RESPONSE_MSG);
  517|       |
  518|       |    /* Set status code and reason text. */
  519|    281|    msg->line.status.code = st_code;
  520|    281|    if (st_text)
  ------------------
  |  Branch (520:9): [True: 0, False: 281]
  ------------------
  521|      0|        pj_strdup(tdata->pool, &msg->line.status.reason, st_text);
  522|    281|    else
  523|    281|        msg->line.status.reason = *pjsip_get_status_text(st_code);
  524|       |
  525|       |    /* Set TX data attributes. */
  526|    281|    tdata->rx_timestamp = rdata->pkt_info.timestamp;
  527|       |
  528|       |    /* Copy all the via headers, in order. */
  529|    281|    via = rdata->msg_info.via;
  530|  1.44k|    while (via) {
  ------------------
  |  Branch (530:12): [True: 1.17k, False: 262]
  ------------------
  531|  1.17k|        pjsip_via_hdr *new_via;
  532|       |
  533|  1.17k|        new_via = (pjsip_via_hdr*)pjsip_hdr_clone(tdata->pool, via);
  534|  1.17k|        if (top_via == NULL)
  ------------------
  |  Branch (534:13): [True: 281, False: 897]
  ------------------
  535|    281|            top_via = new_via;
  536|       |
  537|  1.17k|        pjsip_msg_add_hdr( msg, (pjsip_hdr*)new_via);
  538|  1.17k|        via = via->next;
  539|  1.17k|        if (via != (void*)&req_msg->hdr)
  ------------------
  |  Branch (539:13): [True: 1.15k, False: 19]
  ------------------
  540|  1.15k|            via = (pjsip_via_hdr*) 
  541|  1.15k|                  pjsip_msg_find_hdr(req_msg, PJSIP_H_VIA, via);
  542|     19|        else
  543|     19|            break;
  544|  1.17k|    }
  545|       |
  546|       |    /* Copy all Record-Route headers, in order. */
  547|    281|    rr = (pjsip_rr_hdr*) 
  548|    281|         pjsip_msg_find_hdr(req_msg, PJSIP_H_RECORD_ROUTE, NULL);
  549|    281|    while (rr) {
  ------------------
  |  Branch (549:12): [True: 0, False: 281]
  ------------------
  550|      0|        pjsip_msg_add_hdr(msg, (pjsip_hdr*) pjsip_hdr_clone(tdata->pool, rr));
  551|      0|        rr = rr->next;
  552|      0|        if (rr != (void*)&req_msg->hdr)
  ------------------
  |  Branch (552:13): [True: 0, False: 0]
  ------------------
  553|      0|            rr = (pjsip_rr_hdr*) pjsip_msg_find_hdr(req_msg, 
  554|      0|                                                    PJSIP_H_RECORD_ROUTE, rr);
  555|      0|        else
  556|      0|            break;
  557|      0|    }
  558|       |
  559|       |    /* Copy Call-ID header. */
  560|    281|    hdr = (pjsip_hdr*) pjsip_msg_find_hdr( req_msg, PJSIP_H_CALL_ID, NULL);
  561|    281|    pjsip_msg_add_hdr(msg, (pjsip_hdr*) pjsip_hdr_clone(tdata->pool, hdr));
  562|       |
  563|       |    /* Copy From header. */
  564|    281|    hdr = (pjsip_hdr*) pjsip_hdr_clone(tdata->pool, rdata->msg_info.from);
  565|    281|    pjsip_msg_add_hdr( msg, hdr);
  566|       |
  567|       |    /* Copy To header. */
  568|    281|    to_hdr = (pjsip_to_hdr*) pjsip_hdr_clone(tdata->pool, rdata->msg_info.to);
  569|    281|    pjsip_msg_add_hdr( msg, (pjsip_hdr*)to_hdr);
  570|       |
  571|       |    /* Must add To tag in the response (Section 8.2.6.2), except if this is
  572|       |     * 100 (Trying) response. Same tag must be created for the same request
  573|       |     * (e.g. same tag in provisional and final response). The easiest way
  574|       |     * to do this is to derive the tag from Via branch parameter (or to
  575|       |     * use it directly).
  576|       |     */
  577|    281|    if (to_hdr->tag.slen==0 && st_code > 100 && top_via) {
  ------------------
  |  Branch (577:9): [True: 281, False: 0]
  |  Branch (577:32): [True: 281, False: 0]
  |  Branch (577:49): [True: 281, False: 0]
  ------------------
  578|    281|        to_hdr->tag = top_via->branch_param;
  579|    281|    }
  580|       |
  581|       |    /* Copy CSeq header. */
  582|    281|    hdr = (pjsip_hdr*) pjsip_hdr_clone(tdata->pool, rdata->msg_info.cseq);
  583|    281|    pjsip_msg_add_hdr( msg, hdr);
  584|       |
  585|       |    /* All done. */
  586|    281|    *p_tdata = tdata;
  587|       |
  588|    281|    PJ_LOG(5,(THIS_FILE, "%s created", pjsip_tx_data_get_info(tdata)));
  ------------------
  |  |  106|    281|#define PJ_LOG(level,arg)       do { \
  |  |  107|    281|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|    562|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 281, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 281]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|    281|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 281]
  |  |  ------------------
  ------------------
  589|    281|    return PJ_SUCCESS;
  590|    281|}
pjsip_get_response_addr:
 1684|    281|{
 1685|    281|    pjsip_transport *src_transport = rdata->tp_info.transport;
 1686|       |
 1687|       |    /* Check arguments. */
 1688|    281|    PJ_ASSERT_RETURN(pool && rdata && res_addr, PJ_EINVAL);
  ------------------
  |  |   97|    281|            do { \
  |  |   98|  1.12k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 281, False: 0]
  |  |  |  Branch (98:23): [True: 281, False: 0]
  |  |  |  Branch (98:23): [True: 281, False: 0]
  |  |  ------------------
  |  |   99|    281|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 281]
  |  |  ------------------
  ------------------
  |  Branch (1688:5): [True: 0, False: 0]
  |  Branch (1688:5): [True: 0, False: 0]
  |  Branch (1688:5): [True: 0, False: 0]
  |  Branch (1688:5): [True: 0, False: 0]
  |  Branch (1688:5): [True: 0, False: 0]
  |  Branch (1688:5): [True: 0, False: 0]
  ------------------
 1689|       |
 1690|       |    /* rdata must be a request message! */
 1691|    281|    PJ_ASSERT_RETURN(rdata->msg_info.msg->type == PJSIP_REQUEST_MSG,
  ------------------
  |  |   97|    281|            do { \
  |  |   98|    281|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 281]
  |  |  ------------------
  |  |   99|    281|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 281]
  |  |  ------------------
  ------------------
  |  Branch (1691:5): [True: 0, False: 0]
  |  Branch (1691:5): [True: 0, False: 0]
  ------------------
 1692|    281|                     PJ_EINVAL);
 1693|       |
 1694|       |    /* All requests must have "received" parameter.
 1695|       |     * This must always be done in transport layer.
 1696|       |     */
 1697|    281|    pj_assert(rdata->msg_info.via->recvd_param.slen != 0);
  ------------------
  |  |   65|    281|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (1697:5): [True: 0, False: 281]
  |  Branch (1697:5): [True: 281, False: 0]
  ------------------
 1698|       |
 1699|       |    /* Do the calculation based on RFC 3261 Section 18.2.2 and RFC 3581 */
 1700|       |
 1701|    281|    if (PJSIP_TRANSPORT_IS_RELIABLE(src_transport)) {
  ------------------
  |  |   82|    281|            ((tp)->flag & PJSIP_TRANSPORT_RELIABLE)
  |  |  ------------------
  |  |  |  Branch (82:13): [True: 0, False: 281]
  |  |  ------------------
  ------------------
 1702|       |        /* For reliable protocol such as TCP or SCTP, or TLS over those, the
 1703|       |         * response MUST be sent using the existing connection to the source
 1704|       |         * of the original request that created the transaction, if that 
 1705|       |         * connection is still open. 
 1706|       |         * If that connection is no longer open, the server SHOULD open a 
 1707|       |         * connection to the IP address in the received parameter, if present,
 1708|       |         * using the port in the sent-by value, or the default port for that 
 1709|       |         * transport, if no port is specified. 
 1710|       |         * If that connection attempt fails, the server SHOULD use the 
 1711|       |         * procedures in [4] for servers in order to determine the IP address
 1712|       |         * and port to open the connection and send the response to.
 1713|       |         */
 1714|      0|        res_addr->transport = rdata->tp_info.transport;
 1715|      0|        pj_memcpy(&res_addr->addr, &rdata->pkt_info.src_addr,
 1716|      0|                  rdata->pkt_info.src_addr_len);
 1717|      0|        res_addr->addr_len = rdata->pkt_info.src_addr_len;
 1718|      0|        res_addr->dst_host.type=(pjsip_transport_type_e)src_transport->key.type;
 1719|      0|        res_addr->dst_host.flag = src_transport->flag;
 1720|      0|        pj_strdup( pool, &res_addr->dst_host.addr.host, 
 1721|      0|                   &rdata->msg_info.via->recvd_param);
 1722|      0|        res_addr->dst_host.addr.port = rdata->msg_info.via->sent_by.port;
 1723|      0|        if (res_addr->dst_host.addr.port == 0) {
  ------------------
  |  Branch (1723:13): [True: 0, False: 0]
  ------------------
 1724|      0|            res_addr->dst_host.addr.port = 
 1725|      0|                pjsip_transport_get_default_port_for_type(res_addr->dst_host.type);
 1726|      0|        }
 1727|       |
 1728|    281|    } else if (rdata->msg_info.via->maddr_param.slen) {
  ------------------
  |  Branch (1728:16): [True: 13, False: 268]
  ------------------
 1729|       |        /* Otherwise, if the Via header field value contains a maddr parameter,
 1730|       |         * the response MUST be forwarded to the address listed there, using 
 1731|       |         * the port indicated in sent-by, or port 5060 if none is present. 
 1732|       |         * If the address is a multicast address, the response SHOULD be sent 
 1733|       |         * using the TTL indicated in the ttl parameter, or with a TTL of 1 if
 1734|       |         * that parameter is not present. 
 1735|       |         */
 1736|     13|        res_addr->transport = NULL;
 1737|     13|        res_addr->dst_host.type=(pjsip_transport_type_e)src_transport->key.type;
 1738|     13|        res_addr->dst_host.flag = src_transport->flag;
 1739|     13|        pj_strdup( pool, &res_addr->dst_host.addr.host, 
 1740|     13|                   &rdata->msg_info.via->maddr_param);
 1741|     13|        res_addr->dst_host.addr.port = rdata->msg_info.via->sent_by.port;
 1742|     13|        if (res_addr->dst_host.addr.port == 0)
  ------------------
  |  Branch (1742:13): [True: 11, False: 2]
  ------------------
 1743|     11|            res_addr->dst_host.addr.port = 5060;
 1744|       |
 1745|    268|    } else if (rdata->msg_info.via->rport_param >= 0) {
  ------------------
  |  Branch (1745:16): [True: 21, False: 247]
  ------------------
 1746|       |        /* There is both a "received" parameter and an "rport" parameter, 
 1747|       |         * the response MUST be sent to the IP address listed in the "received"
 1748|       |         * parameter, and the port in the "rport" parameter. 
 1749|       |         * The response MUST be sent from the same address and port that the 
 1750|       |         * corresponding request was received on.
 1751|       |         */
 1752|     21|        res_addr->transport = rdata->tp_info.transport;
 1753|     21|        pj_memcpy(&res_addr->addr, &rdata->pkt_info.src_addr,
 1754|     21|                  rdata->pkt_info.src_addr_len);
 1755|     21|        res_addr->addr_len = rdata->pkt_info.src_addr_len;
 1756|     21|        res_addr->dst_host.type=(pjsip_transport_type_e)src_transport->key.type;
 1757|     21|        res_addr->dst_host.flag = src_transport->flag;
 1758|     21|        pj_strdup( pool, &res_addr->dst_host.addr.host, 
 1759|     21|                   &rdata->msg_info.via->recvd_param);
 1760|     21|        res_addr->dst_host.addr.port = rdata->msg_info.via->sent_by.port;
 1761|     21|        if (res_addr->dst_host.addr.port == 0) {
  ------------------
  |  Branch (1761:13): [True: 18, False: 3]
  ------------------
 1762|     18|            res_addr->dst_host.addr.port = 
 1763|     18|                pjsip_transport_get_default_port_for_type(res_addr->dst_host.type);
 1764|     18|        }
 1765|       |
 1766|    247|    } else {
 1767|    247|        res_addr->transport = NULL;
 1768|    247|        res_addr->dst_host.type=(pjsip_transport_type_e)src_transport->key.type;
 1769|    247|        res_addr->dst_host.flag = src_transport->flag;
 1770|    247|        pj_strdup( pool, &res_addr->dst_host.addr.host, 
 1771|    247|                   &rdata->msg_info.via->recvd_param);
 1772|    247|        res_addr->dst_host.addr.port = rdata->msg_info.via->sent_by.port;
 1773|    247|        if (res_addr->dst_host.addr.port == 0) {
  ------------------
  |  Branch (1773:13): [True: 244, False: 3]
  ------------------
 1774|    244|            res_addr->dst_host.addr.port = 
 1775|    244|                pjsip_transport_get_default_port_for_type(res_addr->dst_host.type);
 1776|    244|        }
 1777|    247|    }
 1778|       |
 1779|    281|    return PJ_SUCCESS;
 1780|    281|}
sip_util.c:init_request_throw:
  205|    168|{
  206|    168|    pjsip_msg *msg;
  207|    168|    pjsip_msg_body *body;
  208|    168|    pjsip_via_hdr *via;
  209|    168|    const pjsip_hdr *endpt_hdr;
  210|       |
  211|       |    /* Create the message. */
  212|    168|    msg = tdata->msg = pjsip_msg_create(tdata->pool, PJSIP_REQUEST_MSG);
  213|       |
  214|       |    /* Init request URI. */
  215|    168|    pj_memcpy(&msg->line.req.method, method, sizeof(*method));
  216|    168|    msg->line.req.uri = param_target;
  217|       |
  218|       |    /* Add additional request headers from endpoint. */
  219|    168|    endpt_hdr = pjsip_endpt_get_request_headers(endpt)->next;
  220|    336|    while (endpt_hdr != pjsip_endpt_get_request_headers(endpt)) {
  ------------------
  |  Branch (220:12): [True: 168, False: 168]
  ------------------
  221|    168|        pjsip_hdr *hdr = (pjsip_hdr*) 
  222|    168|                         pjsip_hdr_shallow_clone(tdata->pool, endpt_hdr);
  223|    168|        pjsip_msg_add_hdr( tdata->msg, hdr );
  224|    168|        endpt_hdr = endpt_hdr->next;
  225|    168|    }
  226|       |
  227|       |    /* Add From header. */
  228|    168|    if (param_from->tag.slen == 0)
  ------------------
  |  Branch (228:9): [True: 0, False: 168]
  ------------------
  229|      0|        pj_create_unique_string(tdata->pool, &param_from->tag);
  230|    168|    pjsip_msg_add_hdr(msg, (pjsip_hdr*)param_from);
  231|       |
  232|       |    /* Add To header. */
  233|    168|    pjsip_msg_add_hdr(msg, (pjsip_hdr*)param_to);
  234|       |
  235|       |    /* Add Contact header. */
  236|    168|    if (param_contact) {
  ------------------
  |  Branch (236:9): [True: 0, False: 168]
  ------------------
  237|      0|        pjsip_msg_add_hdr(msg, (pjsip_hdr*)param_contact);
  238|      0|    }
  239|       |
  240|       |    /* Add Call-ID header. */
  241|    168|    pjsip_msg_add_hdr(msg, (pjsip_hdr*)param_call_id);
  242|       |
  243|       |    /* Add CSeq header. */
  244|    168|    pjsip_msg_add_hdr(msg, (pjsip_hdr*)param_cseq);
  245|       |
  246|       |    /* Add a blank Via header in the front of the message. */
  247|    168|    via = pjsip_via_hdr_create(tdata->pool);
  248|    168|    via->rport_param = pjsip_cfg()->endpt.disable_rport ? -1 : 0;
  ------------------
  |  Branch (248:24): [True: 0, False: 168]
  ------------------
  249|    168|    pjsip_msg_insert_first_hdr(msg, (pjsip_hdr*)via);
  250|       |
  251|       |    /* Add header params as request headers */
  252|    168|    if (PJSIP_URI_SCHEME_IS_SIP(param_target) || 
  ------------------
  |  |  234|    336|    (pj_stricmp2(pjsip_uri_get_scheme(url), "sip")==0)
  |  |  ------------------
  |  |  |  Branch (234:5): [True: 26, False: 142]
  |  |  ------------------
  ------------------
  253|    142|        PJSIP_URI_SCHEME_IS_SIPS(param_target)) 
  ------------------
  |  |  242|    142|    (pj_stricmp2(pjsip_uri_get_scheme(url), "sips")==0)
  |  |  ------------------
  |  |  |  Branch (242:5): [True: 8, False: 134]
  |  |  ------------------
  ------------------
  254|     34|    {
  255|     34|        pjsip_sip_uri *uri = (pjsip_sip_uri*) pjsip_uri_get_uri(param_target);
  256|     34|        pjsip_param *hparam;
  257|       |
  258|     34|        hparam = uri->header_param.next;
  259|     34|        while (hparam != &uri->header_param) {
  ------------------
  |  Branch (259:16): [True: 0, False: 34]
  ------------------
  260|      0|            pjsip_generic_string_hdr *hdr;
  261|       |
  262|      0|            hdr = pjsip_generic_string_hdr_create(tdata->pool, 
  263|      0|                                                  &hparam->name,
  264|      0|                                                  &hparam->value);
  265|      0|            pjsip_msg_add_hdr(msg, (pjsip_hdr*)hdr);
  266|      0|            hparam = hparam->next;
  267|      0|        }
  268|     34|    }
  269|       |
  270|       |    /* Create message body. */
  271|    168|    if (param_text) {
  ------------------
  |  Branch (271:9): [True: 0, False: 168]
  ------------------
  272|      0|        body = PJ_POOL_ZALLOC_T(tdata->pool, pjsip_msg_body);
  ------------------
  |  |  583|      0|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  273|      0|        body->content_type.type = str_TEXT;
  274|      0|        body->content_type.subtype = str_PLAIN;
  275|      0|        body->data = pj_pool_alloc(tdata->pool, param_text->slen );
  276|      0|        pj_memcpy(body->data, param_text->ptr, param_text->slen);
  277|      0|        body->len = (unsigned)param_text->slen;
  278|      0|        body->print_body = &pjsip_print_text_body;
  279|      0|        msg->body = body;
  280|      0|    }
  281|       |
  282|    168|    PJ_LOG(5,(THIS_FILE, "%s created.", 
  ------------------
  |  |  106|    168|#define PJ_LOG(level,arg)       do { \
  |  |  107|    168|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|    336|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 168, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 168]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|    168|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 168]
  |  |  ------------------
  ------------------
  283|    168|                         pjsip_tx_data_get_info(tdata)));
  284|       |
  285|    168|}

LLVMFuzzerInitialize:
  191|      2|{
  192|      2|    pj_status_t status;
  193|       |
  194|      2|    PJ_UNUSED_ARG(argc);
  ------------------
  |  | 1537|      2|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  195|      2|    PJ_UNUSED_ARG(argv);
  ------------------
  |  | 1537|      2|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  196|       |
  197|       |    /* Initialize PJLIB */
  198|      2|    status = pj_init();
  199|      2|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (199:9): [True: 0, False: 2]
  ------------------
  200|      0|        return 1;
  201|       |
  202|       |    /* Initialize memory pool factory */
  203|      2|    pj_caching_pool_init(&caching_pool, &pj_pool_factory_default_policy,
  204|      2|                         PJSIP_TEST_MEM_SIZE);
  ------------------
  |  |   32|      2|#define PJSIP_TEST_MEM_SIZE (2*1024*1024)
  ------------------
  205|       |
  206|       |    /* Create SIP endpoint */
  207|      2|    status = pjsip_endpt_create(&caching_pool.factory, "dialog-fuzzer", &endpt);
  208|      2|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (208:9): [True: 0, False: 2]
  ------------------
  209|      0|        return 1;
  210|       |
  211|       |    /* Initialize transaction layer */
  212|      2|    status = pjsip_tsx_layer_init_module(endpt);
  213|      2|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (213:9): [True: 0, False: 2]
  ------------------
  214|      0|        return 1;
  215|       |
  216|       |    /* Initialize UA layer */
  217|      2|    status = pjsip_ua_init_module(endpt, NULL);
  218|      2|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (218:9): [True: 0, False: 2]
  ------------------
  219|      0|        return 1;
  220|       |
  221|       |    /* Initialize loop transport */
  222|      2|    status = pjsip_loop_start(endpt, &loop_transport);
  223|      2|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (223:9): [True: 0, False: 2]
  ------------------
  224|      0|        return 1;
  225|       |
  226|       |    /* Register dialog test module */
  227|      2|    pj_bzero(&dialog_test_mod, sizeof(dialog_test_mod));
  228|      2|    dialog_test_mod.name = pj_str("dialog-test-mod");
  229|      2|    dialog_test_mod.id = -1;
  230|      2|    dialog_test_mod.priority = PJSIP_MOD_PRIORITY_APPLICATION;
  231|       |
  232|      2|    status = pjsip_endpt_register_module(endpt, &dialog_test_mod);
  233|      2|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (233:9): [True: 0, False: 2]
  ------------------
  234|      0|        return 1;
  235|       |
  236|       |    /* Disable logging for performance */
  237|      2|    pj_log_set_level(0);
  238|       |
  239|      2|    return 0;
  240|      2|}
LLVMFuzzerTestOneInput:
  243|  5.40k|{
  244|  5.40k|    pj_pool_t *pool;
  245|  5.40k|    pj_time_val timeout;
  246|       |
  247|       |    /* Create pool for this iteration */
  248|  5.40k|    pool = pjsip_endpt_create_pool(endpt, "dialog-fuzz", POOL_SIZE, POOL_SIZE);
  ------------------
  |  |   31|  5.40k|#define POOL_SIZE 8000
  ------------------
                  pool = pjsip_endpt_create_pool(endpt, "dialog-fuzz", POOL_SIZE, POOL_SIZE);
  ------------------
  |  |   31|  5.40k|#define POOL_SIZE 8000
  ------------------
  249|  5.40k|    if (!pool)
  ------------------
  |  Branch (249:9): [True: 0, False: 5.40k]
  ------------------
  250|      0|        return 0;
  251|       |
  252|       |    /* Test both UAC and UAS dialog creation */
  253|  5.40k|    test_uac_dialog(pool, Data, Size);
  254|  5.40k|    test_uas_dialog(pool, Data, Size);
  255|       |
  256|       |    /* Release pool */
  257|  5.40k|    pjsip_endpt_release_pool(endpt, pool);
  258|       |
  259|       |    /* Final cleanup of any pending events */
  260|  5.40k|    timeout.sec = 0;
  261|  5.40k|    timeout.msec = 0;
  262|  5.40k|    pjsip_endpt_handle_events(endpt, &timeout);
  263|       |
  264|  5.40k|    return 0;
  265|  5.40k|}
fuzz-sip-dialog.c:test_uac_dialog:
   46|  5.40k|{
   47|  5.40k|    pj_ssize_t len1, len2, len3;
   48|  5.40k|    pj_str_t local_uri, remote_uri, target;
   49|  5.40k|    pjsip_dialog *dlg;
   50|  5.40k|    pj_status_t status;
   51|  5.40k|    pjsip_tx_data *tdata;
   52|  5.40k|    char *route_data;
   53|  5.40k|    pj_str_t route_name;
   54|  5.40k|    pjsip_hdr *hdr;
   55|  5.40k|    pjsip_route_hdr route_set;
   56|  5.40k|    pjsip_route_hdr *route_hdr;
   57|       |
   58|  5.40k|    if (size < 3)
  ------------------
  |  Branch (58:9): [True: 113, False: 5.28k]
  ------------------
   59|    113|        return;
   60|       |
   61|       |    /* Split input data into three URI strings */
   62|  5.28k|    len1 = (size / 3 > 50) ? 50 : size / 3;
  ------------------
  |  Branch (62:12): [True: 1.75k, False: 3.53k]
  ------------------
   63|  5.28k|    len2 = (size / 3 > 50) ? 50 : size / 3;
  ------------------
  |  Branch (63:12): [True: 1.75k, False: 3.53k]
  ------------------
   64|  5.28k|    len3 = (size - len1 - len2 > 50) ? 50 : size - len1 - len2;
  ------------------
  |  Branch (64:12): [True: 1.78k, False: 3.50k]
  ------------------
   65|       |
   66|  5.28k|    local_uri.ptr = alloc_str_from_data(pool, data, 0, len1);
   67|  5.28k|    local_uri.slen = len1;
   68|  5.28k|    remote_uri.ptr = alloc_str_from_data(pool, data, len1, len2);
   69|  5.28k|    remote_uri.slen = len2;
   70|  5.28k|    target.ptr = alloc_str_from_data(pool, data, len1 + len2, len3);
   71|  5.28k|    target.slen = len3;
   72|       |
   73|       |    /* Create UAC dialog */
   74|  5.28k|    dlg = NULL;
   75|  5.28k|    status = pjsip_dlg_create_uac(pjsip_ua_instance(), &local_uri,
   76|  5.28k|                                   NULL, &remote_uri, &target, &dlg);
   77|  5.28k|    if (status != PJ_SUCCESS || !dlg)
  ------------------
  |  Branch (77:9): [True: 5.12k, False: 168]
  |  Branch (77:33): [True: 0, False: 168]
  ------------------
   78|  5.12k|        return;
   79|       |
   80|    168|    pjsip_dlg_inc_lock(dlg);
   81|       |
   82|       |    /* Parse and set route header from fuzzer data */
   83|    168|    if (size > 150) {
  ------------------
  |  Branch (83:9): [True: 51, False: 117]
  ------------------
   84|     51|        route_data = alloc_str_from_data(pool, data, 150, size - 150);
   85|     51|        route_name = pj_str("Route");
   86|     51|        hdr = (pjsip_hdr*)pjsip_parse_hdr(pool, &route_name,
   87|     51|                                           route_data, size - 150, NULL);
   88|     51|        if (hdr && hdr->type == PJSIP_H_ROUTE) {
  ------------------
  |  Branch (88:13): [True: 27, False: 24]
  |  Branch (88:20): [True: 27, False: 0]
  ------------------
   89|     27|            route_hdr = (pjsip_route_hdr*)hdr;
   90|     27|            pj_list_init(&route_set);
   91|     27|            pj_list_push_back(&route_set, route_hdr);
   92|     27|            pjsip_dlg_set_route_set(dlg, &route_set);
   93|     27|        }
   94|     51|    }
   95|       |
   96|       |    /* Create request within dialog */
   97|    168|    tdata = NULL;
   98|    168|    status = pjsip_dlg_create_request(dlg, &pjsip_options_method, -1, &tdata);
   99|    168|    if (status == PJ_SUCCESS && tdata)
  ------------------
  |  Branch (99:9): [True: 168, False: 0]
  |  Branch (99:33): [True: 168, False: 0]
  ------------------
  100|    168|        pjsip_tx_data_dec_ref(tdata);
  101|       |
  102|       |    /* Test session management */
  103|    168|    pjsip_dlg_inc_session(dlg, &dialog_test_mod);
  104|    168|    pjsip_dlg_dec_session(dlg, &dialog_test_mod);
  105|       |
  106|    168|    pjsip_dlg_dec_lock(dlg);
  107|    168|}
fuzz-sip-dialog.c:alloc_str_from_data:
   38|  21.3k|{
   39|  21.3k|    char *buf = (char*)pj_pool_alloc(pool, len + 1);
   40|  21.3k|    pj_memcpy(buf, data + offset, len);
   41|  21.3k|    buf[len] = '\0';
   42|  21.3k|    return buf;
   43|  21.3k|}
fuzz-sip-dialog.c:test_uas_dialog:
  110|  5.40k|{
  111|  5.40k|    char *data_copy;
  112|  5.40k|    pjsip_parser_err_report err_list;
  113|  5.40k|    pjsip_msg *msg;
  114|  5.40k|    pjsip_rx_data rdata;
  115|  5.40k|    pjsip_dialog *dlg;
  116|  5.40k|    pj_status_t status;
  117|  5.40k|    pjsip_tx_data *tdata;
  118|  5.40k|    pjsip_transaction *tsx;
  119|  5.40k|    pj_time_val timeout;
  120|       |
  121|  5.40k|    if (size < 1)
  ------------------
  |  Branch (121:9): [True: 0, False: 5.40k]
  ------------------
  122|      0|        return;
  123|       |
  124|       |    /* Parse input data as SIP message */
  125|  5.40k|    data_copy = alloc_str_from_data(pool, data, 0, size);
  126|  5.40k|    pj_list_init(&err_list);
  127|       |
  128|  5.40k|    msg = pjsip_parse_msg(pool, data_copy, size, &err_list);
  129|  5.40k|    if (!msg || msg->type != PJSIP_REQUEST_MSG)
  ------------------
  |  Branch (129:9): [True: 3.19k, False: 2.20k]
  |  Branch (129:17): [True: 1.16k, False: 1.03k]
  ------------------
  130|  4.36k|        return;
  131|       |
  132|       |    /* Setup received message structure */
  133|  1.03k|    pj_bzero(&rdata, sizeof(rdata));
  134|  1.03k|    rdata.msg_info.msg = msg;
  135|  1.03k|    rdata.tp_info.pool = pool;
  136|  1.03k|    rdata.tp_info.transport = loop_transport;
  137|  1.03k|    rdata.msg_info.via = (pjsip_via_hdr*)pjsip_msg_find_hdr(msg, PJSIP_H_VIA, NULL);
  138|  1.03k|    rdata.msg_info.from = (pjsip_from_hdr*)pjsip_msg_find_hdr(msg, PJSIP_H_FROM, NULL);
  139|  1.03k|    rdata.msg_info.to = (pjsip_to_hdr*)pjsip_msg_find_hdr(msg, PJSIP_H_TO, NULL);
  140|  1.03k|    rdata.msg_info.cseq = (pjsip_cseq_hdr*)pjsip_msg_find_hdr(msg, PJSIP_H_CSEQ, NULL);
  141|  1.03k|    rdata.msg_info.cid = (pjsip_cid_hdr*)pjsip_msg_find_hdr(msg, PJSIP_H_CALL_ID, NULL);
  142|       |
  143|       |    /* Validate required headers */
  144|  1.03k|    if (!rdata.msg_info.via || !rdata.msg_info.from || !rdata.msg_info.to ||
  ------------------
  |  Branch (144:9): [True: 148, False: 889]
  |  Branch (144:32): [True: 40, False: 849]
  |  Branch (144:56): [True: 2, False: 847]
  ------------------
  145|    847|        !rdata.msg_info.cseq || !rdata.msg_info.cid)
  ------------------
  |  Branch (145:9): [True: 4, False: 843]
  |  Branch (145:33): [True: 1, False: 842]
  ------------------
  146|    195|        return;
  147|       |
  148|       |    /* Set recvd_param required by PJSIP transport layer */
  149|    842|    if (rdata.msg_info.via->recvd_param.slen == 0)
  ------------------
  |  Branch (149:9): [True: 828, False: 14]
  ------------------
  150|    828|        rdata.msg_info.via->recvd_param = pj_str("127.0.0.1");
  151|       |
  152|       |    /* Skip if method doesn't create a dialog */
  153|    842|    if (!pjsip_method_creates_dialog(&msg->line.req.method))
  ------------------
  |  Branch (153:9): [True: 119, False: 723]
  ------------------
  154|    119|        return;
  155|       |
  156|       |    /* Skip if To tag already exists */
  157|    723|    if (rdata.msg_info.to->tag.slen != 0)
  ------------------
  |  Branch (157:9): [True: 14, False: 709]
  ------------------
  158|     14|        return;
  159|       |
  160|       |    /* Create UAS dialog from incoming request */
  161|    709|    dlg = NULL;
  162|    709|    status = pjsip_dlg_create_uas_and_inc_lock(pjsip_ua_instance(),
  163|    709|                                                &rdata, NULL, &dlg);
  164|    709|    if (status != PJ_SUCCESS || !dlg)
  ------------------
  |  Branch (164:9): [True: 428, False: 281]
  |  Branch (164:33): [True: 0, False: 281]
  ------------------
  165|    428|        return;
  166|       |
  167|       |    /* Create response within dialog */
  168|    281|    tdata = NULL;
  169|    281|    status = pjsip_dlg_create_response(dlg, &rdata, 200, NULL, &tdata);
  170|    281|    if (status == PJ_SUCCESS && tdata)
  ------------------
  |  Branch (170:9): [True: 281, False: 0]
  |  Branch (170:33): [True: 281, False: 0]
  ------------------
  171|    281|        pjsip_tx_data_dec_ref(tdata);
  172|       |
  173|       |    /* Test session management */
  174|    281|    pjsip_dlg_inc_session(dlg, &dialog_test_mod);
  175|    281|    pjsip_dlg_dec_session(dlg, &dialog_test_mod);
  176|       |
  177|       |    /* Terminate the transaction to prevent memory leak */
  178|    281|    tsx = pjsip_rdata_get_tsx(&rdata);
  179|    281|    if (tsx && tsx->state != PJSIP_TSX_STATE_TERMINATED)
  ------------------
  |  Branch (179:9): [True: 281, False: 0]
  |  Branch (179:16): [True: 281, False: 0]
  ------------------
  180|    281|        pjsip_tsx_terminate(tsx, 500);
  181|       |
  182|    281|    pjsip_dlg_dec_lock(dlg);
  183|       |
  184|       |    /* Process events to cleanup terminated transactions */
  185|    281|    timeout.sec = 0;
  186|    281|    timeout.msec = 0;
  187|    281|    pjsip_endpt_handle_events(endpt, &timeout);
  188|    281|}

