sip_parser.c:pj_cis_match:
  151|  14.8k|{
  152|  14.8k|    return PJ_CIS_ISSET(cis, c);
  ------------------
  |  |   90|  14.8k|#define PJ_CIS_ISSET(cis,c) ((cis)->cis_buf[(int)c] & (1 << (cis)->cis_id))
  ------------------
  153|  14.8k|}
sip_parser.c:pj_scan_is_eof:
  253|   148k|{
  254|   148k|    return scanner->curptr >= scanner->end;
  255|   148k|}
sip_parser.c:pj_scan_get_col:
  541|  38.2k|{
  542|  38.2k|    return (int)(scanner->curptr - scanner->start_line);
  543|  38.2k|}
scanner.c:pj_scan_is_eof:
  253|   403k|{
  254|   403k|    return scanner->curptr >= scanner->end;
  255|   403k|}
scanner.c:pj_cis_match:
  151|   951k|{
  152|   951k|    return PJ_CIS_ISSET(cis, c);
  ------------------
  |  |   90|   951k|#define PJ_CIS_ISSET(cis,c) ((cis)->cis_buf[(int)c] & (1 << (cis)->cis_id))
  ------------------
  153|   951k|}

pj_cis_add_range:
   51|     18|{
   52|       |    /* Can not set zero. This is the requirement of the parser. */
   53|     18|    pj_assert(cstart > 0);
  ------------------
  |  |   65|     18|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (53:5): [True: 0, False: 18]
  |  Branch (53:5): [True: 18, False: 0]
  ------------------
   54|       |
   55|    390|    while (cstart != cend) {
  ------------------
  |  Branch (55:12): [True: 372, False: 18]
  ------------------
   56|    372|        PJ_CIS_SET(cis, cstart);
  ------------------
  |  |   72|    372|#define PJ_CIS_SET(cis,c)   ((cis)->cis_buf[(int)(c)] |= (1 << (cis)->cis_id))
  ------------------
   57|    372|        ++cstart;
   58|    372|    }
   59|     18|}
pj_cis_add_alpha:
   62|      6|{
   63|      6|    pj_cis_add_range( cis, 'a', 'z'+1);
   64|      6|    pj_cis_add_range( cis, 'A', 'Z'+1);
   65|      6|}
pj_cis_add_num:
   68|      6|{
   69|      6|    pj_cis_add_range( cis, '0', '9'+1);
   70|      6|}
pj_cis_add_str:
   73|     23|{
   74|    290|    while (*str) {
  ------------------
  |  Branch (74:12): [True: 267, False: 23]
  ------------------
   75|    267|        PJ_CIS_SET(cis, *str);
  ------------------
  |  |   72|    267|#define PJ_CIS_SET(cis,c)   ((cis)->cis_buf[(int)(c)] |= (1 << (cis)->cis_id))
  ------------------
   76|    267|        ++str;
   77|    267|    }
   78|     23|}
pj_cis_add_cis:
   81|      1|{
   82|      1|    int i;
   83|    257|    for (i=0; i<256; ++i) {
  ------------------
  |  Branch (83:15): [True: 256, False: 1]
  ------------------
   84|    256|        if (PJ_CIS_ISSET(rhs, i))
  ------------------
  |  |   90|    256|#define PJ_CIS_ISSET(cis,c) ((cis)->cis_buf[(int)c] & (1 << (cis)->cis_id))
  |  |  ------------------
  |  |  |  Branch (90:29): [True: 79, False: 177]
  |  |  ------------------
  ------------------
   85|     79|            PJ_CIS_SET(cis, i);
  ------------------
  |  |   72|     79|#define PJ_CIS_SET(cis,c)   ((cis)->cis_buf[(int)(c)] |= (1 << (cis)->cis_id))
  ------------------
   86|    256|    }
   87|      1|}
pj_cis_del_str:
   98|      6|{
   99|     12|    while (*str) {
  ------------------
  |  Branch (99:12): [True: 6, False: 6]
  ------------------
  100|      6|        PJ_CIS_CLR(cis, *str);
  ------------------
  |  |   81|      6|#define PJ_CIS_CLR(cis,c)   ((cis)->cis_buf[(int)c] &= ~(1 << (cis)->cis_id))
  ------------------
  101|      6|        ++str;
  102|      6|    }
  103|      6|}
pj_cis_invert:
  106|      4|{
  107|      4|    unsigned i;
  108|       |    /* Can not set zero. This is the requirement of the parser. */
  109|  1.02k|    for (i=1; i<256; ++i) {
  ------------------
  |  Branch (109:15): [True: 1.02k, False: 4]
  ------------------
  110|  1.02k|        if (PJ_CIS_ISSET(cis,i))
  ------------------
  |  |   90|  1.02k|#define PJ_CIS_ISSET(cis,c) ((cis)->cis_buf[(int)c] & (1 << (cis)->cis_id))
  |  |  ------------------
  |  |  |  Branch (90:29): [True: 13, False: 1.00k]
  |  |  ------------------
  ------------------
  111|     13|            PJ_CIS_CLR(cis,i);
  ------------------
  |  |   81|     13|#define PJ_CIS_CLR(cis,c)   ((cis)->cis_buf[(int)c] &= ~(1 << (cis)->cis_id))
  ------------------
  112|  1.00k|        else
  113|  1.00k|            PJ_CIS_SET(cis,i);
  ------------------
  |  |   72|  1.00k|#define PJ_CIS_SET(cis,c)   ((cis)->cis_buf[(int)(c)] |= (1 << (cis)->cis_id))
  ------------------
  114|  1.02k|    }
  115|      4|}
pj_scan_init:
  120|  1.69k|{
  121|  1.69k|    PJ_CHECK_STACK();
  122|       |
  123|  1.69k|    scanner->begin = scanner->curptr = bufstart;
  124|  1.69k|    scanner->end = bufstart + buflen;
  125|  1.69k|    scanner->line = 1;
  126|  1.69k|    scanner->start_line = scanner->begin;
  127|  1.69k|    scanner->callback = callback;
  128|  1.69k|    scanner->skip_ws = options;
  129|       |
  130|  1.69k|    if (scanner->skip_ws) 
  ------------------
  |  Branch (130:9): [True: 1.69k, False: 0]
  ------------------
  131|  1.69k|        pj_scan_skip_whitespace(scanner);
  132|  1.69k|}
pj_scan_fini:
  136|  1.69k|{
  137|  1.69k|    PJ_CHECK_STACK();
  138|  1.69k|    PJ_UNUSED_ARG(scanner);
  ------------------
  |  | 1537|  1.69k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  139|  1.69k|}
pj_scan_skip_whitespace:
  142|  94.4k|{
  143|  94.4k|    register char *s = scanner->curptr;
  144|       |
  145|   120k|    while (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_SPACE(*s)) {
  ------------------
  |  |   33|   240k|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 120k, False: 230]
  |  |  ------------------
  ------------------
                  while (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_SPACE(*s)) {
  ------------------
  |  |   30|   120k|#define PJ_SCAN_IS_SPACE(c)             ((c)==' ' || (c)=='\t')
  |  |  ------------------
  |  |  |  Branch (30:42): [True: 13.3k, False: 106k]
  |  |  |  Branch (30:54): [True: 12.6k, False: 94.2k]
  |  |  ------------------
  ------------------
  146|  25.9k|        ++s;
  147|  25.9k|    }
  148|       |
  149|  94.4k|    if (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_NEWLINE(*s) &&
  ------------------
  |  |   33|   188k|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 94.2k, False: 230]
  |  |  ------------------
  ------------------
                  if (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_NEWLINE(*s) &&
  ------------------
  |  |   31|   188k|#define PJ_SCAN_IS_NEWLINE(c)           ((c)=='\r' || (c)=='\n')
  |  |  ------------------
  |  |  |  Branch (31:42): [True: 11.9k, False: 82.2k]
  |  |  |  Branch (31:55): [True: 21.3k, False: 60.9k]
  |  |  ------------------
  ------------------
  150|  33.2k|        (scanner->skip_ws & PJ_SCAN_AUTOSKIP_NEWLINE))
  ------------------
  |  Branch (150:9): [True: 0, False: 33.2k]
  ------------------
  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|  94.4k|    if (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_NEWLINE(*s) &&
  ------------------
  |  |   33|   188k|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 94.2k, False: 230]
  |  |  ------------------
  ------------------
                  if (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_NEWLINE(*s) &&
  ------------------
  |  |   31|   188k|#define PJ_SCAN_IS_NEWLINE(c)           ((c)=='\r' || (c)=='\n')
  |  |  ------------------
  |  |  |  Branch (31:42): [True: 11.9k, False: 82.2k]
  |  |  |  Branch (31:55): [True: 21.3k, False: 60.9k]
  |  |  ------------------
  ------------------
  174|  33.2k|        (scanner->skip_ws & PJ_SCAN_AUTOSKIP_WS_HEADER)==
  ------------------
  |  Branch (174:9): [True: 33.2k, False: 0]
  ------------------
  175|  33.2k|         PJ_SCAN_AUTOSKIP_WS_HEADER)
  176|  33.2k|    {
  177|       |        /* Check for header continuation. */
  178|  33.2k|        scanner->curptr = s;
  179|       |
  180|  33.2k|        if (*s == '\r') {
  ------------------
  |  Branch (180:13): [True: 11.9k, False: 21.3k]
  ------------------
  181|  11.9k|            ++s;
  182|  11.9k|        }
  183|  33.2k|        if (PJ_SCAN_CHECK_EOF(s) && *s == '\n') {
  ------------------
  |  |   33|  66.5k|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 33.2k, False: 14]
  |  |  ------------------
  ------------------
  |  Branch (183:37): [True: 25.2k, False: 8.01k]
  ------------------
  184|  25.2k|            ++s;
  185|  25.2k|        }
  186|  33.2k|        scanner->start_line = s;
  187|       |
  188|  33.2k|        if (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_SPACE(*s)) {
  ------------------
  |  |   33|  66.5k|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 33.2k, False: 36]
  |  |  ------------------
  ------------------
                      if (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_SPACE(*s)) {
  ------------------
  |  |   30|  33.2k|#define PJ_SCAN_IS_SPACE(c)             ((c)==' ' || (c)=='\t')
  |  |  ------------------
  |  |  |  Branch (30:42): [True: 3.37k, False: 29.8k]
  |  |  |  Branch (30:54): [True: 322, False: 29.5k]
  |  |  ------------------
  ------------------
  189|  3.69k|            register char *t = s;
  190|  6.44k|            do {
  191|  6.44k|                ++t;
  192|  6.44k|            } while (PJ_SCAN_CHECK_EOF(t) && PJ_SCAN_IS_SPACE(*t));
  ------------------
  |  |   33|  12.8k|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 6.41k, False: 22]
  |  |  ------------------
  ------------------
                          } while (PJ_SCAN_CHECK_EOF(t) && PJ_SCAN_IS_SPACE(*t));
  ------------------
  |  |   30|  6.41k|#define PJ_SCAN_IS_SPACE(c)             ((c)==' ' || (c)=='\t')
  |  |  ------------------
  |  |  |  Branch (30:42): [True: 602, False: 5.81k]
  |  |  |  Branch (30:54): [True: 2.14k, False: 3.67k]
  |  |  ------------------
  ------------------
  193|       |
  194|  3.69k|            ++scanner->line;
  195|  3.69k|            scanner->curptr = t;
  196|  3.69k|        }
  197|  61.2k|    } else {
  198|  61.2k|        scanner->curptr = s;
  199|  61.2k|    }
  200|  94.4k|}
pj_scan_skip_line:
  203|  37.8k|{
  204|  37.8k|    char *s;
  205|       |
  206|  37.8k|    if (pj_scan_is_eof(scanner)) {
  ------------------
  |  Branch (206:9): [True: 0, False: 37.8k]
  ------------------
  207|      0|        return;
  208|      0|    }
  209|       |
  210|  37.8k|    s = pj_memchr(scanner->curptr, '\n', scanner->end - scanner->curptr);
  211|  37.8k|    if (!s) {
  ------------------
  |  Branch (211:9): [True: 614, False: 37.2k]
  ------------------
  212|    614|        scanner->curptr = scanner->end;
  213|  37.2k|    } else {
  214|  37.2k|        scanner->curptr = scanner->start_line = s+1;
  215|  37.2k|        scanner->line++;
  216|  37.2k|   }
  217|  37.8k|}
pj_scan_peek:
  221|  35.0k|{
  222|  35.0k|    register char *s = scanner->curptr;
  223|       |
  224|  35.0k|    if (s >= scanner->end) {
  ------------------
  |  Branch (224:9): [True: 32, False: 34.9k]
  ------------------
  225|     32|        pj_scan_syntax_err(scanner);
  226|     32|        return -1;
  227|     32|    }
  228|       |
  229|   261k|    while (PJ_SCAN_CHECK_EOF(s) && pj_cis_match(spec, *s))
  ------------------
  |  |   33|   522k|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 261k, False: 266]
  |  |  ------------------
  ------------------
  |  Branch (229:36): [True: 226k, False: 34.7k]
  ------------------
  230|   226k|        ++s;
  231|       |
  232|  34.9k|    pj_strset3(out, scanner->curptr, s);
  233|  34.9k|    return *s;
  234|  35.0k|}
pj_scan_get:
  273|   155k|{
  274|   155k|    register char *s = scanner->curptr;
  275|       |
  276|   155k|    pj_assert(pj_cis_match(spec,0)==0);
  ------------------
  |  |   65|   155k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (276:5): [True: 0, False: 155k]
  |  Branch (276:5): [True: 155k, False: 0]
  ------------------
  277|       |
  278|   155k|    if (pj_scan_is_eof(scanner) || !pj_cis_match(spec, *s)) {
  ------------------
  |  Branch (278:9): [True: 142, False: 155k]
  |  Branch (278:36): [True: 10.1k, False: 145k]
  ------------------
  279|  10.3k|        pj_scan_syntax_err(scanner);
  280|  10.3k|        return;
  281|  10.3k|    }
  282|       |
  283|   379k|    do {
  284|   379k|        ++s;
  285|   379k|    } while (PJ_SCAN_CHECK_EOF(s) && pj_cis_match(spec, *s));
  ------------------
  |  |   33|   758k|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 378k, False: 280]
  |  |  ------------------
  ------------------
  |  Branch (285:38): [True: 233k, False: 145k]
  ------------------
  286|       |
  287|   145k|    pj_strset3(out, scanner->curptr, s);
  288|       |
  289|   145k|    scanner->curptr = s;
  290|       |
  291|   145k|    if (!pj_scan_is_eof(scanner) &&
  ------------------
  |  Branch (291:9): [True: 145k, False: 280]
  ------------------
  292|   145k|        PJ_SCAN_IS_PROBABLY_SPACE(*s) && scanner->skip_ws)
  ------------------
  |  |   32|   290k|#define PJ_SCAN_IS_PROBABLY_SPACE(c)    ((c) <= 32)
  |  |  ------------------
  |  |  |  Branch (32:41): [True: 33.5k, False: 111k]
  |  |  ------------------
  ------------------
  |  Branch (292:42): [True: 29.5k, False: 3.97k]
  ------------------
  293|  29.5k|    {
  294|  29.5k|        pj_scan_skip_whitespace(scanner);    
  295|  29.5k|    }
  296|   145k|}
pj_scan_get_quote:
  358|  4.41k|{
  359|  4.41k|    char beg = (char)begin_quote;
  360|  4.41k|    char end = (char)end_quote;
  361|  4.41k|    pj_scan_get_quotes(scanner, &beg, &end, 1, out);
  362|  4.41k|}
pj_scan_get_quotes:
  367|  4.41k|{
  368|  4.41k|    register char *s = scanner->curptr;
  369|  4.41k|    int qpair = -1;
  370|  4.41k|    int i;
  371|       |
  372|  4.41k|    pj_assert(qsize > 0);
  ------------------
  |  |   65|  4.41k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (372:5): [True: 0, False: 4.41k]
  |  Branch (372:5): [True: 4.41k, False: 0]
  ------------------
  373|       |
  374|       |    /* Check and eat the begin_quote. */
  375|  4.41k|    for (i = 0; i < qsize; ++i) {
  ------------------
  |  Branch (375:17): [True: 4.41k, False: 0]
  ------------------
  376|  4.41k|        if (*s == begin_quote[i]) {
  ------------------
  |  Branch (376:13): [True: 4.41k, False: 0]
  ------------------
  377|  4.41k|            qpair = i;
  378|  4.41k|            break;
  379|  4.41k|        }
  380|  4.41k|    }
  381|  4.41k|    if (qpair == -1) {
  ------------------
  |  Branch (381:9): [True: 0, False: 4.41k]
  ------------------
  382|      0|        pj_scan_syntax_err(scanner);
  383|      0|        return;
  384|      0|    }
  385|  4.41k|    ++s;
  386|       |
  387|       |    /* Loop until end_quote is found. 
  388|       |     */
  389|  5.20k|    do {
  390|       |        /* loop until end_quote is found. */
  391|  18.6k|        while (PJ_SCAN_CHECK_EOF(s) && *s != '\n' && *s != end_quote[qpair]) {
  ------------------
  |  |   33|  37.2k|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 18.5k, False: 22]
  |  |  ------------------
  ------------------
  |  Branch (391:40): [True: 17.5k, False: 1.01k]
  |  Branch (391:54): [True: 13.3k, False: 4.17k]
  ------------------
  392|  13.3k|            ++s;
  393|  13.3k|        }
  394|       |
  395|       |        /* check that no backslash character precedes the end_quote. */
  396|  5.20k|        if (*s == end_quote[qpair]) {
  ------------------
  |  Branch (396:13): [True: 4.17k, False: 1.03k]
  ------------------
  397|  4.17k|            if (*(s-1) == '\\') {
  ------------------
  |  Branch (397:17): [True: 880, False: 3.29k]
  ------------------
  398|    880|                char *q = s-2;
  399|    880|                char *r = s-2;
  400|       |
  401|  1.81k|                while (r != scanner->begin && *r == '\\') {
  ------------------
  |  Branch (401:24): [True: 1.81k, False: 0]
  |  Branch (401:47): [True: 932, False: 880]
  ------------------
  402|    932|                    --r;
  403|    932|                }
  404|       |                /* break from main loop if we have odd number of backslashes */
  405|    880|                if (((unsigned)(q-r) & 0x01) == 1) {
  ------------------
  |  Branch (405:21): [True: 88, False: 792]
  ------------------
  406|     88|                    break;
  407|     88|                }
  408|    792|                ++s;
  409|  3.29k|            } else {
  410|       |                /* end_quote is not preceeded by backslash. break now. */
  411|  3.29k|                break;
  412|  3.29k|            }
  413|  4.17k|        } else {
  414|       |            /* loop ended by non-end_quote character. break now. */
  415|  1.03k|            break;
  416|  1.03k|        }
  417|  5.20k|    } while (1);
  ------------------
  |  Branch (417:14): [True: 792, Folded]
  ------------------
  418|       |
  419|       |    /* Check and eat the end quote. */
  420|  4.41k|    if (*s != end_quote[qpair]) {
  ------------------
  |  Branch (420:9): [True: 1.03k, False: 3.38k]
  ------------------
  421|  1.03k|        pj_scan_syntax_err(scanner);
  422|  1.03k|        return;
  423|  1.03k|    }
  424|  3.38k|    ++s;
  425|       |
  426|  3.38k|    pj_strset3(out, scanner->curptr, s);
  427|       |
  428|  3.38k|    scanner->curptr = s;
  429|       |
  430|  3.38k|    if (!pj_scan_is_eof(scanner) &&
  ------------------
  |  Branch (430:9): [True: 3.37k, False: 4]
  ------------------
  431|  3.37k|        PJ_SCAN_IS_PROBABLY_SPACE(*s) && scanner->skip_ws)
  ------------------
  |  |   32|  6.76k|#define PJ_SCAN_IS_PROBABLY_SPACE(c)    ((c) <= 32)
  |  |  ------------------
  |  |  |  Branch (32:41): [True: 848, False: 2.53k]
  |  |  ------------------
  ------------------
  |  Branch (431:42): [True: 826, False: 22]
  ------------------
  432|    826|    {
  433|    826|        pj_scan_skip_whitespace(scanner);
  434|    826|    }
  435|  3.38k|}
pj_scan_get_n:
  440|  4.77k|{
  441|  4.77k|    if (scanner->curptr + N > scanner->end) {
  ------------------
  |  Branch (441:9): [True: 2, False: 4.77k]
  ------------------
  442|      2|        pj_scan_syntax_err(scanner);
  443|      2|        return;
  444|      2|    }
  445|       |
  446|  4.77k|    pj_strset(out, scanner->curptr, N);
  447|       |    
  448|  4.77k|    scanner->curptr += N;
  449|       |
  450|  4.77k|    if (!pj_scan_is_eof(scanner) &&
  ------------------
  |  Branch (450:9): [True: 4.76k, False: 4]
  ------------------
  451|  4.76k|        PJ_SCAN_IS_PROBABLY_SPACE(*scanner->curptr) && scanner->skip_ws)
  ------------------
  |  |   32|  9.53k|#define PJ_SCAN_IS_PROBABLY_SPACE(c)    ((c) <= 32)
  |  |  ------------------
  |  |  |  Branch (32:41): [True: 2.79k, False: 1.97k]
  |  |  ------------------
  ------------------
  |  Branch (451:56): [True: 2.79k, False: 0]
  ------------------
  452|  2.79k|    {
  453|  2.79k|        pj_scan_skip_whitespace(scanner);
  454|  2.79k|    }
  455|  4.77k|}
pj_scan_get_char:
  459|   134k|{
  460|   134k|    register char *s = scanner->curptr;
  461|   134k|    int chr;
  462|       |
  463|   134k|    if (s >= scanner->end || !*s) {
  ------------------
  |  Branch (463:9): [True: 80, False: 134k]
  |  Branch (463:30): [True: 316, False: 134k]
  ------------------
  464|    396|        pj_scan_syntax_err(scanner);
  465|    396|        return 0;
  466|    396|    }
  467|       |
  468|   134k|    chr = *s;
  469|       |
  470|   134k|    ++s;
  471|   134k|    scanner->curptr = s;
  472|   134k|    if (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_PROBABLY_SPACE(*s) &&
  ------------------
  |  |   33|   268k|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 134k, False: 84]
  |  |  ------------------
  ------------------
                  if (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_PROBABLY_SPACE(*s) &&
  ------------------
  |  |   32|   268k|#define PJ_SCAN_IS_PROBABLY_SPACE(c)    ((c) <= 32)
  |  |  ------------------
  |  |  |  Branch (32:41): [True: 26.5k, False: 107k]
  |  |  ------------------
  ------------------
  473|  26.5k|        scanner->skip_ws)
  ------------------
  |  Branch (473:9): [True: 23.8k, False: 2.70k]
  ------------------
  474|  23.8k|    {
  475|  23.8k|        pj_scan_skip_whitespace(scanner);
  476|  23.8k|    }
  477|   134k|    return chr;
  478|   134k|}
pj_scan_get_newline:
  482|  29.3k|{
  483|  29.3k|    if (pj_scan_is_eof(scanner) || !PJ_SCAN_IS_NEWLINE(*scanner->curptr)) {
  ------------------
  |  |   31|  29.3k|#define PJ_SCAN_IS_NEWLINE(c)           ((c)=='\r' || (c)=='\n')
  |  |  ------------------
  |  |  |  Branch (31:42): [True: 8.99k, False: 20.3k]
  |  |  |  Branch (31:55): [True: 12.8k, False: 7.50k]
  |  |  ------------------
  ------------------
  |  Branch (483:9): [True: 4, False: 29.3k]
  ------------------
  484|  7.51k|        pj_scan_syntax_err(scanner);
  485|  7.51k|        return;
  486|  7.51k|    }
  487|       |
  488|       |    /* We have checked scanner->curptr validity above */
  489|  21.8k|    if (*scanner->curptr == '\r') {
  ------------------
  |  Branch (489:9): [True: 8.99k, False: 12.8k]
  ------------------
  490|  8.99k|        ++scanner->curptr;
  491|  8.99k|    }
  492|  21.8k|    if (!pj_scan_is_eof(scanner) && *scanner->curptr == '\n') {
  ------------------
  |  Branch (492:9): [True: 21.8k, False: 10]
  |  Branch (492:37): [True: 13.6k, False: 8.16k]
  ------------------
  493|  13.6k|        ++scanner->curptr;
  494|  13.6k|    }
  495|       |
  496|  21.8k|    ++scanner->line;
  497|  21.8k|    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|  21.8k|}
pj_scan_get_until_ch:
  547|  5.15k|{
  548|  5.15k|    register char *s = scanner->curptr;
  549|       |
  550|  5.15k|    if (s >= scanner->end) {
  ------------------
  |  Branch (550:9): [True: 2, False: 5.15k]
  ------------------
  551|      2|        pj_scan_syntax_err(scanner);
  552|      2|        return;
  553|      2|    }
  554|       |
  555|  25.3k|    while (PJ_SCAN_CHECK_EOF(s) && *s != until_char) {
  ------------------
  |  |   33|  50.6k|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 25.3k, False: 14]
  |  |  ------------------
  ------------------
  |  Branch (555:36): [True: 20.1k, False: 5.13k]
  ------------------
  556|  20.1k|        ++s;
  557|  20.1k|    }
  558|       |
  559|  5.15k|    pj_strset3(out, scanner->curptr, s);
  560|       |
  561|  5.15k|    scanner->curptr = s;
  562|       |
  563|  5.15k|    if (!pj_scan_is_eof(scanner) && PJ_SCAN_IS_PROBABLY_SPACE(*s) &&
  ------------------
  |  |   32|  10.2k|#define PJ_SCAN_IS_PROBABLY_SPACE(c)    ((c) <= 32)
  |  |  ------------------
  |  |  |  Branch (32:41): [True: 0, False: 5.13k]
  |  |  ------------------
  ------------------
  |  Branch (563:9): [True: 5.13k, False: 14]
  ------------------
  564|      0|        scanner->skip_ws)
  ------------------
  |  Branch (564:9): [True: 0, False: 0]
  ------------------
  565|      0|    {
  566|      0|        pj_scan_skip_whitespace(scanner);
  567|      0|    }
  568|  5.15k|}
scanner.c:pj_scan_syntax_err:
   45|  19.2k|{
   46|  19.2k|    (*scanner->callback)(scanner);
   47|  19.2k|}

pj_cis_buf_init:
   26|      2|{
   27|      2|    pj_bzero(cis_buf->cis_buf, sizeof(cis_buf->cis_buf));
   28|      2|    cis_buf->use_mask = 0;
   29|      2|}
pj_cis_init:
   32|     32|{
   33|     32|    unsigned i;
   34|       |
   35|     32|    cis->cis_buf = cis_buf->cis_buf;
   36|       |
   37|    308|    for (i=0; i<PJ_CIS_MAX_INDEX; ++i) {
  ------------------
  |  |   44|    308|#define PJ_CIS_MAX_INDEX   (sizeof(pj_cis_elem_t) << 3)
  ------------------
  |  Branch (37:15): [True: 308, False: 0]
  ------------------
   38|    308|        if ((cis_buf->use_mask & (1 << i)) == 0) {
  ------------------
  |  Branch (38:13): [True: 32, False: 276]
  ------------------
   39|     32|            cis->cis_id = i;
   40|     32|            cis_buf->use_mask |= (1 << i);
   41|     32|            return PJ_SUCCESS;
   42|     32|        }
   43|    308|    }
   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|     32|}
pj_cis_dup:
   50|     18|{
   51|     18|    pj_status_t status;
   52|     18|    unsigned i;
   53|       |
   54|       |    /* Warning: typecasting here! */
   55|     18|    status = pj_cis_init((pj_cis_buf_t*)existing->cis_buf, new_cis);
   56|     18|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (56:9): [True: 0, False: 18]
  ------------------
   57|      0|        return status;
   58|       |
   59|  4.62k|    for (i=0; i<256; ++i) {
  ------------------
  |  Branch (59:15): [True: 4.60k, False: 18]
  ------------------
   60|  4.60k|        if (PJ_CIS_ISSET(existing, i))
  ------------------
  |  |   90|  4.60k|#define PJ_CIS_ISSET(cis,c) ((cis)->cis_buf[(int)c] & (1 << (cis)->cis_id))
  |  |  ------------------
  |  |  |  Branch (90:29): [True: 1.23k, False: 3.37k]
  |  |  ------------------
  ------------------
   61|  1.23k|            PJ_CIS_SET(new_cis, i);
  ------------------
  |  |   72|  1.23k|#define PJ_CIS_SET(cis,c)   ((cis)->cis_buf[(int)(c)] |= (1 << (cis)->cis_id))
  ------------------
   62|  3.37k|        else
   63|  3.37k|            PJ_CIS_CLR(new_cis, i);
  ------------------
  |  |   81|  3.37k|#define PJ_CIS_CLR(cis,c)   ((cis)->cis_buf[(int)c] &= ~(1 << (cis)->cis_id))
  ------------------
   64|  4.60k|    }
   65|       |
   66|     18|    return PJ_SUCCESS;
   67|     18|}

pj_str_unescape:
   25|  12.9k|{
   26|  12.9k|    char *src = src_str->ptr;
   27|  12.9k|    char *end = src + src_str->slen;
   28|  12.9k|    pj_str_t dst_str;
   29|  12.9k|    char *dst;
   30|       |    
   31|  12.9k|    if (pj_strchr(src_str, '%')==NULL)
  ------------------
  |  Branch (31:9): [True: 11.0k, False: 1.86k]
  ------------------
   32|  11.0k|        return *src_str;
   33|       |
   34|  1.86k|    dst = dst_str.ptr = (char*) pj_pool_alloc(pool, src_str->slen);
   35|       |
   36|  25.0k|    while (src != end) {
  ------------------
  |  Branch (36:12): [True: 23.1k, False: 1.86k]
  ------------------
   37|  23.1k|        if (*src == '%' && src < end-2 && pj_isxdigit(*(src+1)) && 
  ------------------
  |  Branch (37:13): [True: 9.42k, False: 13.7k]
  |  Branch (37:28): [True: 7.45k, False: 1.97k]
  |  Branch (37:43): [True: 2.35k, False: 5.10k]
  ------------------
   38|  2.35k|            pj_isxdigit(*(src+2))) 
  ------------------
  |  Branch (38:13): [True: 1.65k, False: 700]
  ------------------
   39|  1.65k|        {
   40|  1.65k|            *dst = (pj_uint8_t) ((pj_hex_digit_to_val(*(src+1)) << 4) + 
   41|  1.65k|                                 pj_hex_digit_to_val(*(src+2)));
   42|  1.65k|            ++dst;
   43|  1.65k|            src += 3;
   44|  21.5k|        } else {
   45|  21.5k|            *dst++ = *src++;
   46|  21.5k|        }
   47|  23.1k|    }
   48|  1.86k|    dst_str.slen = dst - dst_str.ptr;
   49|  1.86k|    return dst_str;
   50|  12.9k|}

sip_parser.c:pj_tolower:
  118|    215|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: 215]
  ------------------
string.c:pj_isxdigit:
  134|  9.80k|PJ_INLINE(int) pj_isxdigit(unsigned char c){ return isxdigit(c); }
string.c:pj_hex_digit_to_val:
  160|  3.30k|{
  161|  3.30k|    if (c <= '9')
  ------------------
  |  Branch (161:9): [True: 1.07k, False: 2.23k]
  ------------------
  162|  1.07k|        return (c-'0') & 0x0F;
  163|  2.23k|    else if (c <= 'F')
  ------------------
  |  Branch (163:14): [True: 2.06k, False: 164]
  ------------------
  164|  2.06k|        return  (c-'A'+10) & 0x0F;
  165|    164|    else
  166|    164|        return (c-'a'+10) & 0x0F;
  167|  3.30k|}
string.c:pj_isdigit:
   74|    874|PJ_INLINE(int) pj_isdigit(unsigned char c) { return isdigit(c); }
string.c:pj_isspace:
   83|  24.9k|PJ_INLINE(int) pj_isspace(unsigned char c) { return isspace(c); }
hash.c:pj_tolower:
  118|  27.8k|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: 27.8k]
  ------------------

fuzz-auth.c:pj_list_init:
   88|  1.69k|{
   89|  1.69k|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|  1.69k|}
sip_msg.c:pj_list_init:
   88|  72.9k|{
   89|  72.9k|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|  72.9k|}
sip_parser.c:pj_list_push_back:
  125|  1.21k|{
  126|  1.21k|    pj_list_insert_before(list, node);
  127|  1.21k|}
sip_uri.c:pj_list_init:
   88|  9.78k|{
   89|  9.78k|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|  9.78k|}
sip_endpoint.c:pj_list_init:
   88|      4|{
   89|      4|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|      4|}
sip_transport.c:pj_list_init:
   88|     19|{
   89|     19|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|     19|}
sip_transport.c:pj_list_push_back:
  125|     16|{
  126|     16|    pj_list_insert_before(list, node);
  127|     16|}
sip_tel_uri.c:pj_list_init:
   88|  3.54k|{
   89|  3.54k|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|  3.54k|}
ioqueue_select.c:pj_list_init:
   88|      3|{
   89|      3|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|      3|}
ioqueue_select.c:pj_list_push_back:
  125|     64|{
  126|     64|    pj_list_insert_before(list, node);
  127|     64|}
list.c:pj_list_init:
   88|  4.85k|{
   89|  4.85k|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|  4.85k|}
lock.c:pj_list_init:
   88|      2|{
   89|      2|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|      2|}
lock.c:pj_list_push_back:
  125|      1|{
  126|      1|    pj_list_insert_before(list, node);
  127|      1|}
pool.c:pj_list_init:
   88|    855|{
   89|    855|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|    855|}
pool_caching.c:pj_list_init:
   88|     17|{
   89|     17|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|     17|}
pool_caching.c:pj_list_empty:
  102|    854|{
  103|    854|    return ((pj_list*)node)->next == node;
  104|    854|}

pj_list_insert_after:
   29|  72.1k|{
   30|  72.1k|    ((pj_list*)node)->prev = pos;
   31|  72.1k|    ((pj_list*)node)->next = ((pj_list*)pos)->next;
   32|  72.1k|    ((pj_list*) ((pj_list*)pos)->next) ->prev = node;
   33|  72.1k|    ((pj_list*)pos)->next = node;
   34|  72.1k|}
pj_list_insert_before:
   38|  67.2k|{
   39|  67.2k|    pj_list_insert_after(((pj_list*)pos)->prev, node);
   40|  67.2k|}
pj_list_insert_nodes_after:
   44|  19.5k|{
   45|  19.5k|    pj_list *lst_last = (pj_list *) ((pj_list*)lst)->prev;
   46|  19.5k|    pj_list *pos_next = (pj_list *) ((pj_list*)pos)->next;
   47|       |
   48|  19.5k|    pj_link_node(pos, lst);
   49|  19.5k|    pj_link_node(lst_last, pos_next);
   50|  19.5k|}
pj_list_insert_nodes_before:
   53|  19.5k|{
   54|  19.5k|    pj_list_insert_nodes_after(((pj_list*)pos)->prev, lst);
   55|  19.5k|}
pj_list_erase:
   93|  4.85k|{
   94|  4.85k|    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|  4.85k|    pj_list_init(node);
  101|  4.85k|}
pj_list_find_node:
  105|      2|{
  106|      2|    pj_list *p = (pj_list *) ((pj_list*)list)->next;
  107|      2|    while (p != list && p != node)
  ------------------
  |  Branch (107:12): [True: 0, False: 2]
  |  Branch (107:25): [True: 0, False: 0]
  ------------------
  108|      0|        p = (pj_list *) p->next;
  109|       |
  110|      2|    return p==node ? p : NULL;
  ------------------
  |  Branch (110:12): [True: 0, False: 2]
  ------------------
  111|      2|}
pj_list_search:
  116|      2|{
  117|      2|    pj_list *p = (pj_list *) ((pj_list*)list)->next;
  118|      2|    while (p != list && (*comp)(value, p) != 0)
  ------------------
  |  Branch (118:12): [True: 0, False: 2]
  |  Branch (118:25): [True: 0, False: 0]
  ------------------
  119|      0|        p = (pj_list *) p->next;
  120|       |
  121|      2|    return p==list ? NULL : p;
  ------------------
  |  Branch (121:12): [True: 2, False: 0]
  ------------------
  122|      2|}
list.c:pj_link_node:
   23|  43.8k|{
   24|  43.8k|    ((pj_list*)prev)->next = next;
   25|  43.8k|    ((pj_list*)next)->prev = prev;
   26|  43.8k|}

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

sip_uri.c:pj_pool_zalloc:
  552|  5.56k|{
  553|  5.56k|    return pj_pool_calloc(pool, 1, size);
  554|  5.56k|}
sip_endpoint.c:pj_pool_zalloc:
  552|      1|{
  553|      1|    return pj_pool_calloc(pool, 1, size);
  554|      1|}
sip_resolve.c:pj_pool_zalloc:
  552|      1|{
  553|      1|    return pj_pool_calloc(pool, 1, size);
  554|      1|}
sip_transport.c:pj_pool_zalloc:
  552|     17|{
  553|     17|    return pj_pool_calloc(pool, 1, size);
  554|     17|}
sip_tel_uri.c:pj_pool_zalloc:
  552|  3.54k|{
  553|  3.54k|    return pj_pool_calloc(pool, 1, size);
  554|  3.54k|}
os_core_unix.c:pj_pool_zalloc:
  552|      2|{
  553|      2|    return pj_pool_calloc(pool, 1, size);
  554|      2|}
ioqueue_select.c:pj_pool_zalloc:
  552|      1|{
  553|      1|    return pj_pool_calloc(pool, 1, size);
  554|      1|}
lock.c:pj_pool_zalloc:
  552|      2|{
  553|      2|    return pj_pool_calloc(pool, 1, size);
  554|      2|}
timer.c:pj_pool_zalloc:
  552|      1|{
  553|      1|    return pj_pool_calloc(pool, 1, size);
  554|      1|}

pj_pool_get_capacity:
   28|    850|{
   29|    850|    return pool->capacity;
   30|    850|}
pj_pool_alloc_from_block:
   45|   182k|{
   46|   182k|    unsigned char *ptr;
   47|       |
   48|   182k|    pj_assert(PJ_IS_POWER_OF_TWO(alignment));
  ------------------
  |  |   65|   182k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (48:5): [True: 0, False: 182k]
  |  Branch (48:5): [True: 0, False: 0]
  |  Branch (48:5): [True: 182k, False: 0]
  |  Branch (48:5): [True: 182k, 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|   182k|    ptr = PJ_POOL_ALIGN_PTR(block->cur, alignment);
  ------------------
  |  |   23|   182k|#define PJ_POOL_ALIGN_PTR(PTR,ALIGNMENT)    (PTR + (-(pj_ssize_t)(PTR) & (ALIGNMENT-1)))
  ------------------
   61|   182k|    if (block->cur <= ptr && /* check pointer overflow */
  ------------------
  |  Branch (61:9): [True: 182k, False: 0]
  ------------------
   62|   182k|        block->end - ptr >= (pj_ssize_t)size) /* check available size */
  ------------------
  |  Branch (62:9): [True: 148k, False: 33.5k]
  ------------------
   63|   148k|    {
   64|       |    //if (ptr + size <= block->end &&
   65|       |    //    /* here we check pointer overflow */
   66|       |    //    block->cur <= ptr && ptr <= ptr + size) {
   67|   148k|        block->cur = ptr + size;
   68|   148k|        return ptr;
   69|   148k|    }
   70|  33.5k|    return NULL;
   71|   182k|}
pj_pool_alloc:
   74|   148k|{
   75|   148k|    return pj_pool_aligned_alloc(pool, 0, size);
   76|   148k|}
pj_pool_aligned_alloc:
   80|   148k|{
   81|   148k|    void *ptr;
   82|       |
   83|   148k|    PJ_ASSERT_RETURN(!alignment || PJ_IS_POWER_OF_TWO(alignment), NULL);
  ------------------
  |  |   97|   148k|            do { \
  |  |   98|   148k|                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: 148k, False: 0]
  |  |  ------------------
  |  |   99|   148k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 148k]
  |  |  ------------------
  ------------------
  |  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|   148k|    if (!alignment)
  ------------------
  |  Branch (85:9): [True: 148k, False: 0]
  ------------------
   86|   148k|        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|   148k|    ptr = pj_pool_alloc_from_block(pool->block_list.next, 
  102|   148k|                                   alignment, size);
  103|   148k|    if (!ptr)
  ------------------
  |  Branch (103:9): [True: 8.06k, False: 140k]
  ------------------
  104|  8.06k|        ptr = pj_pool_allocate_find(pool, alignment, size);
  105|   148k|    return ptr;
  106|   148k|}
pj_pool_calloc:
  110|  9.13k|{
  111|  9.13k|    void *buf = pj_pool_alloc( pool, size*count);
  112|  9.13k|    if (buf)
  ------------------
  |  Branch (112:9): [True: 9.13k, False: 0]
  ------------------
  113|  9.13k|        pj_bzero(buf, size * count);
  114|  9.13k|    return buf;
  115|  9.13k|}
pj_pool_create:
  127|    854|{
  128|    854|    return pj_pool_aligned_create(f, name, initial_size, increment_size, 0, callback);
  129|    854|}
pj_pool_aligned_create:
  137|    854|{
  138|    854|    return (*f->create_pool)(f, name, initial_size, increment_size, alignment, callback);
  139|    854|}
pj_pool_release:
  142|    850|{
  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|    850|    if (pool->factory->release_pool)
  ------------------
  |  Branch (154:9): [True: 850, False: 0]
  ------------------
  155|    850|        (*pool->factory->release_pool)(pool->factory, pool);
  156|    850|}

fuzz-auth.c:pj_memcpy:
  853|  1.69k|{
  854|  1.69k|    return memcpy(dst, src, size);
  855|  1.69k|}
sip_msg.c:pj_memcmp:
  881|  2.75k|{
  882|  2.75k|    return memcmp(buf1, buf2, size);
  883|  2.75k|}
sip_msg.c:pj_bzero:
  820|  38.9k|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|  38.9k|    memset(dst, 0, size);
  825|  38.9k|#endif
  826|  38.9k|}
sip_parser.c:pj_memcpy:
  853|    108|{
  854|    108|    return memcpy(dst, src, size);
  855|    108|}
sip_parser.c:pj_memchr:
  896|  2.50k|{
  897|  2.50k|    return (void*)memchr((void*)buf, c, size);
  898|  2.50k|}
sip_parser.c:pj_memcmp:
  881|  36.8k|{
  882|  36.8k|    return memcmp(buf1, buf2, size);
  883|  36.8k|}
sip_parser.c:pj_memmove:
  867|     51|{
  868|     51|    return memmove(dst, src, size);
  869|     51|}
sip_uri.c:pj_bzero:
  820|  4.88k|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|  4.88k|    memset(dst, 0, size);
  825|  4.88k|#endif
  826|  4.88k|}
sip_endpoint.c:pj_cstr:
  101|      1|{
  102|      1|    str->ptr = (char*)s;
  103|      1|    str->slen = s ? (pj_ssize_t)strlen(s) : 0;
  ------------------
  |  Branch (103:17): [True: 1, False: 0]
  ------------------
  104|      1|    return str;
  105|      1|}
sip_auth_server.c:pj_bzero:
  820|      1|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|      1|    memset(dst, 0, size);
  825|      1|#endif
  826|      1|}
scanner.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|}
scanner.c:pj_memchr:
  896|  37.8k|{
  897|  37.8k|    return (void*)memchr((void*)buf, c, size);
  898|  37.8k|}
scanner.c:pj_strset3:
  149|   188k|{
  150|   188k|    str->ptr = begin;
  151|   188k|    str->slen = (pj_ssize_t)(end-begin);
  152|   188k|    return str;
  153|   188k|}
scanner.c:pj_strset:
  117|  4.77k|{
  118|  4.77k|    str->ptr = ptr;
  119|  4.77k|    str->slen = (pj_ssize_t)length;
  120|  4.77k|    return str;
  121|  4.77k|}
string.c:pj_strchr:
  481|  12.9k|{
  482|  12.9k|    if (str->slen == 0)
  ------------------
  |  Branch (482:9): [True: 0, False: 12.9k]
  ------------------
  483|      0|        return NULL;
  484|  12.9k|    return (char*) memchr((char*)str->ptr, chr, str->slen);
  485|  12.9k|}
string.c:pj_memcpy:
  853|  7.37k|{
  854|  7.37k|    return memcpy(dst, src, size);
  855|  7.37k|}
os_core_unix.c:pj_bzero:
  820|      1|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|      1|    memset(dst, 0, size);
  825|      1|#endif
  826|      1|}
os_core_unix.c:pj_strlen:
  282|      1|{
  283|      1|    return str->slen;
  284|      1|}
ioqueue_select.c:pj_bzero:
  820|      1|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|      1|    memset(dst, 0, size);
  825|      1|#endif
  826|      1|}
lock.c:pj_memcpy:
  853|     69|{
  854|     69|    return memcpy(dst, src, size);
  855|     69|}
pool.c:pj_bzero:
  820|  9.99k|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|  9.99k|    memset(dst, 0, size);
  825|  9.99k|#endif
  826|  9.99k|}
pool_caching.c:pj_bzero:
  820|      1|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|      1|    memset(dst, 0, size);
  825|      1|#endif
  826|      1|}
pool_caching.c:pj_memcpy:
  853|      1|{
  854|      1|    return memcpy(dst, src, size);
  855|      1|}

pj_str:
   24|    543|{
   25|    543|    pj_str_t dst;
   26|    543|    dst.ptr = str;
   27|    543|    dst.slen = str ? pj_ansi_strlen(str) : 0;
  ------------------
  |  |   69|    543|#define pj_ansi_strlen          strlen
  ------------------
  |  Branch (27:16): [True: 543, False: 0]
  ------------------
   28|    543|    return dst;
   29|    543|}
pj_strdup:
   34|    609|{
   35|    609|    pj_assert(src->slen >= 0);
  ------------------
  |  |   65|    609|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (35:5): [True: 0, False: 609]
  |  Branch (35:5): [True: 609, False: 0]
  ------------------
   36|       |
   37|       |    /* Without this, destination will be corrupted */
   38|    609|    if (dst == src)
  ------------------
  |  Branch (38:9): [True: 0, False: 609]
  ------------------
   39|      0|        return dst;
   40|       |
   41|    609|    if (src->slen > 0) {
  ------------------
  |  Branch (41:9): [True: 325, False: 284]
  ------------------
   42|    325|        dst->ptr = (char*)pj_pool_alloc(pool, src->slen);
   43|    325|        pj_memcpy(dst->ptr, src->ptr, src->slen);
   44|    325|    }
   45|    609|    dst->slen = (src->slen < 0)? 0: src->slen;
  ------------------
  |  Branch (45:17): [True: 0, False: 609]
  ------------------
   46|    609|    return dst;
   47|    609|}
pj_strdup_with_null:
   52|      1|{
   53|      1|    pj_ssize_t src_slen = src->slen;
   54|       |
   55|      1|    pj_assert(src->slen >= 0);
  ------------------
  |  |   65|      1|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (55:5): [True: 0, False: 1]
  |  Branch (55:5): [True: 1, False: 0]
  ------------------
   56|       |
   57|       |    /* Check if the source's length is invalid */
   58|      1|    if (src_slen < 0)
  ------------------
  |  Branch (58:9): [True: 0, False: 1]
  ------------------
   59|      0|        src_slen = 0;
   60|       |
   61|      1|    dst->ptr = (char*)pj_pool_alloc(pool, src_slen+1);
   62|      1|    if (src_slen) {
  ------------------
  |  Branch (62:9): [True: 1, False: 0]
  ------------------
   63|      1|        pj_memcpy(dst->ptr, src->ptr, src_slen);
   64|      1|    }
   65|      1|    dst->slen = src_slen;
   66|      1|    dst->ptr[dst->slen] = '\0';
   67|      1|    return dst;
   68|      1|}
pj_strcpy:
  112|  2.35k|{
  113|  2.35k|    pj_assert(src->slen >= 0);
  ------------------
  |  |   65|  2.35k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (113:5): [True: 0, False: 2.35k]
  |  Branch (113:5): [True: 2.35k, False: 0]
  ------------------
  114|       |
  115|  2.35k|    dst->slen = (src->slen < 0)? 0: src->slen;
  ------------------
  |  Branch (115:17): [True: 0, False: 2.35k]
  ------------------
  116|  2.35k|    if (src->slen > 0)
  ------------------
  |  Branch (116:9): [True: 2.35k, False: 0]
  ------------------
  117|  2.35k|        pj_memcpy(dst->ptr, src->ptr, src->slen);
  118|  2.35k|    return dst;
  119|  2.35k|}
pj_stricmp:
  236|  57.4k|{
  237|  57.4k|    pj_assert(str1->slen >= 0);
  ------------------
  |  |   65|  57.4k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (237:5): [True: 0, False: 57.4k]
  |  Branch (237:5): [True: 57.4k, False: 0]
  ------------------
  238|  57.4k|    pj_assert(str2->slen >= 0);
  ------------------
  |  |   65|  57.4k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (238:5): [True: 0, False: 57.4k]
  |  Branch (238:5): [True: 57.4k, False: 0]
  ------------------
  239|       |
  240|  57.4k|    if (str1->slen <= 0) {
  ------------------
  |  Branch (240:9): [True: 6, False: 57.4k]
  ------------------
  241|      6|        return str2->slen<=0 ? 0 : -1;
  ------------------
  |  Branch (241:16): [True: 0, False: 6]
  ------------------
  242|  57.4k|    } else if (str2->slen <= 0) {
  ------------------
  |  Branch (242:16): [True: 0, False: 57.4k]
  ------------------
  243|      0|        return 1;
  244|  57.4k|    } else {
  245|  57.4k|        pj_size_t min = (str1->slen < str2->slen)? str1->slen : str2->slen;
  ------------------
  |  Branch (245:25): [True: 8.00k, False: 49.4k]
  ------------------
  246|  57.4k|        int res = pj_ansi_strnicmp(str1->ptr, str2->ptr, min);
  ------------------
  |  |   96|  57.4k|#define pj_ansi_strnicmp        strncasecmp
  ------------------
  247|  57.4k|        if (res == 0) {
  ------------------
  |  Branch (247:13): [True: 33.2k, False: 24.1k]
  ------------------
  248|  33.2k|            return (str1->slen < str2->slen) ? -1 :
  ------------------
  |  Branch (248:20): [True: 386, False: 32.8k]
  ------------------
  249|  33.2k|                    (str1->slen == str2->slen ? 0 : 1);
  ------------------
  |  Branch (249:22): [True: 32.8k, False: 26]
  ------------------
  250|  33.2k|        } else {
  251|  24.1k|            return res;
  252|  24.1k|        }
  253|  57.4k|    }
  254|  57.4k|}
pj_strcat:
  378|  2.35k|{
  379|  2.35k|    pj_assert(src->slen >= 0);
  ------------------
  |  |   65|  2.35k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (379:5): [True: 0, False: 2.35k]
  |  Branch (379:5): [True: 2.35k, False: 0]
  ------------------
  380|  2.35k|    pj_assert(dst->slen >= 0);
  ------------------
  |  |   65|  2.35k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (380:5): [True: 0, False: 2.35k]
  |  Branch (380:5): [True: 2.35k, False: 0]
  ------------------
  381|       |
  382|  2.35k|    if (src->slen > 0 && dst->slen >= 0) {
  ------------------
  |  Branch (382:9): [True: 2.35k, False: 0]
  |  Branch (382:26): [True: 2.35k, False: 0]
  ------------------
  383|  2.35k|        pj_memcpy(dst->ptr + dst->slen, src->ptr, src->slen);
  384|  2.35k|        dst->slen += src->slen;
  385|  2.35k|    }
  386|  2.35k|}
pj_strcat2:
  389|  2.35k|{
  390|  2.35k|    pj_size_t len = str? pj_ansi_strlen(str) : 0;
  ------------------
  |  |   69|  2.35k|#define pj_ansi_strlen          strlen
  ------------------
  |  Branch (390:21): [True: 2.35k, False: 0]
  ------------------
  391|       |
  392|  2.35k|    pj_assert(dst->slen >= 0);
  ------------------
  |  |   65|  2.35k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (392:5): [True: 0, False: 2.35k]
  |  Branch (392:5): [True: 2.35k, False: 0]
  ------------------
  393|       |
  394|  2.35k|    if (len && dst->slen >= 0) {
  ------------------
  |  Branch (394:9): [True: 2.35k, False: 0]
  |  Branch (394:16): [True: 2.35k, False: 0]
  ------------------
  395|  2.35k|        pj_memcpy(dst->ptr + dst->slen, str, len);
  396|  2.35k|        dst->slen += len;
  397|  2.35k|    }
  398|  2.35k|}
pj_strtrim:
  401|  3.70k|{
  402|  3.70k|    pj_strltrim(str);
  403|  3.70k|    pj_strrtrim(str);
  404|  3.70k|    return str;
  405|  3.70k|}

pj_register_strerror:
  122|      1|{
  123|      1|    unsigned i;
  124|       |
  125|       |    /* Check arguments. */
  126|      1|    PJ_ASSERT_RETURN(start && space && f, PJ_EINVAL);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      4|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 1, False: 0]
  |  |  |  Branch (98:23): [True: 1, False: 0]
  |  |  |  Branch (98:23): [True: 1, False: 0]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  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|      1|    PJ_ASSERT_RETURN(err_msg_hnd_cnt < PJ_ARRAY_SIZE(err_msg_hnd),
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (129:5): [True: 0, False: 0]
  |  Branch (129:5): [True: 0, False: 0]
  ------------------
  130|      1|                     PJ_ETOOMANY);
  131|       |
  132|       |    /* Start error must be greater than PJ_ERRNO_START_USER */
  133|      1|    PJ_ASSERT_RETURN(start >= PJ_ERRNO_START_USER, PJ_EEXISTS);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  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|      1|    for (i=0; i<err_msg_hnd_cnt; ++i) {
  ------------------
  |  Branch (136:15): [True: 0, False: 1]
  ------------------
  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|      1|    err_msg_hnd[err_msg_hnd_cnt].begin = start;
  154|      1|    err_msg_hnd[err_msg_hnd_cnt].end = start + space;
  155|      1|    err_msg_hnd[err_msg_hnd_cnt].strerror = f;
  156|       |
  157|      1|    ++err_msg_hnd_cnt;
  158|       |
  159|      1|    return PJ_SUCCESS;
  160|      1|}

pj_throw_exception_:
   41|  38.2k|{
   42|  38.2k|    struct pj_exception_state_t *handler;
   43|       |
   44|  38.2k|    handler = (struct pj_exception_state_t*) 
   45|  38.2k|              pj_thread_local_get(thread_local_id);
   46|  38.2k|    if (handler == NULL) {
  ------------------
  |  Branch (46:9): [True: 0, False: 38.2k]
  ------------------
   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|  38.2k|    pj_pop_exception_handler_(handler);
   53|  38.2k|    pj_longjmp(handler->state, exception_id);
  ------------------
  |  |   34|  38.2k|#    define pj_longjmp(buf,d)   longjmp(buf,d)
  ------------------
   54|  38.2k|}
pj_push_exception_handler_:
   75|  38.4k|{
   76|  38.4k|    struct pj_exception_state_t *parent_handler = NULL;
   77|       |
   78|  38.4k|    if (thread_local_id == -1) {
  ------------------
  |  Branch (78:9): [True: 1, False: 38.4k]
  ------------------
   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|  38.4k|    parent_handler = (struct pj_exception_state_t *)
   84|  38.4k|                      pj_thread_local_get(thread_local_id);
   85|  38.4k|    rec->prev = parent_handler;
   86|  38.4k|    pj_thread_local_set(thread_local_id, rec);
   87|  38.4k|}
pj_pop_exception_handler_:
   90|  39.8k|{
   91|  39.8k|    struct pj_exception_state_t *handler;
   92|       |
   93|  39.8k|    handler = (struct pj_exception_state_t *)
   94|  39.8k|              pj_thread_local_get(thread_local_id);
   95|  39.8k|    if (handler && handler==rec) {
  ------------------
  |  Branch (95:9): [True: 39.8k, False: 22]
  |  Branch (95:20): [True: 39.8k, False: 0]
  ------------------
   96|  39.8k|        pj_thread_local_set(thread_local_id, handler->prev);
   97|  39.8k|    }
   98|  39.8k|}
pj_exception_id_alloc:
  104|      3|{
  105|      3|    unsigned i;
  106|       |
  107|      3|    pj_enter_critical_section();
  108|       |
  109|       |    /*
  110|       |     * Start from 1 (not 0)!!!
  111|       |     * Exception 0 is reserved for normal path of setjmp()!!!
  112|       |     */
  113|      6|    for (i=1; i<PJ_MAX_EXCEPTION_ID; ++i) {
  ------------------
  |  |  947|      6|#   define PJ_MAX_EXCEPTION_ID      16
  ------------------
  |  Branch (113:15): [True: 6, False: 0]
  ------------------
  114|      6|        if (exception_id_names[i] == NULL) {
  ------------------
  |  Branch (114:13): [True: 3, False: 3]
  ------------------
  115|      3|            exception_id_names[i] = name;
  116|      3|            *id = i;
  117|      3|            pj_leave_critical_section();
  118|      3|            return PJ_SUCCESS;
  119|      3|        }
  120|      6|    }
  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|      3|}

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

pj_hash_calc:
   54|  42.6k|{
   55|  42.6k|    PJ_CHECK_STACK();
   56|       |
   57|  42.6k|    if (keylen==PJ_HASH_KEY_STRING) {
  ------------------
  |  |   45|  42.6k|#define PJ_HASH_KEY_STRING      ((unsigned)-1)
  ------------------
  |  Branch (57:9): [True: 0, False: 42.6k]
  ------------------
   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|  42.6k|    } else {
   63|  42.6k|        const pj_uint8_t *p = (const pj_uint8_t*)key,
   64|  42.6k|                              *end = p + keylen;
   65|  92.2k|        for ( ; p!=end; ++p) {
  ------------------
  |  Branch (65:17): [True: 49.6k, False: 42.6k]
  ------------------
   66|  49.6k|            hash = (hash * PJ_HASH_MULTIPLIER) + *p;
  ------------------
  |  |   30|  49.6k|#define PJ_HASH_MULTIPLIER      33
  ------------------
   67|  49.6k|        }
   68|  42.6k|    }
   69|  42.6k|    return hash;
   70|  42.6k|}
pj_hash_calc_tolower:
   75|  24.1k|{
   76|  24.1k|    long i;
   77|       |
   78|  52.0k|    for (i=0; i<key->slen; ++i) {
  ------------------
  |  Branch (78:15): [True: 27.8k, False: 24.1k]
  ------------------
   79|  27.8k|        int lower = pj_tolower(key->ptr[i]);
   80|  27.8k|        if (result)
  ------------------
  |  Branch (80:13): [True: 27.8k, False: 0]
  ------------------
   81|  27.8k|            result[i] = (char)lower;
   82|       |
   83|  27.8k|        hval = hval * PJ_HASH_MULTIPLIER + lower;
  ------------------
  |  |   30|  27.8k|#define PJ_HASH_MULTIPLIER      33
  ------------------
   84|  27.8k|    }
   85|       |
   86|  24.1k|    return hval;
   87|  24.1k|}
pj_hash_create:
   91|      1|{
   92|      1|    pj_hash_table_t *h;
   93|      1|    unsigned table_size;
   94|       |    
   95|       |    /* Check that PJ_HASH_ENTRY_BUF_SIZE is correct. */
   96|      1|    PJ_ASSERT_RETURN(sizeof(pj_hash_entry)<=PJ_HASH_ENTRY_BUF_SIZE, NULL);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [Folded, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (96:5): [True: 0, Folded]
  |  Branch (96:5): [True: 0, Folded]
  ------------------
   97|       |
   98|      1|    h = PJ_POOL_ALLOC_T(pool, pj_hash_table_t);
  ------------------
  |  |  569|      1|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
   99|      1|    h->count = 0;
  100|       |
  101|      1|    PJ_LOG( 6, ("hashtbl", "hash table %p created from pool %s", h, pj_pool_getobjname(pool)));
  ------------------
  |  |  106|      1|#define PJ_LOG(level,arg)       do { \
  |  |  107|      1|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      2|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 1]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|      1|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 1]
  |  |  ------------------
  ------------------
  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|      1|    table_size = 8;
  108|      2|    do {
  109|      2|        table_size <<= 1;    
  110|      2|    } while (table_size < size);
  ------------------
  |  Branch (110:14): [True: 1, False: 1]
  ------------------
  111|      1|    table_size -= 1;
  112|       |    
  113|      1|    h->rows = table_size;
  114|      1|    h->table = (pj_hash_entry**)
  115|      1|               pj_pool_calloc(pool, table_size+1, sizeof(pj_hash_entry*));
  116|      1|    return h;
  117|      1|}

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

pj_ioqueue_create:
  196|      1|{
  197|       |    return pj_ioqueue_create2(pool, max_fd, NULL, p_ioqueue);
  198|      1|}
pj_ioqueue_create2:
  210|      1|{
  211|      1|    pj_ioqueue_t *ioqueue;
  212|      1|    pj_lock_t *lock;
  213|      1|    pj_size_t i;
  214|      1|    pj_status_t rc;
  215|       |
  216|       |    /* Check that arguments are valid. */
  217|      1|    PJ_ASSERT_RETURN(pool != NULL && p_ioqueue != NULL && 
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      6|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 1, False: 0]
  |  |  |  Branch (98:23): [True: 1, False: 0]
  |  |  |  Branch (98:23): [True: 1, False: 0]
  |  |  |  Branch (98:23): [True: 1, False: 0]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  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|      1|                     max_fd > 0 && max_fd <= PJ_IOQUEUE_MAX_HANDLES, 
  219|      1|                     PJ_EINVAL);
  220|       |
  221|       |    /* Check that size of pj_ioqueue_op_key_t is sufficient */
  222|      1|    PJ_ASSERT_RETURN(sizeof(pj_ioqueue_op_key_t)-sizeof(void*) >=
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [Folded, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (222:5): [True: 0, Folded]
  |  Branch (222:5): [True: 0, Folded]
  ------------------
  223|      1|                     sizeof(union operation_key), PJ_EBUG);
  224|       |
  225|       |    /* Create and init common ioqueue stuffs */
  226|      1|    ioqueue = PJ_POOL_ZALLOC_T(pool, pj_ioqueue_t);
  ------------------
  |  |  583|      1|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  227|      1|    ioqueue_init(ioqueue);
  228|       |
  229|      1|    if (cfg)
  ------------------
  |  Branch (229:9): [True: 0, False: 1]
  ------------------
  230|      0|        pj_memcpy(&ioqueue->cfg, cfg, sizeof(*cfg));
  231|      1|    else
  232|      1|        pj_ioqueue_cfg_default(&ioqueue->cfg);
  233|      1|    ioqueue->max = (unsigned)max_fd;
  234|      1|    ioqueue->count = 0;
  235|      1|    PJ_FD_ZERO(&ioqueue->rfdset);
  236|      1|    PJ_FD_ZERO(&ioqueue->wfdset);
  237|      1|#if PJ_HAS_TCP
  238|      1|    PJ_FD_ZERO(&ioqueue->xfdset);
  239|      1|#endif
  240|      1|    pj_list_init(&ioqueue->active_list);
  241|       |
  242|      1|    rescan_fdset(ioqueue);
  243|       |
  244|      1|#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|      1|    rc = pj_mutex_create_simple(pool, NULL, &ioqueue->ref_cnt_mutex);
  254|      1|    if (rc != PJ_SUCCESS)
  ------------------
  |  Branch (254:9): [True: 0, False: 1]
  ------------------
  255|      0|        return rc;
  256|       |
  257|       |
  258|       |    /* Init key list */
  259|      1|    pj_list_init(&ioqueue->free_list);
  260|      1|    pj_list_init(&ioqueue->closing_list);
  261|       |
  262|       |
  263|       |    /* Pre-create all keys according to max_fd */
  264|     65|    for (i=0; i<max_fd; ++i) {
  ------------------
  |  Branch (264:15): [True: 64, False: 1]
  ------------------
  265|     64|        pj_ioqueue_key_t *key;
  266|       |
  267|     64|        key = PJ_POOL_ALLOC_T(pool, pj_ioqueue_key_t);
  ------------------
  |  |  569|     64|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
  268|     64|        key->ref_count = 0;
  269|     64|        rc = pj_lock_create_recursive_mutex(pool, NULL, &key->lock);
  270|     64|        if (rc != PJ_SUCCESS) {
  ------------------
  |  Branch (270:13): [True: 0, False: 64]
  ------------------
  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|     64|        pj_list_push_back(&ioqueue->free_list, key);
  281|     64|    }
  282|      1|#endif
  283|       |
  284|       |    /* Create and init ioqueue mutex */
  285|      1|    rc = pj_lock_create_simple_mutex(pool, "ioq%p", &lock);
  286|      1|    if (rc != PJ_SUCCESS)
  ------------------
  |  Branch (286:9): [True: 0, False: 1]
  ------------------
  287|      0|        return rc;
  288|       |
  289|      1|    rc = pj_ioqueue_set_lock(ioqueue, lock, PJ_TRUE);
  290|      1|    if (rc != PJ_SUCCESS)
  ------------------
  |  Branch (290:9): [True: 0, False: 1]
  ------------------
  291|      0|        return rc;
  292|       |
  293|      1|    PJ_LOG(4, ("pjlib", "select() I/O Queue created (%p)", ioqueue));
  ------------------
  |  |  106|      1|#define PJ_LOG(level,arg)       do { \
  |  |  107|      1|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      2|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 1, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 1]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      1|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 1]
  |  |  ------------------
  ------------------
  294|       |
  295|      1|    *p_ioqueue = ioqueue;
  296|      1|    return PJ_SUCCESS;
  297|      1|}
pj_ioqueue_poll:
  933|    850|{
  934|    850|    pj_fd_set_t rfdset, wfdset, xfdset;
  935|    850|    int nfds;
  936|    850|    int i, count, event_cnt, processed_cnt;
  937|    850|    pj_ioqueue_key_t *h;
  938|    850|    enum { MAX_EVENTS = PJ_IOQUEUE_MAX_CAND_EVENTS };
  939|    850|    struct event
  940|    850|    {
  941|    850|        pj_ioqueue_key_t        *key;
  942|    850|        enum ioqueue_event_type  event_type;
  943|    850|    } event[MAX_EVENTS];
  944|       |
  945|    850|    PJ_ASSERT_RETURN(ioqueue, -PJ_EINVAL);
  ------------------
  |  |   97|    850|            do { \
  |  |   98|    850|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 850]
  |  |  ------------------
  |  |   99|    850|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 850]
  |  |  ------------------
  ------------------
  |  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|    850|    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|    850|    if (PJ_FD_COUNT(&ioqueue->rfdset)==0 &&
  ------------------
  |  Branch (959:9): [True: 850, False: 0]
  ------------------
  960|    850|        PJ_FD_COUNT(&ioqueue->wfdset)==0 
  ------------------
  |  Branch (960:9): [True: 850, False: 0]
  ------------------
  961|    850|#if defined(PJ_HAS_TCP) && PJ_HAS_TCP!=0
  962|    850|        && PJ_FD_COUNT(&ioqueue->xfdset)==0
  ------------------
  |  Branch (962:12): [True: 850, False: 0]
  ------------------
  963|    850|#endif
  964|    850|        )
  965|    850|    {
  966|    850|#if PJ_IOQUEUE_HAS_SAFE_UNREG
  967|    850|        scan_closing_keys(ioqueue);
  968|    850|#endif
  969|    850|        pj_lock_release(ioqueue->lock);
  970|    850|        TRACE__((THIS_FILE, "     poll: no fd is set"));
  971|    850|        if (timeout)
  ------------------
  |  Branch (971:13): [True: 850, False: 0]
  ------------------
  972|    850|            pj_thread_sleep(PJ_TIME_VAL_MSEC(*timeout));
  ------------------
  |  |  477|    850|#define PJ_TIME_VAL_MSEC(t)     ((t).sec * 1000 + (t).msec)
  ------------------
  973|    850|        return 0;
  974|    850|    }
  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|      1|{
  183|       |    ioqueue->nfds = FD_SETSIZE-1;
  184|      1|}
ioqueue_select.c:scan_closing_keys:
  702|    850|{
  703|    850|    pj_time_val now;
  704|    850|    pj_ioqueue_key_t *h;
  705|       |
  706|    850|    pj_gettickcount(&now);
  707|    850|    h = ioqueue->closing_list.next;
  708|    850|    while (h != &ioqueue->closing_list) {
  ------------------
  |  Branch (708:12): [True: 0, False: 850]
  ------------------
  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|    850|}

pj_lock_create_simple_mutex:
   87|      2|{
   88|      2|    return create_mutex_lock(pool, name, PJ_MUTEX_SIMPLE, lock);
   89|      2|}
pj_lock_create_recursive_mutex:
   94|     67|{
   95|     67|    return create_mutex_lock(pool, name, PJ_MUTEX_RECURSE, lock);
   96|     67|}
pj_lock_acquire:
  177|  3.40k|{
  178|  3.40k|    PJ_ASSERT_RETURN(lock != NULL, PJ_EINVAL);
  ------------------
  |  |   97|  3.40k|            do { \
  |  |   98|  3.40k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 3.40k]
  |  |  ------------------
  |  |   99|  3.40k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 3.40k]
  |  |  ------------------
  ------------------
  |  Branch (178:5): [True: 0, False: 0]
  |  Branch (178:5): [True: 0, False: 0]
  ------------------
  179|  3.40k|    return (*lock->acquire)(lock->lock_object);
  180|  3.40k|}
pj_lock_release:
  189|  3.40k|{
  190|  3.40k|    PJ_ASSERT_RETURN(lock != NULL, PJ_EINVAL);
  ------------------
  |  |   97|  3.40k|            do { \
  |  |   98|  3.40k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 3.40k]
  |  |  ------------------
  |  |   99|  3.40k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 3.40k]
  |  |  ------------------
  ------------------
  |  Branch (190:5): [True: 0, False: 0]
  |  Branch (190:5): [True: 0, False: 0]
  ------------------
  191|  3.40k|    return (*lock->release)(lock->lock_object);
  192|  3.40k|}
pj_grp_lock_create:
  413|      1|{
  414|      1|    pj_grp_lock_t *glock;
  415|      1|    grp_lock_item *own_lock;
  416|      1|    pj_status_t status;
  417|       |
  418|      1|    PJ_ASSERT_RETURN(pool && p_grp_lock, PJ_EINVAL);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 1, False: 0]
  |  |  |  Branch (98:23): [True: 1, False: 0]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  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|      1|    PJ_UNUSED_ARG(cfg);
  ------------------
  |  | 1537|      1|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  421|       |
  422|      1|    pool = pj_pool_create(pool->factory, "glck%p", 512, 512, NULL);
  423|      1|    if (!pool)
  ------------------
  |  Branch (423:9): [True: 0, False: 1]
  ------------------
  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|      1|    glock = PJ_POOL_ZALLOC_T(pool, pj_grp_lock_t);
  ------------------
  |  |  583|      1|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  427|      1|    glock->base.lock_object = glock;
  428|      1|    glock->base.acquire = &grp_lock_acquire;
  429|      1|    glock->base.tryacquire = &grp_lock_tryacquire;
  430|      1|    glock->base.release = &grp_lock_release;
  431|      1|    glock->base.destroy = &grp_lock_destroy;
  432|       |
  433|      1|    glock->pool = pool;
  434|      1|    pj_list_init(&glock->lock_list);
  435|      1|    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|      1|    status = pj_atomic_create(pool, 0, &glock->ref_cnt);
  442|      1|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (442:9): [True: 0, False: 1]
  ------------------
  443|      0|        goto on_error;
  444|       |
  445|      1|    status = pj_lock_create_recursive_mutex(pool, pool->obj_name,
  446|      1|                                            &glock->own_lock);
  447|      1|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (447:9): [True: 0, False: 1]
  ------------------
  448|      0|        goto on_error;
  449|       |
  450|      1|    own_lock = PJ_POOL_ZALLOC_T(pool, grp_lock_item);
  ------------------
  |  |  583|      1|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  451|      1|    own_lock->lock = glock->own_lock;
  452|      1|    pj_list_push_back(&glock->lock_list, own_lock);
  453|       |
  454|      1|    *p_grp_lock = glock;
  455|      1|    return PJ_SUCCESS;
  456|       |
  457|      0|on_error:
  458|      0|    grp_lock_destroy(glock);
  459|      0|    return status;
  460|      1|}
pj_grp_lock_add_ref:
  648|      1|{
  649|      1|    return grp_lock_add_ref(glock);
  650|      1|}
lock.c:create_mutex_lock:
   62|     69|{
   63|     69|    pj_lock_t *p_lock;
   64|     69|    pj_mutex_t *mutex;
   65|     69|    pj_status_t rc;
   66|       |
   67|     69|    PJ_ASSERT_RETURN(pool && lock, PJ_EINVAL);
  ------------------
  |  |   97|     69|            do { \
  |  |   98|    138|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 69, False: 0]
  |  |  |  Branch (98:23): [True: 69, False: 0]
  |  |  ------------------
  |  |   99|     69|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 69]
  |  |  ------------------
  ------------------
  |  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|     69|    p_lock = PJ_POOL_ALLOC_T(pool, pj_lock_t);
  ------------------
  |  |  569|     69|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
   70|     69|    if (!p_lock)
  ------------------
  |  Branch (70:9): [True: 0, False: 69]
  ------------------
   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|     69|    pj_memcpy(p_lock, &mutex_lock_template, sizeof(pj_lock_t));
   74|     69|    rc = pj_mutex_create(pool, name, type, &mutex);
   75|     69|    if (rc != PJ_SUCCESS)
  ------------------
  |  Branch (75:9): [True: 0, False: 69]
  ------------------
   76|      0|        return rc;
   77|       |
   78|     69|    p_lock->lock_object = mutex;
   79|     69|    *lock = p_lock;
   80|     69|    return PJ_SUCCESS;
   81|     69|}
lock.c:grp_lock_add_ref:
  554|      1|{
  555|      1|    pj_atomic_inc(glock->ref_cnt);
  556|      1|    return PJ_SUCCESS;
  557|      1|}

pj_log_get_indent:
  128|      1|{
  129|      1|    int indent = log_get_raw_indent();
  130|      1|    return indent > LOG_MAX_INDENT ? LOG_MAX_INDENT : indent;
  ------------------
  |  |   84|      1|#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: 1]
  ------------------
  131|      1|}
pj_log_init:
  149|      1|{
  150|      1|#if PJ_HAS_THREADS
  151|      1|    if (thread_suspended_tls_id == -1) {
  ------------------
  |  Branch (151:9): [True: 1, False: 0]
  ------------------
  152|      1|        pj_status_t status;
  153|      1|        status = pj_thread_local_alloc(&thread_suspended_tls_id);
  154|      1|        if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (154:13): [True: 0, False: 1]
  ------------------
  155|      0|            thread_suspended_tls_id = -1;
  156|      0|            return status;
  157|      0|        }
  158|       |
  159|      1|#  if PJ_LOG_ENABLE_INDENT
  160|      1|        status = pj_thread_local_alloc(&thread_indent_tls_id);
  161|      1|        if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (161:13): [True: 0, False: 1]
  ------------------
  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|      1|#  endif
  168|      1|        pj_atexit(&logging_shutdown);
  169|      1|    }
  170|      1|#endif
  171|      1|    g_last_thread = NULL;
  172|       |
  173|       |    /* Normalize log decor, e.g: unset thread flags when threading is
  174|       |     * disabled.
  175|       |     */
  176|      1|    pj_log_set_decor(pj_log_get_decor());
  177|       |
  178|      1|    return PJ_SUCCESS;
  179|      1|}
pj_log_set_decor:
  182|      1|{
  183|      1|    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|      1|}
pj_log_get_decor:
  197|      2|{
  198|      2|    return log_decor;
  199|      2|}
pj_log_set_level:
  252|      1|{
  253|      1|    pj_log_max_level = level;
  254|      1|}
pj_log_get_level:
  258|  1.10k|{
  259|  1.10k|    return pj_log_max_level;
  260|  1.10k|}
pj_log:
  340|      1|{
  341|      1|    pj_time_val now;
  342|      1|    pj_parsed_time ptime;
  343|      1|    char *pre;
  344|      1|#if PJ_LOG_USE_STACK_BUFFER
  345|      1|    char log_buffer[PJ_LOG_MAX_SIZE];
  346|      1|#endif
  347|      1|    int saved_level, len, print_len;
  348|       |
  349|      1|    PJ_CHECK_STACK();
  350|       |
  351|      1|    if (level > pj_log_max_level)
  ------------------
  |  Branch (351:9): [True: 0, False: 1]
  ------------------
  352|      0|        return;
  353|       |
  354|      1|    if (is_logging_suspended())
  ------------------
  |  Branch (354:9): [True: 0, False: 1]
  ------------------
  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|      1|    suspend_logging(&saved_level);
  362|       |
  363|       |    /* Get current date/time. */
  364|      1|    pj_gettimeofday(&now);
  365|      1|    pj_time_decode(&now, &ptime);
  366|       |
  367|      1|    pre = log_buffer;
  368|      1|    if (log_decor & PJ_LOG_HAS_LEVEL_TEXT) {
  ------------------
  |  Branch (368:9): [True: 0, False: 1]
  ------------------
  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|      1|    if (log_decor & PJ_LOG_HAS_DAY_NAME) {
  ------------------
  |  Branch (374:9): [True: 0, False: 1]
  ------------------
  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|      1|    if (log_decor & PJ_LOG_HAS_YEAR) {
  ------------------
  |  Branch (380:9): [True: 0, False: 1]
  ------------------
  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|      1|    if (log_decor & PJ_LOG_HAS_MONTH) {
  ------------------
  |  Branch (384:9): [True: 0, False: 1]
  ------------------
  385|      0|        *pre++ = '-';
  386|      0|        pre += pj_utoa_pad(ptime.mon+1, pre, 2, '0');
  387|      0|    }
  388|      1|    if (log_decor & PJ_LOG_HAS_DAY_OF_MON) {
  ------------------
  |  Branch (388:9): [True: 0, False: 1]
  ------------------
  389|      0|        *pre++ = '-';
  390|      0|        pre += pj_utoa_pad(ptime.day, pre, 2, '0');
  391|      0|    }
  392|      1|    if (log_decor & PJ_LOG_HAS_TIME) {
  ------------------
  |  Branch (392:9): [True: 1, False: 0]
  ------------------
  393|      1|        if (pre!=log_buffer) *pre++ = ' ';
  ------------------
  |  Branch (393:13): [True: 0, False: 1]
  ------------------
  394|      1|        pre += pj_utoa_pad(ptime.hour, pre, 2, '0');
  395|      1|        *pre++ = ':';
  396|      1|        pre += pj_utoa_pad(ptime.min, pre, 2, '0');
  397|      1|        *pre++ = ':';
  398|      1|        pre += pj_utoa_pad(ptime.sec, pre, 2, '0');
  399|      1|    }
  400|      1|    if (log_decor & PJ_LOG_HAS_MICRO_SEC) {
  ------------------
  |  Branch (400:9): [True: 1, False: 0]
  ------------------
  401|      1|        *pre++ = '.';
  402|      1|        pre += pj_utoa_pad(ptime.msec, pre, 3, '0');
  403|      1|    }
  404|      1|    if (log_decor & PJ_LOG_HAS_SENDER) {
  ------------------
  |  Branch (404:9): [True: 1, False: 0]
  ------------------
  405|      1|        enum { SENDER_WIDTH = PJ_LOG_SENDER_WIDTH };
  406|      1|        pj_size_t sender_len = strlen(sender);
  407|      1|        if (pre!=log_buffer) *pre++ = ' ';
  ------------------
  |  Branch (407:13): [True: 1, False: 0]
  ------------------
  408|      1|        if (sender_len <= SENDER_WIDTH) {
  ------------------
  |  Branch (408:13): [True: 1, False: 0]
  ------------------
  409|      9|            while (sender_len < SENDER_WIDTH)
  ------------------
  |  Branch (409:20): [True: 8, False: 1]
  ------------------
  410|      8|                *pre++ = ' ', ++sender_len;
  411|     15|            while (*sender)
  ------------------
  |  Branch (411:20): [True: 14, False: 1]
  ------------------
  412|     14|                *pre++ = *sender++;
  413|      1|        } 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|      1|    }
  419|      1|    if (log_decor & PJ_LOG_HAS_THREAD_ID) {
  ------------------
  |  Branch (419:9): [True: 0, False: 1]
  ------------------
  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|      1|    if (log_decor != 0 && log_decor != PJ_LOG_HAS_NEWLINE)
  ------------------
  |  Branch (436:9): [True: 1, False: 0]
  |  Branch (436:27): [True: 1, False: 0]
  ------------------
  437|      1|        *pre++ = ' ';
  438|       |
  439|      1|    if (log_decor & PJ_LOG_HAS_THREAD_SWC) {
  ------------------
  |  Branch (439:9): [True: 1, False: 0]
  ------------------
  440|      1|        void *current_thread = (void*)pj_thread_this();
  441|      1|        if (current_thread != g_last_thread) {
  ------------------
  |  Branch (441:13): [True: 1, False: 0]
  ------------------
  442|      1|            *pre++ = '!';
  443|      1|            g_last_thread = current_thread;
  444|      1|        } else {
  445|      0|            *pre++ = ' ';
  446|      0|        }
  447|      1|    } else if (log_decor & PJ_LOG_HAS_SPACE) {
  ------------------
  |  Branch (447:16): [True: 0, False: 0]
  ------------------
  448|      0|        *pre++ = ' ';
  449|      0|    }
  450|       |
  451|      1|#if PJ_LOG_ENABLE_INDENT
  452|      1|    if (log_decor & PJ_LOG_HAS_INDENT) {
  ------------------
  |  Branch (452:9): [True: 1, False: 0]
  ------------------
  453|      1|        int indent = pj_log_get_indent();
  454|      1|        if (indent > 0) {
  ------------------
  |  Branch (454:13): [True: 0, False: 1]
  ------------------
  455|      0|            pj_memset(pre, PJ_LOG_INDENT_CHAR, indent);
  ------------------
  |  |  469|      0|#   define PJ_LOG_INDENT_CHAR       '.'
  ------------------
  456|      0|            pre += indent;
  457|      0|        }
  458|      1|    }
  459|      1|#endif
  460|       |
  461|      1|    len = (int)(pre - log_buffer);
  462|       |
  463|       |    /* Print the whole message to the string log_buffer. */
  464|      1|    print_len = pj_ansi_vsnprintf(pre, sizeof(log_buffer)-len, format, 
  ------------------
  |  |  122|      1|#define pj_ansi_vsnprintf       vsnprintf
  ------------------
  465|      1|                                  marker);
  466|      1|    if (print_len < 0) {
  ------------------
  |  Branch (466:9): [True: 0, False: 1]
  ------------------
  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|      1|    if (print_len < 0 || print_len >= (int)(sizeof(log_buffer)-len)) {
  ------------------
  |  Branch (471:9): [True: 0, False: 1]
  |  Branch (471:26): [True: 0, False: 1]
  ------------------
  472|      0|        print_len = sizeof(log_buffer) - len - 1;
  473|      0|    }
  474|      1|    len = len + print_len;
  475|      1|    if (len >= 0 && len < (int)sizeof(log_buffer)-2) {
  ------------------
  |  Branch (475:9): [True: 1, False: 0]
  |  Branch (475:21): [True: 1, False: 0]
  ------------------
  476|      1|        if (log_decor & PJ_LOG_HAS_CR) {
  ------------------
  |  Branch (476:13): [True: 0, False: 1]
  ------------------
  477|      0|            log_buffer[len++] = '\r';
  478|      0|        }
  479|      1|        if (log_decor & PJ_LOG_HAS_NEWLINE) {
  ------------------
  |  Branch (479:13): [True: 1, False: 0]
  ------------------
  480|      1|            log_buffer[len++] = '\n';
  481|      1|        }
  482|      1|        log_buffer[len] = '\0';
  483|      1|    } 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|      1|    resume_logging(&saved_level);
  498|       |
  499|      1|    if (log_writer)
  ------------------
  |  Branch (499:9): [True: 1, False: 0]
  ------------------
  500|      1|        (*log_writer)(level, log_buffer, len);
  501|      1|}
pj_log_4:
  548|      1|{
  549|      1|    va_list arg;
  550|      1|    va_start(arg, format);
  551|      1|    pj_log(obj, 4, format, arg);
  552|       |    va_end(arg);
  553|      1|}
log.c:log_get_raw_indent:
  110|      1|{
  111|      1|    return (long)(pj_ssize_t)pj_thread_local_get(thread_indent_tls_id);
  112|      1|}
log.c:is_logging_suspended:
  323|      1|{
  324|      1|#if PJ_HAS_THREADS
  325|      1|    if (thread_suspended_tls_id != -1) 
  ------------------
  |  Branch (325:9): [True: 1, False: 0]
  ------------------
  326|      1|    {
  327|      1|        pj_ssize_t *ils;
  328|      1|        ils = (pj_ssize_t *)pj_thread_local_get(thread_suspended_tls_id);
  329|      1|        return (ils? (*ils == PJ_TRUE): PJ_FALSE);
  ------------------
  |  Branch (329:17): [True: 0, False: 1]
  ------------------
  330|      1|    }
  331|      0|    else
  332|      0|#endif
  333|      0|    {
  334|      0|        return pj_log_max_level == 0;
  335|      0|    }
  336|      1|}
log.c:suspend_logging:
  280|      1|{
  281|       |    /* Save the level regardless, just in case PJLIB is shutdown
  282|       |     * between suspend and resume.
  283|       |     */
  284|      1|    *saved_level = pj_log_max_level;
  285|       |
  286|      1|#if PJ_HAS_THREADS
  287|      1|    if (thread_suspended_tls_id != -1) 
  ------------------
  |  Branch (287:9): [True: 1, False: 0]
  ------------------
  288|      1|    {
  289|      1|        static pj_ssize_t suspend_log = PJ_TRUE;
  290|      1|        pj_thread_local_set(thread_suspended_tls_id, 
  291|      1|                            (void*)&suspend_log);
  292|      1|    } 
  293|      0|    else
  294|      0|#endif
  295|      0|    {
  296|      0|        pj_log_max_level = 0;
  297|      0|    }
  298|      1|}
log.c:resume_logging:
  302|      1|{
  303|      1|#if PJ_HAS_THREADS
  304|      1|    if (thread_suspended_tls_id != -1) 
  ------------------
  |  Branch (304:9): [True: 1, False: 0]
  ------------------
  305|      1|    {
  306|      1|        static pj_ssize_t suspend_log = PJ_FALSE;
  307|      1|        pj_thread_local_set(thread_suspended_tls_id, 
  308|      1|                            (void*)&suspend_log);
  309|      1|    }
  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|      1|}

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

pj_init:
  202|      1|{
  203|      1|    char dummy_guid[PJ_GUID_MAX_LENGTH];
  204|      1|    pj_str_t guid;
  205|      1|    pj_status_t rc;
  206|       |
  207|       |    /* Check if PJLIB have been initialized */
  208|      1|    if (initialized) {
  ------------------
  |  Branch (208:9): [True: 0, False: 1]
  ------------------
  209|      0|        ++initialized;
  210|      0|        return PJ_SUCCESS;
  211|      0|    }
  212|       |
  213|       |    /* Init logging */
  214|      1|    pj_log_init();
  215|       |
  216|      1|#if PJ_HAS_THREADS
  217|       |    /* Init this thread's TLS. */
  218|      1|    if ((rc=pj_thread_init()) != 0) {
  ------------------
  |  Branch (218:9): [True: 0, False: 1]
  ------------------
  219|      0|        return rc;
  220|      0|    }
  221|       |
  222|       |    /* Critical section. */
  223|      1|    if ((rc=init_mutex(&critical_section, "critsec", PJ_MUTEX_RECURSE)) != 0)
  ------------------
  |  Branch (223:9): [True: 0, False: 1]
  ------------------
  224|      0|        return rc;
  225|       |
  226|      1|#endif
  227|       |
  228|       |    /* Initialize exception ID for the pool.
  229|       |     * Must do so after critical section is configured.
  230|       |     */
  231|      1|    rc = pj_exception_id_alloc("PJLIB/No memory", &PJ_NO_MEMORY_EXCEPTION);
  232|      1|    if (rc != PJ_SUCCESS)
  ------------------
  |  Branch (232:9): [True: 0, False: 1]
  ------------------
  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|      1|    guid.ptr = dummy_guid;
  241|      1|    pj_generate_unique_string( &guid );
  242|       |
  243|       |    /* Startup timestamp */
  244|      1|#if defined(PJ_HAS_HIGH_RES_TIMER) && PJ_HAS_HIGH_RES_TIMER != 0
  245|      1|    {
  246|      1|        pj_timestamp dummy_ts;
  247|      1|        if ((rc=pj_get_timestamp(&dummy_ts)) != 0) {
  ------------------
  |  Branch (247:13): [True: 0, False: 1]
  ------------------
  248|      0|            return rc;
  249|      0|        }
  250|      1|    }
  251|      1|#endif
  252|       |
  253|       |    /* Flag PJLIB as initialized */
  254|      1|    ++initialized;
  255|      1|    pj_assert(initialized == 1);
  ------------------
  |  |   65|      1|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (255:5): [True: 0, False: 1]
  |  Branch (255:5): [True: 1, False: 0]
  ------------------
  256|       |
  257|      1|    PJ_LOG(4,(THIS_FILE, "pjlib %s for POSIX initialized",
  ------------------
  |  |  106|      1|#define PJ_LOG(level,arg)       do { \
  |  |  107|      1|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      2|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 1, Folded]
  |  |  |  Branch (107:70): [True: 1, False: 0]
  |  |  ------------------
  |  |  108|      1|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      1|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      1|                                    } \
  |  |  110|      1|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 1]
  |  |  ------------------
  ------------------
  258|      1|              PJ_VERSION));
  259|       |
  260|      1|    return PJ_SUCCESS;
  261|      1|}
pj_atexit:
  267|      3|{
  268|      3|    if (atexit_count >= PJ_ARRAY_SIZE(atexit_func))
  ------------------
  |  |  315|      3|#define PJ_ARRAY_SIZE(a)    (sizeof(a)/sizeof(a[0]))
  ------------------
  |  Branch (268:9): [True: 0, False: 3]
  ------------------
  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|      3|    atexit_func[atexit_count++] = func;
  272|      3|    return PJ_SUCCESS;
  273|      3|}
pj_thread_register:
  608|      1|{
  609|      1|#if PJ_HAS_THREADS
  610|      1|    char stack_ptr;
  611|      1|    pj_status_t rc;
  612|      1|    pj_thread_t *thread = (pj_thread_t *)desc;
  613|      1|    pj_str_t thread_name = pj_str((char*)cstr_thread_name);
  614|       |
  615|       |    /* Size sanity check. */
  616|      1|    if (sizeof(pj_thread_desc) < sizeof(pj_thread_t)) {
  ------------------
  |  Branch (616:9): [Folded, False: 1]
  ------------------
  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|      1|    if (pj_thread_local_get (thread_tls_id) != 0) {
  ------------------
  |  Branch (622:9): [True: 0, False: 1]
  ------------------
  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|      1|    pj_assert(thread->signature1 != SIGNATURE1 ||
  ------------------
  |  |   65|      1|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (637:5): [True: 1, False: 0]
  |  Branch (637:5): [True: 0, False: 0]
  |  Branch (637:5): [True: 0, False: 0]
  |  Branch (637:5): [True: 1, False: 0]
  |  Branch (637:5): [True: 0, False: 0]
  |  Branch (637:5): [True: 0, False: 0]
  ------------------
  638|      1|              thread->signature2 != SIGNATURE2 ||
  639|      1|              (thread->thread == pthread_self()));
  640|       |
  641|       |    /* Initialize and set the thread entry. */
  642|      1|    pj_bzero(desc, sizeof(struct pj_thread_t));
  643|      1|    thread->thread = pthread_self();
  644|      1|    thread->signature1 = SIGNATURE1;
  ------------------
  |  |   70|      1|#define SIGNATURE1  0xDEAFBEEF
  ------------------
  645|      1|    thread->signature2 = SIGNATURE2;
  ------------------
  |  |   71|      1|#define SIGNATURE2  0xDEADC0DE
  ------------------
  646|       |
  647|      1|    if(cstr_thread_name && pj_strlen(&thread_name) < sizeof(thread->obj_name)-1)
  ------------------
  |  Branch (647:8): [True: 1, False: 0]
  |  Branch (647:28): [True: 1, False: 0]
  ------------------
  648|      1|        pj_ansi_snprintf(thread->obj_name, sizeof(thread->obj_name),
  ------------------
  |  |  114|      1|#define pj_ansi_snprintf        snprintf
  ------------------
  649|      1|                         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|      1|    rc = pj_thread_local_set(thread_tls_id, thread);
  655|      1|    if (rc != PJ_SUCCESS) {
  ------------------
  |  Branch (655:9): [True: 0, False: 1]
  ------------------
  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|      1|    PJ_UNUSED_ARG(stack_ptr);
  ------------------
  |  | 1537|      1|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  666|      1|#endif
  667|       |
  668|      1|    *ptr_thread = thread;
  669|      1|    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|      1|}
pj_thread_init:
  681|      1|{
  682|      1|#if PJ_HAS_THREADS
  683|      1|    pj_status_t rc;
  684|      1|    pj_thread_t *dummy;
  685|       |
  686|      1|    rc = pj_thread_local_alloc(&thread_tls_id );
  687|      1|    if (rc != PJ_SUCCESS) {
  ------------------
  |  Branch (687:9): [True: 0, False: 1]
  ------------------
  688|      0|        return rc;
  689|      0|    }
  690|      1|    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|      1|}
pj_thread_this:
  967|  6.81k|{
  968|  6.81k|#if PJ_HAS_THREADS
  969|  6.81k|    pj_thread_t *rec = (pj_thread_t*)pj_thread_local_get(thread_tls_id);
  970|       |
  971|  6.81k|    if (rec == NULL) {
  ------------------
  |  Branch (971:9): [True: 0, False: 6.81k]
  ------------------
  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|  6.81k|    return rec;
  984|       |#else
  985|       |    pj_assert(!"Threading is not enabled!");
  986|       |    return NULL;
  987|       |#endif
  988|  6.81k|}
pj_thread_sleep:
 1081|    850|{
 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|    850|    PJ_CHECK_STACK();
 1097|       |
 1098|    850|    pj_set_os_error(0);
 1099|       |
 1100|    850|    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|    850|    if (pj_get_native_os_error() == ETIMEDOUT)
  ------------------
  |  |   33|    850|#   define pj_get_native_os_error()         (errno)
  ------------------
  |  Branch (1112:9): [True: 0, False: 850]
  ------------------
 1113|      0|        return PJ_SUCCESS;
 1114|       |
 1115|    850|    return pj_get_os_error();
 1116|       |
 1117|    850|#endif  /* PJ_RTEMS */
 1118|    850|}
pj_atomic_create:
 1183|      2|{
 1184|       |#if EMULATE_ATOMICS
 1185|       |    pj_status_t rc;
 1186|       |#endif
 1187|      2|    pj_atomic_t *atomic_var;
 1188|       |
 1189|      2|    atomic_var = PJ_POOL_ZALLOC_T(pool, pj_atomic_t);
  ------------------
  |  |  583|      2|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
 1190|       |
 1191|      2|    PJ_ASSERT_RETURN(atomic_var, 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 (1191:5): [True: 0, False: 0]
  |  Branch (1191:5): [True: 0, False: 0]
  ------------------
 1192|       |
 1193|      2|#if HAS_STD_ATOMICS
 1194|      2|    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|      2|    *ptr_atomic = atomic_var;
 1205|      2|    return PJ_SUCCESS;
 1206|      2|}
pj_atomic_inc_and_get:
 1282|      1|{
 1283|      1|    pj_atomic_value_t new_value;
 1284|       |
 1285|      1|    PJ_CHECK_STACK();
 1286|       |
 1287|      1|#if HAS_STD_ATOMICS
 1288|      1|    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|      1|    return new_value;
 1298|      1|}
pj_atomic_inc:
 1303|      1|{
 1304|      1|    PJ_ASSERT_ON_FAIL(atomic_var, return);
  ------------------
  |  |  111|      1|            { \
  |  |  112|      1|                pj_assert(expr); \
  |  |  ------------------
  |  |  |  |   65|      1|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  113|      1|                if (!(expr)) exec_on_fail; \
  |  |  ------------------
  |  |  |  Branch (113:21): [True: 0, False: 1]
  |  |  ------------------
  |  |  114|      1|            }
  ------------------
  |  Branch (1304:5): [True: 0, False: 1]
  |  Branch (1304:5): [True: 1, False: 0]
  ------------------
 1305|      1|    pj_atomic_inc_and_get(atomic_var);
 1306|      1|}
pj_thread_local_alloc:
 1375|      5|{
 1376|      5|#if PJ_HAS_THREADS
 1377|      5|    pthread_key_t key;
 1378|      5|    int rc;
 1379|       |
 1380|      5|    PJ_ASSERT_RETURN(p_index != NULL, PJ_EINVAL);
  ------------------
  |  |   97|      5|            do { \
  |  |   98|      5|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 5]
  |  |  ------------------
  |  |   99|      5|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 5]
  |  |  ------------------
  ------------------
  |  Branch (1380:5): [True: 0, False: 0]
  |  Branch (1380:5): [True: 0, False: 0]
  ------------------
 1381|       |
 1382|      5|    pj_assert( sizeof(pthread_key_t) <= sizeof(long));
  ------------------
  |  |   65|      5|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (1382:5): [True: 0, Folded]
  |  Branch (1382:5): [True: 5, Folded]
  ------------------
 1383|      5|    if ((rc=pthread_key_create(&key, NULL)) != 0)
  ------------------
  |  Branch (1383:9): [True: 0, False: 5]
  ------------------
 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|      5|    *p_index = key;
 1387|      5|    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|      5|}
pj_thread_local_set:
 1422|  78.2k|{
 1423|       |    //Can't check stack because this function is called in the
 1424|       |    //beginning before main thread is initialized.
 1425|       |    //PJ_CHECK_STACK();
 1426|  78.2k|#if PJ_HAS_THREADS
 1427|  78.2k|    int rc=pthread_setspecific(index, value);
 1428|  78.2k|    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: 78.2k, False: 0]
  ------------------
 1429|       |#else
 1430|       |    pj_assert(index >= 0 && index < MAX_THREADS);
 1431|       |    tls[index] = value;
 1432|       |    return PJ_SUCCESS;
 1433|       |#endif
 1434|  78.2k|}
pj_thread_local_get:
 1437|   123k|{
 1438|       |    //Can't check stack because this function is called
 1439|       |    //by PJ_CHECK_STACK() itself!!!
 1440|       |    //PJ_CHECK_STACK();
 1441|   123k|#if PJ_HAS_THREADS
 1442|   123k|    return pthread_getspecific(index);
 1443|       |#else
 1444|       |    pj_assert(index >= 0 && index < MAX_THREADS);
 1445|       |    return tls[index];
 1446|       |#endif
 1447|   123k|}
pj_enter_critical_section:
 1451|      5|{
 1452|      5|#if PJ_HAS_THREADS
 1453|      5|    pj_mutex_lock(&critical_section);
 1454|      5|#endif
 1455|      5|}
pj_leave_critical_section:
 1458|      5|{
 1459|      5|#if PJ_HAS_THREADS
 1460|      5|    pj_mutex_unlock(&critical_section);
 1461|      5|#endif
 1462|      5|}
pj_mutex_create:
 1562|     71|{
 1563|     71|#if PJ_HAS_THREADS
 1564|     71|    pj_status_t rc;
 1565|     71|    pj_mutex_t *mutex;
 1566|       |
 1567|     71|    PJ_ASSERT_RETURN(pool && ptr_mutex, PJ_EINVAL);
  ------------------
  |  |   97|     71|            do { \
  |  |   98|    142|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 71, False: 0]
  |  |  |  Branch (98:23): [True: 71, False: 0]
  |  |  ------------------
  |  |   99|     71|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 71]
  |  |  ------------------
  ------------------
  |  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|     71|    mutex = PJ_POOL_ALLOC_T(pool, pj_mutex_t);
  ------------------
  |  |  569|     71|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
 1570|     71|    PJ_ASSERT_RETURN(mutex, PJ_ENOMEM);
  ------------------
  |  |   97|     71|            do { \
  |  |   98|     71|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 71]
  |  |  ------------------
  |  |   99|     71|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 71]
  |  |  ------------------
  ------------------
  |  Branch (1570:5): [True: 0, False: 0]
  |  Branch (1570:5): [True: 0, False: 0]
  ------------------
 1571|       |
 1572|     71|    if ((rc=init_mutex(mutex, name, type)) != PJ_SUCCESS)
  ------------------
  |  Branch (1572:9): [True: 0, False: 71]
  ------------------
 1573|      0|        return rc;
 1574|       |
 1575|     71|    *ptr_mutex = mutex;
 1576|     71|    return PJ_SUCCESS;
 1577|       |#else /* PJ_HAS_THREADS */
 1578|       |    *ptr_mutex = (pj_mutex_t*)1;
 1579|       |    return PJ_SUCCESS;
 1580|       |#endif
 1581|     71|}
pj_mutex_create_simple:
 1589|      1|{
 1590|      1|    return pj_mutex_create(pool, name, PJ_MUTEX_SIMPLE, mutex);
 1591|      1|}
pj_mutex_create_recursive:
 1599|      1|{
 1600|      1|    return pj_mutex_create(pool, name, PJ_MUTEX_RECURSE, mutex);
 1601|      1|}
pj_mutex_lock:
 1607|  3.40k|{
 1608|  3.40k|#if PJ_HAS_THREADS
 1609|  3.40k|    pj_status_t status;
 1610|       |
 1611|  3.40k|    PJ_CHECK_STACK();
 1612|  3.40k|    PJ_ASSERT_RETURN(mutex, PJ_EINVAL);
  ------------------
  |  |   97|  3.40k|            do { \
  |  |   98|  3.40k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 3.40k]
  |  |  ------------------
  |  |   99|  3.40k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 3.40k]
  |  |  ------------------
  ------------------
  |  Branch (1612:5): [True: 0, False: 0]
  |  Branch (1612:5): [True: 0, False: 0]
  ------------------
 1613|       |
 1614|  3.40k|#if PJ_DEBUG
 1615|  3.40k|    PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s is waiting (mutex owner=%s)",
  ------------------
  |  |  106|  3.40k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  3.40k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  6.81k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 3.40k]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  3.40k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 3.40k]
  |  |  ------------------
  ------------------
 1616|  3.40k|                                pj_thread_this()->obj_name,
 1617|  3.40k|                                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|  3.40k|    status = pthread_mutex_lock( &mutex->mutex );
 1624|       |
 1625|       |
 1626|  3.40k|#if PJ_DEBUG
 1627|  3.40k|    if (status == PJ_SUCCESS) {
  ------------------
  |  Branch (1627:9): [True: 3.40k, False: 0]
  ------------------
 1628|  3.40k|        mutex->owner = pj_thread_this();
 1629|  3.40k|        pj_ansi_strxcpy(mutex->owner_name, mutex->owner->obj_name,
 1630|  3.40k|                        sizeof(mutex->owner_name));
 1631|  3.40k|        ++mutex->nesting_level;
 1632|  3.40k|    }
 1633|       |
 1634|  3.40k|    PJ_LOG(6,(mutex->obj_name,
  ------------------
  |  |  106|  3.40k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  3.40k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  6.81k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 3.40k]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  3.40k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 3.40k]
  |  |  ------------------
  ------------------
 1635|  3.40k|              (status==0 ?
 1636|  3.40k|                "Mutex acquired by thread %s (level=%d)" :
 1637|  3.40k|                "Mutex acquisition FAILED by %s (level=%d)"),
 1638|  3.40k|              pj_thread_this()->obj_name,
 1639|  3.40k|              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|  3.40k|    if (status == 0)
  ------------------
  |  Branch (1646:9): [True: 3.40k, False: 0]
  ------------------
 1647|  3.40k|        return PJ_SUCCESS;
 1648|      0|    else
 1649|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1650|       |#else   /* PJ_HAS_THREADS */
 1651|       |    pj_assert( mutex == (pj_mutex_t*)1 );
 1652|       |    return PJ_SUCCESS;
 1653|       |#endif
 1654|  3.40k|}
pj_mutex_unlock:
 1660|  3.40k|{
 1661|  3.40k|#if PJ_HAS_THREADS
 1662|  3.40k|    pj_status_t status;
 1663|       |
 1664|  3.40k|    PJ_CHECK_STACK();
 1665|  3.40k|    PJ_ASSERT_RETURN(mutex, PJ_EINVAL);
  ------------------
  |  |   97|  3.40k|            do { \
  |  |   98|  3.40k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 3.40k]
  |  |  ------------------
  |  |   99|  3.40k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 3.40k]
  |  |  ------------------
  ------------------
  |  Branch (1665:5): [True: 0, False: 0]
  |  Branch (1665:5): [True: 0, False: 0]
  ------------------
 1666|       |
 1667|  3.40k|#if PJ_DEBUG
 1668|  3.40k|    pj_assert(mutex->owner == pj_thread_this());
  ------------------
  |  |   65|  3.40k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (1668:5): [True: 0, False: 3.40k]
  |  Branch (1668:5): [True: 3.40k, False: 0]
  ------------------
 1669|  3.40k|    if (--mutex->nesting_level == 0) {
  ------------------
  |  Branch (1669:9): [True: 3.40k, False: 2]
  ------------------
 1670|  3.40k|        mutex->owner = NULL;
 1671|  3.40k|        mutex->owner_name[0] = '\0';
 1672|  3.40k|    }
 1673|       |
 1674|  3.40k|    PJ_LOG(6,(mutex->obj_name, "Mutex released by thread %s (level=%d)",
  ------------------
  |  |  106|  3.40k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  3.40k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  6.81k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 3.40k]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  3.40k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 3.40k]
  |  |  ------------------
  ------------------
 1675|  3.40k|                                pj_thread_this()->obj_name,
 1676|  3.40k|                                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|  3.40k|    status = pthread_mutex_unlock( &mutex->mutex );
 1683|  3.40k|    if (status == 0)
  ------------------
  |  Branch (1683:9): [True: 3.40k, False: 0]
  ------------------
 1684|  3.40k|        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|  3.40k|}
pj_rwmutex_create:
 1805|      1|{
 1806|      1|    pj_rwmutex_t *rwm;
 1807|      1|    pj_status_t status;
 1808|       |
 1809|      1|    PJ_UNUSED_ARG(name);
  ------------------
  |  | 1537|      1|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1810|       |
 1811|      1|    rwm = PJ_POOL_ALLOC_T(pool, pj_rwmutex_t);
  ------------------
  |  |  569|      1|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
 1812|      1|    PJ_ASSERT_RETURN(rwm, PJ_ENOMEM);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (1812:5): [True: 0, False: 0]
  |  Branch (1812:5): [True: 0, False: 0]
  ------------------
 1813|       |
 1814|      1|    status = pthread_rwlock_init(&rwm->rwlock, NULL);
 1815|      1|    if (status != 0)
  ------------------
  |  Branch (1815:9): [True: 0, False: 1]
  ------------------
 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|      1|    *p_mutex = rwm;
 1819|      1|    return PJ_SUCCESS;
 1820|      1|}
pj_rwmutex_lock_write:
 1842|      1|{
 1843|      1|    pj_status_t status;
 1844|       |
 1845|      1|    status = pthread_rwlock_wrlock(&mutex->rwlock);
 1846|      1|    if (status != 0)
  ------------------
  |  Branch (1846:9): [True: 0, False: 1]
  ------------------
 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|      1|    return PJ_SUCCESS;
 1850|      1|}
pj_rwmutex_unlock_write:
 1866|      1|{
 1867|      1|    pj_status_t status;
 1868|       |
 1869|      1|    status = pthread_rwlock_unlock(&mutex->rwlock);
 1870|      1|    if (status != 0)
  ------------------
  |  Branch (1870:9): [True: 0, False: 1]
  ------------------
 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|      1|    return PJ_SUCCESS;
 1874|      1|}
os_core_unix.c:init_mutex:
 1473|     72|{
 1474|     72|#if PJ_HAS_THREADS
 1475|     72|    pthread_mutexattr_t attr;
 1476|     72|    int rc;
 1477|       |
 1478|     72|    PJ_CHECK_STACK();
 1479|       |
 1480|     72|    rc = pthread_mutexattr_init(&attr);
 1481|     72|    if (rc != 0)
  ------------------
  |  Branch (1481:9): [True: 0, False: 72]
  ------------------
 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|     72|    if (type == PJ_MUTEX_SIMPLE) {
  ------------------
  |  Branch (1484:9): [True: 3, False: 69]
  ------------------
 1485|      3|#if (defined(PJ_LINUX) && PJ_LINUX!=0) || \
 1486|      3|    defined(PJ_HAS_PTHREAD_MUTEXATTR_SETTYPE)
 1487|      3|        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|     69|    } else {
 1495|     69|#if (defined(PJ_LINUX) && PJ_LINUX!=0) || \
 1496|     69|     defined(PJ_HAS_PTHREAD_MUTEXATTR_SETTYPE)
 1497|     69|        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|     69|    }
 1514|       |
 1515|     72|    if (rc != 0) {
  ------------------
  |  Branch (1515:9): [True: 0, False: 72]
  ------------------
 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|     72|    rc = pthread_mutex_init(&mutex->mutex, &attr);
 1520|     72|    if (rc != 0) {
  ------------------
  |  Branch (1520:9): [True: 0, False: 72]
  ------------------
 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|     72|    rc = pthread_mutexattr_destroy(&attr);
 1525|     72|    if (rc != 0) {
  ------------------
  |  Branch (1525:9): [True: 0, False: 72]
  ------------------
 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|     72|#if PJ_DEBUG
 1532|       |    /* Set owner. */
 1533|     72|    mutex->nesting_level = 0;
 1534|     72|    mutex->owner = NULL;
 1535|     72|    mutex->owner_name[0] = '\0';
 1536|     72|#endif
 1537|       |
 1538|       |    /* Set name. */
 1539|     72|    if (!name) {
  ------------------
  |  Branch (1539:9): [True: 65, False: 7]
  ------------------
 1540|     65|        name = "mtx%p";
 1541|     65|    }
 1542|     72|    if (strchr(name, '%')) {
  ------------------
  |  Branch (1542:9): [True: 69, False: 3]
  ------------------
 1543|     69|        pj_ansi_snprintf(mutex->obj_name, PJ_MAX_OBJ_NAME, name, mutex);
  ------------------
  |  |  114|     69|#define pj_ansi_snprintf        snprintf
  ------------------
                      pj_ansi_snprintf(mutex->obj_name, PJ_MAX_OBJ_NAME, name, mutex);
  ------------------
  |  |  320|     69|#define PJ_MAX_OBJ_NAME 32
  ------------------
 1544|     69|    } else {
 1545|      3|        pj_ansi_strxcpy(mutex->obj_name, name, PJ_MAX_OBJ_NAME);
  ------------------
  |  |  320|      3|#define PJ_MAX_OBJ_NAME 32
  ------------------
 1546|      3|    }
 1547|       |
 1548|     72|    PJ_LOG(6, (mutex->obj_name, "Mutex created"));
  ------------------
  |  |  106|     72|#define PJ_LOG(level,arg)       do { \
  |  |  107|     72|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|    144|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 72]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|     72|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 72]
  |  |  ------------------
  ------------------
 1549|     72|    return PJ_SUCCESS;
 1550|       |#else /* PJ_HAS_THREADS */
 1551|       |    return PJ_SUCCESS;
 1552|       |#endif
 1553|     72|}

pj_get_os_error:
   24|    850|{
   25|    850|    return PJ_STATUS_FROM_OS(errno);
  ------------------
  |  |  334|    850|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  ------------------
  |  |  |  |  528|    850|#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: 850, False: 0]
  |  |  ------------------
  ------------------
   26|    850|}
pj_set_os_error:
   29|    850|{
   30|    850|    errno = PJ_STATUS_TO_OS(code);
  ------------------
  |  |  350|    850|#   define PJ_STATUS_TO_OS(e) (e == 0 ? PJ_SUCCESS : e - PJ_ERRNO_START_SYS)
  |  |  ------------------
  |  |  |  |  528|    850|#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: 850, False: 0]
  |  |  ------------------
  ------------------
   31|    850|}

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

pj_gettimeofday:
   32|      1|{
   33|      1|    struct timeval the_time;
   34|      1|    int rc;
   35|       |
   36|      1|    PJ_CHECK_STACK();
   37|       |
   38|      1|    rc = gettimeofday(&the_time, NULL);
   39|      1|    if (rc != 0)
  ------------------
  |  Branch (39:9): [True: 0, False: 1]
  ------------------
   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|    p_tv->sec = the_time.tv_sec;
   43|      1|    p_tv->msec = the_time.tv_usec / 1000;
   44|      1|    return PJ_SUCCESS;
   45|      1|}

pj_elapsed_time:
  165|    850|{
  166|    850|    pj_highprec_t elapsed = elapsed_msec(start, stop);
  167|    850|    pj_time_val tv_elapsed;
  168|       |
  169|    850|    if (PJ_HIGHPREC_VALUE_IS_ZERO(elapsed)) {
  ------------------
  |  |   30|    850|#   define PJ_HIGHPREC_VALUE_IS_ZERO(a)     (a==0)
  |  |  ------------------
  |  |  |  Branch (30:45): [True: 0, False: 850]
  |  |  ------------------
  ------------------
  170|      0|        tv_elapsed.sec = tv_elapsed.msec = 0;
  171|      0|        return tv_elapsed;
  172|    850|    } else {
  173|    850|        pj_highprec_t sec, msec;
  174|       |
  175|    850|        sec = elapsed;
  176|    850|        pj_highprec_div(sec, MSEC);
  ------------------
  |  |   64|    850|#   define pj_highprec_div(a1,a2)   (a1 = a1 / a2)
  ------------------
  177|    850|        tv_elapsed.sec = (long)sec;
  178|       |
  179|    850|        msec = elapsed;
  180|    850|        pj_highprec_mod(msec, MSEC);
  ------------------
  |  |   31|    850|#   define pj_highprec_mod(a,b)             (a=fmod(a,b))
  ------------------
  181|    850|        tv_elapsed.msec = (long)msec;
  182|       |
  183|    850|        return tv_elapsed;
  184|    850|    }
  185|    850|}
pj_gettickcount:
  194|    850|{
  195|    850|    pj_timestamp ts, start;
  196|    850|    pj_status_t status;
  197|       |
  198|    850|    if ((status = pj_get_timestamp(&ts)) != PJ_SUCCESS)
  ------------------
  |  Branch (198:9): [True: 0, False: 850]
  ------------------
  199|      0|        return status;
  200|       |
  201|    850|    pj_set_timestamp32(&start, 0, 0);
  202|    850|    *tv = pj_elapsed_time(&start, &ts);
  203|       |
  204|    850|    return PJ_SUCCESS;
  205|    850|}
os_timestamp_common.c:get_elapsed:
   33|    850|{
   34|    850|#if defined(PJ_HAS_INT64) && PJ_HAS_INT64!=0
   35|    850|    return u64tohighprec(stop->u64 - start->u64);
  ------------------
  |  |   29|    850|#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|    850|}
os_timestamp_common.c:elapsed_msec:
   51|    850|{
   52|    850|    pj_timestamp ts_freq;
   53|    850|    pj_highprec_t freq, elapsed;
   54|       |
   55|    850|    if (pj_get_timestamp_freq(&ts_freq) != PJ_SUCCESS)
  ------------------
  |  Branch (55:9): [True: 0, False: 850]
  ------------------
   56|      0|        return 0;
   57|       |
   58|       |    /* Convert frequency timestamp */
   59|    850|#if defined(PJ_HAS_INT64) && PJ_HAS_INT64!=0
   60|    850|    freq = u64tohighprec(ts_freq.u64);
  ------------------
  |  |   29|    850|#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|    850|    elapsed = get_elapsed(start, stop);
   69|       |
   70|       |    /* usec = elapsed * MSEC / freq */
   71|    850|    pj_highprec_div(freq, MSEC);
  ------------------
  |  |   64|    850|#   define pj_highprec_div(a1,a2)   (a1 = a1 / a2)
  ------------------
   72|       |     
   73|       |    /* Avoid division by zero. */
   74|    850|    if (freq == 0) {
  ------------------
  |  Branch (74:9): [True: 0, False: 850]
  ------------------
   75|       |      /* Regard freq = 1 */
   76|      0|      pj_highprec_mul(elapsed, MSEC);
  ------------------
  |  |   55|      0|#   define pj_highprec_mul(a1,a2)   (a1 = a1 * a2)
  ------------------
   77|    850|    } else {
   78|    850|      pj_highprec_div(elapsed, freq);
  ------------------
  |  |   64|    850|#   define pj_highprec_div(a1,a2)   (a1 = a1 / a2)
  ------------------
   79|    850|    }
   80|    850|    return elapsed;
   81|    850|}

pj_get_timestamp:
  228|    851|{
  229|    851|    struct timespec tp;
  230|       |
  231|    851|    if (clock_gettime(CLOCK_MONOTONIC, &tp) != 0) {
  ------------------
  |  Branch (231:9): [True: 0, False: 851]
  ------------------
  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|    851|    ts->u64 = tp.tv_sec;
  236|    851|    ts->u64 *= NSEC_PER_SEC;
  ------------------
  |  |  225|    851|#define NSEC_PER_SEC    1000000000
  ------------------
  237|    851|    ts->u64 += tp.tv_nsec;
  238|       |
  239|    851|    return PJ_SUCCESS;
  240|    851|}
pj_get_timestamp_freq:
  243|    850|{
  244|    850|    freq->u32.hi = 0;
  245|    850|    freq->u32.lo = NSEC_PER_SEC;
  ------------------
  |  |  225|    850|#define NSEC_PER_SEC    1000000000
  ------------------
  246|       |
  247|    850|    return PJ_SUCCESS;
  248|    850|}

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

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

pj_caching_pool_init:
   57|      1|{
   58|      1|    int i;
   59|      1|    pj_pool_t *pool;
   60|      1|    pj_status_t status;
   61|       |
   62|      1|    PJ_CHECK_STACK();
   63|       |
   64|      1|    pj_bzero(cp, sizeof(*cp));
   65|       |    
   66|      1|    cp->max_capacity = max_capacity;
   67|      1|    pj_list_init(&cp->used_list);
   68|     17|    for (i=0; i<PJ_CACHING_POOL_ARRAY_SIZE; ++i)
  ------------------
  |  |  889|     17|#define PJ_CACHING_POOL_ARRAY_SIZE      16
  ------------------
  |  Branch (68:15): [True: 16, False: 1]
  ------------------
   69|     16|        pj_list_init(&cp->free_list[i]);
   70|       |
   71|      1|    if (policy == NULL) {
  ------------------
  |  Branch (71:9): [True: 0, False: 1]
  ------------------
   72|      0|        policy = &pj_pool_factory_default_policy;
   73|      0|    }
   74|       |    
   75|      1|    pj_memcpy(&cp->factory.policy, policy, sizeof(pj_pool_factory_policy));
   76|      1|    cp->factory.create_pool = &cpool_create_pool;
   77|      1|    cp->factory.release_pool = &cpool_release_pool;
   78|      1|    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|      1|    PJ_UNUSED_ARG(cpool_on_block_alloc);
  ------------------
  |  | 1537|      1|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
   86|      1|    PJ_UNUSED_ARG(cpool_on_block_free);
  ------------------
  |  | 1537|      1|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
   87|       |
   88|      1|    pool = pj_pool_create_on_buf("cachingpool", cp->pool_buf, sizeof(cp->pool_buf));
   89|      1|    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|      1|    PJ_ASSERT_ON_FAIL(status==PJ_SUCCESS, return);
  ------------------
  |  |  111|      1|            { \
  |  |  112|      1|                pj_assert(expr); \
  |  |  ------------------
  |  |  |  |   65|      1|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  113|      1|                if (!(expr)) exec_on_fail; \
  |  |  ------------------
  |  |  |  Branch (113:21): [True: 0, False: 1]
  |  |  ------------------
  |  |  114|      1|            }
  ------------------
  |  Branch (92:5): [True: 0, False: 1]
  |  Branch (92:5): [True: 1, False: 0]
  ------------------
   93|      1|}
pool_caching.c:cpool_create_pool:
  138|    854|{
  139|    854|    pj_caching_pool *cp = (pj_caching_pool*)pf;
  140|    854|    pj_pool_t *pool;
  141|    854|    int idx;
  142|       |
  143|    854|    PJ_CHECK_STACK();
  144|       |
  145|    854|    pj_lock_acquire(cp->lock);
  146|       |
  147|       |    /* Use pool factory's policy when callback is NULL */
  148|    854|    if (callback == NULL) {
  ------------------
  |  Branch (148:9): [True: 2, False: 852]
  ------------------
  149|      2|        callback = pf->policy.callback;
  150|      2|    }
  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|    854|    if (initial_size <= pool_sizes[START_SIZE]) {
  ------------------
  |  |   51|    854|#define START_SIZE  5
  ------------------
  |  Branch (157:9): [True: 853, False: 1]
  ------------------
  158|    853|        for (idx=START_SIZE-1; 
  ------------------
  |  |   51|    853|#define START_SIZE  5
  ------------------
  159|  1.71k|             idx >= 0 && pool_sizes[idx] >= initial_size;
  ------------------
  |  Branch (159:14): [True: 1.71k, False: 0]
  |  Branch (159:26): [True: 860, False: 853]
  ------------------
  160|    860|             --idx)
  161|    860|            ;
  162|    853|        ++idx;
  163|    853|    } else {
  164|      1|        for (idx=START_SIZE+1; 
  ------------------
  |  |   51|      1|#define START_SIZE  5
  ------------------
  165|      2|             idx < PJ_CACHING_POOL_ARRAY_SIZE && 
  ------------------
  |  |  889|      4|#define PJ_CACHING_POOL_ARRAY_SIZE      16
  ------------------
  |  Branch (165:14): [True: 2, False: 0]
  ------------------
  166|      2|                  pool_sizes[idx] < initial_size;
  ------------------
  |  Branch (166:19): [True: 1, False: 1]
  ------------------
  167|      1|             ++idx)
  168|      1|            ;
  169|      1|    }
  170|       |
  171|       |    /* Check whether there's a pool in the list. */
  172|    854|    if (idx==PJ_CACHING_POOL_ARRAY_SIZE || pj_list_empty(&cp->free_list[idx])) {
  ------------------
  |  |  889|  1.70k|#define PJ_CACHING_POOL_ARRAY_SIZE      16
  ------------------
  |  Branch (172:9): [True: 0, False: 854]
  |  Branch (172:44): [True: 854, False: 0]
  ------------------
  173|       |        /* No pool is available. */
  174|       |        /* Set minimum size. */
  175|    854|        if (idx < PJ_CACHING_POOL_ARRAY_SIZE)
  ------------------
  |  |  889|    854|#define PJ_CACHING_POOL_ARRAY_SIZE      16
  ------------------
  |  Branch (175:13): [True: 854, False: 0]
  ------------------
  176|    854|            initial_size =  pool_sizes[idx];
  177|       |
  178|       |        /* Create new pool */
  179|    854|        pool = pj_pool_create_int(&cp->factory, name, initial_size, 
  180|    854|                                  increment_sz, alignment, callback);
  181|    854|        if (!pool) {
  ------------------
  |  Branch (181:13): [True: 0, False: 854]
  ------------------
  182|      0|            pj_lock_release(cp->lock);
  183|      0|            return NULL;
  184|      0|        }
  185|       |
  186|    854|    } else {
  187|       |        /* Get one pool from the list. */
  188|      0|        pool = (pj_pool_t*) cp->free_list[idx].next;
  189|      0|        pj_list_erase(pool);
  190|       |
  191|       |        /* Initialize the pool. */
  192|      0|        pj_pool_init_int(pool, name, increment_sz, alignment, callback);
  193|       |
  194|       |        /* Update pool manager's free capacity. */
  195|      0|        if (cp->capacity > pj_pool_get_capacity(pool)) {
  ------------------
  |  Branch (195:13): [True: 0, False: 0]
  ------------------
  196|      0|            cp->capacity -= pj_pool_get_capacity(pool);
  197|      0|        } else {
  198|      0|            cp->capacity = 0;
  199|      0|        }
  200|       |
  201|      0|        PJ_LOG(6, (pool->obj_name, "pool reused, size=%lu",
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  202|      0|                   (unsigned long)pool->capacity));
  203|      0|    }
  204|       |
  205|       |    /* Put in used list. */
  206|    854|    pj_list_insert_before( &cp->used_list, pool );
  207|       |
  208|       |    /* Mark factory data */
  209|    854|    pool->factory_data = (void*) (pj_ssize_t) idx;
  210|       |
  211|       |    /* Increment used count. */
  212|    854|    ++cp->used_count;
  213|       |
  214|    854|    pj_lock_release(cp->lock);
  215|    854|    return pool;
  216|    854|}
pool_caching.c:cpool_release_pool:
  219|    850|{
  220|    850|    pj_caching_pool *cp = (pj_caching_pool*)pf;
  221|    850|    pj_size_t pool_capacity;
  222|    850|    unsigned i;
  223|       |
  224|    850|    PJ_CHECK_STACK();
  225|       |
  226|    850|    PJ_ASSERT_ON_FAIL(pf && pool, return);
  ------------------
  |  |  111|    850|            { \
  |  |  112|    850|                pj_assert(expr); \
  |  |  ------------------
  |  |  |  |   65|    850|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  113|  1.70k|                if (!(expr)) exec_on_fail; \
  |  |  ------------------
  |  |  |  Branch (113:23): [True: 850, False: 0]
  |  |  |  Branch (113:23): [True: 850, False: 0]
  |  |  ------------------
  |  |  114|    850|            }
  ------------------
  |  Branch (226:5): [True: 0, False: 850]
  |  Branch (226:5): [True: 0, False: 0]
  |  Branch (226:5): [True: 850, False: 0]
  |  Branch (226:5): [True: 850, False: 0]
  ------------------
  227|       |
  228|    850|    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|    850|    pj_list_erase(pool);
  241|       |
  242|       |    /* Decrement used count. */
  243|    850|    --cp->used_count;
  244|       |
  245|    850|    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|    850|    if (pool_capacity > pool_sizes[PJ_CACHING_POOL_ARRAY_SIZE-1] ||
  ------------------
  |  |  889|    850|#define PJ_CACHING_POOL_ARRAY_SIZE      16
  ------------------
  |  Branch (251:9): [True: 66, False: 784]
  ------------------
  252|    784|        cp->capacity + pool_capacity > cp->max_capacity)
  ------------------
  |  Branch (252:9): [True: 784, False: 0]
  ------------------
  253|    850|    {
  254|    850|        pj_pool_destroy_int(pool);
  255|    850|        pj_lock_release(cp->lock);
  256|    850|        return;
  257|    850|    }
  258|       |
  259|       |    /* Reset pool. */
  260|      0|    PJ_LOG(6, (pool->obj_name, "recycle(): cap=%lu, used=%lu(%lu%%)", 
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  261|      0|               (unsigned long)pool_capacity,
  262|      0|               (unsigned long)pj_pool_get_used_size(pool), 
  263|      0|               (unsigned long)(pj_pool_get_used_size(pool)*100/
  264|      0|                               pool_capacity)));
  265|      0|    pj_pool_reset(pool);
  266|       |
  267|      0|    pool_capacity = pj_pool_get_capacity(pool);
  268|       |
  269|       |    /*
  270|       |     * Otherwise put the pool in our recycle list.
  271|       |     */
  272|      0|    i = (unsigned) (unsigned long) (pj_ssize_t) pool->factory_data;
  273|       |
  274|      0|    pj_assert(i<PJ_CACHING_POOL_ARRAY_SIZE);
  ------------------
  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (274:5): [True: 0, False: 0]
  |  Branch (274:5): [True: 0, False: 0]
  ------------------
  275|      0|    if (i >= PJ_CACHING_POOL_ARRAY_SIZE ) {
  ------------------
  |  |  889|      0|#define PJ_CACHING_POOL_ARRAY_SIZE      16
  ------------------
  |  Branch (275:9): [True: 0, False: 0]
  ------------------
  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|      0|    pj_list_insert_after(&cp->free_list[i], pool);
  283|      0|    cp->capacity += pool_capacity;
  284|       |
  285|      0|    pj_lock_release(cp->lock);
  286|      0|}

pool_policy_malloc.c:default_block_alloc:
   33|  4.87k|{
   34|  4.87k|    void *p;
   35|       |
   36|  4.87k|    PJ_CHECK_STACK();
   37|       |
   38|  4.87k|    if (factory->on_block_alloc) {
  ------------------
  |  Branch (38:9): [True: 0, False: 4.87k]
  ------------------
   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|  4.87k|    p = malloc(size+(SIG_SIZE << 1));
  ------------------
  |  |   64|  4.87k|#   define SIG_SIZE         0
  ------------------
   46|       |
   47|  4.87k|    if (p == NULL) {
  ------------------
  |  Branch (47:9): [True: 0, False: 4.87k]
  ------------------
   48|      0|        if (factory->on_block_free) 
  ------------------
  |  Branch (48:13): [True: 0, False: 0]
  ------------------
   49|      0|            factory->on_block_free(factory, size);
   50|  4.87k|    } else {
   51|       |        /* Apply signature when PJ_SAFE_POOL is set. It will move
   52|       |         * "p" pointer forward.
   53|       |         */
   54|  4.87k|        APPLY_SIG(p, size);
   55|  4.87k|    }
   56|       |
   57|  4.87k|    return p;
   58|  4.87k|}
pool_policy_malloc.c:default_block_free:
   62|  4.85k|{
   63|  4.85k|    PJ_CHECK_STACK();
   64|       |
   65|  4.85k|    if (factory->on_block_free) 
  ------------------
  |  Branch (65:9): [True: 0, False: 4.85k]
  ------------------
   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|  4.85k|    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|  4.85k|    free(mem);
   78|  4.85k|}

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

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

pj_strltrim:
  201|  19.7k|{
  202|  19.7k|    char *end = str->ptr + str->slen;
  203|  19.7k|    register char *p = str->ptr;
  204|       |
  205|  19.7k|    pj_assert(str->slen >= 0);
  ------------------
  |  |   65|  19.7k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (205:5): [True: 0, False: 19.7k]
  |  Branch (205:5): [True: 19.7k, False: 0]
  ------------------
  206|       |
  207|  20.6k|    while (p < end && pj_isspace(*p))
  ------------------
  |  Branch (207:12): [True: 20.1k, False: 450]
  |  Branch (207:23): [True: 872, False: 19.2k]
  ------------------
  208|    872|        ++p;
  209|  19.7k|    str->slen -= (p - str->ptr);
  210|  19.7k|    str->ptr = p;
  211|  19.7k|    return str;
  212|  19.7k|}
pj_strrtrim:
  215|  3.70k|{
  216|  3.70k|    char *end = str->ptr + str->slen;
  217|  3.70k|    register char *p = end - 1;
  218|       |
  219|  3.70k|    pj_assert(str->slen >= 0);
  ------------------
  |  |   65|  3.70k|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (219:5): [True: 0, False: 3.70k]
  |  Branch (219:5): [True: 3.70k, False: 0]
  ------------------
  220|       |
  221|  5.02k|    while (p >= str->ptr && pj_isspace(*p))
  ------------------
  |  Branch (221:12): [True: 4.77k, False: 242]
  |  Branch (221:29): [True: 1.31k, False: 3.46k]
  ------------------
  222|  1.31k|        --p;
  223|  3.70k|    str->slen -= ((end - p) - 1);
  224|  3.70k|    return str;
  225|  3.70k|}
pj_strtol2:
  274|  8.06k|{
  275|  8.06k|    pj_str_t s;
  276|  8.06k|    unsigned long retval = 0;
  277|  8.06k|    pj_bool_t is_negative = PJ_FALSE;
  278|  8.06k|    int rc = 0;
  279|       |
  280|  8.06k|    PJ_CHECK_STACK();
  281|       |
  282|  8.06k|    if (!str || !value) {
  ------------------
  |  Branch (282:9): [True: 0, False: 8.06k]
  |  Branch (282:17): [True: 0, False: 8.06k]
  ------------------
  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|  8.06k|    PJ_ASSERT_RETURN(str->slen >= 0, PJ_EINVAL);
  ------------------
  |  |   97|  8.06k|            do { \
  |  |   98|  8.06k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 8.06k]
  |  |  ------------------
  |  |   99|  8.06k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 8.06k]
  |  |  ------------------
  ------------------
  |  Branch (285:5): [True: 0, False: 0]
  |  Branch (285:5): [True: 0, False: 0]
  ------------------
  286|       |
  287|  8.06k|    s = *str;
  288|  8.06k|    pj_strltrim(&s);
  289|       |
  290|  8.06k|    if (s.slen == 0)
  ------------------
  |  Branch (290:9): [True: 96, False: 7.96k]
  ------------------
  291|     96|        return PJ_EINVAL;
  ------------------
  |  |  393|     96|#define PJ_EINVAL           (PJ_ERRNO_START_STATUS + 4) /* 70004 */
  |  |  ------------------
  |  |  |  |  521|     96|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|     96|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|     96|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  292|       |
  293|  7.96k|    if (s.ptr[0] == '+' || s.ptr[0] == '-') {
  ------------------
  |  Branch (293:9): [True: 268, False: 7.70k]
  |  Branch (293:28): [True: 146, False: 7.55k]
  ------------------
  294|    414|        is_negative = (s.ptr[0] == '-');
  295|    414|        s.ptr += 1;
  296|    414|        s.slen -= 1;
  297|    414|    }
  298|       |
  299|  7.96k|    rc = pj_strtoul3(&s, &retval, 10);
  300|  7.96k|    if (rc == PJ_EINVAL) {
  ------------------
  |  |  393|  7.96k|#define PJ_EINVAL           (PJ_ERRNO_START_STATUS + 4) /* 70004 */
  |  |  ------------------
  |  |  |  |  521|  7.96k|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|  7.96k|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|  7.96k|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (300:9): [True: 348, False: 7.62k]
  ------------------
  301|    348|        return rc;
  302|  7.62k|    } else if (rc != PJ_SUCCESS) {
  ------------------
  |  Branch (302:16): [True: 34, False: 7.58k]
  ------------------
  303|     34|        *value = is_negative ? PJ_MINLONG : PJ_MAXLONG;
  ------------------
  |  |   45|     34|#define PJ_MINLONG      LONG_MIN
  ------------------
                      *value = is_negative ? PJ_MINLONG : PJ_MAXLONG;
  ------------------
  |  |   42|     34|#define PJ_MAXLONG      LONG_MAX
  ------------------
  |  Branch (303:18): [True: 2, False: 32]
  ------------------
  304|     34|        return is_negative ? PJ_ETOOSMALL : PJ_ETOOBIG;
  ------------------
  |  |  469|      2|#define PJ_ETOOSMALL        (PJ_ERRNO_START_STATUS + 19)/* 70019 */
  |  |  ------------------
  |  |  |  |  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
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      return is_negative ? PJ_ETOOSMALL : PJ_ETOOBIG;
  ------------------
  |  |  458|     32|#define PJ_ETOOBIG          (PJ_ERRNO_START_STATUS + 17)/* 70017 */
  |  |  ------------------
  |  |  |  |  521|     32|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|     32|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|     32|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (304:16): [True: 2, False: 32]
  ------------------
  305|     34|    }
  306|       |
  307|  7.58k|    if (retval > PJ_MAXLONG && !is_negative) {
  ------------------
  |  |   42|  15.1k|#define PJ_MAXLONG      LONG_MAX
  ------------------
  |  Branch (307:9): [True: 200, False: 7.38k]
  |  Branch (307:32): [True: 198, False: 2]
  ------------------
  308|    198|        *value = PJ_MAXLONG;
  ------------------
  |  |   42|    198|#define PJ_MAXLONG      LONG_MAX
  ------------------
  309|    198|        return PJ_ETOOBIG;
  ------------------
  |  |  458|    198|#define PJ_ETOOBIG          (PJ_ERRNO_START_STATUS + 17)/* 70017 */
  |  |  ------------------
  |  |  |  |  521|    198|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|    198|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|    198|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  310|    198|    }
  311|       |
  312|  7.38k|    if (retval > (PJ_MAXLONG + 1UL) && is_negative) {
  ------------------
  |  |   42|  7.38k|#define PJ_MAXLONG      LONG_MAX
  ------------------
  |  Branch (312:9): [True: 2, False: 7.38k]
  |  Branch (312:40): [True: 2, False: 0]
  ------------------
  313|      2|        *value = PJ_MINLONG;
  ------------------
  |  |   45|      2|#define PJ_MINLONG      LONG_MIN
  ------------------
  314|      2|        return PJ_ETOOSMALL;
  ------------------
  |  |  469|      2|#define PJ_ETOOSMALL        (PJ_ERRNO_START_STATUS + 19)/* 70019 */
  |  |  ------------------
  |  |  |  |  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
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  315|      2|    }
  316|       |
  317|  7.38k|    if (is_negative && retval == PJ_MAXLONG + 1UL) {
  ------------------
  |  |   42|    140|#define PJ_MAXLONG      LONG_MAX
  ------------------
  |  Branch (317:9): [True: 140, False: 7.24k]
  |  Branch (317:24): [True: 0, False: 140]
  ------------------
  318|      0|        *value = PJ_MINLONG;
  ------------------
  |  |   45|      0|#define PJ_MINLONG      LONG_MIN
  ------------------
  319|      0|        return PJ_SUCCESS;
  320|      0|    }
  321|       |
  322|  7.38k|    *value = is_negative ? -(long)retval : retval;
  ------------------
  |  Branch (322:14): [True: 140, False: 7.24k]
  ------------------
  323|       |
  324|  7.38k|    return PJ_SUCCESS;
  325|  7.38k|}
pj_strtoul:
  328|    178|{
  329|    178|    unsigned long value;
  330|    178|    unsigned i;
  331|       |
  332|    178|    PJ_CHECK_STACK();
  333|       |
  334|    178|    pj_assert(str->slen >= 0);
  ------------------
  |  |   65|    178|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (334:5): [True: 0, False: 178]
  |  Branch (334:5): [True: 178, False: 0]
  ------------------
  335|       |
  336|    178|    value = 0;
  337|    982|    for (i=0; i<(unsigned)str->slen; ++i) {
  ------------------
  |  Branch (337:15): [True: 874, False: 108]
  ------------------
  338|    874|        if (!pj_isdigit(str->ptr[i]))
  ------------------
  |  Branch (338:13): [True: 70, False: 804]
  ------------------
  339|     70|            break;
  340|    804|        value = value * 10 + (str->ptr[i] - '0');
  341|    804|    }
  342|    178|    return value;
  343|    178|}
pj_strtoul3:
  385|  7.96k|{
  386|  7.96k|    pj_str_t s;
  387|  7.96k|    unsigned i;
  388|       |
  389|  7.96k|    PJ_CHECK_STACK();
  390|       |
  391|  7.96k|    if (!str || !value) {
  ------------------
  |  Branch (391:9): [True: 0, False: 7.96k]
  |  Branch (391:17): [True: 0, False: 7.96k]
  ------------------
  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|  7.96k|    PJ_ASSERT_RETURN(str->slen >= 0, PJ_EINVAL);
  ------------------
  |  |   97|  7.96k|            do { \
  |  |   98|  7.96k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 7.96k]
  |  |  ------------------
  |  |   99|  7.96k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 7.96k]
  |  |  ------------------
  ------------------
  |  Branch (394:5): [True: 0, False: 0]
  |  Branch (394:5): [True: 0, False: 0]
  ------------------
  395|       |    
  396|  7.96k|    s = *str;
  397|  7.96k|    pj_strltrim(&s);
  398|       |
  399|  7.96k|    if (s.slen == 0 || s.ptr[0] < '0' ||
  ------------------
  |  Branch (399:9): [True: 112, False: 7.85k]
  |  Branch (399:24): [True: 104, False: 7.75k]
  ------------------
  400|  7.75k|        (base <= 10 && (unsigned)s.ptr[0] > ('0' - 1) + base) ||
  ------------------
  |  Branch (400:10): [True: 7.75k, False: 0]
  |  Branch (400:24): [True: 132, False: 7.62k]
  ------------------
  401|  7.62k|        (base == 16 && !pj_isxdigit(s.ptr[0])))
  ------------------
  |  Branch (401:10): [True: 0, False: 7.62k]
  |  Branch (401:24): [True: 0, False: 0]
  ------------------
  402|    348|    {
  403|    348|        return PJ_EINVAL;
  ------------------
  |  |  393|    348|#define PJ_EINVAL           (PJ_ERRNO_START_STATUS + 4) /* 70004 */
  |  |  ------------------
  |  |  |  |  521|    348|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|    348|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|    348|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  404|    348|    }
  405|       |
  406|  7.62k|    *value = 0;
  407|  7.62k|    if (base <= 10) {
  ------------------
  |  Branch (407:9): [True: 7.62k, False: 0]
  ------------------
  408|  35.7k|        for (i=0; i<(unsigned)s.slen; ++i) {
  ------------------
  |  Branch (408:19): [True: 29.2k, False: 6.56k]
  ------------------
  409|  29.2k|            unsigned c = s.ptr[i] - '0';
  410|  29.2k|            if (s.ptr[i] < '0' || (unsigned)s.ptr[i] > ('0' - 1) + base) {
  ------------------
  |  Branch (410:17): [True: 116, False: 29.0k]
  |  Branch (410:35): [True: 910, False: 28.1k]
  ------------------
  411|  1.02k|                break;
  412|  1.02k|            }
  413|  28.1k|            if (*value > PJ_MAXULONG / base) {
  ------------------
  |  |   48|  28.1k|#define PJ_MAXULONG     ULONG_MAX
  ------------------
  |  Branch (413:17): [True: 34, False: 28.1k]
  ------------------
  414|     34|                *value = PJ_MAXULONG;
  ------------------
  |  |   48|     34|#define PJ_MAXULONG     ULONG_MAX
  ------------------
  415|     34|                return PJ_ETOOBIG;
  ------------------
  |  |  458|     34|#define PJ_ETOOBIG          (PJ_ERRNO_START_STATUS + 17)/* 70017 */
  |  |  ------------------
  |  |  |  |  521|     34|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|     34|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|     34|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  416|     34|            }
  417|       |
  418|  28.1k|            *value *= base;
  419|  28.1k|            if ((PJ_MAXULONG - *value) < c) {
  ------------------
  |  |   48|  28.1k|#define PJ_MAXULONG     ULONG_MAX
  ------------------
  |  Branch (419:17): [True: 0, False: 28.1k]
  ------------------
  420|      0|                *value = PJ_MAXULONG;
  ------------------
  |  |   48|      0|#define PJ_MAXULONG     ULONG_MAX
  ------------------
  421|      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
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  422|      0|            }
  423|  28.1k|            *value += c;
  424|  28.1k|        }
  425|  7.62k|    } 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|  7.58k|    return PJ_SUCCESS;
  447|  7.62k|}
pj_utoa_pad:
  561|      4|{
  562|      4|    char *p;
  563|      4|    int len;
  564|       |
  565|      4|    PJ_CHECK_STACK();
  566|       |
  567|      4|    p = buf;
  568|      8|    do {
  569|      8|        unsigned long digval = (unsigned long) (val % 10);
  570|      8|        val /= 10;
  571|      8|        *p++ = (char) (digval + '0');
  572|      8|    } while (val > 0);
  ------------------
  |  Branch (572:14): [True: 4, False: 4]
  ------------------
  573|       |
  574|      4|    len = (int)(p-buf);
  575|      5|    while (len < min_dig) {
  ------------------
  |  Branch (575:12): [True: 1, False: 4]
  ------------------
  576|      1|        *p++ = (char)pad;
  577|      1|        ++len;
  578|      1|    }
  579|      4|    *p-- = '\0';
  580|       |
  581|      4|    do {
  582|      4|        char temp = *p;
  583|      4|        *p = *buf;
  584|      4|        *buf = temp;
  585|      4|        --p;
  586|      4|        ++buf;
  587|      4|    } while (buf < p);
  ------------------
  |  Branch (587:14): [True: 0, False: 4]
  ------------------
  588|       |
  589|      4|    return len;
  590|      4|}
pj_ansi_strxcpy:
  631|  4.26k|{
  632|  4.26k|    char *odst = dst;
  633|       |
  634|  4.26k|    PJ_ASSERT_RETURN(dst && src, -PJ_EINVAL);
  ------------------
  |  |   97|  4.26k|            do { \
  |  |   98|  8.53k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 4.26k, False: 0]
  |  |  |  Branch (98:23): [True: 4.26k, False: 0]
  |  |  ------------------
  |  |   99|  4.26k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 4.26k]
  |  |  ------------------
  ------------------
  |  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|  4.26k|    if (dst_size==0)
  ------------------
  |  Branch (636:9): [True: 0, False: 4.26k]
  ------------------
  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|  65.6k|    while (--dst_size && (*dst=*src) != 0) {
  ------------------
  |  Branch (639:12): [True: 65.6k, False: 0]
  |  Branch (639:26): [True: 61.4k, False: 4.26k]
  ------------------
  640|  61.4k|        ++dst;
  641|  61.4k|        ++src;
  642|  61.4k|    }
  643|       |
  644|  4.26k|    if (!*dst && !*src) {
  ------------------
  |  Branch (644:9): [True: 4.26k, False: 0]
  |  Branch (644:18): [True: 4.26k, False: 0]
  ------------------
  645|  4.26k|        return (int)(dst-odst);
  646|  4.26k|    } else {
  647|      0|        *dst = '\0';
  648|      0|        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: 0]
  ------------------
  649|      0|    }
  650|  4.26k|}

pj_timer_heap_create:
  592|      1|{
  593|      1|    pj_timer_heap_t *ht;
  594|      1|    pj_size_t i;
  595|       |
  596|      1|    PJ_ASSERT_RETURN(pool && p_heap, PJ_EINVAL);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 1, False: 0]
  |  |  |  Branch (98:23): [True: 1, False: 0]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  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|      1|    *p_heap = NULL;
  599|       |
  600|       |    /* Magic? */
  601|      1|    size += 2;
  602|       |
  603|       |    /* Allocate timer heap data structure from the pool */
  604|      1|    ht = PJ_POOL_ZALLOC_T(pool, pj_timer_heap_t);
  ------------------
  |  |  583|      1|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  605|      1|    if (!ht)
  ------------------
  |  Branch (605:9): [True: 0, False: 1]
  ------------------
  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|      1|    ht->max_size = size;
  610|      1|    ht->cur_size = 0;
  611|      1|    ht->max_entries_per_poll = DEFAULT_MAX_TIMED_OUT_PER_POLL;
  ------------------
  |  |   46|      1|#define DEFAULT_MAX_TIMED_OUT_PER_POLL  (64)
  ------------------
  612|      1|    ht->timer_ids_freelist = 1;
  613|      1|    ht->pool = pool;
  614|       |
  615|       |    /* Lock. */
  616|      1|    ht->lock = NULL;
  617|      1|    ht->auto_delete_lock = 0;
  618|       |
  619|       |    // Create the heap array.
  620|      1|    ht->heap = (pj_timer_entry_dup**)
  621|      1|               pj_pool_calloc(pool, (unsigned)size,
  622|      1|                              sizeof(pj_timer_entry_dup*));
  623|      1|    if (!ht->heap)
  ------------------
  |  Branch (623:9): [True: 0, False: 1]
  ------------------
  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|      1|#if PJ_TIMER_USE_COPY
  627|       |    // Create the timer entry copies array.
  628|      1|    ht->timer_dups = (pj_timer_entry_dup*)
  629|      1|                     pj_pool_alloc(pool, sizeof(pj_timer_entry_dup) * size);
  630|      1|    if (!ht->timer_dups)
  ------------------
  |  Branch (630:9): [True: 0, False: 1]
  ------------------
  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|      1|#endif
  633|       |
  634|       |    // Create the parallel
  635|      1|    ht->timer_ids = (pj_timer_id_t *)
  636|      1|                    pj_pool_alloc( pool, sizeof(pj_timer_id_t) * size);
  637|      1|    if (!ht->timer_ids)
  ------------------
  |  Branch (637:9): [True: 0, False: 1]
  ------------------
  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|  3.07k|    for (i=0; i<size; ++i)
  ------------------
  |  Branch (643:15): [True: 3.07k, False: 1]
  ------------------
  644|  3.07k|        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|      1|    *p_heap = ht;
  651|      1|    return PJ_SUCCESS;
  652|      1|}
pj_timer_heap_set_lock:
  665|      1|{
  666|      1|    if (ht->lock && ht->auto_delete_lock)
  ------------------
  |  Branch (666:9): [True: 0, False: 1]
  |  Branch (666:21): [True: 0, False: 0]
  ------------------
  667|      0|        pj_lock_destroy(ht->lock);
  668|       |
  669|      1|    ht->lock = lock;
  670|      1|    ht->auto_delete_lock = auto_del;
  671|      1|}
pj_timer_heap_set_max_timed_out_per_poll:
  676|      1|{
  677|      1|    unsigned old_count = ht->max_entries_per_poll;
  678|      1|    ht->max_entries_per_poll = count;
  679|      1|    return old_count;
  680|      1|}
pj_timer_heap_poll:
  860|    850|{
  861|    850|    pj_time_val now;
  862|    850|    pj_time_val min_time_node = {0,0};
  863|    850|    unsigned count;
  864|    850|    pj_timer_id_t slot = 0;
  865|       |
  866|    850|    PJ_ASSERT_RETURN(ht, 0);
  ------------------
  |  |   97|    850|            do { \
  |  |   98|    850|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 850]
  |  |  ------------------
  |  |   99|    850|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 850]
  |  |  ------------------
  ------------------
  |  Branch (866:5): [True: 0, False: 0]
  |  Branch (866:5): [True: 0, False: 0]
  ------------------
  867|       |
  868|    850|    lock_timer_heap(ht);
  869|    850|    if (!ht->cur_size && next_delay) {
  ------------------
  |  Branch (869:9): [True: 850, False: 0]
  |  Branch (869:26): [True: 850, False: 0]
  ------------------
  870|    850|        next_delay->sec = next_delay->msec = PJ_MAXINT32;
  ------------------
  |  |   30|    850|#define PJ_MAXINT32     0x7fffffff
  ------------------
  871|    850|        unlock_timer_heap(ht);
  872|    850|        return 0;
  873|    850|    }
  874|       |
  875|      0|    count = 0;
  876|      0|    pj_gettickcount(&now);
  877|       |
  878|      0|    if (ht->cur_size) {
  ------------------
  |  Branch (878:9): [True: 0, 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|      0|        min_time_node = ht->heap[slot]->_timer_value;
  883|      0|    }
  884|       |
  885|      0|    while ( ht->cur_size && 
  ------------------
  |  Branch (885:13): [True: 0, False: 0]
  ------------------
  886|      0|            PJ_TIME_VAL_LTE(min_time_node, now) &&
  ------------------
  |  |  529|      0|#define PJ_TIME_VAL_LTE(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  887|      0|            count < ht->max_entries_per_poll ) 
  ------------------
  |  Branch (887:13): [True: 0, False: 0]
  ------------------
  888|      0|    {
  889|      0|        pj_timer_entry_dup *node = remove_node(ht, slot);
  890|      0|        pj_timer_entry *entry = GET_ENTRY(node);
  ------------------
  |  |  106|      0|#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|      0|        pj_grp_lock_t *grp_lock;
  895|      0|        pj_bool_t valid = PJ_TRUE;
  896|       |
  897|      0|        ++count;
  898|       |
  899|      0|        grp_lock = node->_grp_lock;
  900|      0|        node->_grp_lock = NULL;
  901|      0|        if (GET_FIELD(node, cb) != entry->cb ||
  ------------------
  |  |  107|      0|#define GET_FIELD(node, _timer_id) node->dup._timer_id
  ------------------
  |  Branch (901:13): [True: 0, False: 0]
  ------------------
  902|      0|            GET_FIELD(node, user_data) != entry->user_data)
  ------------------
  |  |  107|      0|#define GET_FIELD(node, _timer_id) node->dup._timer_id
  ------------------
  |  Branch (902:13): [True: 0, False: 0]
  ------------------
  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|      0|        unlock_timer_heap(ht);
  922|       |
  923|      0|        PJ_RACE_ME(5);
  924|       |
  925|      0|        if (valid && entry->cb)
  ------------------
  |  Branch (925:13): [True: 0, False: 0]
  |  Branch (925:22): [True: 0, False: 0]
  ------------------
  926|      0|            (*entry->cb)(ht, entry);
  927|       |
  928|      0|        if (valid && grp_lock)
  ------------------
  |  Branch (928:13): [True: 0, False: 0]
  |  Branch (928:22): [True: 0, False: 0]
  ------------------
  929|      0|            pj_grp_lock_dec_ref(grp_lock);
  930|       |
  931|      0|        lock_timer_heap(ht);
  932|       |        /* Now, the timer is really free for re-use. */
  933|       |        ///push_freelist(ht, node_timer_id);
  934|       |
  935|      0|        if (ht->cur_size) {
  ------------------
  |  Branch (935:13): [True: 0, False: 0]
  ------------------
  936|       |#if PJ_TIMER_USE_LINKED_LIST
  937|       |            slot = ht->timer_ids[GET_FIELD(ht->head_list.next, _timer_id)];
  938|       |#endif
  939|      0|            min_time_node = ht->heap[slot]->_timer_value;
  940|       |            /* Update now */
  941|      0|            pj_gettickcount(&now);
  942|      0|        }
  943|      0|    }
  944|      0|    if (ht->cur_size && next_delay) {
  ------------------
  |  Branch (944:9): [True: 0, False: 0]
  |  Branch (944:25): [True: 0, False: 0]
  ------------------
  945|      0|        *next_delay = ht->heap[0]->_timer_value;
  946|      0|        if (count > 0)
  ------------------
  |  Branch (946:13): [True: 0, False: 0]
  ------------------
  947|      0|            pj_gettickcount(&now);
  948|      0|        PJ_TIME_VAL_SUB(*next_delay, now);
  ------------------
  |  |  554|      0|#define PJ_TIME_VAL_SUB(t1, t2)     do {                            \
  |  |  555|      0|                                        (t1).sec -= (t2).sec;       \
  |  |  556|      0|                                        (t1).msec -= (t2).msec;     \
  |  |  557|      0|                                        pj_time_val_normalize(&(t1)); \
  |  |  558|      0|                                    } while (0)
  |  |  ------------------
  |  |  |  Branch (558:46): [Folded, False: 0]
  |  |  ------------------
  ------------------
  949|      0|        if (next_delay->sec < 0 || next_delay->msec < 0)
  ------------------
  |  Branch (949:13): [True: 0, False: 0]
  |  Branch (949:36): [True: 0, False: 0]
  ------------------
  950|      0|            next_delay->sec = next_delay->msec = 0;
  951|      0|    } else if (next_delay) {
  ------------------
  |  Branch (951:16): [True: 0, False: 0]
  ------------------
  952|      0|        next_delay->sec = next_delay->msec = PJ_MAXINT32;
  ------------------
  |  |   30|      0|#define PJ_MAXINT32     0x7fffffff
  ------------------
  953|      0|    }
  954|      0|    unlock_timer_heap(ht);
  955|       |
  956|      0|    return count;
  957|    850|}
timer.c:lock_timer_heap:
  189|    850|{
  190|    850|    if (ht->lock) {
  ------------------
  |  Branch (190:9): [True: 850, False: 0]
  ------------------
  191|    850|        pj_lock_acquire(ht->lock);
  192|    850|    }
  193|    850|}
timer.c:unlock_timer_heap:
  196|    850|{
  197|    850|    if (ht->lock) {
  ------------------
  |  Branch (197:9): [True: 850, False: 0]
  ------------------
  198|    850|        pj_lock_release(ht->lock);
  199|    850|    }
  200|    850|}

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

sip_endpoint.c:pjsip_cfg:
  301|      1|{
  302|      1|    return &pjsip_sip_cfg_var;
  303|      1|}

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

pjsip_auth_srv_init:
   48|      1|{
   49|      1|    PJ_ASSERT_RETURN(pool && auth_srv && realm && lookup, PJ_EINVAL);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      6|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 1, False: 0]
  |  |  |  Branch (98:23): [True: 1, False: 0]
  |  |  |  Branch (98:23): [True: 1, False: 0]
  |  |  |  Branch (98:23): [True: 1, False: 0]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (49:5): [True: 0, False: 0]
  |  Branch (49:5): [True: 0, False: 0]
  |  Branch (49:5): [True: 0, False: 0]
  |  Branch (49:5): [True: 0, False: 0]
  |  Branch (49:5): [True: 0, False: 0]
  |  Branch (49:5): [True: 0, False: 0]
  |  Branch (49:5): [True: 0, False: 0]
  |  Branch (49:5): [True: 0, False: 0]
  ------------------
   50|       |
   51|      1|    pj_bzero(auth_srv, sizeof(*auth_srv));
   52|      1|    pj_strdup( pool, &auth_srv->realm, realm);
   53|      1|    auth_srv->lookup = lookup;
   54|      1|    auth_srv->is_proxy = (options & PJSIP_AUTH_SRV_IS_PROXY);
  ------------------
  |  |  450|      1|#define PJSIP_AUTH_SRV_IS_PROXY     1
  ------------------
   55|       |
   56|      1|    return PJ_SUCCESS;
   57|      1|}

pjsip_endpt_register_module:
  161|      1|{
  162|      1|    pj_status_t status = PJ_SUCCESS;
  163|      1|    pjsip_module *m;
  164|      1|    unsigned i;
  165|       |
  166|      1|    pj_rwmutex_lock_write(endpt->mod_mutex);
  167|       |
  168|      1|    if (endpt->mod_running && !endpt->mod_reg_unreg) {
  ------------------
  |  Branch (168:9): [True: 0, False: 1]
  |  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|      2|    PJ_ASSERT_ON_FAIL(  pj_list_find_node(&endpt->module_list, mod) == NULL,
  ------------------
  |  |  111|      1|            { \
  |  |  112|      1|                pj_assert(expr); \
  |  |  ------------------
  |  |  |  |   65|      1|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  113|      1|                if (!(expr)) exec_on_fail; \
  |  |  ------------------
  |  |  |  Branch (113:21): [True: 0, False: 1]
  |  |  ------------------
  |  |  114|      1|            }
  ------------------
  |  Branch (182:5): [True: 0, False: 1]
  |  Branch (182:5): [True: 1, False: 0]
  ------------------
  183|      2|                        {status = PJ_EEXISTS; goto on_return;});
  184|       |
  185|       |    /* Make sure that no module with the same name has been registered. */
  186|      2|    PJ_ASSERT_ON_FAIL(  pj_list_search(&endpt->module_list, &mod->name, 
  ------------------
  |  |  111|      1|            { \
  |  |  112|      1|                pj_assert(expr); \
  |  |  ------------------
  |  |  |  |   65|      1|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  113|      1|                if (!(expr)) exec_on_fail; \
  |  |  ------------------
  |  |  |  Branch (113:21): [True: 0, False: 1]
  |  |  ------------------
  |  |  114|      1|            }
  ------------------
  |  Branch (186:5): [True: 0, False: 1]
  |  Branch (186:5): [True: 1, False: 0]
  ------------------
  187|      2|                                       &cmp_mod_name)==NULL,
  188|      2|                        {status = PJ_EEXISTS; goto on_return; });
  189|       |
  190|       |    /* Find unused ID for this module. */
  191|      2|    for (i=0; i<PJ_ARRAY_SIZE(endpt->modules); ++i) {
  ------------------
  |  |  315|      1|#define PJ_ARRAY_SIZE(a)    (sizeof(a)/sizeof(a[0]))
  ------------------
  |  Branch (191:15): [True: 1, False: 0]
  ------------------
  192|      1|        if (endpt->modules[i] == NULL)
  ------------------
  |  Branch (192:13): [True: 1, False: 0]
  ------------------
  193|      1|            break;
  194|      1|    }
  195|      2|    if (i == PJ_ARRAY_SIZE(endpt->modules)) {
  ------------------
  |  |  315|      1|#define PJ_ARRAY_SIZE(a)    (sizeof(a)/sizeof(a[0]))
  ------------------
  |  Branch (195:9): [True: 0, False: 1]
  ------------------
  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|      1|    mod->id = i;
  203|       |
  204|       |    /* Try to load the module. */
  205|      1|    if (mod->load) {
  ------------------
  |  Branch (205:9): [True: 0, False: 1]
  ------------------
  206|      0|        status = (*mod->load)(endpt);
  207|      0|        if (status != PJ_SUCCESS)
  ------------------
  |  Branch (207:13): [True: 0, False: 0]
  ------------------
  208|      0|            goto on_return;
  209|      0|    }
  210|       |
  211|       |    /* Try to start the module. */
  212|      1|    if (mod->start) {
  ------------------
  |  Branch (212:9): [True: 0, False: 1]
  ------------------
  213|      0|        status = (*mod->start)();
  214|      0|        if (status != PJ_SUCCESS)
  ------------------
  |  Branch (214:13): [True: 0, False: 0]
  ------------------
  215|      0|            goto on_return;
  216|      0|    }
  217|       |
  218|       |    /* Save the module. */
  219|      1|    endpt->modules[i] = mod;
  220|       |
  221|       |    /* Put in the module list, sorted by priority. */
  222|      1|    m = endpt->module_list.next;
  223|      1|    while (m != &endpt->module_list) {
  ------------------
  |  Branch (223:12): [True: 0, False: 1]
  ------------------
  224|      0|        if (m->priority > mod->priority)
  ------------------
  |  Branch (224:13): [True: 0, False: 0]
  ------------------
  225|      0|            break;
  226|      0|        m = m->next;
  227|      0|    }
  228|      1|    pj_list_insert_before(m, mod);
  229|       |
  230|       |    /* Done. */
  231|       |
  232|      1|    PJ_LOG(4,(THIS_FILE, "Module \"%.*s\" registered", 
  ------------------
  |  |  106|      1|#define PJ_LOG(level,arg)       do { \
  |  |  107|      1|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      2|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 1, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 1]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  480|      0|    #define pj_log_wrapper_4(arg)       pj_log_4 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      1|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 1]
  |  |  ------------------
  ------------------
  233|      1|              (int)mod->name.slen, mod->name.ptr));
  234|       |
  235|      1|on_return:
  236|      1|    pj_rwmutex_unlock_write(endpt->mod_mutex);
  237|      1|    return status;
  238|      1|}
pjsip_endpt_create:
  452|      1|{
  453|      1|    pj_status_t status;
  454|      1|    pj_pool_t *pool;
  455|      1|    pjsip_endpoint *endpt;
  456|      1|    pjsip_max_fwd_hdr *mf_hdr;
  457|      1|    pj_lock_t *lock = NULL;
  458|       |
  459|       |
  460|      1|    status = pj_register_strerror(PJSIP_ERRNO_START, PJ_ERRNO_SPACE_SIZE,
  ------------------
  |  |   47|      1|#define PJSIP_ERRNO_START       (PJ_ERRNO_START_USER)
  |  |  ------------------
  |  |  |  |  535|      1|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  528|      1|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  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
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      1|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|      1|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  status = pj_register_strerror(PJSIP_ERRNO_START, PJ_ERRNO_SPACE_SIZE,
  ------------------
  |  |  515|      1|#define PJ_ERRNO_SPACE_SIZE     50000
  ------------------
  461|      1|                                  &pjsip_strerror);
  462|      1|    pj_assert(status == PJ_SUCCESS);
  ------------------
  |  |   65|      1|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (462:5): [True: 0, False: 1]
  |  Branch (462:5): [True: 1, False: 0]
  ------------------
  463|       |
  464|      1|    PJ_LOG(5, (THIS_FILE, "Creating endpoint instance..."));
  ------------------
  |  |  106|      1|#define PJ_LOG(level,arg)       do { \
  |  |  107|      1|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      2|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 1, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 1]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      1|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 1]
  |  |  ------------------
  ------------------
  465|       |
  466|      1|    *p_endpt = NULL;
  467|       |
  468|       |    /* Create pool */
  469|      1|    pool = pj_pool_create(pf, "pept%p", 
  470|      1|                          PJSIP_POOL_LEN_ENDPT, PJSIP_POOL_INC_ENDPT,
  ------------------
  |  |  974|      1|#   define PJSIP_POOL_LEN_ENDPT         (16000)
  ------------------
                                        PJSIP_POOL_LEN_ENDPT, PJSIP_POOL_INC_ENDPT,
  ------------------
  |  |  981|      1|#   define PJSIP_POOL_INC_ENDPT         (4000)
  ------------------
  471|      1|                          &pool_callback);
  472|      1|    if (!pool)
  ------------------
  |  Branch (472:9): [True: 0, False: 1]
  ------------------
  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|      1|    endpt = PJ_POOL_ZALLOC_T(pool, pjsip_endpoint);
  ------------------
  |  |  583|      1|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  477|      1|    endpt->pool = pool;
  478|      1|    endpt->pf = pf;
  479|       |
  480|       |    /* Init modules list. */
  481|      1|    pj_list_init(&endpt->module_list);
  482|       |
  483|       |    /* Initialize exit callback list. */
  484|      1|    pj_list_init(&endpt->exit_cb_list);
  485|       |
  486|       |    /* Create R/W mutex for module manipulation. */
  487|      1|    status = pj_rwmutex_create(endpt->pool, "ept%p", &endpt->mod_mutex);
  488|      1|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (488:9): [True: 0, False: 1]
  ------------------
  489|      0|        goto on_error;
  490|       |
  491|       |    /* Init parser. */
  492|      1|    init_sip_parser();
  493|       |
  494|       |    /* Init tel: uri */
  495|      1|    pjsip_tel_uri_subsys_init();
  496|       |
  497|       |    /* Get name. */
  498|      1|    if (name != NULL) {
  ------------------
  |  Branch (498:9): [True: 1, False: 0]
  ------------------
  499|      1|        pj_str_t temp;
  500|      1|        pj_strdup_with_null(endpt->pool, &endpt->name, pj_cstr(&temp, name));
  501|      1|    } else {
  502|      0|        pj_strdup_with_null(endpt->pool, &endpt->name, pj_gethostname());
  503|      0|    }
  504|       |
  505|       |    /* Create mutex for the events, etc. */
  506|      1|    status = pj_mutex_create_recursive( endpt->pool, "ept%p", &endpt->mutex );
  507|      1|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (507:9): [True: 0, False: 1]
  ------------------
  508|      0|        goto on_error;
  509|      0|    }
  510|       |
  511|       |    /* Create timer heap to manage all timers within this endpoint. */
  512|      1|    status = pj_timer_heap_create( endpt->pool, PJSIP_MAX_TIMER_COUNT, 
  ------------------
  |  |  966|      1|#   define PJSIP_MAX_TIMER_COUNT        (2*pjsip_cfg()->tsx.max_count + \
  |  |  967|      1|                                         2*PJSIP_MAX_DIALOG_COUNT)
  |  |  ------------------
  |  |  |  |  327|      1|#   define PJSIP_MAX_DIALOG_COUNT       (512-1)
  |  |  ------------------
  ------------------
  513|      1|                                   &endpt->timer_heap);
  514|      1|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (514:9): [True: 0, False: 1]
  ------------------
  515|      0|        goto on_error;
  516|      0|    }
  517|       |
  518|       |    /* Set recursive lock for the timer heap. */
  519|      1|    status = pj_lock_create_recursive_mutex( endpt->pool, "edpt%p", &lock);
  520|      1|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (520:9): [True: 0, False: 1]
  ------------------
  521|      0|        goto on_error;
  522|      0|    }
  523|      1|    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|      1|    pj_timer_heap_set_max_timed_out_per_poll(endpt->timer_heap, 
  527|      1|                                             PJSIP_MAX_TIMED_OUT_ENTRIES);
  ------------------
  |  |  660|      1|#   define PJSIP_MAX_TIMED_OUT_ENTRIES  10
  ------------------
  528|       |
  529|       |    /* Create ioqueue. */
  530|      1|    status = pj_ioqueue_create( endpt->pool, PJSIP_MAX_TRANSPORTS, &endpt->ioqueue);
  ------------------
  |  |  337|      1|#   define PJSIP_MAX_TRANSPORTS         (PJ_IOQUEUE_MAX_HANDLES)
  |  |  ------------------
  |  |  |  |  738|      1|#   define PJ_IOQUEUE_MAX_HANDLES       (64)
  |  |  ------------------
  ------------------
  531|      1|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (531:9): [True: 0, False: 1]
  ------------------
  532|      0|        goto on_error;
  533|      0|    }
  534|       |
  535|       |    /* Create transport manager. */
  536|      1|    status = pjsip_tpmgr_create( endpt->pool, endpt,
  537|      1|                                 &endpt_on_rx_msg,
  538|      1|                                 &endpt_on_tx_msg,
  539|      1|                                 &endpt->transport_mgr);
  540|      1|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (540:9): [True: 0, False: 1]
  ------------------
  541|      0|        goto on_error;
  542|      0|    }
  543|       |
  544|       |    /* Create asynchronous DNS resolver. */
  545|      1|    status = pjsip_resolver_create(endpt->pool, &endpt->resolver);
  546|      1|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (546:9): [True: 0, False: 1]
  ------------------
  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|      1|    pj_list_init(&endpt->req_hdr);
  554|       |
  555|       |    /* Add "Max-Forwards" for request header. */
  556|      1|    mf_hdr = pjsip_max_fwd_hdr_create(endpt->pool,
  557|      1|                                      PJSIP_MAX_FORWARDS_VALUE);
  ------------------
  |  | 1060|      1|#define PJSIP_MAX_FORWARDS_VALUE        70
  ------------------
  558|      1|    pj_list_insert_before( &endpt->req_hdr, mf_hdr);
  559|       |
  560|       |    /* Initialize capability header list. */
  561|      1|    pj_list_init(&endpt->cap_hdr);
  562|       |
  563|       |
  564|       |    /* Done. */
  565|      1|    *p_endpt = endpt;
  566|      1|    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|      1|}
pjsip_endpt_create_pool:
  677|    851|{
  678|    851|    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|    851|    pool = pj_pool_create( endpt->pf, pool_name,
  687|    851|                           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|    851|    if (!pool) {
  ------------------
  |  Branch (694:9): [True: 0, False: 851]
  ------------------
  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|    851|    return pool;
  699|    851|}
pjsip_endpt_release_pool:
  706|    850|{
  707|    850|    PJ_LOG(6, (THIS_FILE, "Releasing pool %s", pj_pool_getobjname(pool)));
  ------------------
  |  |  106|    850|#define PJ_LOG(level,arg)       do { \
  |  |  107|    850|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  1.70k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 850]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|    850|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 850]
  |  |  ------------------
  ------------------
  708|       |
  709|       |    /* Don't need to acquire mutex since pool factory is thread safe
  710|       |       pj_mutex_lock(endpt->mutex);
  711|       |     */
  712|    850|    pj_pool_release( pool );
  713|       |
  714|    850|    PJ_UNUSED_ARG(endpt);
  ------------------
  |  | 1537|    850|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  715|       |    /*
  716|       |    pj_mutex_unlock(endpt->mutex);
  717|       |     */
  718|    850|}
pjsip_endpt_handle_events2:
  724|    850|{
  725|    850|    enum { MAX_TIMEOUT_ON_ERR = 10 };
  726|       |    /* timeout is 'out' var. This just to make compiler happy. */
  727|    850|    pj_time_val timeout = { 0, 0};
  728|    850|    unsigned count = 0, net_event_count = 0;
  729|    850|    int c;
  730|       |
  731|    850|    PJ_LOG(6, (THIS_FILE, "pjsip_endpt_handle_events()"));
  ------------------
  |  |  106|    850|#define PJ_LOG(level,arg)       do { \
  |  |  107|    850|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  1.70k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 850]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|    850|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 850]
  |  |  ------------------
  ------------------
  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|    850|    timeout.sec = timeout.msec = 0;
  737|    850|    c = pj_timer_heap_poll( endpt->timer_heap, &timeout );
  738|    850|    if (c > 0)
  ------------------
  |  Branch (738:9): [True: 0, False: 850]
  ------------------
  739|      0|        count += c;
  740|       |
  741|       |    /* timer_heap_poll should never ever returns negative value, or otherwise
  742|       |     * ioqueue_poll() will block forever!
  743|       |     */
  744|    850|    pj_assert(timeout.sec >= 0 && timeout.msec >= 0);
  ------------------
  |  |   65|    850|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (744:5): [True: 0, False: 850]
  |  Branch (744:5): [True: 0, False: 0]
  |  Branch (744:5): [True: 850, False: 0]
  |  Branch (744:5): [True: 850, False: 0]
  ------------------
  745|    850|    if (timeout.msec >= 1000) timeout.msec = 999;
  ------------------
  |  Branch (745:9): [True: 850, False: 0]
  ------------------
  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|    850|    if (max_timeout && PJ_TIME_VAL_GT(timeout, *max_timeout)) {
  ------------------
  |  |  497|    850|#define PJ_TIME_VAL_GT(t1, t2)  ((t1).sec>(t2).sec || \
  |  |  ------------------
  |  |  |  Branch (497:34): [True: 850, False: 0]
  |  |  ------------------
  |  |  498|    850|                                ((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: 850, False: 0]
  ------------------
  751|    850|        timeout = *max_timeout;
  752|    850|    }
  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|    850|    do {
  766|    850|        c = pj_ioqueue_poll( endpt->ioqueue, &timeout);
  767|    850|        if (c < 0) {
  ------------------
  |  Branch (767:13): [True: 0, False: 850]
  ------------------
  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|    850|        } else if (c == 0) {
  ------------------
  |  Branch (777:20): [True: 850, False: 0]
  ------------------
  778|    850|            break;
  779|    850|        } else {
  780|      0|            net_event_count += c;
  781|      0|            timeout.sec = timeout.msec = 0;
  782|      0|        }
  783|    850|    } 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|    850|    count += net_event_count;
  786|    850|    if (p_count)
  ------------------
  |  Branch (786:9): [True: 0, False: 850]
  ------------------
  787|      0|        *p_count = count;
  788|       |
  789|    850|    return PJ_SUCCESS;
  790|    850|}
pjsip_endpt_handle_events:
  797|    850|{
  798|       |    return pjsip_endpt_handle_events2(endpt, max_timeout, NULL);
  799|    850|}

pjsip_method_init_np:
  272|    462|{
  273|    462|    unsigned i;
  274|  3.21k|    for (i=0; i<PJ_ARRAY_SIZE(method_names); ++i) {
  ------------------
  |  |  315|  3.21k|#define PJ_ARRAY_SIZE(a)    (sizeof(a)/sizeof(a[0]))
  ------------------
  |  Branch (274:15): [True: 2.75k, False: 456]
  ------------------
  275|  2.75k|        if (pj_memcmp(str, method_names[i], sizeof(pj_str_t))==0 || 
  ------------------
  |  Branch (275:13): [True: 0, False: 2.75k]
  ------------------
  276|  2.75k|            pj_stricmp(str, method_names[i])==0) 
  ------------------
  |  Branch (276:13): [True: 6, False: 2.74k]
  ------------------
  277|      6|        {
  278|      6|            m->id = (pjsip_method_e)i;
  279|      6|            m->name = *method_names[i];
  280|      6|            return;
  281|      6|        }
  282|  2.75k|    }
  283|    456|    m->id = PJSIP_OTHER_METHOD;
  284|    456|    m->name = *str;
  285|    456|}
pjsip_msg_create:
  318|  1.68k|{
  319|  1.68k|    pjsip_msg *msg = PJ_POOL_ALLOC_T(pool, pjsip_msg);
  ------------------
  |  |  569|  1.68k|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
  320|  1.68k|    pj_list_init(&msg->hdr);
  321|  1.68k|    msg->type = type;
  322|       |    msg->body = NULL;
  323|  1.68k|    return msg;
  324|  1.68k|}
pjsip_hdr_find:
  361|     43|{
  362|     43|    const pjsip_hdr *hdr=(const pjsip_hdr*) start, *end=hdr_list;
  363|       |
  364|     43|    if (hdr == NULL) {
  ------------------
  |  Branch (364:9): [True: 43, False: 0]
  ------------------
  365|     43|        hdr = end->next;
  366|     43|    }
  367|    661|    for (; hdr!=end; hdr = hdr->next) {
  ------------------
  |  Branch (367:12): [True: 634, False: 27]
  ------------------
  368|    634|        if (hdr->type == hdr_type)
  ------------------
  |  Branch (368:13): [True: 16, False: 618]
  ------------------
  369|     16|            return (void*)hdr;
  370|    634|    }
  371|     27|    return NULL;
  372|     43|}
pjsip_msg_find_hdr:
  411|     43|{
  412|     43|    return pjsip_hdr_find(&msg->hdr, hdr_type, start);
  413|     43|}
pjsip_media_type_cp:
  718|     20|{
  719|     20|    PJ_ASSERT_ON_FAIL(pool && dst && src, return);
  ------------------
  |  |  111|     20|            { \
  |  |  112|     20|                pj_assert(expr); \
  |  |  ------------------
  |  |  |  |   65|     20|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  113|     80|                if (!(expr)) exec_on_fail; \
  |  |  ------------------
  |  |  |  Branch (113:23): [True: 20, False: 0]
  |  |  |  Branch (113:23): [True: 20, False: 0]
  |  |  |  Branch (113:23): [True: 20, False: 0]
  |  |  ------------------
  |  |  114|     20|            }
  ------------------
  |  Branch (719:5): [True: 0, False: 20]
  |  Branch (719:5): [True: 0, False: 0]
  |  Branch (719:5): [True: 0, False: 0]
  |  Branch (719:5): [True: 20, False: 0]
  |  Branch (719:5): [True: 20, False: 0]
  |  Branch (719:5): [True: 20, False: 0]
  ------------------
  720|     20|    pj_strdup(pool, &dst->type,    &src->type);
  721|     20|    pj_strdup(pool, &dst->subtype, &src->subtype);
  722|     20|    pjsip_param_clone(pool, &dst->param, &src->param);
  723|     20|}
pjsip_generic_string_hdr_init2:
  748|  5.83k|{
  749|  5.83k|    init_hdr(hdr, PJSIP_H_OTHER, &generic_hdr_vptr);
  750|  5.83k|    if (hname) {
  ------------------
  |  Branch (750:9): [True: 5.83k, False: 0]
  ------------------
  751|  5.83k|        hdr->name = *hname;
  752|  5.83k|        hdr->sname = *hname;
  753|  5.83k|    }
  754|  5.83k|    if (hvalue) {
  ------------------
  |  Branch (754:9): [True: 5.83k, False: 0]
  ------------------
  755|  5.83k|        hdr->hvalue = *hvalue;
  756|  5.83k|    } else {
  757|       |        hdr->hvalue.ptr = NULL;
  758|      0|        hdr->hvalue.slen = 0;
  759|      0|    }
  760|  5.83k|}
pjsip_generic_string_hdr_init:
  767|  5.83k|{
  768|  5.83k|    pjsip_generic_string_hdr *hdr = (pjsip_generic_string_hdr*) mem;
  769|  5.83k|    pj_str_t dup_hname, dup_hval;
  770|       |
  771|  5.83k|    if (hnames) {
  ------------------
  |  Branch (771:9): [True: 0, False: 5.83k]
  ------------------
  772|      0|        pj_strdup(pool, &dup_hname, hnames);
  773|  5.83k|    } else {
  774|  5.83k|        pj_bzero(&dup_hname, sizeof(pj_str_t));
  775|  5.83k|    }
  776|       |
  777|  5.83k|    if (hvalue) {
  ------------------
  |  Branch (777:9): [True: 0, False: 5.83k]
  ------------------
  778|      0|        pj_strdup(pool, &dup_hval, hvalue);
  779|  5.83k|    } else {
  780|  5.83k|        pj_bzero(&dup_hval, sizeof(pj_str_t));
  781|  5.83k|    }
  782|       |
  783|  5.83k|    pjsip_generic_string_hdr_init2(hdr, &dup_hname, &dup_hval);
  784|  5.83k|    return hdr;
  785|  5.83k|}
pjsip_generic_string_hdr_create:
  790|  5.83k|{
  791|  5.83k|    void *mem = pj_pool_alloc(pool, sizeof(pjsip_generic_string_hdr));
  792|  5.83k|    return pjsip_generic_string_hdr_init(pool, mem, hnames, hvalue);
  793|  5.83k|}
pjsip_cid_hdr_init:
 1060|    276|{
 1061|    276|    pjsip_cid_hdr *hdr = (pjsip_cid_hdr*) mem;
 1062|       |
 1063|    276|    PJ_UNUSED_ARG(pool);
  ------------------
  |  | 1537|    276|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1064|       |
 1065|    276|    init_hdr(hdr, PJSIP_H_CALL_ID, &generic_hdr_vptr);
 1066|    276|    return hdr;
 1067|       |
 1068|    276|}
pjsip_cid_hdr_create:
 1071|    276|{
 1072|    276|    void *mem = pj_pool_alloc(pool, sizeof(pjsip_cid_hdr));
 1073|    276|    return pjsip_cid_hdr_init(pool, mem);
 1074|    276|}
pjsip_clen_hdr_init:
 1094|    934|{
 1095|    934|    pjsip_clen_hdr *hdr = (pjsip_clen_hdr*) mem;
 1096|       |
 1097|    934|    PJ_UNUSED_ARG(pool);
  ------------------
  |  | 1537|    934|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1098|       |
 1099|    934|    init_hdr(hdr, PJSIP_H_CONTENT_LENGTH, &clen_hdr_vptr);
 1100|    934|    hdr->len = 0;
 1101|    934|    return hdr;
 1102|    934|}
pjsip_clen_hdr_create:
 1105|    934|{
 1106|    934|    void *mem = pj_pool_alloc(pool, sizeof(pjsip_clen_hdr));
 1107|    934|    return pjsip_clen_hdr_init(pool, mem);
 1108|    934|}
pjsip_contact_hdr_init:
 1238|  6.72k|{
 1239|  6.72k|    pjsip_contact_hdr *hdr = (pjsip_contact_hdr*) mem;
 1240|       |
 1241|  6.72k|    PJ_UNUSED_ARG(pool);
  ------------------
  |  | 1537|  6.72k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1242|       |
 1243|  6.72k|    pj_bzero(mem, sizeof(pjsip_contact_hdr));
 1244|  6.72k|    init_hdr(hdr, PJSIP_H_CONTACT, &contact_hdr_vptr);
 1245|  6.72k|    hdr->expires = PJSIP_EXPIRES_NOT_SPECIFIED;
  ------------------
  |  | 1427|  6.72k|#define PJSIP_EXPIRES_NOT_SPECIFIED     ((pj_uint32_t)0xFFFFFFFFUL)
  ------------------
 1246|  6.72k|    pj_list_init(&hdr->other_param);
 1247|  6.72k|    return hdr;
 1248|  6.72k|}
pjsip_contact_hdr_create:
 1251|  6.72k|{
 1252|  6.72k|    void *mem = pj_pool_alloc(pool, sizeof(pjsip_contact_hdr));
 1253|  6.72k|    return pjsip_contact_hdr_init(pool, mem);
 1254|  6.72k|}
pjsip_ctype_hdr_init:
 1379|  2.90k|{
 1380|  2.90k|    pjsip_ctype_hdr *hdr = (pjsip_ctype_hdr*) mem;
 1381|       |
 1382|  2.90k|    PJ_UNUSED_ARG(pool);
  ------------------
  |  | 1537|  2.90k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1383|       |
 1384|  2.90k|    pj_bzero(mem, sizeof(pjsip_ctype_hdr));
 1385|  2.90k|    init_hdr(hdr, PJSIP_H_CONTENT_TYPE, &ctype_hdr_vptr);
 1386|  2.90k|    pj_list_init(&hdr->media.param);
 1387|  2.90k|    return hdr;
 1388|       |
 1389|  2.90k|}
pjsip_ctype_hdr_create:
 1392|  2.90k|{
 1393|  2.90k|    void *mem = pj_pool_alloc(pool, sizeof(pjsip_ctype_hdr));
 1394|  2.90k|    return pjsip_ctype_hdr_init(pool, mem);
 1395|  2.90k|}
pjsip_expires_hdr_init:
 1473|    490|{
 1474|    490|    pjsip_expires_hdr *hdr = (pjsip_expires_hdr*) mem;
 1475|       |
 1476|    490|    PJ_UNUSED_ARG(pool);
  ------------------
  |  | 1537|    490|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1477|       |
 1478|    490|    init_hdr(hdr, PJSIP_H_EXPIRES, &generic_int_hdr_vptr);
 1479|    490|    hdr->ivalue = value;
 1480|    490|    return hdr;
 1481|       |
 1482|    490|}
pjsip_expires_hdr_create:
 1486|    490|{
 1487|    490|    void *mem = pj_pool_alloc(pool, sizeof(pjsip_expires_hdr));
 1488|    490|    return pjsip_expires_hdr_init(pool, mem, value);
 1489|    490|}
pjsip_from_hdr_init:
 1512|  6.24k|{
 1513|  6.24k|    pjsip_from_hdr *hdr = (pjsip_from_hdr*) mem;
 1514|       |
 1515|  6.24k|    PJ_UNUSED_ARG(pool);
  ------------------
  |  | 1537|  6.24k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1516|       |
 1517|  6.24k|    pj_bzero(mem, sizeof(pjsip_from_hdr));
 1518|  6.24k|    init_hdr(hdr, PJSIP_H_FROM, &fromto_hdr_vptr);
 1519|  6.24k|    pj_list_init(&hdr->other_param);
 1520|  6.24k|    return hdr;
 1521|  6.24k|}
pjsip_from_hdr_create:
 1524|  6.24k|{
 1525|  6.24k|    void *mem = pj_pool_alloc(pool, sizeof(pjsip_from_hdr));
 1526|  6.24k|    return pjsip_from_hdr_init(pool, mem);
 1527|  6.24k|}
pjsip_to_hdr_init:
 1531|  6.27k|{
 1532|  6.27k|    pjsip_to_hdr *hdr = (pjsip_to_hdr*) mem;
 1533|       |
 1534|  6.27k|    PJ_UNUSED_ARG(pool);
  ------------------
  |  | 1537|  6.27k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1535|       |
 1536|  6.27k|    pj_bzero(mem, sizeof(pjsip_to_hdr));
 1537|  6.27k|    init_hdr(hdr, PJSIP_H_TO, &fromto_hdr_vptr);
 1538|  6.27k|    pj_list_init(&hdr->other_param);
 1539|  6.27k|    return hdr;
 1540|       |
 1541|  6.27k|}
pjsip_to_hdr_create:
 1544|  6.27k|{
 1545|  6.27k|    void *mem = pj_pool_alloc(pool, sizeof(pjsip_to_hdr));
 1546|  6.27k|    return pjsip_to_hdr_init(pool, mem);
 1547|  6.27k|}
pjsip_max_fwd_hdr_init:
 1636|      1|{
 1637|      1|    pjsip_max_fwd_hdr *hdr = (pjsip_max_fwd_hdr*) mem;
 1638|       |
 1639|      1|    PJ_UNUSED_ARG(pool);
  ------------------
  |  | 1537|      1|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1640|       |
 1641|      1|    init_hdr(hdr, PJSIP_H_MAX_FORWARDS, &generic_int_hdr_vptr);
 1642|      1|    hdr->ivalue = value;
 1643|      1|    return hdr;
 1644|       |
 1645|      1|}
pjsip_max_fwd_hdr_create:
 1649|      1|{
 1650|      1|    void *mem = pj_pool_alloc(pool, sizeof(pjsip_max_fwd_hdr));
 1651|      1|    return pjsip_max_fwd_hdr_init(pool, mem, value);
 1652|      1|}
pjsip_supported_hdr_init:
 1964|  9.20k|{
 1965|  9.20k|    pjsip_supported_hdr *hdr = (pjsip_supported_hdr*) mem;
 1966|       |
 1967|  9.20k|    PJ_UNUSED_ARG(pool);
  ------------------
  |  | 1537|  9.20k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1968|  9.20k|    init_hdr(hdr, PJSIP_H_SUPPORTED, &generic_array_hdr_vptr);
 1969|  9.20k|    hdr->count = 0;
 1970|  9.20k|    return hdr;
 1971|  9.20k|}
pjsip_supported_hdr_create:
 1974|  9.20k|{
 1975|  9.20k|    void *mem = pj_pool_alloc(pool, sizeof(pjsip_supported_hdr));
 1976|  9.20k|    return pjsip_supported_hdr_init(pool, mem);
 1977|  9.20k|}
pjsip_via_hdr_init:
 2019|  5.10k|{
 2020|  5.10k|    pjsip_via_hdr *hdr = (pjsip_via_hdr*) mem;
 2021|       |
 2022|  5.10k|    PJ_UNUSED_ARG(pool);
  ------------------
  |  | 1537|  5.10k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 2023|       |
 2024|  5.10k|    pj_bzero(mem, sizeof(pjsip_via_hdr));
 2025|  5.10k|    init_hdr(hdr, PJSIP_H_VIA, &via_hdr_vptr);
 2026|  5.10k|    hdr->ttl_param = -1;
 2027|  5.10k|    hdr->rport_param = -1;
 2028|  5.10k|    pj_list_init(&hdr->other_param);
 2029|  5.10k|    return hdr;
 2030|       |
 2031|  5.10k|}
pjsip_via_hdr_create:
 2034|  5.10k|{
 2035|  5.10k|    void *mem = pj_pool_alloc(pool, sizeof(pjsip_via_hdr));
 2036|  5.10k|    return pjsip_via_hdr_init(pool, mem);
 2037|  5.10k|}

pjsip_parser_const:
  290|  9.10k|{
  291|  9.10k|    return &pconst;
  292|  9.10k|}
init_sip_parser:
  549|      1|{
  550|      1|    pj_enter_critical_section();
  551|      1|    if (++parser_is_initialized == 1) {
  ------------------
  |  Branch (551:9): [True: 1, False: 0]
  ------------------
  552|      1|        init_parser();
  553|      1|    }
  554|      1|    pj_leave_critical_section();
  555|      1|}
pjsip_register_hdr_parser:
  665|     23|{
  666|     23|    unsigned i;
  667|     23|    pj_size_t len;
  668|     23|    char hname_lcase[PJSIP_MAX_HNAME_LEN+1];
  669|     23|    pj_status_t status;
  670|       |
  671|       |    /* Check that name is not too long */
  672|     23|    len = pj_ansi_strlen(hname);
  ------------------
  |  |   69|     23|#define pj_ansi_strlen          strlen
  ------------------
  673|     23|    if (len > PJSIP_MAX_HNAME_LEN) {
  ------------------
  |  | 1145|     23|#define PJSIP_MAX_HNAME_LEN             64
  ------------------
  |  Branch (673:9): [True: 0, False: 23]
  ------------------
  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|     23|    status = int_register_parser(hname, fptr);
  680|     23|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (680:9): [True: 0, False: 23]
  ------------------
  681|      0|        return status;
  682|      0|    }
  683|       |
  684|       |    /* Get the lower-case name */
  685|    238|    for (i=0; i<len; ++i) {
  ------------------
  |  Branch (685:15): [True: 215, False: 23]
  ------------------
  686|    215|        hname_lcase[i] = (char)pj_tolower(hname[i]);
  687|    215|    }
  688|     23|    hname_lcase[len] = '\0';
  689|       |
  690|       |    /* Register the lower-case version of the name */
  691|     23|    status = int_register_parser(hname_lcase, fptr);
  692|     23|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (692:9): [True: 0, False: 23]
  ------------------
  693|      0|        return status;
  694|      0|    }
  695|       |    
  696|       |
  697|       |    /* Register the shortname version of the name */
  698|     23|    if (hshortname) {
  ------------------
  |  Branch (698:9): [True: 8, False: 15]
  ------------------
  699|      8|        status = int_register_parser(hshortname, fptr);
  700|      8|        if (status != PJ_SUCCESS) 
  ------------------
  |  Branch (700:13): [True: 0, False: 8]
  ------------------
  701|      0|            return status;
  702|      8|    }
  703|     23|    return PJ_SUCCESS;
  704|     23|}
pjsip_register_uri_parser:
  783|      3|{
  784|      3|    if (uri_handler_count >= PJ_ARRAY_SIZE(uri_handler))
  ------------------
  |  |  315|      3|#define PJ_ARRAY_SIZE(a)    (sizeof(a)/sizeof(a[0]))
  ------------------
  |  Branch (784:9): [True: 0, False: 3]
  ------------------
  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|      3|    uri_handler[uri_handler_count].scheme = pj_str((char*)scheme);
  788|      3|    uri_handler[uri_handler_count].parse = func;
  789|      3|    ++uri_handler_count;
  790|       |
  791|      3|    return PJ_SUCCESS;
  792|      3|}
pjsip_parse_msg:
  798|  1.69k|{
  799|  1.69k|    pjsip_msg *msg = NULL;
  800|  1.69k|    pj_scanner scanner;
  801|  1.69k|    pjsip_parse_ctx context;
  802|       |
  803|  1.69k|    pj_scan_init(&scanner, buf, size, PJ_SCAN_AUTOSKIP_WS_HEADER, 
  804|  1.69k|                 &on_syntax_error);
  805|       |
  806|  1.69k|    context.scanner = &scanner;
  807|  1.69k|    context.pool = pool;
  808|  1.69k|    context.rdata = NULL;
  809|       |
  810|  1.69k|    msg = int_parse_msg(&context, err_list);
  811|       |
  812|  1.69k|    pj_scan_fini(&scanner);
  813|  1.69k|    return msg;
  814|  1.69k|}
pjsip_parse_param_imp:
 1268|  16.7k|{
 1269|  16.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|  16.7k|}
pjsip_parse_uri_param_imp:
 1281|  6.99k|{
 1282|  6.99k|    parse_param_imp(scanner,pool, pname, pvalue, &pconst.pjsip_PARAM_CHAR_SPEC,
 1283|  6.99k|                    &pconst.pjsip_PARAM_CHAR_SPEC_ESC, option);
 1284|  6.99k|}
sip_parser.c:init_parser:
  329|      1|{
  330|      1|    pj_status_t status;
  331|       |
  332|       |    /*
  333|       |     * Syntax error exception number.
  334|       |     */
  335|      1|    pj_assert (PJSIP_SYN_ERR_EXCEPTION == -1);
  ------------------
  |  |   65|      1|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (335:5): [True: 0, False: 1]
  |  Branch (335:5): [True: 1, False: 0]
  ------------------
  336|      1|    status = pj_exception_id_alloc("PJSIP syntax error", 
  337|      1|                                   &PJSIP_SYN_ERR_EXCEPTION);
  338|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (338:5): [True: 0, False: 0]
  |  Branch (338:5): [True: 0, False: 0]
  ------------------
  339|       |
  340|       |    /*
  341|       |     * Invalid value exception.
  342|       |     */
  343|      1|    pj_assert (PJSIP_EINVAL_ERR_EXCEPTION == -2);
  ------------------
  |  |   65|      1|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (343:5): [True: 0, False: 1]
  |  Branch (343:5): [True: 1, False: 0]
  ------------------
  344|      1|    status = pj_exception_id_alloc("PJSIP invalid value error", 
  345|      1|                                   &PJSIP_EINVAL_ERR_EXCEPTION);
  346|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  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|      1|    pj_cis_buf_init(&cis_buf);
  353|       |
  354|      1|    status = pj_cis_init(&cis_buf, &pconst.pjsip_DIGIT_SPEC);
  355|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (355:5): [True: 0, False: 0]
  |  Branch (355:5): [True: 0, False: 0]
  ------------------
  356|      1|    pj_cis_add_num(&pconst.pjsip_DIGIT_SPEC);
  357|       |    
  358|      1|    status = pj_cis_init(&cis_buf, &pconst.pjsip_ALPHA_SPEC);
  359|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (359:5): [True: 0, False: 0]
  |  Branch (359:5): [True: 0, False: 0]
  ------------------
  360|      1|    pj_cis_add_alpha( &pconst.pjsip_ALPHA_SPEC );
  361|       |    
  362|      1|    status = pj_cis_init(&cis_buf, &pconst.pjsip_ALNUM_SPEC);
  363|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (363:5): [True: 0, False: 0]
  |  Branch (363:5): [True: 0, False: 0]
  ------------------
  364|      1|    pj_cis_add_alpha( &pconst.pjsip_ALNUM_SPEC );
  365|      1|    pj_cis_add_num( &pconst.pjsip_ALNUM_SPEC );
  366|       |
  367|      1|    status = pj_cis_init(&cis_buf, &pconst.pjsip_NOT_NEWLINE);
  368|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (368:5): [True: 0, False: 0]
  |  Branch (368:5): [True: 0, False: 0]
  ------------------
  369|      1|    pj_cis_add_str(&pconst.pjsip_NOT_NEWLINE, "\r\n");
  370|      1|    pj_cis_invert(&pconst.pjsip_NOT_NEWLINE);
  371|       |
  372|      1|    status = pj_cis_init(&cis_buf, &pconst.pjsip_NOT_COMMA_OR_NEWLINE);
  373|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (373:5): [True: 0, False: 0]
  |  Branch (373:5): [True: 0, False: 0]
  ------------------
  374|      1|    pj_cis_add_str( &pconst.pjsip_NOT_COMMA_OR_NEWLINE, ",\r\n");
  375|      1|    pj_cis_invert(&pconst.pjsip_NOT_COMMA_OR_NEWLINE);
  376|       |
  377|      1|    status = pj_cis_dup(&pconst.pjsip_TOKEN_SPEC, &pconst.pjsip_ALNUM_SPEC);
  378|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (378:5): [True: 0, False: 0]
  |  Branch (378:5): [True: 0, False: 0]
  ------------------
  379|      1|    pj_cis_add_str( &pconst.pjsip_TOKEN_SPEC, TOKEN);
  ------------------
  |  |   47|      1|#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|      1|    status = pj_cis_dup(&pconst.pjsip_VIA_PARAM_SPEC, &pconst.pjsip_TOKEN_SPEC);
  389|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (389:5): [True: 0, False: 0]
  |  Branch (389:5): [True: 0, False: 0]
  ------------------
  390|      1|    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|      1|    status = pj_cis_dup(&pconst.pjsip_HOST_SPEC, &pconst.pjsip_ALNUM_SPEC);
  400|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (400:5): [True: 0, False: 0]
  |  Branch (400:5): [True: 0, False: 0]
  ------------------
  401|      1|    pj_cis_add_str( &pconst.pjsip_HOST_SPEC, HOST);
  ------------------
  |  |   49|      1|#define HOST                "_-."
  ------------------
  402|       |
  403|      1|    status = pj_cis_dup(&pconst.pjsip_HEX_SPEC, &pconst.pjsip_DIGIT_SPEC);
  404|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (404:5): [True: 0, False: 0]
  |  Branch (404:5): [True: 0, False: 0]
  ------------------
  405|      1|    pj_cis_add_str( &pconst.pjsip_HEX_SPEC, HEX_DIGIT);
  ------------------
  |  |   50|      1|#define HEX_DIGIT           "abcdefABCDEF"
  ------------------
  406|       |
  407|      1|    status = pj_cis_dup(&pconst.pjsip_PARAM_CHAR_SPEC, &pconst.pjsip_ALNUM_SPEC);
  408|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (408:5): [True: 0, False: 0]
  |  Branch (408:5): [True: 0, False: 0]
  ------------------
  409|      1|    pj_cis_add_str(&pconst.pjsip_PARAM_CHAR_SPEC, PARAM_CHAR);
  ------------------
  |  |   51|      1|#define PARAM_CHAR          "[]/:&+$" UNRESERVED ESCAPED
  |  |  ------------------
  |  |  |  |   44|      1|#define ESCAPED             "%"
  |  |  ------------------
  ------------------
  410|       |
  411|      1|    status = pj_cis_dup(&pconst.pjsip_PARAM_CHAR_SPEC_ESC, &pconst.pjsip_PARAM_CHAR_SPEC);
  412|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (412:5): [True: 0, False: 0]
  |  Branch (412:5): [True: 0, False: 0]
  ------------------
  413|      1|    pj_cis_del_str(&pconst.pjsip_PARAM_CHAR_SPEC_ESC, ESCAPED);
  ------------------
  |  |   44|      1|#define ESCAPED             "%"
  ------------------
  414|       |
  415|      1|    status = pj_cis_dup(&pconst.pjsip_HDR_CHAR_SPEC, &pconst.pjsip_ALNUM_SPEC);
  416|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (416:5): [True: 0, False: 0]
  |  Branch (416:5): [True: 0, False: 0]
  ------------------
  417|      1|    pj_cis_add_str(&pconst.pjsip_HDR_CHAR_SPEC, HDR_CHAR);
  ------------------
  |  |   53|      1|#define HDR_CHAR            HNV_UNRESERVED UNRESERVED ESCAPED
  |  |  ------------------
  |  |  |  |   52|      1|#define HNV_UNRESERVED      "[]/?:+$"
  |  |  ------------------
  |  |               #define HDR_CHAR            HNV_UNRESERVED UNRESERVED ESCAPED
  |  |  ------------------
  |  |  |  |   44|      1|#define ESCAPED             "%"
  |  |  ------------------
  ------------------
  418|       |
  419|      1|    status = pj_cis_dup(&pconst.pjsip_HDR_CHAR_SPEC_ESC, &pconst.pjsip_HDR_CHAR_SPEC);
  420|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (420:5): [True: 0, False: 0]
  |  Branch (420:5): [True: 0, False: 0]
  ------------------
  421|      1|    pj_cis_del_str(&pconst.pjsip_HDR_CHAR_SPEC_ESC, ESCAPED);
  ------------------
  |  |   44|      1|#define ESCAPED             "%"
  ------------------
  422|       |
  423|      1|    status = pj_cis_dup(&pconst.pjsip_USER_SPEC, &pconst.pjsip_ALNUM_SPEC);
  424|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (424:5): [True: 0, False: 0]
  |  Branch (424:5): [True: 0, False: 0]
  ------------------
  425|      1|    pj_cis_add_str( &pconst.pjsip_USER_SPEC, UNRESERVED ESCAPED USER_UNRESERVED );
  ------------------
  |  |   43|      1|#define UNRESERVED          ALNUM MARK
  |  |  ------------------
  |  |  |  |   42|      1|#define MARK                "-_.!~*'()"
  |  |  ------------------
  ------------------
                  pj_cis_add_str( &pconst.pjsip_USER_SPEC, UNRESERVED ESCAPED USER_UNRESERVED );
  ------------------
  |  |   45|      1|#define USER_UNRESERVED     "&=+$,;?/"
  ------------------
  426|       |
  427|      1|    status = pj_cis_dup(&pconst.pjsip_USER_SPEC_ESC, &pconst.pjsip_USER_SPEC);
  428|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (428:5): [True: 0, False: 0]
  |  Branch (428:5): [True: 0, False: 0]
  ------------------
  429|      1|    pj_cis_del_str( &pconst.pjsip_USER_SPEC_ESC, ESCAPED);
  ------------------
  |  |   44|      1|#define ESCAPED             "%"
  ------------------
  430|       |
  431|      1|    status = pj_cis_dup(&pconst.pjsip_USER_SPEC_LENIENT, &pconst.pjsip_USER_SPEC);
  432|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (432:5): [True: 0, False: 0]
  |  Branch (432:5): [True: 0, False: 0]
  ------------------
  433|      1|    pj_cis_add_str(&pconst.pjsip_USER_SPEC_LENIENT, "#");
  434|       |
  435|      1|    status = pj_cis_dup(&pconst.pjsip_USER_SPEC_LENIENT_ESC, &pconst.pjsip_USER_SPEC_ESC);
  436|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (436:5): [True: 0, False: 0]
  |  Branch (436:5): [True: 0, False: 0]
  ------------------
  437|      1|    pj_cis_add_str(&pconst.pjsip_USER_SPEC_LENIENT_ESC, "#");
  438|       |
  439|      1|    status = pj_cis_dup(&pconst.pjsip_PASSWD_SPEC, &pconst.pjsip_ALNUM_SPEC);
  440|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (440:5): [True: 0, False: 0]
  |  Branch (440:5): [True: 0, False: 0]
  ------------------
  441|      1|    pj_cis_add_str( &pconst.pjsip_PASSWD_SPEC, UNRESERVED ESCAPED PASS);
  ------------------
  |  |   43|      1|#define UNRESERVED          ALNUM MARK
  |  |  ------------------
  |  |  |  |   42|      1|#define MARK                "-_.!~*'()"
  |  |  ------------------
  ------------------
                  pj_cis_add_str( &pconst.pjsip_PASSWD_SPEC, UNRESERVED ESCAPED PASS);
  ------------------
  |  |   46|      1|#define PASS                "&=+$,"
  ------------------
  442|       |
  443|      1|    status = pj_cis_dup(&pconst.pjsip_PASSWD_SPEC_ESC, &pconst.pjsip_PASSWD_SPEC);
  444|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (444:5): [True: 0, False: 0]
  |  Branch (444:5): [True: 0, False: 0]
  ------------------
  445|      1|    pj_cis_del_str( &pconst.pjsip_PASSWD_SPEC_ESC, ESCAPED);
  ------------------
  |  |   44|      1|#define ESCAPED             "%"
  ------------------
  446|       |
  447|      1|    status = pj_cis_init(&cis_buf, &pconst.pjsip_PROBE_USER_HOST_SPEC);
  448|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (448:5): [True: 0, False: 0]
  |  Branch (448:5): [True: 0, False: 0]
  ------------------
  449|      1|    pj_cis_add_str( &pconst.pjsip_PROBE_USER_HOST_SPEC, "@ \n>");
  450|      1|    pj_cis_invert( &pconst.pjsip_PROBE_USER_HOST_SPEC );
  451|       |
  452|      1|    status = pj_cis_init(&cis_buf, &pconst.pjsip_DISPLAY_SPEC);
  453|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (453:5): [True: 0, False: 0]
  |  Branch (453:5): [True: 0, False: 0]
  ------------------
  454|      1|    pj_cis_add_str( &pconst.pjsip_DISPLAY_SPEC, ":\r\n<");
  455|      1|    pj_cis_invert(&pconst.pjsip_DISPLAY_SPEC);
  456|       |
  457|      1|    status = pj_cis_dup(&pconst.pjsip_OTHER_URI_CONTENT, &pconst.pjsip_ALNUM_SPEC);
  458|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (458:5): [True: 0, False: 0]
  |  Branch (458:5): [True: 0, False: 0]
  ------------------
  459|      1|    pj_cis_add_str( &pconst.pjsip_OTHER_URI_CONTENT, GENERIC_URI_CHARS);
  ------------------
  |  |   58|      1|#define GENERIC_URI_CHARS   "#?;:@&=+-_.!~*'()%$,/" "%"
  ------------------
  460|       |
  461|       |    /*
  462|       |     * Register URI parsers.
  463|       |     */
  464|       |
  465|      1|    status = pjsip_register_uri_parser("sip", &int_parse_sip_url);
  466|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (466:5): [True: 0, False: 0]
  |  Branch (466:5): [True: 0, False: 0]
  ------------------
  467|       |
  468|      1|    status = pjsip_register_uri_parser("sips", &int_parse_sip_url);
  469|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (469:5): [True: 0, False: 0]
  |  Branch (469:5): [True: 0, False: 0]
  ------------------
  470|       |
  471|       |    /*
  472|       |     * Register header parsers.
  473|       |     */
  474|       |
  475|      1|    status = pjsip_register_hdr_parser( "Accept", NULL, &parse_hdr_accept);
  476|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (476:5): [True: 0, False: 0]
  |  Branch (476:5): [True: 0, False: 0]
  ------------------
  477|       |
  478|      1|    status = pjsip_register_hdr_parser( "Allow", NULL, &parse_hdr_allow);
  479|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (479:5): [True: 0, False: 0]
  |  Branch (479:5): [True: 0, False: 0]
  ------------------
  480|       |
  481|      1|    status = pjsip_register_hdr_parser( "Call-ID", "i", &parse_hdr_call_id);
  482|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (482:5): [True: 0, False: 0]
  |  Branch (482:5): [True: 0, False: 0]
  ------------------
  483|       |
  484|      1|    status = pjsip_register_hdr_parser( "Contact", "m", &parse_hdr_contact);
  485|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (485:5): [True: 0, False: 0]
  |  Branch (485:5): [True: 0, False: 0]
  ------------------
  486|       |
  487|      1|    status = pjsip_register_hdr_parser( "Content-Length", "l", 
  488|      1|                                        &parse_hdr_content_len);
  489|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (489:5): [True: 0, False: 0]
  |  Branch (489:5): [True: 0, False: 0]
  ------------------
  490|       |
  491|      1|    status = pjsip_register_hdr_parser( "Content-Type", "c", 
  492|      1|                                        &parse_hdr_content_type);
  493|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (493:5): [True: 0, False: 0]
  |  Branch (493:5): [True: 0, False: 0]
  ------------------
  494|       |
  495|      1|    status = pjsip_register_hdr_parser( "CSeq", NULL, &parse_hdr_cseq);
  496|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (496:5): [True: 0, False: 0]
  |  Branch (496:5): [True: 0, False: 0]
  ------------------
  497|       |
  498|      1|    status = pjsip_register_hdr_parser( "Expires", NULL, &parse_hdr_expires);
  499|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (499:5): [True: 0, False: 0]
  |  Branch (499:5): [True: 0, False: 0]
  ------------------
  500|       |
  501|      1|    status = pjsip_register_hdr_parser( "From", "f", &parse_hdr_from);
  502|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (502:5): [True: 0, False: 0]
  |  Branch (502:5): [True: 0, False: 0]
  ------------------
  503|       |
  504|      1|    status = pjsip_register_hdr_parser( "Max-Forwards", NULL, 
  505|      1|                                        &parse_hdr_max_forwards);
  506|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (506:5): [True: 0, False: 0]
  |  Branch (506:5): [True: 0, False: 0]
  ------------------
  507|       |
  508|      1|    status = pjsip_register_hdr_parser( "Min-Expires", NULL, 
  509|      1|                                        &parse_hdr_min_expires);
  510|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (510:5): [True: 0, False: 0]
  |  Branch (510:5): [True: 0, False: 0]
  ------------------
  511|       |
  512|      1|    status = pjsip_register_hdr_parser( "Record-Route", NULL, &parse_hdr_rr);
  513|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (513:5): [True: 0, False: 0]
  |  Branch (513:5): [True: 0, False: 0]
  ------------------
  514|       |
  515|      1|    status = pjsip_register_hdr_parser( "Route", NULL, &parse_hdr_route);
  516|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (516:5): [True: 0, False: 0]
  |  Branch (516:5): [True: 0, False: 0]
  ------------------
  517|       |
  518|      1|    status = pjsip_register_hdr_parser( "Require", NULL, &parse_hdr_require);
  519|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (519:5): [True: 0, False: 0]
  |  Branch (519:5): [True: 0, False: 0]
  ------------------
  520|       |
  521|      1|    status = pjsip_register_hdr_parser( "Retry-After", NULL, 
  522|      1|                                        &parse_hdr_retry_after);
  523|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (523:5): [True: 0, False: 0]
  |  Branch (523:5): [True: 0, False: 0]
  ------------------
  524|       |
  525|      1|    status = pjsip_register_hdr_parser( "Supported", "k", 
  526|      1|                                        &parse_hdr_supported);
  527|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (527:5): [True: 0, False: 0]
  |  Branch (527:5): [True: 0, False: 0]
  ------------------
  528|       |
  529|      1|    status = pjsip_register_hdr_parser( "To", "t", &parse_hdr_to);
  530|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (530:5): [True: 0, False: 0]
  |  Branch (530:5): [True: 0, False: 0]
  ------------------
  531|       |
  532|      1|    status = pjsip_register_hdr_parser( "Unsupported", NULL, 
  533|      1|                                        &parse_hdr_unsupported);
  534|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (534:5): [True: 0, False: 0]
  |  Branch (534:5): [True: 0, False: 0]
  ------------------
  535|       |
  536|      1|    status = pjsip_register_hdr_parser( "Via", "v", &parse_hdr_via);
  537|      1|    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (537:5): [True: 0, False: 0]
  |  Branch (537:5): [True: 0, False: 0]
  ------------------
  538|       |
  539|       |    /* 
  540|       |     * Register auth parser. 
  541|       |     */
  542|       |
  543|      1|    status = pjsip_auth_init_parser();
  544|       |
  545|      1|    return status;
  546|      1|}
sip_parser.c:int_parse_sip_url:
 1508|  4.88k|{
 1509|  4.88k|    pj_str_t scheme;
 1510|  4.88k|    pjsip_sip_uri *url = NULL;
 1511|  4.88k|    int colon;
 1512|  4.88k|    int skip_ws = scanner->skip_ws;
 1513|  4.88k|    scanner->skip_ws = 0;
 1514|       |
 1515|  4.88k|    pj_scan_get(scanner, &pconst.pjsip_TOKEN_SPEC, &scheme);
 1516|  4.88k|    colon = pj_scan_get_char(scanner);
 1517|  4.88k|    if (colon != ':') {
  ------------------
  |  Branch (1517:9): [True: 0, False: 4.88k]
  ------------------
 1518|      0|        PJ_THROW(PJSIP_SYN_ERR_EXCEPTION);
  ------------------
  |  |  402|      0|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
 1519|      0|    }
 1520|       |
 1521|  4.88k|    if (parser_stricmp(scheme, pconst.pjsip_SIP_STR)==0) {
  ------------------
  |  |  207|  4.88k|#define parser_stricmp(s1, s2)  (s1.slen!=s2.slen || pj_stricmp_alnum(&s1, &s2))
  |  |  ------------------
  |  |  |  |  408|  2.12k|#define pj_stricmp_alnum    pj_stricmp
  |  |  ------------------
  |  |  |  Branch (207:34): [True: 2.75k, False: 2.12k]
  |  |  |  Branch (207:54): [True: 0, False: 2.12k]
  |  |  ------------------
  ------------------
  |  Branch (1521:9): [True: 2.12k, False: 2.75k]
  ------------------
 1522|  2.12k|        url = pjsip_sip_uri_create(pool, 0);
 1523|       |
 1524|  2.75k|    } else if (parser_stricmp(scheme, pconst.pjsip_SIPS_STR)==0) {
  ------------------
  |  |  207|  2.75k|#define parser_stricmp(s1, s2)  (s1.slen!=s2.slen || pj_stricmp_alnum(&s1, &s2))
  |  |  ------------------
  |  |  |  |  408|  2.75k|#define pj_stricmp_alnum    pj_stricmp
  |  |  ------------------
  |  |  |  Branch (207:34): [True: 0, False: 2.75k]
  |  |  |  Branch (207:54): [True: 0, False: 2.75k]
  |  |  ------------------
  ------------------
  |  Branch (1524:16): [True: 2.75k, False: 0]
  ------------------
 1525|  2.75k|        url = pjsip_sip_uri_create(pool, 1);
 1526|       |
 1527|  2.75k|    } 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|  4.88k|    if (int_is_next_user(scanner)) {
  ------------------
  |  Branch (1536:9): [True: 240, False: 4.64k]
  ------------------
 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|    240|        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|    240|    }
 1549|       |
 1550|       |    /* Get host:port */
 1551|  4.88k|    int_parse_uri_host_port(scanner, &url->host, &url->port);
 1552|       |
 1553|       |    /* Get URL parameters. */
 1554|  4.88k|    if (parse_params) {
  ------------------
  |  Branch (1554:9): [True: 936, False: 3.94k]
  ------------------
 1555|  7.92k|      while (*scanner->curptr == ';' ) {
  ------------------
  |  Branch (1555:14): [True: 6.99k, False: 936]
  ------------------
 1556|  6.99k|        pj_str_t pname, pvalue;
 1557|       |
 1558|  6.99k|        int_parse_uri_param( scanner, pool, &pname, &pvalue, 0);
 1559|       |
 1560|  6.99k|        if (!parser_stricmp(pname, pconst.pjsip_USER_STR) && pvalue.slen) {
  ------------------
  |  |  207|  13.9k|#define parser_stricmp(s1, s2)  (s1.slen!=s2.slen || pj_stricmp_alnum(&s1, &s2))
  |  |  ------------------
  |  |  |  |  408|    954|#define pj_stricmp_alnum    pj_stricmp
  |  |  ------------------
  |  |  |  Branch (207:34): [True: 6.03k, False: 954]
  |  |  |  Branch (207:54): [True: 758, False: 196]
  |  |  ------------------
  ------------------
  |  Branch (1560:62): [True: 64, False: 132]
  ------------------
 1561|     64|            url->user_param = pvalue;
 1562|       |
 1563|  6.92k|        } else if (!parser_stricmp(pname, pconst.pjsip_METHOD_STR) && pvalue.slen) {
  ------------------
  |  |  207|  13.8k|#define parser_stricmp(s1, s2)  (s1.slen!=s2.slen || pj_stricmp_alnum(&s1, &s2))
  |  |  ------------------
  |  |  |  |  408|    292|#define pj_stricmp_alnum    pj_stricmp
  |  |  ------------------
  |  |  |  Branch (207:34): [True: 6.63k, False: 292]
  |  |  |  Branch (207:54): [True: 204, False: 88]
  |  |  ------------------
  ------------------
  |  Branch (1563:71): [True: 34, False: 54]
  ------------------
 1564|     34|            url->method_param = pvalue;
 1565|       |
 1566|  6.89k|        } else if (!parser_stricmp(pname, pconst.pjsip_TRANSPORT_STR) && pvalue.slen) {
  ------------------
  |  |  207|  13.7k|#define parser_stricmp(s1, s2)  (s1.slen!=s2.slen || pj_stricmp_alnum(&s1, &s2))
  |  |  ------------------
  |  |  |  |  408|    166|#define pj_stricmp_alnum    pj_stricmp
  |  |  ------------------
  |  |  |  Branch (207:34): [True: 6.72k, False: 166]
  |  |  |  Branch (207:54): [True: 70, False: 96]
  |  |  ------------------
  ------------------
  |  Branch (1566:74): [True: 32, False: 64]
  ------------------
 1567|     32|            url->transport_param = pvalue;
 1568|       |
 1569|  6.86k|        } else if (!parser_stricmp(pname, pconst.pjsip_TTL_STR) && pvalue.slen) {
  ------------------
  |  |  207|  13.7k|#define parser_stricmp(s1, s2)  (s1.slen!=s2.slen || pj_stricmp_alnum(&s1, &s2))
  |  |  ------------------
  |  |  |  |  408|  1.41k|#define pj_stricmp_alnum    pj_stricmp
  |  |  ------------------
  |  |  |  Branch (207:34): [True: 5.44k, False: 1.41k]
  |  |  |  Branch (207:54): [True: 1.09k, False: 318]
  |  |  ------------------
  ------------------
  |  Branch (1569:68): [True: 182, False: 136]
  ------------------
 1570|    182|            strtoi_validate(&pvalue, PJSIP_MIN_TTL, PJSIP_MAX_TTL,
  ------------------
  |  |   47|    182|#define PJSIP_MIN_TTL               0           /**< For limit checks */
  ------------------
                          strtoi_validate(&pvalue, PJSIP_MIN_TTL, PJSIP_MAX_TTL,
  ------------------
  |  |   48|    182|#define PJSIP_MAX_TTL               PJ_MAXUINT8 /**< For limit checks */
  |  |  ------------------
  |  |  |  |   39|    182|#define PJ_MAXUINT8     0xff
  |  |  ------------------
  ------------------
 1571|    182|                            &url->ttl_param);
 1572|  6.68k|        } else if (!parser_stricmp(pname, pconst.pjsip_MADDR_STR) && pvalue.slen) {
  ------------------
  |  |  207|  13.3k|#define parser_stricmp(s1, s2)  (s1.slen!=s2.slen || pj_stricmp_alnum(&s1, &s2))
  |  |  ------------------
  |  |  |  |  408|    464|#define pj_stricmp_alnum    pj_stricmp
  |  |  ------------------
  |  |  |  Branch (207:34): [True: 6.21k, False: 464]
  |  |  |  Branch (207:54): [True: 304, False: 160]
  |  |  ------------------
  ------------------
  |  Branch (1572:70): [True: 92, False: 68]
  ------------------
 1573|     92|            url->maddr_param = pvalue;
 1574|       |
 1575|  6.58k|        } else if (!parser_stricmp(pname, pconst.pjsip_LR_STR)) {
  ------------------
  |  |  207|  6.58k|#define parser_stricmp(s1, s2)  (s1.slen!=s2.slen || pj_stricmp_alnum(&s1, &s2))
  |  |  ------------------
  |  |  |  |  408|  1.32k|#define pj_stricmp_alnum    pj_stricmp
  |  |  ------------------
  |  |  |  Branch (207:34): [True: 5.26k, False: 1.32k]
  |  |  |  Branch (207:54): [True: 1.21k, False: 104]
  |  |  ------------------
  ------------------
 1576|    104|            url->lr_param = 1;
 1577|       |
 1578|  6.48k|        } else {
 1579|  6.48k|            pjsip_param *p = PJ_POOL_ALLOC_T(pool, pjsip_param);
  ------------------
  |  |  569|  6.48k|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
 1580|  6.48k|            p->name = pname;
 1581|  6.48k|            p->value = pvalue;
 1582|  6.48k|            pj_list_insert_before(&url->other_param, p);
 1583|  6.48k|        }
 1584|  6.99k|      }
 1585|    936|    }
 1586|       |
 1587|       |    /* Get header params. */
 1588|  4.88k|    if (parse_params && *scanner->curptr == '?') {
  ------------------
  |  Branch (1588:9): [True: 882, False: 4.00k]
  |  Branch (1588:25): [True: 210, False: 672]
  ------------------
 1589|  1.15k|      do {
 1590|  1.15k|        pjsip_param *param;
 1591|  1.15k|        param = PJ_POOL_ALLOC_T(pool, pjsip_param);
  ------------------
  |  |  569|  1.15k|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
 1592|  1.15k|        int_parse_hparam(scanner, pool, &param->name, &param->value);
 1593|  1.15k|        pj_list_insert_before(&url->header_param, param);
 1594|  1.15k|      } while (*scanner->curptr == '&');
  ------------------
  |  Branch (1594:16): [True: 944, False: 210]
  ------------------
 1595|    210|    }
 1596|       |
 1597|  4.88k|    scanner->skip_ws = skip_ws;
 1598|  4.88k|    pj_scan_skip_whitespace(scanner);
 1599|  4.88k|    return url;
 1600|  4.88k|}
sip_parser.c:int_is_next_user:
 1377|  4.88k|{
 1378|  4.88k|    pj_str_t dummy;
 1379|  4.88k|    int is_user;
 1380|       |
 1381|       |    /* Find character '@'. If this character exist, then the token
 1382|       |     * must be a username.
 1383|       |     */
 1384|  4.88k|    if (pj_scan_peek( scanner, &pconst.pjsip_PROBE_USER_HOST_SPEC, &dummy) == '@')
  ------------------
  |  Branch (1384:9): [True: 240, False: 4.64k]
  ------------------
 1385|    240|        is_user = 1;
 1386|  4.64k|    else
 1387|  4.64k|        is_user = 0;
 1388|       |
 1389|  4.88k|    return is_user;
 1390|  4.88k|}
sip_parser.c:int_parse_user_pass:
 1395|    240|{
 1396|    240|    parser_get_and_unescape(scanner, pool, &pconst.pjsip_USER_SPEC_LENIENT, 
 1397|    240|                            &pconst.pjsip_USER_SPEC_LENIENT_ESC, user);
 1398|       |
 1399|    240|    if ( *scanner->curptr == ':') {
  ------------------
  |  Branch (1399:10): [True: 44, False: 196]
  ------------------
 1400|     44|        pj_scan_get_char( scanner );
 1401|     44|        parser_get_and_unescape(scanner, pool, &pconst.pjsip_PASSWD_SPEC,
 1402|     44|                                &pconst.pjsip_PASSWD_SPEC_ESC, pass);
 1403|    196|    } else {
 1404|    196|        pass->ptr = NULL;
 1405|    196|        pass->slen = 0;
 1406|    196|    }
 1407|       |
 1408|       |    /* Get the '@' */
 1409|    240|    pj_scan_get_char( scanner );
 1410|    240|}
sip_parser.c:parser_get_and_unescape:
  214|  9.18k|{
  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|  9.18k|    PJ_UNUSED_ARG(unesc_spec);
  ------------------
  |  | 1537|  9.18k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  221|  9.18k|    pj_scan_get(scanner, spec, token);
  222|  9.18k|    *token = pj_str_unescape(pool, token);
  223|  9.18k|#endif
  224|  9.18k|}
sip_parser.c:int_parse_uri_host_port:
 1361|  4.88k|{
 1362|  4.88k|    int_parse_host(scanner, host);
 1363|       |
 1364|       |    /* RFC3261 section 19.1.2: host don't need to be unescaped */
 1365|  4.88k|    if (*scanner->curptr == ':') {
  ------------------
  |  Branch (1365:9): [True: 2.26k, False: 2.62k]
  ------------------
 1366|  2.26k|        pj_str_t port;
 1367|  2.26k|        pj_scan_get_char(scanner);
 1368|  2.26k|        pj_scan_get(scanner, &pconst.pjsip_DIGIT_SPEC, &port);
 1369|  2.26k|        strtoi_validate(&port, PJSIP_MIN_PORT, PJSIP_MAX_PORT, p_port);
  ------------------
  |  |   45|  2.26k|#define PJSIP_MIN_PORT              0           /**< For limit checks */
  ------------------
                      strtoi_validate(&port, PJSIP_MIN_PORT, PJSIP_MAX_PORT, p_port);
  ------------------
  |  |   46|  2.26k|#define PJSIP_MAX_PORT              PJ_MAXUINT16/**< For limit checks */
  |  |  ------------------
  |  |  |  |   36|  2.26k|#define PJ_MAXUINT16    0xffff
  |  |  ------------------
  ------------------
 1370|  2.62k|    } else {
 1371|  2.62k|        *p_port = 0;
 1372|  2.62k|    }
 1373|  4.88k|}
sip_parser.c:int_parse_host:
 1344|  7.07k|{
 1345|  7.07k|    if (*scanner->curptr == '[') {
  ------------------
  |  Branch (1345:9): [True: 1.36k, False: 5.71k]
  ------------------
 1346|       |        /* Note: the '[' and ']' characters are removed from the host */
 1347|  1.36k|        pj_scan_get_char(scanner);
 1348|  1.36k|        pj_scan_get_until_ch(scanner, ']', host);
 1349|  1.36k|        pj_scan_get_char(scanner);
 1350|       |        /* Empty IPv6 address (e.g. "sip:[]") is invalid */
 1351|  1.36k|        if (host->slen == 0)
  ------------------
  |  Branch (1351:13): [True: 182, False: 1.18k]
  ------------------
 1352|    182|            on_syntax_error(scanner);
 1353|  5.71k|    } else {
 1354|  5.71k|        pj_scan_get( scanner, &pconst.pjsip_HOST_SPEC, host);
 1355|  5.71k|    }
 1356|  7.07k|}
sip_parser.c:int_parse_uri_param:
 1303|  6.99k|{
 1304|       |    /* Get ';' character */
 1305|  6.99k|    pj_scan_get_char(scanner);
 1306|       |
 1307|       |    /* Get pname and optionally pvalue */
 1308|  6.99k|    pjsip_parse_uri_param_imp(scanner, pool, pname, pvalue, 
 1309|  6.99k|                              option);
 1310|  6.99k|}
sip_parser.c:int_parse_hparam:
 1316|  1.15k|{
 1317|       |    /* Get '?' or '&' character. */
 1318|  1.15k|    pj_scan_get_char(scanner);
 1319|       |
 1320|       |    /* hname */
 1321|  1.15k|    parser_get_and_unescape(scanner, pool, &pconst.pjsip_HDR_CHAR_SPEC, 
 1322|  1.15k|                            &pconst.pjsip_HDR_CHAR_SPEC_ESC, hname);
 1323|       |
 1324|       |    /* Init hvalue */
 1325|  1.15k|    hvalue->ptr = NULL;
 1326|  1.15k|    hvalue->slen = 0;
 1327|       |
 1328|       |    /* pvalue, if any */
 1329|  1.15k|    if (*scanner->curptr == '=') {
  ------------------
  |  Branch (1329:9): [True: 858, False: 296]
  ------------------
 1330|    858|        pj_scan_get_char(scanner);
 1331|    858|        if (!pj_scan_is_eof(scanner) && 
  ------------------
  |  Branch (1331:13): [True: 856, False: 2]
  ------------------
 1332|    856|            pj_cis_match(&pconst.pjsip_HDR_CHAR_SPEC, *scanner->curptr))
  ------------------
  |  Branch (1332:13): [True: 54, False: 802]
  ------------------
 1333|     54|        {
 1334|     54|            parser_get_and_unescape(scanner, pool, &pconst.pjsip_HDR_CHAR_SPEC,
 1335|     54|                                    &pconst.pjsip_HDR_CHAR_SPEC_ESC, hvalue);
 1336|     54|        }
 1337|    858|    }
 1338|  1.15k|}
sip_parser.c:parse_hdr_call_id:
 1889|    276|{
 1890|    276|    pjsip_cid_hdr *hdr = pjsip_cid_hdr_create(ctx->pool);
 1891|    276|    pj_scan_get( ctx->scanner, &pconst.pjsip_NOT_NEWLINE, &hdr->id);
 1892|    276|    parse_hdr_end(ctx->scanner);
 1893|       |
 1894|    276|    if (ctx->rdata)
  ------------------
  |  Branch (1894:9): [True: 0, False: 276]
  ------------------
 1895|      0|        ctx->rdata->msg_info.cid = hdr;
 1896|       |
 1897|    276|    return (pjsip_hdr*)hdr;
 1898|    276|}
sip_parser.c:parse_hdr_contact:
 1958|  5.53k|{
 1959|  5.53k|    pjsip_contact_hdr *first = NULL;
 1960|  5.53k|    pj_scanner *scanner = ctx->scanner;
 1961|       |    
 1962|  6.72k|    do {
 1963|  6.72k|        pjsip_contact_hdr *hdr = pjsip_contact_hdr_create(ctx->pool);
 1964|  6.72k|        if (first == NULL)
  ------------------
  |  Branch (1964:13): [True: 5.53k, False: 1.19k]
  ------------------
 1965|  5.53k|            first = hdr;
 1966|  1.19k|        else
 1967|  1.19k|            pj_list_insert_before(first, hdr);
 1968|       |
 1969|  6.72k|        if (*scanner->curptr == '*') {
  ------------------
  |  Branch (1969:13): [True: 710, False: 6.01k]
  ------------------
 1970|    710|            pj_scan_get_char(scanner);
 1971|    710|            hdr->star = 1;
 1972|       |
 1973|  6.01k|        } else {
 1974|  6.01k|            hdr->star = 0;
 1975|  6.01k|            hdr->uri = int_parse_uri_or_name_addr(scanner, ctx->pool, 
 1976|  6.01k|                                                  PJSIP_PARSE_URI_AS_NAMEADDR |
 1977|  6.01k|                                                  PJSIP_PARSE_URI_IN_FROM_TO_HDR);
 1978|       |
 1979|  6.01k|            int_parse_contact_param(hdr, scanner, ctx->pool);
 1980|  6.01k|        }
 1981|       |
 1982|  6.72k|        if (*scanner->curptr != ',')
  ------------------
  |  Branch (1982:13): [True: 2.67k, False: 4.05k]
  ------------------
 1983|  2.67k|            break;
 1984|       |
 1985|  4.05k|        pj_scan_get_char(scanner);
 1986|       |
 1987|  4.05k|    } while (1);
  ------------------
  |  Branch (1987:14): [True: 1.19k, Folded]
  ------------------
 1988|       |
 1989|  5.53k|    parse_hdr_end(scanner);
 1990|       |
 1991|  5.53k|    return (pjsip_hdr*)first;
 1992|  5.53k|}
sip_parser.c:int_parse_contact_param:
 1904|  3.48k|{
 1905|  14.8k|    while ( *scanner->curptr == ';' ) {
  ------------------
  |  Branch (1905:13): [True: 11.3k, False: 3.48k]
  ------------------
 1906|  11.3k|        pj_str_t pname, pvalue;
 1907|       |
 1908|  11.3k|        int_parse_param( scanner, pool, &pname, &pvalue, 0);
 1909|  11.3k|        if (!parser_stricmp(pname, pconst.pjsip_Q_STR) && pvalue.slen) {
  ------------------
  |  |  207|  22.6k|#define parser_stricmp(s1, s2)  (s1.slen!=s2.slen || pj_stricmp_alnum(&s1, &s2))
  |  |  ------------------
  |  |  |  |  408|  4.31k|#define pj_stricmp_alnum    pj_stricmp
  |  |  ------------------
  |  |  |  Branch (207:34): [True: 7.03k, False: 4.31k]
  |  |  |  Branch (207:54): [True: 1.64k, False: 2.66k]
  |  |  ------------------
  ------------------
  |  Branch (1909:59): [True: 2.50k, False: 164]
  ------------------
 1910|  2.50k|            char *dot_pos = (char*) pj_memchr(pvalue.ptr, '.', pvalue.slen);
 1911|  2.50k|            if (!dot_pos) {
  ------------------
  |  Branch (1911:17): [True: 276, False: 2.22k]
  ------------------
 1912|    276|                strtoi_validate(&pvalue, PJSIP_MIN_Q1000, PJSIP_MAX_Q1000,
  ------------------
  |  |   51|    276|#define PJSIP_MIN_Q1000             0           /**< For limit checks */
  ------------------
                              strtoi_validate(&pvalue, PJSIP_MIN_Q1000, PJSIP_MAX_Q1000,
  ------------------
  |  |   52|    276|#define PJSIP_MAX_Q1000             PJ_MAXINT32 / 1000/**< For limit checks */
  |  |  ------------------
  |  |  |  |   30|    276|#define PJ_MAXINT32     0x7fffffff
  |  |  ------------------
  ------------------
 1913|    276|                                &hdr->q1000);
 1914|    276|                hdr->q1000 *= 1000;
 1915|  2.22k|            } else {
 1916|  2.22k|                pj_str_t tmp = pvalue;
 1917|  2.22k|                unsigned long qval_frac;
 1918|       |
 1919|  2.22k|                tmp.slen = dot_pos - pvalue.ptr;
 1920|  2.22k|                strtoi_validate(&tmp, PJSIP_MIN_Q1000, PJSIP_MAX_Q1000,
  ------------------
  |  |   51|  2.22k|#define PJSIP_MIN_Q1000             0           /**< For limit checks */
  ------------------
                              strtoi_validate(&tmp, PJSIP_MIN_Q1000, PJSIP_MAX_Q1000,
  ------------------
  |  |   52|  2.22k|#define PJSIP_MAX_Q1000             PJ_MAXINT32 / 1000/**< For limit checks */
  |  |  ------------------
  |  |  |  |   30|  2.22k|#define PJ_MAXINT32     0x7fffffff
  |  |  ------------------
  ------------------
 1921|  2.22k|                                &hdr->q1000);
 1922|  2.22k|                hdr->q1000 *= 1000;
 1923|       |
 1924|  2.22k|                pvalue.slen = (pvalue.ptr+pvalue.slen) - (dot_pos+1);
 1925|  2.22k|                pvalue.ptr = dot_pos + 1;
 1926|  2.22k|                if (pvalue.slen > 3) {
  ------------------
  |  Branch (1926:21): [True: 1.12k, False: 1.10k]
  ------------------
 1927|  1.12k|                    pvalue.slen = 3;
 1928|  1.12k|                }
 1929|  2.22k|                qval_frac = pj_strtoul_mindigit(&pvalue, 3);
 1930|  2.22k|                if ((unsigned)hdr->q1000 > (PJ_MAXINT32 - qval_frac)) {
  ------------------
  |  |   30|  2.22k|#define PJ_MAXINT32     0x7fffffff
  ------------------
  |  Branch (1930:21): [True: 0, False: 2.22k]
  ------------------
 1931|      0|                    PJ_THROW(PJSIP_SYN_ERR_EXCEPTION);
  ------------------
  |  |  402|      0|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
 1932|      0|                }
 1933|  2.22k|                hdr->q1000 += qval_frac;
 1934|  2.22k|            }    
 1935|  8.84k|        } else if (!parser_stricmp(pname, pconst.pjsip_EXPIRES_STR) && 
  ------------------
  |  |  207|  17.6k|#define parser_stricmp(s1, s2)  (s1.slen!=s2.slen || pj_stricmp_alnum(&s1, &s2))
  |  |  ------------------
  |  |  |  |  408|    406|#define pj_stricmp_alnum    pj_stricmp
  |  |  ------------------
  |  |  |  Branch (207:34): [True: 8.43k, False: 406]
  |  |  |  Branch (207:54): [True: 290, False: 116]
  |  |  ------------------
  ------------------
 1936|    116|                   pvalue.slen) 
  ------------------
  |  Branch (1936:20): [True: 70, False: 46]
  ------------------
 1937|     70|        {
 1938|     70|            hdr->expires = pj_strtoul(&pvalue);
 1939|     70|            if (hdr->expires == PJSIP_EXPIRES_NOT_SPECIFIED)
  ------------------
  |  | 1427|     70|#define PJSIP_EXPIRES_NOT_SPECIFIED     ((pj_uint32_t)0xFFFFFFFFUL)
  ------------------
  |  Branch (1939:17): [True: 0, False: 70]
  ------------------
 1940|      0|                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|  8.77k|        } else {
 1948|  8.77k|            pjsip_param *p = PJ_POOL_ALLOC_T(pool, pjsip_param);
  ------------------
  |  |  569|  8.77k|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
 1949|  8.77k|            p->name = pname;
 1950|  8.77k|            p->value = pvalue;
 1951|  8.77k|            pj_list_insert_before(&hdr->other_param, p);
 1952|  8.77k|        }
 1953|  11.3k|    }
 1954|  3.48k|}
sip_parser.c:int_parse_param:
 1291|  16.7k|{
 1292|       |    /* Get ';' character */
 1293|  16.7k|    pj_scan_get_char(scanner);
 1294|       |
 1295|       |    /* Get pname and optionally pvalue */
 1296|  16.7k|    pjsip_parse_param_imp(scanner, pool, pname, pvalue, option);
 1297|  16.7k|}
sip_parser.c:pj_strtoul_mindigit:
  192|  2.13k|{
  193|  2.13k|    unsigned long value;
  194|  2.13k|    unsigned i;
  195|       |
  196|  2.13k|    value = 0;
  197|  6.34k|    for (i=0; i<(unsigned)str->slen; ++i) {
  ------------------
  |  Branch (197:15): [True: 4.21k, False: 2.13k]
  ------------------
  198|  4.21k|        value = value * 10 + (str->ptr[i] - '0');
  199|  4.21k|    }
  200|  4.31k|    for (; i<mindig; ++i) {
  ------------------
  |  Branch (200:12): [True: 2.18k, False: 2.13k]
  ------------------
  201|  2.18k|        value = value * 10;
  202|  2.18k|    }
  203|  2.13k|    return value;
  204|  2.13k|}
sip_parser.c:parse_hdr_content_len:
 1996|    934|{
 1997|    934|    pj_str_t digit;
 1998|    934|    pjsip_clen_hdr *hdr;
 1999|       |
 2000|    934|    hdr = pjsip_clen_hdr_create(ctx->pool);
 2001|    934|    pj_scan_get(ctx->scanner, &pconst.pjsip_DIGIT_SPEC, &digit);
 2002|    934|    strtoi_validate(&digit, PJSIP_MIN_CONTENT_LENGTH,
  ------------------
  |  |   43|    934|#define PJSIP_MIN_CONTENT_LENGTH    0           /**< For limit checks */
  ------------------
 2003|    934|                    PJSIP_MAX_CONTENT_LENGTH, &hdr->len);
  ------------------
  |  |   44|    934|#define PJSIP_MAX_CONTENT_LENGTH    PJ_MAXINT32 /**< For limit checks */
  |  |  ------------------
  |  |  |  |   30|    934|#define PJ_MAXINT32     0x7fffffff
  |  |  ------------------
  ------------------
 2004|    934|    parse_hdr_end(ctx->scanner);
 2005|       |
 2006|    934|    if (ctx->rdata)
  ------------------
  |  Branch (2006:9): [True: 0, False: 934]
  ------------------
 2007|      0|        ctx->rdata->msg_info.clen = hdr;
 2008|       |
 2009|    934|    return (pjsip_hdr*)hdr;
 2010|    934|}
sip_parser.c:parse_hdr_content_type:
 2014|  2.90k|{
 2015|  2.90k|    pjsip_ctype_hdr *hdr;
 2016|  2.90k|    pj_scanner *scanner = ctx->scanner;
 2017|       |
 2018|  2.90k|    hdr = pjsip_ctype_hdr_create(ctx->pool);
 2019|       |    
 2020|       |    /* Parse media type and subtype. */
 2021|  2.90k|    pj_scan_get(scanner, &pconst.pjsip_TOKEN_SPEC, &hdr->media.type);
 2022|  2.90k|    pj_scan_get_char(scanner);
 2023|  2.90k|    pj_scan_get(scanner, &pconst.pjsip_TOKEN_SPEC, &hdr->media.subtype);
 2024|       |
 2025|       |    /* Parse media parameters */
 2026|  4.41k|    while (*scanner->curptr == ';') {
  ------------------
  |  Branch (2026:12): [True: 1.51k, False: 2.90k]
  ------------------
 2027|  1.51k|        pjsip_param *param = PJ_POOL_ALLOC_T(ctx->pool, pjsip_param);
  ------------------
  |  |  569|  1.51k|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
 2028|  1.51k|        int_parse_param(scanner, ctx->pool, &param->name, &param->value, 0);
 2029|  1.51k|        pj_list_push_back(&hdr->media.param, param);
 2030|  1.51k|    }
 2031|       |
 2032|  2.90k|    parse_hdr_end(ctx->scanner);
 2033|       |
 2034|  2.90k|    if (ctx->rdata)
  ------------------
  |  Branch (2034:9): [True: 0, False: 2.90k]
  ------------------
 2035|      0|        ctx->rdata->msg_info.ctype = hdr;
 2036|       |
 2037|  2.90k|    return (pjsip_hdr*)hdr;
 2038|  2.90k|}
sip_parser.c:parse_hdr_expires:
 2066|    490|{
 2067|    490|    pjsip_expires_hdr *hdr = pjsip_expires_hdr_create(ctx->pool, 0);
 2068|    490|    parse_generic_int_hdr(hdr, ctx->scanner);
 2069|    490|    return (pjsip_hdr*)hdr;
 2070|    490|}
sip_parser.c:parse_generic_int_hdr:
 1863|    490|{
 1864|    490|    pj_str_t tmp;
 1865|    490|    pj_scan_get( scanner, &pconst.pjsip_DIGIT_SPEC, &tmp);
 1866|    490|    hdr->ivalue = pj_strtoul(&tmp);
 1867|    490|    parse_hdr_end(scanner);
 1868|    490|}
sip_parser.c:parse_hdr_from:
 2102|  6.24k|{
 2103|  6.24k|    pjsip_from_hdr *hdr = pjsip_from_hdr_create(ctx->pool);
 2104|  6.24k|    parse_hdr_fromto(ctx->scanner, ctx->pool, hdr);
 2105|  6.24k|    if (ctx->rdata)
  ------------------
  |  Branch (2105:9): [True: 0, False: 6.24k]
  ------------------
 2106|      0|        ctx->rdata->msg_info.from = hdr;
 2107|       |
 2108|  6.24k|    return (pjsip_hdr*)hdr;
 2109|  6.24k|}
sip_parser.c:parse_hdr_fromto:
 2076|  12.5k|{
 2077|  12.5k|    hdr->uri = int_parse_uri_or_name_addr(scanner, pool, 
 2078|  12.5k|                                          PJSIP_PARSE_URI_AS_NAMEADDR |
 2079|  12.5k|                                          PJSIP_PARSE_URI_IN_FROM_TO_HDR);
 2080|       |
 2081|  16.3k|    while ( *scanner->curptr == ';' ) {
  ------------------
  |  Branch (2081:13): [True: 3.84k, False: 12.5k]
  ------------------
 2082|  3.84k|        pj_str_t pname, pvalue;
 2083|       |
 2084|  3.84k|        int_parse_param( scanner, pool, &pname, &pvalue, 0);
 2085|       |
 2086|  3.84k|        if (!parser_stricmp(pname, pconst.pjsip_TAG_STR)) {
  ------------------
  |  |  207|  3.84k|#define parser_stricmp(s1, s2)  (s1.slen!=s2.slen || pj_stricmp_alnum(&s1, &s2))
  |  |  ------------------
  |  |  |  |  408|  2.49k|#define pj_stricmp_alnum    pj_stricmp
  |  |  ------------------
  |  |  |  Branch (207:34): [True: 1.35k, False: 2.49k]
  |  |  |  Branch (207:54): [True: 1.42k, False: 1.07k]
  |  |  ------------------
  ------------------
 2087|  1.07k|            hdr->tag = pvalue;
 2088|       |            
 2089|  2.77k|        } else {
 2090|  2.77k|            pjsip_param *p = PJ_POOL_ALLOC_T(pool, pjsip_param);
  ------------------
  |  |  569|  2.77k|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
 2091|  2.77k|            p->name = pname;
 2092|  2.77k|            p->value = pvalue;
 2093|  2.77k|            pj_list_insert_before(&hdr->other_param, p);
 2094|  2.77k|        }
 2095|  3.84k|    }
 2096|       |
 2097|  12.5k|    parse_hdr_end(scanner);
 2098|  12.5k|}
sip_parser.c:int_parse_name_addr:
 1605|  10.0k|{
 1606|  10.0k|    int has_bracket;
 1607|  10.0k|    pjsip_name_addr *name_addr;
 1608|       |
 1609|  10.0k|    name_addr = pjsip_name_addr_create(pool);
 1610|       |
 1611|  10.0k|    if (*scanner->curptr == '"') {
  ------------------
  |  Branch (1611:9): [True: 3.93k, False: 6.14k]
  ------------------
 1612|  3.93k|        pj_scan_get_quote( scanner, '"', '"', &name_addr->display);
 1613|       |        /* Trim the leading and ending quote */
 1614|  3.93k|        name_addr->display.ptr++;
 1615|  3.93k|        name_addr->display.slen -= 2;
 1616|       |
 1617|  6.14k|    } else if (*scanner->curptr != '<') {
  ------------------
  |  Branch (1617:16): [True: 5.56k, False: 574]
  ------------------
 1618|  5.56k|        int next;
 1619|  5.56k|        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|  5.56k|        next = pj_scan_peek(scanner, &pconst.pjsip_DISPLAY_SPEC, &dummy);
 1627|  5.56k|        if (next == '<') {
  ------------------
  |  Branch (1627:13): [True: 3.70k, False: 1.85k]
  ------------------
 1628|       |            /* Ok, this is what we're looking for, a display name. */
 1629|  3.70k|            pj_scan_get_until_ch( scanner, '<', &name_addr->display);
 1630|  3.70k|            pj_strtrim(&name_addr->display);
 1631|  3.70k|        }
 1632|  5.56k|    }
 1633|       |
 1634|       |    /* Manually skip whitespace. */
 1635|  10.0k|    pj_scan_skip_whitespace(scanner);
 1636|       |
 1637|       |    /* Get the SIP-URL */
 1638|  10.0k|    has_bracket = (*scanner->curptr == '<');
 1639|  10.0k|    if (has_bracket) {
  ------------------
  |  Branch (1639:9): [True: 4.31k, False: 5.76k]
  ------------------
 1640|  4.31k|        pj_scan_get_char(scanner);
 1641|  5.76k|    } else if (name_addr->display.slen) {
  ------------------
  |  Branch (1641:16): [True: 972, False: 4.78k]
  ------------------
 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|    972|        PJ_THROW( PJSIP_SYN_ERR_EXCEPTION);
  ------------------
  |  |  402|    972|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
 1647|    972|    }
 1648|  9.10k|    name_addr->uri = int_parse_uri( scanner, pool, PJ_TRUE );
 1649|  9.10k|    if (has_bracket) {
  ------------------
  |  Branch (1649:9): [True: 1.68k, False: 7.42k]
  ------------------
 1650|  1.68k|        if (pj_scan_get_char(scanner) != '>')
  ------------------
  |  Branch (1650:13): [True: 1.37k, False: 304]
  ------------------
 1651|  1.37k|            PJ_THROW( PJSIP_SYN_ERR_EXCEPTION);
  ------------------
  |  |  402|  1.37k|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
 1652|  1.68k|    }
 1653|       |
 1654|  7.72k|    return name_addr;
 1655|  9.10k|}
sip_parser.c:int_parse_uri:
 1468|  8.86k|{
 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|  8.86k|        pj_str_t scheme;
 1478|  8.86k|        int colon;
 1479|  8.86k|        pjsip_parse_uri_func *func;
 1480|       |
 1481|       |        /* Get scheme. */
 1482|  8.86k|        colon = pj_scan_peek(scanner, &pconst.pjsip_TOKEN_SPEC, &scheme);
 1483|  8.86k|        if (colon != ':') {
  ------------------
  |  Branch (1483:13): [True: 3.29k, False: 5.56k]
  ------------------
 1484|  3.29k|            PJ_THROW(PJSIP_SYN_ERR_EXCEPTION);
  ------------------
  |  |  402|  3.29k|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
 1485|  3.29k|        }
 1486|       |
 1487|  5.56k|        func = find_uri_handler(&scheme);
 1488|  5.56k|        if (func)  {
  ------------------
  |  Branch (1488:13): [True: 5.55k, False: 14]
  ------------------
 1489|  5.55k|            return (pjsip_uri*)(*func)(scanner, pool, parse_params);
 1490|       |
 1491|  5.55k|        } else {
 1492|       |            /* Unsupported URI scheme */
 1493|     14|            PJ_THROW(PJSIP_SYN_ERR_EXCEPTION);
  ------------------
  |  |  402|     14|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
 1494|     14|            UNREACHED({ return NULL; /* Not reached. */ })
 1495|     14|        }
 1496|       |
 1497|       |    /*
 1498|       |    }
 1499|       |    */
 1500|  5.56k|}
sip_parser.c:find_uri_handler:
  771|  13.9k|{
  772|  13.9k|    unsigned i;
  773|  40.5k|    for (i=0; i<uri_handler_count; ++i) {
  ------------------
  |  Branch (773:15): [True: 34.9k, False: 5.56k]
  ------------------
  774|  34.9k|        if (parser_stricmp(uri_handler[i].scheme, (*scheme))==0)
  ------------------
  |  |  207|  34.9k|#define parser_stricmp(s1, s2)  (s1.slen!=s2.slen || pj_stricmp_alnum(&s1, &s2))
  |  |  ------------------
  |  |  |  |  408|  13.4k|#define pj_stricmp_alnum    pj_stricmp
  |  |  ------------------
  |  |  |  Branch (207:34): [True: 21.5k, False: 13.4k]
  |  |  |  Branch (207:54): [True: 4.99k, False: 8.43k]
  |  |  ------------------
  ------------------
  |  Branch (774:13): [True: 8.43k, False: 26.5k]
  ------------------
  775|  8.43k|            return uri_handler[i].parse;
  776|  34.9k|    }
  777|  5.56k|    return &int_parse_other_uri;
  778|  13.9k|}
sip_parser.c:int_parse_other_uri:
 1662|  5.56k|{
 1663|  5.56k|    pjsip_other_uri *uri = 0;
 1664|  5.56k|    const pjsip_parser_const_t *pc = pjsip_parser_const();
 1665|  5.56k|    int skip_ws = scanner->skip_ws;
 1666|       |
 1667|  5.56k|    PJ_UNUSED_ARG(parse_params);
  ------------------
  |  | 1537|  5.56k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1668|       |
 1669|  5.56k|    scanner->skip_ws = 0;
 1670|       |    
 1671|  5.56k|    uri = pjsip_other_uri_create(pool); 
 1672|       |    
 1673|  5.56k|    pj_scan_get(scanner, &pc->pjsip_TOKEN_SPEC, &uri->scheme);
 1674|  5.56k|    if (pj_scan_get_char(scanner) != ':') {
  ------------------
  |  Branch (1674:9): [True: 638, False: 4.92k]
  ------------------
 1675|    638|        PJ_THROW(PJSIP_SYN_ERR_EXCEPTION);
  ------------------
  |  |  402|    638|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
 1676|    638|    }
 1677|       |    
 1678|  4.92k|    pj_scan_get(scanner, &pc->pjsip_OTHER_URI_CONTENT, &uri->content);
 1679|  4.92k|    scanner->skip_ws = skip_ws;
 1680|       |    
 1681|  4.92k|    return uri;
 1682|  5.56k|}
sip_parser.c:parse_hdr_supported:
 2167|  9.20k|{
 2168|  9.20k|    pjsip_supported_hdr *hdr;
 2169|  9.20k|    pj_bool_t new_hdr = (ctx->rdata==NULL || 
  ------------------
  |  Branch (2169:26): [True: 9.20k, False: 0]
  ------------------
 2170|      0|                         ctx->rdata->msg_info.supported == NULL);
  ------------------
  |  Branch (2170:26): [True: 0, False: 0]
  ------------------
 2171|       |
 2172|  9.20k|    if (ctx->rdata && ctx->rdata->msg_info.supported) {
  ------------------
  |  Branch (2172:9): [True: 0, False: 9.20k]
  |  Branch (2172:23): [True: 0, False: 0]
  ------------------
 2173|      0|        hdr = ctx->rdata->msg_info.supported;
 2174|  9.20k|    } else {
 2175|  9.20k|        hdr = pjsip_supported_hdr_create(ctx->pool);
 2176|  9.20k|        if (ctx->rdata)
  ------------------
  |  Branch (2176:13): [True: 0, False: 9.20k]
  ------------------
 2177|      0|            ctx->rdata->msg_info.supported = hdr;
 2178|  9.20k|    }
 2179|       |
 2180|  9.20k|    parse_generic_array_hdr(hdr, ctx->scanner);
 2181|  9.20k|    return new_hdr ? (pjsip_hdr*)hdr : NULL;
  ------------------
  |  Branch (2181:12): [True: 9.13k, False: 68]
  ------------------
 2182|  9.20k|}
sip_parser.c:parse_hdr_to:
 2186|  6.27k|{
 2187|  6.27k|    pjsip_to_hdr *hdr = pjsip_to_hdr_create(ctx->pool);
 2188|  6.27k|    parse_hdr_fromto(ctx->scanner, ctx->pool, hdr);
 2189|       |
 2190|  6.27k|    if (ctx->rdata)
  ------------------
  |  Branch (2190:9): [True: 0, False: 6.27k]
  ------------------
 2191|      0|        ctx->rdata->msg_info.to = hdr;
 2192|       |
 2193|  6.27k|    return (pjsip_hdr*)hdr;
 2194|  6.27k|}
sip_parser.c:parse_hdr_via:
 2354|  5.03k|{
 2355|  5.03k|    pjsip_via_hdr *first = NULL;
 2356|  5.03k|    pj_scanner *scanner = ctx->scanner;
 2357|       |
 2358|  5.10k|    do {
 2359|  5.10k|        pjsip_via_hdr *hdr = pjsip_via_hdr_create(ctx->pool);
 2360|  5.10k|        if (!first)
  ------------------
  |  Branch (2360:13): [True: 5.03k, False: 76]
  ------------------
 2361|  5.03k|            first = hdr;
 2362|     76|        else
 2363|     76|            pj_list_insert_before(first, hdr);
 2364|       |
 2365|  5.10k|        parse_sip_version(scanner);
 2366|  5.10k|        if (pj_scan_get_char(scanner) != '/')
  ------------------
  |  Branch (2366:13): [True: 278, False: 4.82k]
  ------------------
 2367|    278|            on_syntax_error(scanner);
 2368|       |
 2369|  5.10k|        pj_scan_get( scanner, &pconst.pjsip_TOKEN_SPEC, &hdr->transport);
 2370|  5.10k|        int_parse_host(scanner, &hdr->sent_by.host);
 2371|       |
 2372|  5.10k|        if (*scanner->curptr==':') {
  ------------------
  |  Branch (2372:13): [True: 228, False: 4.87k]
  ------------------
 2373|    228|            pj_str_t digit;
 2374|    228|            pj_scan_get_char(scanner);
 2375|    228|            pj_scan_get(scanner, &pconst.pjsip_DIGIT_SPEC, &digit);
 2376|    228|            strtoi_validate(&digit, PJSIP_MIN_PORT, PJSIP_MAX_PORT,
  ------------------
  |  |   45|    228|#define PJSIP_MIN_PORT              0           /**< For limit checks */
  ------------------
                          strtoi_validate(&digit, PJSIP_MIN_PORT, PJSIP_MAX_PORT,
  ------------------
  |  |   46|    228|#define PJSIP_MAX_PORT              PJ_MAXUINT16/**< For limit checks */
  |  |  ------------------
  |  |  |  |   36|    228|#define PJ_MAXUINT16    0xffff
  |  |  ------------------
  ------------------
 2377|    228|                            &hdr->sent_by.port);
 2378|    228|        }
 2379|       |        
 2380|  5.10k|        int_parse_via_param(hdr, scanner, ctx->pool);
 2381|       |
 2382|  5.10k|        if (*scanner->curptr == '(') {
  ------------------
  |  Branch (2382:13): [True: 76, False: 5.03k]
  ------------------
 2383|     76|            pj_scan_get_char(scanner);
 2384|     76|            pj_scan_get_until_ch( scanner, ')', &hdr->comment);
 2385|     76|            pj_scan_get_char( scanner );
 2386|     76|        }
 2387|       |
 2388|  5.10k|        if (*scanner->curptr != ',')
  ------------------
  |  Branch (2388:13): [True: 1.36k, False: 3.74k]
  ------------------
 2389|  1.36k|            break;
 2390|       |
 2391|  3.74k|        pj_scan_get_char(scanner);
 2392|       |
 2393|  3.74k|    } while (1);
  ------------------
  |  Branch (2393:14): [True: 76, Folded]
  ------------------
 2394|       |
 2395|  5.03k|    parse_hdr_end(scanner);
 2396|       |
 2397|  5.03k|    if (ctx->rdata && ctx->rdata->msg_info.via == NULL)
  ------------------
  |  Branch (2397:9): [True: 0, False: 5.03k]
  |  Branch (2397:23): [True: 0, False: 0]
  ------------------
 2398|      0|        ctx->rdata->msg_info.via = first;
 2399|       |
 2400|  5.03k|    return (pjsip_hdr*)first;
 2401|  5.03k|}
sip_parser.c:parse_sip_version:
  990|  6.55k|{
  991|  6.55k|    pj_str_t SIP = { "SIP", 3 };
  992|  6.55k|    pj_str_t V2 = { "2.0", 3 };
  993|  6.55k|    pj_str_t sip, version;
  994|       |
  995|  6.55k|    pj_scan_get( scanner, &pconst.pjsip_ALPHA_SPEC, &sip);
  996|  6.55k|    if (pj_scan_get_char(scanner) != '/')
  ------------------
  |  Branch (996:9): [True: 476, False: 6.08k]
  ------------------
  997|    476|        on_syntax_error(scanner);
  998|  6.55k|    pj_scan_get_n( scanner, 3, &version);
  999|  6.55k|    if (pj_stricmp(&sip, &SIP) || pj_stricmp(&version, &V2))
  ------------------
  |  Branch (999:9): [True: 1.95k, False: 4.60k]
  |  Branch (999:35): [True: 936, False: 3.66k]
  ------------------
 1000|  1.10k|        on_syntax_error(scanner);
 1001|  6.55k|}
sip_parser.c:int_parse_via_param:
 2207|  1.84k|{
 2208|  7.54k|    while ( *scanner->curptr == ';' ) {
  ------------------
  |  Branch (2208:13): [True: 5.70k, False: 1.84k]
  ------------------
 2209|  5.70k|        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|  5.70k|        pj_scan_get_char(scanner);
 2222|  5.70k|        parse_param_imp(scanner, pool, &pname, &pvalue,
 2223|  5.70k|                        &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|  5.70k|                        NULL,
 2228|  5.70k|                        0);
 2229|       |
 2230|  5.70k|        if (!parser_stricmp(pname, pconst.pjsip_BRANCH_STR) && pvalue.slen) {
  ------------------
  |  |  207|  11.4k|#define parser_stricmp(s1, s2)  (s1.slen!=s2.slen || pj_stricmp_alnum(&s1, &s2))
  |  |  ------------------
  |  |  |  |  408|    378|#define pj_stricmp_alnum    pj_stricmp
  |  |  ------------------
  |  |  |  Branch (207:34): [True: 5.32k, False: 378]
  |  |  |  Branch (207:54): [True: 226, False: 152]
  |  |  ------------------
  ------------------
  |  Branch (2230:64): [True: 104, False: 48]
  ------------------
 2231|    104|            hdr->branch_param = pvalue;
 2232|       |
 2233|  5.59k|        } else if (!parser_stricmp(pname, pconst.pjsip_TTL_STR) && pvalue.slen) {
  ------------------
  |  |  207|  11.1k|#define parser_stricmp(s1, s2)  (s1.slen!=s2.slen || pj_stricmp_alnum(&s1, &s2))
  |  |  ------------------
  |  |  |  |  408|  2.39k|#define pj_stricmp_alnum    pj_stricmp
  |  |  ------------------
  |  |  |  Branch (207:34): [True: 3.20k, False: 2.39k]
  |  |  |  Branch (207:54): [True: 1.39k, False: 992]
  |  |  ------------------
  ------------------
  |  Branch (2233:68): [True: 906, False: 86]
  ------------------
 2234|    906|            strtoi_validate(&pvalue, PJSIP_MIN_TTL, PJSIP_MAX_TTL,
  ------------------
  |  |   47|    906|#define PJSIP_MIN_TTL               0           /**< For limit checks */
  ------------------
                          strtoi_validate(&pvalue, PJSIP_MIN_TTL, PJSIP_MAX_TTL,
  ------------------
  |  |   48|    906|#define PJSIP_MAX_TTL               PJ_MAXUINT8 /**< For limit checks */
  |  |  ------------------
  |  |  |  |   39|    906|#define PJ_MAXUINT8     0xff
  |  |  ------------------
  ------------------
 2235|    906|                            &hdr->ttl_param);
 2236|       |            
 2237|  4.69k|        } else if (!parser_stricmp(pname, pconst.pjsip_MADDR_STR) && pvalue.slen) {
  ------------------
  |  |  207|  9.38k|#define parser_stricmp(s1, s2)  (s1.slen!=s2.slen || pj_stricmp_alnum(&s1, &s2))
  |  |  ------------------
  |  |  |  |  408|    460|#define pj_stricmp_alnum    pj_stricmp
  |  |  ------------------
  |  |  |  Branch (207:34): [True: 4.23k, False: 460]
  |  |  |  Branch (207:54): [True: 332, False: 128]
  |  |  ------------------
  ------------------
  |  Branch (2237:70): [True: 92, False: 36]
  ------------------
 2238|     92|            hdr->maddr_param = pvalue;
 2239|       |
 2240|  4.60k|        } else if (!parser_stricmp(pname, pconst.pjsip_RECEIVED_STR) && pvalue.slen) {
  ------------------
  |  |  207|  9.20k|#define parser_stricmp(s1, s2)  (s1.slen!=s2.slen || pj_stricmp_alnum(&s1, &s2))
  |  |  ------------------
  |  |  |  |  408|    270|#define pj_stricmp_alnum    pj_stricmp
  |  |  ------------------
  |  |  |  Branch (207:34): [True: 4.33k, False: 270]
  |  |  |  Branch (207:54): [True: 130, False: 140]
  |  |  ------------------
  ------------------
  |  Branch (2240:73): [True: 76, False: 64]
  ------------------
 2241|     76|            hdr->recvd_param = pvalue;
 2242|       |
 2243|  4.52k|        } else if (!parser_stricmp(pname, pconst.pjsip_RPORT_STR)) {
  ------------------
  |  |  207|  4.52k|#define parser_stricmp(s1, s2)  (s1.slen!=s2.slen || pj_stricmp_alnum(&s1, &s2))
  |  |  ------------------
  |  |  |  |  408|    368|#define pj_stricmp_alnum    pj_stricmp
  |  |  ------------------
  |  |  |  Branch (207:34): [True: 4.15k, False: 368]
  |  |  |  Branch (207:54): [True: 308, False: 60]
  |  |  ------------------
  ------------------
 2244|     60|            if (pvalue.slen) {
  ------------------
  |  Branch (2244:17): [True: 30, False: 30]
  ------------------
 2245|     30|                strtoi_validate(&pvalue, PJSIP_MIN_PORT, PJSIP_MAX_PORT,
  ------------------
  |  |   45|     30|#define PJSIP_MIN_PORT              0           /**< For limit checks */
  ------------------
                              strtoi_validate(&pvalue, PJSIP_MIN_PORT, PJSIP_MAX_PORT,
  ------------------
  |  |   46|     30|#define PJSIP_MAX_PORT              PJ_MAXUINT16/**< For limit checks */
  |  |  ------------------
  |  |  |  |   36|     30|#define PJ_MAXUINT16    0xffff
  |  |  ------------------
  ------------------
 2246|     30|                                &hdr->rport_param);
 2247|     30|            } else
 2248|     30|                hdr->rport_param = 0;
 2249|  4.46k|        } else {
 2250|  4.46k|            pjsip_param *p = PJ_POOL_ALLOC_T(pool, pjsip_param);
  ------------------
  |  |  569|  4.46k|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
 2251|  4.46k|            p->name = pname;
 2252|  4.46k|            p->value = pvalue;
 2253|  4.46k|            pj_list_insert_before(&hdr->other_param, p);
 2254|  4.46k|        }
 2255|  5.70k|    }
 2256|  1.84k|}
sip_parser.c:int_register_parser:
  610|     54|{
  611|     54|    unsigned    pos;
  612|     54|    handler_rec rec;
  613|       |
  614|     54|    if (handler_count >= PJ_ARRAY_SIZE(handler)) {
  ------------------
  |  |  315|     54|#define PJ_ARRAY_SIZE(a)    (sizeof(a)/sizeof(a[0]))
  ------------------
  |  Branch (614:9): [True: 0, False: 54]
  ------------------
  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|     54|    rec.handler = fptr;
  621|     54|    rec.hname_len = strlen(name);
  622|     54|    if (rec.hname_len >= sizeof(rec.hname)) {
  ------------------
  |  Branch (622:9): [True: 0, False: 54]
  ------------------
  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|     54|    pj_memcpy(rec.hname, name, rec.hname_len);
  628|     54|    rec.hname[rec.hname_len] = '\0';
  629|       |
  630|       |    /* Calculate hash value. */
  631|     54|    rec.hname_hash = pj_hash_calc(0, rec.hname, (unsigned)rec.hname_len);
  632|       |
  633|       |    /* Get the pos to insert the new handler. */
  634|    773|    for (pos=0; pos < handler_count; ++pos) {
  ------------------
  |  Branch (634:17): [True: 770, False: 3]
  ------------------
  635|    770|        int d;
  636|    770|        d = compare_handler(&handler[pos], rec.hname, rec.hname_len, 
  637|    770|                            rec.hname_hash);
  638|    770|        if (d == 0) {
  ------------------
  |  Branch (638:13): [True: 0, False: 770]
  ------------------
  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|    770|        if (d > 0) {
  ------------------
  |  Branch (642:13): [True: 51, False: 719]
  ------------------
  643|     51|            break;
  644|     51|        }
  645|    770|    }
  646|       |
  647|       |    /* Shift handlers. */
  648|     54|    if (pos != handler_count) {
  ------------------
  |  Branch (648:9): [True: 51, False: 3]
  ------------------
  649|     51|        pj_memmove( &handler[pos+1], &handler[pos], 
  650|     51|                    (handler_count-pos)*sizeof(handler_rec));
  651|     51|    }
  652|       |    /* Add new handler. */
  653|     54|    pj_memcpy( &handler[pos], &rec, sizeof(handler_rec));
  654|     54|    ++handler_count;
  655|       |
  656|     54|    return PJ_SUCCESS;
  657|     54|}
sip_parser.c:compare_handler:
  588|   350k|{
  589|   350k|    PJ_UNUSED_ARG(name_len);
  ------------------
  |  | 1537|   350k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  590|       |
  591|       |    /* Compare hashed value. */
  592|   350k|    if (r1->hname_hash < hash)
  ------------------
  |  Branch (592:9): [True: 26.8k, False: 323k]
  ------------------
  593|  26.8k|        return -1;
  594|   323k|    if (r1->hname_hash > hash)
  ------------------
  |  Branch (594:9): [True: 286k, False: 36.8k]
  ------------------
  595|   286k|        return 1;
  596|       |
  597|       |    /* Compare length. */
  598|  36.8k|    if (r1->hname_len < name_len)
  ------------------
  |  Branch (598:9): [True: 0, False: 36.8k]
  ------------------
  599|      0|        return -1;
  600|  36.8k|    if (r1->hname_len > name_len)
  ------------------
  |  Branch (600:9): [True: 0, False: 36.8k]
  ------------------
  601|      0|        return 1;
  602|       |
  603|       |    /* Equal length and equal hash. compare the strings. */
  604|  36.8k|    return pj_memcmp(r1->hname, name, name_len);
  605|  36.8k|}
sip_parser.c:on_syntax_error:
  228|  21.3k|{
  229|  21.3k|    PJ_UNUSED_ARG(scanner);
  ------------------
  |  | 1537|  21.3k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  230|  21.3k|    PJ_THROW(PJSIP_SYN_ERR_EXCEPTION);
  ------------------
  |  |  402|  21.3k|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
  231|  21.3k|}
sip_parser.c:strtoi_validate:
  264|  8.06k|{ 
  265|  8.06k|    long retval;
  266|  8.06k|    pj_status_t status;
  267|       |
  268|  8.06k|    if (!str || !value) {
  ------------------
  |  Branch (268:9): [True: 0, False: 8.06k]
  |  Branch (268:17): [True: 0, False: 8.06k]
  ------------------
  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|  8.06k|    status = pj_strtol2(str, &retval);
  273|  8.06k|    if (status != PJ_EINVAL) {
  ------------------
  |  |  393|  8.06k|#define PJ_EINVAL           (PJ_ERRNO_START_STATUS + 4) /* 70004 */
  |  |  ------------------
  |  |  |  |  521|  8.06k|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|  8.06k|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|  8.06k|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (273:9): [True: 7.62k, False: 444]
  ------------------
  274|  7.62k|        if (min_val > retval) {
  ------------------
  |  Branch (274:13): [True: 72, False: 7.54k]
  ------------------
  275|     72|            *value = min_val;
  276|     72|            status = PJ_ETOOSMALL;
  ------------------
  |  |  469|     72|#define PJ_ETOOSMALL        (PJ_ERRNO_START_STATUS + 19)/* 70019 */
  |  |  ------------------
  |  |  |  |  521|     72|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|     72|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|     72|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  277|  7.54k|        } else if (retval > max_val) {
  ------------------
  |  Branch (277:20): [True: 586, False: 6.96k]
  ------------------
  278|    586|            *value = max_val;
  279|    586|            status = PJ_ETOOBIG;
  ------------------
  |  |  458|    586|#define PJ_ETOOBIG          (PJ_ERRNO_START_STATUS + 17)/* 70017 */
  |  |  ------------------
  |  |  |  |  521|    586|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|    586|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|    586|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  280|    586|        } else
  281|  6.96k|            *value = (int)retval;
  282|  7.62k|    }
  283|       |
  284|  8.06k|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (284:9): [True: 1.10k, False: 6.96k]
  ------------------
  285|  1.10k|        on_str_parse_error(str, status);
  286|  8.06k|}
sip_parser.c:on_str_parse_error:
  235|  1.10k|{
  236|  1.10k|    char *s;
  237|       |
  238|  1.10k|    switch(rc) {
  239|    444|    case PJ_EINVAL:
  ------------------
  |  |  393|    444|#define PJ_EINVAL           (PJ_ERRNO_START_STATUS + 4) /* 70004 */
  |  |  ------------------
  |  |  |  |  521|    444|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|    444|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|    444|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (239:5): [True: 444, False: 658]
  ------------------
  240|    444|        s = "NULL input string, invalid input string, or NULL return "\
  241|    444|            "value pointer";
  242|    444|        break;
  243|     72|    case PJ_ETOOSMALL:
  ------------------
  |  |  469|     72|#define PJ_ETOOSMALL        (PJ_ERRNO_START_STATUS + 19)/* 70019 */
  |  |  ------------------
  |  |  |  |  521|     72|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|     72|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|     72|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (243:5): [True: 72, False: 1.03k]
  ------------------
  244|     72|        s = "String value was less than the minimum allowed value.";
  245|     72|        break;
  246|    586|    case PJ_ETOOBIG:
  ------------------
  |  |  458|    586|#define PJ_ETOOBIG          (PJ_ERRNO_START_STATUS + 17)/* 70017 */
  |  |  ------------------
  |  |  |  |  521|    586|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  509|    586|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  515|    586|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (246:5): [True: 586, False: 516]
  ------------------
  247|    586|        s = "String value was greater than the maximum allowed value.";
  248|    586|        break;
  249|      0|    default:
  ------------------
  |  Branch (249:5): [True: 0, False: 1.10k]
  ------------------
  250|      0|        s = "Unknown error";
  251|  1.10k|    }
  252|       |
  253|  1.10k|    if (str) {
  ------------------
  |  Branch (253:9): [True: 1.10k, False: 0]
  ------------------
  254|  1.10k|        PJ_LOG(1, (THIS_FILE, "Error parsing '%.*s': %s",
  ------------------
  |  |  106|  1.10k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  1.10k|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|  2.20k|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 1.10k, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 1.10k]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  432|      0|    #define pj_log_wrapper_1(arg)       pj_log_1 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|  1.10k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 1.10k]
  |  |  ------------------
  ------------------
  255|  1.10k|                   (int)str->slen, str->ptr, s));
  256|  1.10k|    } 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|  1.10k|    PJ_THROW(PJSIP_EINVAL_ERR_EXCEPTION);
  ------------------
  |  |  402|  1.10k|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
  260|  1.10k|}
sip_parser.c:int_parse_msg:
 1021|  1.69k|{
 1022|       |    /* These variables require "volatile" so their values get
 1023|       |     * preserved when re-entering the PJ_TRY block after an error.
 1024|       |     */
 1025|  1.69k|    volatile pj_bool_t parsing_headers;
 1026|  1.69k|    pjsip_msg *volatile msg = NULL;
 1027|  1.69k|    pjsip_ctype_hdr *volatile ctype_hdr = NULL;
 1028|       |
 1029|  1.69k|    pj_str_t hname;
 1030|  1.69k|    pj_scanner *scanner = ctx->scanner;
 1031|  1.69k|    pj_pool_t *pool = ctx->pool;
 1032|  1.69k|    PJ_USE_EXCEPTION;
  ------------------
  |  |  367|  1.69k|#define PJ_USE_EXCEPTION    struct pj_exception_state_t pj_x_except__; int pj_x_code__
  ------------------
 1033|       |
 1034|  1.69k|    parsing_headers = PJ_FALSE;
 1035|       |
 1036|  38.4k|retry_parse:
 1037|  38.4k|    PJ_TRY 
  ------------------
  |  |  373|  38.4k|#define PJ_TRY              if (1) { \
  |  |  ------------------
  |  |  |  Branch (373:33): [True: 38.4k, Folded]
  |  |  ------------------
  |  |  374|  38.4k|                                pj_push_exception_handler_(&pj_x_except__); \
  |  |  375|  38.4k|                                pj_x_code__ = pj_setjmp(pj_x_except__.state); \
  |  |  ------------------
  |  |  |  |   31|  38.4k|#    define pj_setjmp(buf)      setjmp(buf)
  |  |  ------------------
  |  |  376|  38.4k|                                if (pj_x_code__ == 0)
  |  |  ------------------
  |  |  |  Branch (376:37): [True: 38.4k, False: 0]
  |  |  ------------------
  ------------------
 1038|  38.4k|    {
 1039|  38.4k|        if (parsing_headers)
  ------------------
  |  Branch (1039:13): [True: 36.7k, False: 1.69k]
  ------------------
 1040|  36.7k|            goto parse_headers;
 1041|       |
 1042|       |        /* Skip leading newlines. */
 1043|  4.53k|        while (IS_NEWLINE(*scanner->curptr)) {
  ------------------
  |  |   62|  4.53k|#define IS_NEWLINE(c)   ((c)=='\r' || (c)=='\n')
  |  |  ------------------
  |  |  |  Branch (62:26): [True: 710, False: 3.82k]
  |  |  |  Branch (62:39): [True: 2.13k, False: 1.69k]
  |  |  ------------------
  ------------------
 1044|  2.84k|            pj_scan_get_newline(scanner);
 1045|  2.84k|        }
 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|  1.69k|        if (pj_scan_is_eof(scanner))
  ------------------
  |  Branch (1051:13): [True: 10, False: 1.68k]
  ------------------
 1052|     10|            return NULL;
 1053|       |
 1054|       |        /* Parse request or status line */
 1055|  1.68k|        if (is_next_sip_version(scanner)) {
  ------------------
  |  Branch (1055:13): [True: 1.14k, False: 538]
  ------------------
 1056|  1.14k|            msg = pjsip_msg_create(pool, PJSIP_RESPONSE_MSG);
 1057|  1.14k|            int_parse_status_line( scanner, &msg->line.status );
 1058|  1.14k|        } else {
 1059|    538|            msg = pjsip_msg_create(pool, PJSIP_REQUEST_MSG);
 1060|    538|            int_parse_req_line(scanner, pool, &msg->line.req );
 1061|    538|        }
 1062|       |
 1063|  1.68k|        parsing_headers = PJ_TRUE;
 1064|       |
 1065|  37.8k|parse_headers:
 1066|       |        /* Parse headers. */
 1067|  57.1k|        do {
 1068|  57.1k|            pjsip_parse_hdr_func * func;
 1069|  57.1k|            pjsip_hdr *hdr = NULL;
 1070|       |
 1071|       |            /* Init hname just in case parsing fails.
 1072|       |             * Ref: PROTOS #2412
 1073|       |             */
 1074|  57.1k|            hname.slen = 0;
 1075|       |            
 1076|       |            /* Get hname. */
 1077|  57.1k|            pj_scan_get( scanner, &pconst.pjsip_TOKEN_SPEC, &hname);
 1078|  57.1k|            if (pj_scan_get_char( scanner ) != ':') {
  ------------------
  |  Branch (1078:17): [True: 9.49k, False: 47.6k]
  ------------------
 1079|  9.49k|                PJ_THROW(PJSIP_SYN_ERR_EXCEPTION);
  ------------------
  |  |  402|  9.49k|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
 1080|  9.49k|            }
 1081|       |            
 1082|       |            /* Find handler. */
 1083|  47.6k|            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|  47.6k|            if (func) {
  ------------------
  |  Branch (1089:17): [True: 36.8k, False: 10.7k]
  ------------------
 1090|  36.8k|                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|  36.8k|                if (hdr && hdr->type == PJSIP_H_CONTENT_TYPE) {
  ------------------
  |  Branch (1102:21): [True: 13.8k, False: 23.0k]
  |  Branch (1102:28): [True: 1.29k, False: 12.5k]
  ------------------
 1103|  1.29k|                    ctype_hdr = (pjsip_ctype_hdr*)hdr;
 1104|  1.29k|                }
 1105|       |
 1106|  36.8k|            } else {
 1107|  10.7k|                hdr = parse_hdr_generic_string(ctx);
 1108|  10.7k|                hdr->name = hdr->sname = hname;
 1109|  10.7k|            }
 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|  47.6k|            if (hdr)
  ------------------
  |  Branch (1117:17): [True: 19.5k, False: 28.1k]
  ------------------
 1118|  19.5k|                pj_list_insert_nodes_before(&msg->hdr, hdr);
 1119|       |            
 1120|       |            /* Parse until EOF or an empty line is found. */
 1121|  47.6k|        } while (!pj_scan_is_eof(scanner) && !IS_NEWLINE(*scanner->curptr));
  ------------------
  |  |   62|  19.3k|#define IS_NEWLINE(c)   ((c)=='\r' || (c)=='\n')
  |  |  ------------------
  |  |  |  Branch (62:26): [True: 6, False: 19.3k]
  |  |  |  Branch (62:39): [True: 44, False: 19.3k]
  |  |  ------------------
  ------------------
  |  Branch (1121:18): [True: 19.3k, False: 28.3k]
  ------------------
 1122|       |        
 1123|  28.3k|        parsing_headers = PJ_FALSE;
 1124|       |
 1125|       |        /* If empty line is found, eat it. */
 1126|  28.3k|        if (!pj_scan_is_eof(scanner)) {
  ------------------
  |  Branch (1126:13): [True: 50, False: 28.3k]
  ------------------
 1127|     50|            if (IS_NEWLINE(*scanner->curptr)) {
  ------------------
  |  |   62|     50|#define IS_NEWLINE(c)   ((c)=='\r' || (c)=='\n')
  |  |  ------------------
  |  |  |  Branch (62:26): [True: 6, False: 44]
  |  |  |  Branch (62:39): [True: 44, False: 0]
  |  |  ------------------
  ------------------
 1128|     50|                pj_scan_get_newline(scanner);
 1129|     50|            }
 1130|     50|        }
 1131|       |
 1132|       |        /* If we have Content-Type header, treat the rest of the message 
 1133|       |         * as body.
 1134|       |         */
 1135|  28.3k|        if (ctype_hdr && scanner->curptr!=scanner->end) {
  ------------------
  |  Branch (1135:13): [True: 34, False: 28.3k]
  |  Branch (1135:26): [True: 20, False: 14]
  ------------------
 1136|       |            /* New: if Content-Type indicates that this is a multipart
 1137|       |             * message body, parse it.
 1138|       |             */
 1139|     20|            const pj_str_t STR_MULTIPART = { "multipart", 9 };
 1140|     20|            pjsip_msg_body *body;
 1141|       |
 1142|     20|            if (pj_stricmp(&ctype_hdr->media.type, &STR_MULTIPART)==0) {
  ------------------
  |  Branch (1142:17): [True: 0, False: 20]
  ------------------
 1143|      0|                body = pjsip_multipart_parse(pool, scanner->curptr,
 1144|      0|                                             scanner->end - scanner->curptr,
 1145|      0|                                             &ctype_hdr->media, 0);
 1146|     20|            } else {
 1147|     20|                body = PJ_POOL_ALLOC_T(pool, pjsip_msg_body);
  ------------------
  |  |  569|     20|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
 1148|     20|                pjsip_media_type_cp(pool, &body->content_type,
 1149|     20|                                    &ctype_hdr->media);
 1150|       |
 1151|     20|                body->data = scanner->curptr;
 1152|     20|                body->len = (unsigned)(scanner->end - scanner->curptr);
 1153|     20|                body->print_body = &pjsip_print_text_body;
 1154|     20|                body->clone_data = &pjsip_clone_text_data;
 1155|     20|            }
 1156|       |
 1157|     20|            msg->body = body;
 1158|     20|        }
 1159|  28.3k|    }
 1160|      0|    PJ_CATCH_ANY 
 1161|      0|    {
 1162|       |        /* Exception was thrown during parsing. 
 1163|       |         * Skip until newline, and parse next header. 
 1164|       |         */
 1165|  38.2k|        if (err_list) {
  ------------------
  |  Branch (1165:13): [True: 38.2k, False: 18.4E]
  ------------------
 1166|  38.2k|            pjsip_parser_err_report *err_info;
 1167|       |            
 1168|  38.2k|            err_info = PJ_POOL_ALLOC_T(pool, pjsip_parser_err_report);
  ------------------
  |  |  569|  38.2k|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
 1169|  38.2k|            err_info->except_code = PJ_GET_EXCEPTION();
  ------------------
  |  |  409|  38.2k|#define PJ_GET_EXCEPTION()      (pj_x_code__)
  ------------------
 1170|  38.2k|            err_info->line = scanner->line;
 1171|       |            /* Scanner's column is zero based, so add 1 */
 1172|  38.2k|            err_info->col = pj_scan_get_col(scanner) + 1;
 1173|  38.2k|            if (parsing_headers)
  ------------------
  |  Branch (1173:17): [True: 37.6k, False: 538]
  ------------------
 1174|  37.6k|                err_info->hname = hname;
 1175|    538|            else if (msg && msg->type == PJSIP_REQUEST_MSG)
  ------------------
  |  Branch (1175:22): [True: 538, False: 0]
  |  Branch (1175:29): [True: 520, False: 18]
  ------------------
 1176|    520|                err_info->hname = pj_str("Request Line");
 1177|     18|            else if (msg && msg->type == PJSIP_RESPONSE_MSG)
  ------------------
  |  Branch (1177:22): [True: 18, False: 0]
  |  Branch (1177:29): [True: 18, False: 0]
  ------------------
 1178|     18|                err_info->hname = pj_str("Status Line");
 1179|      0|            else
 1180|      0|                err_info->hname.slen = 0;
 1181|       |            
 1182|  38.2k|            pj_list_insert_before(err_list, err_info);
 1183|  38.2k|        }
 1184|       |        
 1185|  37.6k|        if (parsing_headers) {
  ------------------
  |  Branch (1185:13): [True: 37.6k, False: 18.4E]
  ------------------
 1186|  37.6k|            if (!pj_scan_is_eof(scanner)) {
  ------------------
  |  Branch (1186:17): [True: 37.4k, False: 200]
  ------------------
 1187|       |                /* Skip until next line.
 1188|       |                 * Watch for header continuation.
 1189|       |                 */
 1190|  37.8k|                do {
 1191|  37.8k|                    pj_scan_skip_line(scanner);
 1192|  37.8k|                } while (IS_SPACE(*scanner->curptr));
  ------------------
  |  |   63|  37.8k|#define IS_SPACE(c)     ((c)==' ' || (c)=='\t')
  |  |  ------------------
  |  |  |  Branch (63:26): [True: 260, False: 37.5k]
  |  |  |  Branch (63:38): [True: 112, False: 37.4k]
  |  |  ------------------
  ------------------
 1193|  37.4k|            }
 1194|       |
 1195|       |            /* Restore flag. Flag may be set in int_parse_sip_url() */
 1196|  37.6k|            scanner->skip_ws = PJ_SCAN_AUTOSKIP_WS_HEADER;
 1197|       |
 1198|       |            /* Continue parse next header, if any. */
 1199|  37.6k|            if (!pj_scan_is_eof(scanner) && !IS_NEWLINE(*scanner->curptr)) {
  ------------------
  |  |   62|  36.8k|#define IS_NEWLINE(c)   ((c)=='\r' || (c)=='\n')
  |  |  ------------------
  |  |  |  Branch (62:26): [True: 8, False: 36.7k]
  |  |  |  Branch (62:39): [True: 76, False: 36.7k]
  |  |  ------------------
  ------------------
  |  Branch (1199:17): [True: 36.8k, False: 862]
  ------------------
 1200|  36.7k|                goto retry_parse;
 1201|  36.7k|            }
 1202|  37.6k|        }
 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|  38.4k|}
sip_parser.c:is_next_sip_version:
 1004|  1.68k|{
 1005|  1.68k|    pj_str_t SIP = { "SIP", 3 };
 1006|  1.68k|    pj_str_t sip;
 1007|  1.68k|    int c;
 1008|       |
 1009|  1.68k|    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|  1.68k|    return c && (c=='/' || c==' ' || c=='\t') && pj_stricmp(&sip, &SIP)==0;
  ------------------
  |  Branch (1015:12): [True: 1.67k, False: 6]
  |  Branch (1015:18): [True: 232, False: 1.44k]
  |  Branch (1015:28): [True: 980, False: 466]
  |  Branch (1015:38): [True: 50, False: 416]
  |  Branch (1015:50): [True: 1.14k, False: 116]
  ------------------
 1016|  1.68k|}
sip_parser.c:int_parse_req_line:
 1688|    538|{
 1689|    538|    pj_str_t token;
 1690|       |
 1691|    538|    pj_scan_get( scanner, &pconst.pjsip_TOKEN_SPEC, &token);
 1692|    538|    pjsip_method_init_np( &req_line->method, &token);
 1693|       |
 1694|    538|    req_line->uri = int_parse_uri(scanner, pool, PJ_TRUE);
 1695|    538|    parse_sip_version(scanner);
 1696|    538|    pj_scan_get_newline( scanner );
 1697|    538|}
sip_parser.c:parse_param_imp:
 1217|  29.3k|{
 1218|       |    /* pname */
 1219|  29.3k|    if (!esc_spec) {
  ------------------
  |  Branch (1219:9): [True: 22.4k, False: 6.99k]
  ------------------
 1220|  22.4k|        pj_scan_get(scanner, spec, pname);
 1221|  22.4k|    } else {
 1222|  6.99k|        parser_get_and_unescape(scanner, pool, spec, esc_spec, pname);
 1223|  6.99k|    }
 1224|       |
 1225|       |    /* init pvalue */
 1226|  29.3k|    pvalue->ptr = NULL;
 1227|  29.3k|    pvalue->slen = 0;
 1228|       |
 1229|       |    /* pvalue, if any */
 1230|  29.3k|    if (*scanner->curptr == '=') {
  ------------------
  |  Branch (1230:9): [True: 6.28k, False: 23.1k]
  ------------------
 1231|  6.28k|        pj_scan_get_char(scanner);
 1232|  6.28k|        if (!pj_scan_is_eof(scanner)) {
  ------------------
  |  Branch (1232:13): [True: 6.27k, False: 12]
  ------------------
 1233|       |            /* pvalue can be a quoted string. */
 1234|  6.27k|            if (*scanner->curptr == '"') {
  ------------------
  |  Branch (1234:17): [True: 478, False: 5.79k]
  ------------------
 1235|    478|                pj_scan_get_quote( scanner, '"', '"', pvalue);
 1236|    478|                if (option & PJSIP_PARSE_REMOVE_QUOTE) {
  ------------------
  |  Branch (1236:21): [True: 0, False: 478]
  ------------------
 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|  5.79k|            } else if(pj_cis_match(spec, *scanner->curptr)) {
  ------------------
  |  Branch (1252:23): [True: 5.20k, False: 588]
  ------------------
 1253|  5.20k|                if (!esc_spec) {
  ------------------
  |  Branch (1253:21): [True: 4.50k, False: 702]
  ------------------
 1254|  4.50k|                    pj_scan_get(scanner, spec, pvalue);
 1255|  4.50k|                } else {
 1256|    702|                    parser_get_and_unescape(scanner, pool, spec, esc_spec,
 1257|    702|                                            pvalue);
 1258|    702|                }
 1259|  5.20k|            }
 1260|  6.27k|        }
 1261|  6.28k|    }
 1262|  29.3k|}
sip_parser.c:int_parse_uri_or_name_addr:
 1415|  18.5k|{
 1416|  18.5k|    pjsip_uri *uri;
 1417|  18.5k|    int is_name_addr = 0;
 1418|       |
 1419|       |    /* Exhaust any whitespaces. */
 1420|  18.5k|    pj_scan_skip_whitespace(scanner);
 1421|       |
 1422|  18.5k|    if (*scanner->curptr=='"' || *scanner->curptr=='<') {
  ------------------
  |  Branch (1422:9): [True: 3.93k, False: 14.5k]
  |  Branch (1422:34): [True: 574, False: 14.0k]
  ------------------
 1423|  4.51k|        uri = (pjsip_uri*)int_parse_name_addr( scanner, pool );
 1424|  4.51k|        is_name_addr = 1;
 1425|  14.0k|    } else {
 1426|  14.0k|        pj_str_t scheme;
 1427|  14.0k|        int next_ch;
 1428|       |
 1429|  14.0k|        next_ch = pj_scan_peek( scanner, &pconst.pjsip_DISPLAY_SPEC, &scheme);
 1430|       |
 1431|  14.0k|        if (next_ch==':') {
  ------------------
  |  Branch (1431:13): [True: 8.44k, False: 5.58k]
  ------------------
 1432|  8.44k|            pjsip_parse_uri_func *func = find_uri_handler(&scheme);
 1433|       |
 1434|  8.44k|            if (func == NULL) {
  ------------------
  |  Branch (1434:17): [True: 0, False: 8.44k]
  ------------------
 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.44k|            uri = (pjsip_uri*)
 1440|  8.44k|                  (*func)(scanner, pool, 
 1441|  8.44k|                          (opt & PJSIP_PARSE_URI_IN_FROM_TO_HDR)==0);
 1442|       |
 1443|       |
 1444|  8.44k|        } else {
 1445|  5.58k|            uri = (pjsip_uri*)int_parse_name_addr( scanner, pool );
 1446|  5.58k|            is_name_addr = 1;
 1447|  5.58k|        }
 1448|  14.0k|    }
 1449|       |
 1450|       |    /* Should we return the URI object as name address? */
 1451|  18.5k|    if (opt & PJSIP_PARSE_URI_AS_NAMEADDR) {
  ------------------
  |  Branch (1451:9): [True: 9.17k, False: 9.36k]
  ------------------
 1452|  9.17k|        if (is_name_addr == 0) {
  ------------------
  |  Branch (1452:13): [True: 7.11k, False: 2.06k]
  ------------------
 1453|  7.11k|            pjsip_name_addr *name_addr;
 1454|       |
 1455|  7.11k|            name_addr = pjsip_name_addr_create(pool);
 1456|  7.11k|            name_addr->uri = uri;
 1457|       |
 1458|  7.11k|            uri = (pjsip_uri*)name_addr;
 1459|  7.11k|        }
 1460|  9.17k|    }
 1461|       |
 1462|  18.5k|    return uri;
 1463|  18.5k|}
sip_parser.c:int_parse_status_line:
 1702|  1.14k|{
 1703|  1.14k|    pj_str_t token;
 1704|       |
 1705|  1.14k|    parse_sip_version(scanner);
 1706|  1.14k|    pj_scan_get( scanner, &pconst.pjsip_DIGIT_SPEC, &token);
 1707|  1.14k|    strtoi_validate(&token, PJSIP_MIN_STATUS_CODE, PJSIP_MAX_STATUS_CODE,
  ------------------
  |  |   49|  1.14k|#define PJSIP_MIN_STATUS_CODE       100         /**< For limit checks */
  ------------------
                  strtoi_validate(&token, PJSIP_MIN_STATUS_CODE, PJSIP_MAX_STATUS_CODE,
  ------------------
  |  |   50|  1.14k|#define PJSIP_MAX_STATUS_CODE       999         /**< For limit checks */
  ------------------
 1708|  1.14k|                    &status_line->code);
 1709|  1.14k|    if (*scanner->curptr != '\r' && *scanner->curptr != '\n')
  ------------------
  |  Branch (1709:9): [True: 1.06k, False: 86]
  |  Branch (1709:37): [True: 1.01k, False: 46]
  ------------------
 1710|  1.01k|        pj_scan_get( scanner, &pconst.pjsip_NOT_NEWLINE, &status_line->reason);
 1711|    132|    else
 1712|    132|        status_line->reason.slen=0, status_line->reason.ptr=NULL;
 1713|  1.14k|    pj_scan_get_newline( scanner );
 1714|  1.14k|}
sip_parser.c:parse_hdr_end:
 1749|  27.0k|{
 1750|  27.0k|    if (pj_scan_is_eof(scanner)) {
  ------------------
  |  Branch (1750:9): [True: 130, False: 26.8k]
  ------------------
 1751|    130|        ;   /* Do nothing. */
 1752|  26.8k|    } else if (*scanner->curptr == '&') {
  ------------------
  |  Branch (1752:16): [True: 1.54k, False: 25.3k]
  ------------------
 1753|  1.54k|        pj_scan_get_char(scanner);
 1754|  25.3k|    } else {
 1755|  25.3k|        pj_scan_get_newline(scanner);
 1756|  25.3k|    }
 1757|  27.0k|}
sip_parser.c:parse_generic_array_hdr:
 1768|  9.20k|{
 1769|  9.20k|    pj_str_t elem;
 1770|       |
 1771|       |    /* Some header fields allow empty elements in the value:
 1772|       |     *   Accept, Allow, Supported
 1773|       |     */
 1774|  9.20k|    if (pj_scan_is_eof(scanner) || 
  ------------------
  |  Branch (1774:9): [True: 2, False: 9.20k]
  ------------------
 1775|  9.20k|        *scanner->curptr == '\r' || *scanner->curptr == '\n') 
  ------------------
  |  Branch (1775:9): [True: 5.78k, False: 3.42k]
  |  Branch (1775:37): [True: 1.68k, False: 1.73k]
  ------------------
 1776|  7.46k|    {
 1777|  7.46k|        goto end;
 1778|  7.46k|    }
 1779|       |
 1780|  1.73k|    if (hdr->count >= PJ_ARRAY_SIZE(hdr->values)) {
  ------------------
  |  |  315|  1.73k|#define PJ_ARRAY_SIZE(a)    (sizeof(a)/sizeof(a[0]))
  ------------------
  |  Branch (1780:9): [True: 0, False: 1.73k]
  ------------------
 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|  3.52k|    while (hdr->count < PJ_ARRAY_SIZE(hdr->values))
  ------------------
  |  |  315|  3.52k|#define PJ_ARRAY_SIZE(a)    (sizeof(a)/sizeof(a[0]))
  ------------------
  |  Branch (1790:12): [True: 3.52k, False: 2]
  ------------------
 1791|  3.52k|    {
 1792|       |        /* Skip any leading/consecutive commas */
 1793|  6.16k|        while (*scanner->curptr == ',') {
  ------------------
  |  Branch (1793:16): [True: 2.64k, False: 3.52k]
  ------------------
 1794|  2.64k|            pj_scan_get_char(scanner);
 1795|  2.64k|        }
 1796|       |        
 1797|       |        /* Check for end of header */
 1798|  3.52k|        if (pj_scan_is_eof(scanner) || 
  ------------------
  |  Branch (1798:13): [True: 2, False: 3.52k]
  ------------------
 1799|  3.52k|            *scanner->curptr == '\r' || *scanner->curptr == '\n') 
  ------------------
  |  Branch (1799:13): [True: 266, False: 3.25k]
  |  Branch (1799:41): [True: 130, False: 3.12k]
  ------------------
 1800|    398|        {
 1801|    398|            break;
 1802|    398|        }
 1803|       |        
 1804|       |        /* Get element */
 1805|  3.12k|        pj_scan_get( scanner, &pconst.pjsip_NOT_COMMA_OR_NEWLINE, &elem);
 1806|  3.12k|        if (elem.slen > 0) {
  ------------------
  |  Branch (1806:13): [True: 3.12k, False: 0]
  ------------------
 1807|  3.12k|            hdr->values[hdr->count++] = elem;
 1808|  3.12k|        }
 1809|       |        
 1810|       |        /* If not followed by comma, we're done */
 1811|  3.12k|        if (*scanner->curptr != ',') {
  ------------------
  |  Branch (1811:13): [True: 1.33k, False: 1.79k]
  ------------------
 1812|  1.33k|            break;
 1813|  1.33k|        }
 1814|  3.12k|    }
 1815|       |
 1816|  9.20k|end:
 1817|  9.20k|    parse_hdr_end(scanner);
 1818|  9.20k|}
sip_parser.c:find_handler:
  741|  42.7k|{
  742|  42.7k|    pj_uint32_t hash;
  743|  42.7k|    char hname_copy[PJSIP_MAX_HNAME_LEN];
  744|  42.7k|    pj_str_t tmp;
  745|  42.7k|    pjsip_parse_hdr_func *func;
  746|       |
  747|  42.7k|    if (hname->slen >= PJSIP_MAX_HNAME_LEN) {
  ------------------
  |  | 1145|  42.7k|#define PJSIP_MAX_HNAME_LEN             64
  ------------------
  |  Branch (747:9): [True: 92, False: 42.6k]
  ------------------
  748|       |        /* Guaranteed not to be able to find handler. */
  749|     92|        return NULL;
  750|     92|    }
  751|       |
  752|       |    /* First, common case, try to find handler with exact name */
  753|  42.6k|    hash = pj_hash_calc(0, hname->ptr, (unsigned)hname->slen);
  754|  42.6k|    func = find_handler_imp(hash, hname);
  755|  42.6k|    if (func)
  ------------------
  |  Branch (755:9): [True: 18.4k, False: 24.1k]
  ------------------
  756|  18.4k|        return func;
  757|       |
  758|       |
  759|       |    /* If not found, try converting the header name to lowercase and
  760|       |     * search again.
  761|       |     */
  762|  24.1k|    hash = pj_hash_calc_tolower(0, hname_copy, hname);
  763|  24.1k|    tmp.ptr = hname_copy;
  764|  24.1k|    tmp.slen = hname->slen;
  765|  24.1k|    return find_handler_imp(hash, &tmp);
  766|  42.6k|}
sip_parser.c:find_handler_imp:
  710|  66.7k|{
  711|  66.7k|    handler_rec *first;
  712|  66.7k|    int          comp;
  713|  66.7k|    unsigned     n;
  714|       |
  715|       |    /* Binary search for the handler. */
  716|  66.7k|    comp = -1;
  717|  66.7k|    first = &handler[0];
  718|  66.7k|    n = handler_count;
  719|   379k|    for (; n > 0; ) {
  ------------------
  |  Branch (719:12): [True: 349k, False: 29.9k]
  ------------------
  720|   349k|        unsigned half = n / 2;
  721|   349k|        handler_rec *mid = first + half;
  722|       |
  723|   349k|        comp = compare_handler(mid, hname->ptr, hname->slen, hash);
  724|   349k|        if (comp < 0) {
  ------------------
  |  Branch (724:13): [True: 26.1k, False: 323k]
  ------------------
  725|  26.1k|            first = ++mid;
  726|  26.1k|            n -= half + 1;
  727|   323k|        } else if (comp==0) {
  ------------------
  |  Branch (727:20): [True: 36.8k, False: 286k]
  ------------------
  728|  36.8k|            first = mid;
  729|  36.8k|            break;
  730|   286k|        } else {
  731|   286k|            n = half;
  732|   286k|        }
  733|   349k|    }
  734|       |
  735|  66.7k|    return comp==0 ? first->handler : NULL;
  ------------------
  |  Branch (735:12): [True: 36.8k, False: 29.9k]
  ------------------
  736|  66.7k|}
sip_parser.c:parse_hdr_generic_string:
 2405|  5.83k|{
 2406|  5.83k|    pjsip_generic_string_hdr *hdr;
 2407|       |
 2408|  5.83k|    hdr = pjsip_generic_string_hdr_create(ctx->pool, NULL, NULL);
 2409|  5.83k|    parse_generic_string_hdr(hdr, ctx);
 2410|  5.83k|    return (pjsip_hdr*)hdr;
 2411|       |
 2412|  5.83k|}
sip_parser.c:parse_generic_string_hdr:
 1831|  5.83k|{
 1832|  5.83k|    pj_scanner *scanner = ctx->scanner;
 1833|       |
 1834|  5.83k|    hdr->hvalue.slen = 0;
 1835|       |
 1836|       |    /* header may be mangled hence the loop */
 1837|  8.38k|    while (pj_cis_match(&pconst.pjsip_NOT_NEWLINE, *scanner->curptr)) {
  ------------------
  |  Branch (1837:12): [True: 4.96k, False: 3.41k]
  ------------------
 1838|  4.96k|        pj_str_t next, tmp;
 1839|       |
 1840|  4.96k|        pj_scan_get( scanner, &pconst.pjsip_NOT_NEWLINE, &hdr->hvalue);
 1841|  4.96k|        if (pj_scan_is_eof(scanner) || IS_NEWLINE(*scanner->curptr))
  ------------------
  |  |   62|  4.93k|#define IS_NEWLINE(c)   ((c)=='\r' || (c)=='\n')
  |  |  ------------------
  |  |  |  Branch (62:26): [True: 224, False: 4.71k]
  |  |  |  Branch (62:39): [True: 2.16k, False: 2.54k]
  |  |  ------------------
  ------------------
  |  Branch (1841:13): [True: 32, False: 4.93k]
  ------------------
 1842|  2.41k|            break;
 1843|       |        /* mangled, get next fraction */
 1844|  2.54k|        pj_scan_get( scanner, &pconst.pjsip_NOT_NEWLINE, &next);
 1845|       |        /* concatenate */
 1846|  2.54k|        tmp.ptr = (char*)pj_pool_alloc(ctx->pool, 
 1847|  2.54k|                                       hdr->hvalue.slen + next.slen + 2);
 1848|  2.54k|        tmp.slen = 0;
 1849|  2.54k|        pj_strcpy(&tmp, &hdr->hvalue);
 1850|  2.54k|        pj_strcat2(&tmp, " ");
 1851|  2.54k|        pj_strcat(&tmp, &next);
 1852|  2.54k|        tmp.ptr[tmp.slen] = '\0';
 1853|       |
 1854|  2.54k|        hdr->hvalue = tmp;
 1855|  2.54k|    }
 1856|       |
 1857|  5.83k|    parse_hdr_end(scanner);
 1858|  5.83k|}

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

pjsip_tel_uri_create:
   97|  3.54k|{
   98|  3.54k|    pjsip_tel_uri *uri = PJ_POOL_ZALLOC_T(pool, pjsip_tel_uri);
  ------------------
  |  |  583|  3.54k|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
   99|  3.54k|    uri->vptr = &tel_uri_vptr;
  100|  3.54k|    pj_list_init(&uri->other_param);
  101|  3.54k|    return uri;
  102|  3.54k|}
pjsip_tel_uri_subsys_init:
  118|      1|{
  119|      1|    pj_status_t status;
  120|       |
  121|      1|    pj_cis_buf_init(&cis_buf);
  122|       |
  123|      1|    status = pj_cis_init(&cis_buf, &pjsip_TEL_EXT_VALUE_SPEC);
  124|      1|    PJ_ASSERT_RETURN(status==PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (124:5): [True: 0, False: 0]
  |  Branch (124:5): [True: 0, False: 0]
  ------------------
  125|      1|    pj_cis_add_str(&pjsip_TEL_EXT_VALUE_SPEC, PHONE_DIGITS);
  ------------------
  |  |   36|      1|#define PHONE_DIGITS        DIGITS VISUAL_SEP
  |  |  ------------------
  |  |  |  |   32|      1|#define DIGITS              "0123456789"
  |  |  ------------------
  |  |               #define PHONE_DIGITS        DIGITS VISUAL_SEP
  |  |  ------------------
  |  |  |  |   35|      1|#define VISUAL_SEP          "-.()"
  |  |  ------------------
  ------------------
  126|       |
  127|      1|    status = pj_cis_init(&cis_buf, &pjsip_TEL_NUMBER_SPEC);
  128|      1|    PJ_ASSERT_RETURN(status==PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (128:5): [True: 0, False: 0]
  |  Branch (128:5): [True: 0, False: 0]
  ------------------
  129|      1|    pj_cis_add_str(&pjsip_TEL_NUMBER_SPEC, NUMBER_SPEC);
  ------------------
  |  |   39|      1|#define NUMBER_SPEC         LOCAL_DIGITS GLOBAL_DIGITS
  |  |  ------------------
  |  |  |  |   38|      1|#define LOCAL_DIGITS        HEX_DIGITS "*#" VISUAL_SEP
  |  |  |  |  ------------------
  |  |  |  |  |  |   34|      1|#define HEX_DIGITS          DIGITS HEX
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   32|      1|#define DIGITS              "0123456789"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define NUMBER_SPEC         LOCAL_DIGITS GLOBAL_DIGITS
  |  |  ------------------
  |  |  |  |   37|      1|#define GLOBAL_DIGITS       "+" PHONE_DIGITS
  |  |  |  |  ------------------
  |  |  |  |  |  |   36|      1|#define PHONE_DIGITS        DIGITS VISUAL_SEP
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   35|      1|#define VISUAL_SEP          "-.()"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  130|       |
  131|      1|    status = pj_cis_init(&cis_buf, &pjsip_TEL_VISUAL_SEP_SPEC);
  132|      1|    PJ_ASSERT_RETURN(status==PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (132:5): [True: 0, False: 0]
  |  Branch (132:5): [True: 0, False: 0]
  ------------------
  133|      1|    pj_cis_add_str(&pjsip_TEL_VISUAL_SEP_SPEC, VISUAL_SEP);
  ------------------
  |  |   35|      1|#define VISUAL_SEP          "-.()"
  ------------------
  134|       |
  135|      1|    status = pj_cis_init(&cis_buf, &pjsip_TEL_PHONE_CONTEXT_SPEC);
  136|      1|    PJ_ASSERT_RETURN(status==PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (136:5): [True: 0, False: 0]
  |  Branch (136:5): [True: 0, False: 0]
  ------------------
  137|      1|    pj_cis_add_alpha(&pjsip_TEL_PHONE_CONTEXT_SPEC);
  138|      1|    pj_cis_add_num(&pjsip_TEL_PHONE_CONTEXT_SPEC);
  139|      1|    pj_cis_add_str(&pjsip_TEL_PHONE_CONTEXT_SPEC, PHONE_CONTEXT);
  ------------------
  |  |   40|      1|#define PHONE_CONTEXT       ALPHA GLOBAL_DIGITS
  |  |  ------------------
  |  |  |  |   37|      1|#define GLOBAL_DIGITS       "+" PHONE_DIGITS
  |  |  |  |  ------------------
  |  |  |  |  |  |   36|      1|#define PHONE_DIGITS        DIGITS VISUAL_SEP
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   35|      1|#define VISUAL_SEP          "-.()"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  140|       |
  141|      1|    status = pj_cis_init(&cis_buf, &pjsip_TEL_URIC_SPEC);
  142|      1|    PJ_ASSERT_RETURN(status==PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (142:5): [True: 0, False: 0]
  |  Branch (142:5): [True: 0, False: 0]
  ------------------
  143|      1|    pj_cis_add_alpha(&pjsip_TEL_URIC_SPEC);
  144|      1|    pj_cis_add_num(&pjsip_TEL_URIC_SPEC);
  145|      1|    pj_cis_add_str(&pjsip_TEL_URIC_SPEC, URIC);
  ------------------
  |  |   46|      1|#define URIC                RESERVED UNRESERVED ESCAPED "[]+"
  |  |  ------------------
  |  |  |  |   42|      1|#define RESERVED            "/:@&$,+"
  |  |  ------------------
  ------------------
  146|       |
  147|      1|    status = pj_cis_init(&cis_buf, &pjsip_TEL_PNAME_SPEC);
  148|      1|    PJ_ASSERT_RETURN(status==PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (148:5): [True: 0, False: 0]
  |  Branch (148:5): [True: 0, False: 0]
  ------------------
  149|      1|    pj_cis_add_alpha(&pjsip_TEL_PNAME_SPEC);
  150|      1|    pj_cis_add_num(&pjsip_TEL_PNAME_SPEC);
  151|      1|    pj_cis_add_str(&pjsip_TEL_PNAME_SPEC, "-");
  152|       |
  153|      1|    status = pj_cis_init(&cis_buf, &pjsip_TEL_PVALUE_SPEC);
  154|      1|    PJ_ASSERT_RETURN(status==PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (154:5): [True: 0, False: 0]
  |  Branch (154:5): [True: 0, False: 0]
  ------------------
  155|      1|    pj_cis_add_alpha(&pjsip_TEL_PVALUE_SPEC);
  156|      1|    pj_cis_add_num(&pjsip_TEL_PVALUE_SPEC);
  157|      1|    pj_cis_add_str(&pjsip_TEL_PVALUE_SPEC, PARAM_CHAR);
  ------------------
  |  |   48|      1|#define PARAM_CHAR          PARAM_UNRESERVED UNRESERVED ESCAPED
  |  |  ------------------
  |  |  |  |   47|      1|#define PARAM_UNRESERVED    "[]/:&+$"
  |  |  ------------------
  |  |               #define PARAM_CHAR          PARAM_UNRESERVED UNRESERVED ESCAPED
  |  |  ------------------
  |  |  |  |   45|      1|#define ESCAPED             "%"
  |  |  ------------------
  ------------------
  158|       |
  159|      1|    status = pj_cis_dup(&pjsip_TEL_PVALUE_SPEC_ESC, &pjsip_TEL_PVALUE_SPEC);
  160|      1|    pj_cis_del_str(&pjsip_TEL_PVALUE_SPEC_ESC, "%");
  161|       |
  162|      1|    status = pj_cis_dup(&pjsip_TEL_PARSING_PVALUE_SPEC, &pjsip_TEL_URIC_SPEC);
  163|      1|    PJ_ASSERT_RETURN(status==PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (163:5): [True: 0, False: 0]
  |  Branch (163:5): [True: 0, False: 0]
  ------------------
  164|      1|    pj_cis_add_cis(&pjsip_TEL_PARSING_PVALUE_SPEC, &pjsip_TEL_PVALUE_SPEC);
  165|      1|    pj_cis_add_str(&pjsip_TEL_PARSING_PVALUE_SPEC, "=");
  166|       |
  167|      1|    status = pj_cis_dup(&pjsip_TEL_PARSING_PVALUE_SPEC_ESC, 
  168|      1|                        &pjsip_TEL_PARSING_PVALUE_SPEC);
  169|      1|    pj_cis_del_str(&pjsip_TEL_PARSING_PVALUE_SPEC_ESC, "%");
  170|       |
  171|      1|    status = pjsip_register_uri_parser("tel", &tel_uri_parse);
  172|      1|    PJ_ASSERT_RETURN(status==PJ_SUCCESS, status);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (172:5): [True: 0, False: 0]
  |  Branch (172:5): [True: 0, False: 0]
  ------------------
  173|       |
  174|      1|    return PJ_SUCCESS;
  175|      1|}
sip_tel_uri.c:tel_uri_parse:
  372|  3.54k|{
  373|  3.54k|    pjsip_tel_uri *uri;
  374|  3.54k|    pj_str_t token;
  375|  3.54k|    int skip_ws = scanner->skip_ws;
  376|  3.54k|    const pjsip_parser_const_t *pc = pjsip_parser_const();
  377|       |
  378|  3.54k|    scanner->skip_ws = 0;
  379|       |
  380|       |    /* Parse scheme. */
  381|  3.54k|    pj_scan_get(scanner, &pc->pjsip_TOKEN_SPEC, &token);
  382|  3.54k|    if (pj_scan_get_char(scanner) != ':')
  ------------------
  |  Branch (382:9): [True: 0, False: 3.54k]
  ------------------
  383|      0|        PJ_THROW(PJSIP_SYN_ERR_EXCEPTION);
  ------------------
  |  |  402|      0|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
  384|  3.54k|    if (pj_stricmp_alnum(&token, &pc->pjsip_TEL_STR) != 0)
  ------------------
  |  |  408|  3.54k|#define pj_stricmp_alnum    pj_stricmp
  ------------------
  |  Branch (384:9): [True: 0, False: 3.54k]
  ------------------
  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|  3.54k|    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|  3.54k|    pj_scan_get(scanner, &pjsip_TEL_NUMBER_SPEC, &uri->number);
  395|  3.54k|    uri->number = pj_str_unescape(pool, &uri->number);
  396|  3.54k|#endif
  397|       |
  398|       |    /* Get all parameters. */
  399|  3.54k|    if (parse_params && *scanner->curptr==';') {
  ------------------
  |  Branch (399:9): [True: 634, False: 2.91k]
  |  Branch (399:25): [True: 84, False: 550]
  ------------------
  400|     84|        pj_str_t pname, pvalue;
  401|       |
  402|  2.29k|        do {
  403|       |            /* Eat the ';' separator. */
  404|  2.29k|            pj_scan_get_char(scanner);
  405|       |
  406|       |            /* Get pname. */
  407|  2.29k|            pj_scan_get(scanner, &pc->pjsip_PARAM_CHAR_SPEC, &pname);
  408|       |
  409|  2.29k|            if (*scanner->curptr == '=') {
  ------------------
  |  Branch (409:17): [True: 252, False: 2.04k]
  ------------------
  410|    252|                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|    252|                    pj_scan_get(scanner, &pjsip_TEL_PARSING_PVALUE_SPEC, 
  418|    252|                                &pvalue);
  419|    252|                    pvalue = pj_str_unescape(pool, &pvalue);
  420|    252|#               endif
  421|       |
  422|  2.04k|            } else {
  423|  2.04k|                pvalue.slen = 0;
  424|  2.04k|                pvalue.ptr = NULL;
  425|  2.04k|            }
  426|       |
  427|       |            /* Save the parameters. */
  428|  2.29k|            if (pj_stricmp_alnum(&pname, &pjsip_ISUB_STR)==0) {
  ------------------
  |  |  408|  2.29k|#define pj_stricmp_alnum    pj_stricmp
  ------------------
  |  Branch (428:17): [True: 148, False: 2.14k]
  ------------------
  429|    148|                uri->isub_param = pvalue;
  430|  2.14k|            } else if (pj_stricmp_alnum(&pname, &pjsip_EXT_STR)==0) {
  ------------------
  |  |  408|  2.14k|#define pj_stricmp_alnum    pj_stricmp
  ------------------
  |  Branch (430:24): [True: 60, False: 2.08k]
  ------------------
  431|     60|                uri->ext_param = pvalue;
  432|  2.08k|            } else if (pj_stricmp_alnum(&pname, &pjsip_PH_CTX_STR)==0) {
  ------------------
  |  |  408|  2.08k|#define pj_stricmp_alnum    pj_stricmp
  ------------------
  |  Branch (432:24): [True: 64, False: 2.02k]
  ------------------
  433|     64|                uri->context = pvalue;
  434|  2.02k|            } else {
  435|  2.02k|                pjsip_param *param = PJ_POOL_ALLOC_T(pool, pjsip_param);
  ------------------
  |  |  569|  2.02k|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
  436|  2.02k|                param->name = pname;
  437|  2.02k|                param->value = pvalue;
  438|  2.02k|                pj_list_insert_before(&uri->other_param, param);
  439|  2.02k|            }
  440|       |
  441|  2.29k|        } while (*scanner->curptr==';');
  ------------------
  |  Branch (441:18): [True: 2.21k, False: 84]
  ------------------
  442|     84|    }
  443|       |
  444|  3.54k|    scanner->skip_ws = skip_ws;
  445|  3.54k|    pj_scan_skip_whitespace(scanner);
  446|  3.54k|    return uri;
  447|  3.54k|}

pjsip_tpmgr_create:
 1674|      1|{
 1675|      1|    pjsip_tpmgr *mgr;
 1676|      1|    pj_status_t status;
 1677|      1|    unsigned i = 0;
 1678|      1|    pj_pool_t *mgr_pool;
 1679|       |
 1680|      1|    PJ_ASSERT_RETURN(pool && endpt && rx_cb && p_mgr, PJ_EINVAL);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      6|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 1, False: 0]
  |  |  |  Branch (98:23): [True: 1, False: 0]
  |  |  |  Branch (98:23): [True: 1, False: 0]
  |  |  |  Branch (98:23): [True: 1, False: 0]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  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|      1|    status = pjsip_endpt_register_module(endpt, &mod_msg_print);
 1684|      1|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (1684:9): [True: 0, False: 1]
  ------------------
 1685|      0|        return status;
 1686|       |
 1687|       |    /* Create and initialize transport manager. */
 1688|      1|    mgr_pool = pjsip_endpt_create_pool(endpt, "tpmgr",
 1689|      1|                                       TPMGR_POOL_INIT_SIZE,
  ------------------
  |  |   86|      1|#   define TPMGR_POOL_INIT_SIZE 1000
  ------------------
 1690|      1|                                       TPMGR_POOL_INC_SIZE);
  ------------------
  |  |   91|      1|    #define TPMGR_POOL_INC_SIZE 1000
  ------------------
 1691|      1|    mgr = PJ_POOL_ZALLOC_T(mgr_pool, pjsip_tpmgr);
  ------------------
  |  |  583|      1|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
 1692|      1|    mgr->endpt = endpt;
 1693|      1|    mgr->on_rx_msg = rx_cb;
 1694|      1|    mgr->on_tx_msg = tx_cb;
 1695|      1|    mgr->pool = mgr_pool;
 1696|       |
 1697|      1|    if (!mgr->pool)
  ------------------
  |  Branch (1697:9): [True: 0, False: 1]
  ------------------
 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|      1|    pj_list_init(&mgr->factory_list);
 1701|      1|    pj_list_init(&mgr->tdata_list);
 1702|      1|    pj_list_init(&mgr->tp_entry_freelist);
 1703|       |
 1704|      1|    mgr->table = pj_hash_create(mgr->pool, PJSIP_TPMGR_HTABLE_SIZE);
  ------------------
  |  |  346|      1|#   define PJSIP_TPMGR_HTABLE_SIZE      31
  ------------------
 1705|      1|    if (!mgr->table)
  ------------------
  |  Branch (1705:9): [True: 0, False: 1]
  ------------------
 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|      1|    status = pj_lock_create_recursive_mutex(mgr->pool, "tmgr%p", &mgr->lock);
 1709|      1|    if (status != PJ_SUCCESS)
  ------------------
  |  Branch (1709:9): [True: 0, False: 1]
  ------------------
 1710|      0|        return status;
 1711|       |
 1712|     17|    for (; i < PJSIP_TRANSPORT_ENTRY_ALLOC_CNT; ++i) {
  ------------------
  |  |  100|     17|#   define PJSIP_TRANSPORT_ENTRY_ALLOC_CNT  16
  ------------------
  |  Branch (1712:12): [True: 16, False: 1]
  ------------------
 1713|     16|        transport *tp_add = NULL;
 1714|       |
 1715|     16|        tp_add = PJ_POOL_ZALLOC_T(mgr->pool, transport);
  ------------------
  |  |  583|     16|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
 1716|     16|        if (!tp_add)
  ------------------
  |  Branch (1716:13): [True: 0, False: 16]
  ------------------
 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|     16|        pj_list_init(tp_add);
 1719|     16|        pj_list_push_back(&mgr->tp_entry_freelist, tp_add);
 1720|     16|    }
 1721|       |
 1722|      1|#if defined(PJ_DEBUG) && PJ_DEBUG!=0
 1723|      1|    status = pj_atomic_create(mgr->pool, 0, &mgr->tdata_counter);
 1724|      1|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (1724:9): [True: 0, False: 1]
  ------------------
 1725|      0|        pj_lock_destroy(mgr->lock);
 1726|      0|        return status;
 1727|      0|    }
 1728|      1|#endif
 1729|       |
 1730|       |    /* Set transport state callback */
 1731|      1|    pjsip_tpmgr_set_state_cb(mgr, &tp_state_callback);
 1732|       |
 1733|      1|    PJ_LOG(5, (THIS_FILE, "Transport manager created."));
  ------------------
  |  |  106|      1|#define PJ_LOG(level,arg)       do { \
  |  |  107|      1|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      2|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 1, Folded]
  |  |  |  Branch (107:70): [True: 0, False: 1]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  ------------------
  |  |  |  |  496|      0|    #define pj_log_wrapper_5(arg)       pj_log_5 arg
  |  |  ------------------
  |  |  109|      0|                                    } \
  |  |  110|      1|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 1]
  |  |  ------------------
  ------------------
 1734|       |
 1735|      1|    *p_mgr = mgr;
 1736|      1|    return PJ_SUCCESS;
 1737|      1|}
pjsip_tpmgr_set_state_cb:
 2882|      1|{
 2883|      1|    PJ_ASSERT_RETURN(mgr, PJ_EINVAL);
  ------------------
  |  |   97|      1|            do { \
  |  |   98|      1|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 1]
  |  |  ------------------
  |  |   99|      1|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (2883:5): [True: 0, False: 0]
  |  Branch (2883:5): [True: 0, False: 0]
  ------------------
 2884|       |
 2885|      1|    mgr->tp_state_cb = cb;
 2886|       |
 2887|      1|    return PJ_SUCCESS;
 2888|      1|}

pjsip_param_clone:
   72|     20|{
   73|     20|    const pjsip_param *p = src_list->next;
   74|       |
   75|     20|    pj_list_init(dst_list);
   76|    304|    while (p && p != src_list) {
  ------------------
  |  Branch (76:12): [True: 304, False: 0]
  |  Branch (76:17): [True: 284, False: 20]
  ------------------
   77|    284|        pjsip_param *new_param = PJ_POOL_ALLOC_T(pool, pjsip_param);
  ------------------
  |  |  569|    284|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
   78|    284|        pj_strdup(pool, &new_param->name, &p->name);
   79|    284|        pj_strdup(pool, &new_param->value, &p->value);
   80|    284|        pj_list_insert_before(dst_list, new_param);
   81|    284|        p = p->next;
   82|    284|    }
   83|     20|}
pjsip_sip_uri_set_secure:
  231|  4.88k|{
  232|  4.88k|    url->vptr = secure ? &sips_url_vptr : &sip_url_vptr;
  ------------------
  |  Branch (232:17): [True: 2.75k, False: 2.12k]
  ------------------
  233|  4.88k|}
pjsip_sip_uri_init:
  236|  4.88k|{
  237|  4.88k|    pj_bzero(url, sizeof(*url));
  238|  4.88k|    url->ttl_param = -1;
  239|  4.88k|    pjsip_sip_uri_set_secure(url, secure);
  240|  4.88k|    pj_list_init(&url->other_param);
  241|  4.88k|    pj_list_init(&url->header_param);
  242|  4.88k|}
pjsip_sip_uri_create:
  246|  4.88k|{
  247|  4.88k|    pjsip_sip_uri *url = PJ_POOL_ALLOC_T(pool, pjsip_sip_uri);
  ------------------
  |  |  569|  4.88k|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
  248|  4.88k|    pjsip_sip_uri_init(url, secure);
  249|  4.88k|    return url;
  250|  4.88k|}
pjsip_name_addr_init:
  552|  17.1k|{
  553|  17.1k|    name->vptr = &name_addr_vptr;
  554|  17.1k|    name->uri = NULL;
  555|  17.1k|    name->display.slen = 0;
  556|       |    name->display.ptr = NULL;
  557|  17.1k|}
pjsip_name_addr_create:
  560|  17.1k|{
  561|  17.1k|    pjsip_name_addr *name_addr = PJ_POOL_ALLOC_T(pool, pjsip_name_addr);
  ------------------
  |  |  569|  17.1k|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
  562|  17.1k|    pjsip_name_addr_init(name_addr);
  563|  17.1k|    return name_addr;
  564|  17.1k|}
pjsip_other_uri_create:
  671|  5.56k|{
  672|  5.56k|    pjsip_other_uri *uri = PJ_POOL_ZALLOC_T(pool, pjsip_other_uri);
  ------------------
  |  |  583|  5.56k|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  673|  5.56k|    uri->vptr = &other_uri_vptr;
  674|  5.56k|    return uri;
  675|  5.56k|}

LLVMFuzzerTestOneInput:
  150|    850|{
  151|    850|    static int initialized = 0;
  152|    850|    pj_pool_t *pool;
  153|    850|    pjsip_msg *msg;
  154|    850|    pj_time_val timeout = {0, 0};
  155|       |
  156|       |    /* === One-time initialization === */
  157|    850|    if (!initialized) {
  ------------------
  |  Branch (157:9): [True: 1, False: 849]
  ------------------
  158|      1|        pj_status_t status;
  159|      1|        pj_pool_t *init_pool;
  160|      1|        pj_str_t realm;
  161|       |
  162|      1|        pj_init();
  163|      1|        pj_caching_pool_init(&caching_pool, &pj_pool_factory_default_policy, 0);
  164|      1|        pj_log_set_level(0);
  165|       |
  166|       |        /* Create SIP endpoint */
  167|      1|        status = pjsip_endpt_create(&caching_pool.factory, "fuzz", &endpt);
  168|      1|        if (status != PJ_SUCCESS)
  ------------------
  |  Branch (168:13): [True: 0, False: 1]
  ------------------
  169|      0|            return 0;
  170|       |
  171|       |        /* Initialize auth server */
  172|      1|        init_pool = pj_pool_create(&caching_pool.factory, "init", 1000, 1000, NULL);
  173|      1|        realm = pj_str("example.com");
  174|      1|        pjsip_auth_srv_init(init_pool, &auth_srv, &realm, &lookup_cred, 0);
  175|       |
  176|      1|        initialized = 1;
  177|      1|    }
  178|       |
  179|    850|    pool = pjsip_endpt_create_pool(endpt, "fuzz", POOL_SIZE, POOL_SIZE);
  ------------------
  |  |   28|    850|#define POOL_SIZE 4000
  ------------------
                  pool = pjsip_endpt_create_pool(endpt, "fuzz", POOL_SIZE, POOL_SIZE);
  ------------------
  |  |   28|    850|#define POOL_SIZE 4000
  ------------------
  180|    850|    if (!pool)
  ------------------
  |  Branch (180:9): [True: 0, False: 850]
  ------------------
  181|      0|        return 0;
  182|       |
  183|       |    /* Parse message and test auth server functions */
  184|    850|    msg = parse_sip_message(pool, Data, Size, 0);
  185|    850|    if (msg) {
  ------------------
  |  Branch (185:9): [True: 9, False: 841]
  ------------------
  186|      9|        test_auth_server_verify(pool, msg);
  187|      9|    }
  188|       |
  189|    850|    msg = parse_sip_message(pool, Data, Size, 1);
  190|    850|    if (msg) {
  ------------------
  |  Branch (190:9): [True: 0, False: 850]
  ------------------
  191|      0|        test_auth_server_challenge(pool, msg);
  192|      0|    }
  193|       |
  194|       |    /* Cleanup */
  195|    850|    pjsip_endpt_release_pool(endpt, pool);
  196|    850|    pjsip_endpt_handle_events(endpt, &timeout);
  197|       |
  198|    850|    return 0;
  199|    850|}
fuzz-auth.c:parse_sip_message:
   52|  1.70k|{
   53|  1.70k|    char *msg_buf;
   54|  1.70k|    pjsip_parser_err_report err_list;
   55|  1.70k|    pjsip_msg *msg;
   56|       |
   57|  1.70k|    if (size < 10)
  ------------------
  |  Branch (57:9): [True: 6, False: 1.69k]
  ------------------
   58|      6|        return NULL;
   59|       |
   60|  1.69k|    if (size > MAX_FUZZ_MSG_SIZE)
  ------------------
  |  |   29|  1.69k|#define MAX_FUZZ_MSG_SIZE (POOL_SIZE - 1)
  |  |  ------------------
  |  |  |  |   28|  1.69k|#define POOL_SIZE 4000
  |  |  ------------------
  ------------------
  |  Branch (60:9): [True: 30, False: 1.66k]
  ------------------
   61|     30|        size = MAX_FUZZ_MSG_SIZE;
  ------------------
  |  |   29|     30|#define MAX_FUZZ_MSG_SIZE (POOL_SIZE - 1)
  |  |  ------------------
  |  |  |  |   28|     30|#define POOL_SIZE 4000
  |  |  ------------------
  ------------------
   62|       |
   63|       |    /* Copy to null-terminated buffer */
   64|  1.69k|    msg_buf = (char*)pj_pool_alloc(pool, size + 1);
   65|  1.69k|    pj_memcpy(msg_buf, data, size);
   66|  1.69k|    msg_buf[size] = '\0';
   67|       |
   68|       |    /* Parse SIP message */
   69|  1.69k|    pj_list_init(&err_list);
   70|  1.69k|    msg = pjsip_parse_msg(pool, msg_buf, (pj_size_t)size, &err_list);
   71|       |
   72|  1.69k|    if (!msg || msg->type != PJSIP_REQUEST_MSG || !msg->line.req.uri)
  ------------------
  |  Branch (72:9): [True: 1.49k, False: 200]
  |  Branch (72:17): [True: 182, False: 18]
  |  Branch (72:51): [True: 0, False: 18]
  ------------------
   73|  1.67k|        return NULL;
   74|       |
   75|       |    /* Check required headers for response creation */
   76|     18|    if (require_full_headers) {
  ------------------
  |  Branch (76:9): [True: 9, False: 9]
  ------------------
   77|      9|        if (!pjsip_msg_find_hdr(msg, PJSIP_H_VIA, NULL) ||
  ------------------
  |  Branch (77:13): [True: 3, False: 6]
  ------------------
   78|      6|            !pjsip_msg_find_hdr(msg, PJSIP_H_FROM, NULL) ||
  ------------------
  |  Branch (78:13): [True: 2, False: 4]
  ------------------
   79|      4|            !pjsip_msg_find_hdr(msg, PJSIP_H_TO, NULL) ||
  ------------------
  |  Branch (79:13): [True: 1, False: 3]
  ------------------
   80|      3|            !pjsip_msg_find_hdr(msg, PJSIP_H_CALL_ID, NULL) ||
  ------------------
  |  Branch (80:13): [True: 0, False: 3]
  ------------------
   81|      3|            !pjsip_msg_find_hdr(msg, PJSIP_H_CSEQ, NULL))
  ------------------
  |  Branch (81:13): [True: 3, False: 0]
  ------------------
   82|      9|            return NULL;
   83|      9|    }
   84|       |
   85|      9|    return msg;
   86|     18|}
fuzz-auth.c:test_auth_server_verify:
   90|      9|{
   91|      9|    pjsip_rx_data rdata;
   92|      9|    pjsip_authorization_hdr *auth_hdr;
   93|       |
   94|       |    /* Look for Authorization or Proxy-Authorization header */
   95|      9|    auth_hdr = (pjsip_authorization_hdr*)
   96|      9|               pjsip_msg_find_hdr(msg, PJSIP_H_AUTHORIZATION, NULL);
   97|      9|    if (!auth_hdr) {
  ------------------
  |  Branch (97:9): [True: 9, False: 0]
  ------------------
   98|      9|        auth_hdr = (pjsip_authorization_hdr*)
   99|      9|                   pjsip_msg_find_hdr(msg, PJSIP_H_PROXY_AUTHORIZATION, NULL);
  100|      9|    }
  101|      9|    if (!auth_hdr)
  ------------------
  |  Branch (101:9): [True: 9, False: 0]
  ------------------
  102|      9|        return;
  103|       |
  104|       |    /* Setup minimal rdata */
  105|      0|    pj_bzero(&rdata, sizeof(rdata));
  106|      0|    rdata.msg_info.msg = msg;
  107|      0|    rdata.tp_info.pool = pool;
  108|       |
  109|       |    /* Test verification */
  110|      0|    int status_code;
  111|      0|    pjsip_auth_srv_verify(&auth_srv, &rdata, &status_code);
  112|      0|}

