http_client.c:pj_scan_is_eof:
  253|    175|{
  254|    175|    return scanner->curptr >= scanner->end;
  255|    175|}
scanner.c:pj_scan_is_eof:
  253|    520|{
  254|    520|    return scanner->curptr >= scanner->end;
  255|    520|}

pj_http_req_parse_url:
  809|    217|{
  810|    217|    pj_scanner scanner;
  811|    217|    pj_size_t len = url->slen;
  812|    217|    PJ_USE_EXCEPTION;
  ------------------
  |  |  367|    217|#define PJ_USE_EXCEPTION    struct pj_exception_state_t pj_x_except__; int pj_x_code__
  ------------------
  813|       |
  814|    217|    if (!len) return -1;
  ------------------
  |  Branch (814:9): [True: 0, False: 217]
  ------------------
  815|       |    
  816|    217|    pj_bzero(hurl, sizeof(*hurl));
  817|    217|    pj_scan_init(&scanner, url->ptr, url->slen, 0, &on_syntax_error);
  818|       |
  819|    217|    PJ_TRY {
  ------------------
  |  |  373|    217|#define PJ_TRY              if (1) { \
  |  |  ------------------
  |  |  |  Branch (373:33): [True: 217, Folded]
  |  |  ------------------
  |  |  374|    217|                                pj_push_exception_handler_(&pj_x_except__); \
  |  |  375|    217|                                pj_x_code__ = pj_setjmp(pj_x_except__.state); \
  |  |  ------------------
  |  |  |  |   31|    217|#    define pj_setjmp(buf)      setjmp(buf)
  |  |  ------------------
  |  |  376|    217|                                if (pj_x_code__ == 0)
  |  |  ------------------
  |  |  |  Branch (376:37): [True: 217, False: 0]
  |  |  ------------------
  ------------------
  820|    217|        pj_str_t s;
  821|       |
  822|       |        /* Exhaust any whitespaces. */
  823|    217|        pj_scan_skip_whitespace(&scanner);
  824|       |
  825|       |        /* Parse the protocol */
  826|    217|        pj_scan_get_until_ch(&scanner, ':', &s);
  827|    217|        {
  828|    217|            int i;
  829|    670|            for (i = 0; i < NUM_PROTOCOL; i++) {
  ------------------
  |  |   44|    670|#define NUM_PROTOCOL            4
  ------------------
  |  Branch (829:25): [True: 574, False: 96]
  ------------------
  830|    574|                if (!pj_stricmp2(&s, http_protocol_names[i])) {
  ------------------
  |  Branch (830:21): [True: 121, False: 453]
  ------------------
  831|    121|                    pj_strset2(&hurl->protocol,
  832|    121|                               (char*)http_protocol_names[i]);
  833|    121|                    break;
  834|    121|                }
  835|    574|            }
  836|    217|            if (i == NUM_PROTOCOL) {
  ------------------
  |  |   44|    217|#define NUM_PROTOCOL            4
  ------------------
  |  Branch (836:17): [True: 87, False: 130]
  ------------------
  837|     87|                PJ_THROW(PJ_ENOTSUP); /* unsupported protocol */
  ------------------
  |  |  402|     87|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
  838|     87|            }
  839|    217|        }
  840|       |
  841|    130|        if (pj_scan_strcmp(&scanner, "://", 3)) {
  ------------------
  |  Branch (841:13): [True: 17, False: 113]
  ------------------
  842|     17|            PJ_THROW(PJLIB_UTIL_EHTTPINURL); // no "://" after protocol name
  ------------------
  |  |  402|     17|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
  843|     17|        }
  844|    113|        pj_scan_advance_n(&scanner, 3, PJ_FALSE);
  845|       |
  846|    113|        if (get_url_at_pos(url->ptr, url->slen)) {
  ------------------
  |  Branch (846:13): [True: 21, False: 92]
  ------------------
  847|       |            /* Parse username and password */
  848|     21|            pj_scan_get_until_chr(&scanner, ":@", &hurl->username);
  849|     21|            if (*scanner.curptr == ':') {
  ------------------
  |  Branch (849:17): [True: 6, False: 15]
  ------------------
  850|      6|                pj_scan_get_char(&scanner);
  851|      6|                pj_scan_get_until_chr(&scanner, "@", &hurl->passwd);
  852|     15|            } else {
  853|     15|                hurl->passwd.slen = 0;
  854|     15|            }
  855|     21|            pj_scan_get_char(&scanner);
  856|     21|        }
  857|       |
  858|       |        /* Parse the host and port number (if any) */
  859|    113|        pj_scan_get_until_chr(&scanner, ":/", &s);
  860|    113|        pj_strassign(&hurl->host, &s);
  861|    113|        if (hurl->host.slen==0)
  ------------------
  |  Branch (861:13): [True: 2, False: 111]
  ------------------
  862|      2|            PJ_THROW(PJ_EINVAL);
  ------------------
  |  |  402|      2|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
  863|    111|        if (pj_scan_is_eof(&scanner) || *scanner.curptr == '/') {
  ------------------
  |  Branch (863:13): [True: 61, False: 50]
  |  Branch (863:41): [True: 4, False: 46]
  ------------------
  864|       |            /* No port number specified */
  865|       |            /* Assume default http/https port number */
  866|     43|            hurl->port = get_http_default_port(&hurl->protocol);
  867|     43|            pj_assert(hurl->port > 0);
  ------------------
  |  |   65|     43|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (867:13): [True: 0, False: 43]
  |  Branch (867:13): [True: 43, False: 0]
  ------------------
  868|     68|        } else {
  869|     68|            pj_scan_advance_n(&scanner, 1, PJ_FALSE);
  870|     68|            pj_scan_get_until_ch(&scanner, '/', &s);
  871|       |            /* Parse the port number */
  872|     68|            hurl->port = (pj_uint16_t)pj_strtoul(&s);
  873|     68|            if (!hurl->port)
  ------------------
  |  Branch (873:17): [True: 2, False: 66]
  ------------------
  874|      2|                PJ_THROW(PJLIB_UTIL_EHTTPINPORT); // invalid port number
  ------------------
  |  |  402|      2|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
  875|     68|        }
  876|       |
  877|    109|        if (!pj_scan_is_eof(&scanner)) {
  ------------------
  |  Branch (877:13): [True: 13, False: 96]
  ------------------
  878|     13|            hurl->path.ptr = scanner.curptr;
  879|     13|            hurl->path.slen = scanner.end - scanner.curptr;
  880|     96|        } else {
  881|       |            /* no path, append '/' */
  882|     96|            pj_cstr(&hurl->path, "/");
  883|     96|        }
  884|    109|    }
  885|      0|    PJ_CATCH_ANY {
  886|      0|        pj_scan_fini(&scanner);
  887|      0|        return PJ_GET_EXCEPTION();
  ------------------
  |  |  409|      0|#define PJ_GET_EXCEPTION()      (pj_x_code__)
  ------------------
  888|      0|    }
  889|    109|    PJ_END;
  ------------------
  |  |  394|    109|#define PJ_END                  pj_pop_exception_handler_(&pj_x_except__); \
  |  |  395|    109|                            } else {}
  ------------------
  890|       |
  891|    109|    pj_scan_fini(&scanner);
  892|    109|    return PJ_SUCCESS;
  893|    217|}
http_client.c:on_syntax_error:
  199|     23|{
  200|     23|    PJ_UNUSED_ARG(scanner);
  ------------------
  |  | 1537|     23|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  201|     23|    PJ_THROW(PJ_EINVAL);  // syntax error
  ------------------
  |  |  402|     23|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
  202|     23|}
http_client.c:get_url_at_pos:
  784|    103|{
  785|    103|    const char *end = str + len;
  786|    103|    const char *p = str;
  787|       |
  788|       |    /* skip scheme: */
  789|  1.87k|    while (p!=end && *p!='/') ++p;
  ------------------
  |  Branch (789:12): [True: 1.87k, False: 0]
  |  Branch (789:22): [True: 1.76k, False: 103]
  ------------------
  790|    103|    if (p!=end && *p=='/') ++p;
  ------------------
  |  Branch (790:9): [True: 103, False: 0]
  |  Branch (790:19): [True: 103, False: 0]
  ------------------
  791|    103|    if (p!=end && *p=='/') ++p;
  ------------------
  |  Branch (791:9): [True: 103, False: 0]
  |  Branch (791:19): [True: 103, False: 0]
  ------------------
  792|    103|    if (p==end) return NULL;
  ------------------
  |  Branch (792:9): [True: 11, False: 92]
  ------------------
  793|       |
  794|  6.10k|    for (; p!=end; ++p) {
  ------------------
  |  Branch (794:12): [True: 6.04k, False: 59]
  ------------------
  795|  6.04k|        switch (*p) {
  ------------------
  |  Branch (795:17): [True: 33, False: 6.00k]
  ------------------
  796|     12|        case '/':
  ------------------
  |  Branch (796:9): [True: 12, False: 6.02k]
  ------------------
  797|     12|            return NULL;
  798|     21|        case '@':
  ------------------
  |  Branch (798:9): [True: 21, False: 6.02k]
  ------------------
  799|     21|            return (char*)p;
  800|  6.04k|        }
  801|  6.04k|    }
  802|       |
  803|     59|    return NULL;
  804|     92|}
http_client.c:get_http_default_port:
  170|     43|{
  171|     43|    int i;
  172|       |
  173|     83|    for (i = 0; i < NUM_PROTOCOL; i++) {
  ------------------
  |  |   44|     83|#define NUM_PROTOCOL            4
  ------------------
  |  Branch (173:17): [True: 83, False: 0]
  ------------------
  174|     83|        if (!pj_stricmp2(protocol, http_protocol_names[i])) {
  ------------------
  |  Branch (174:13): [True: 43, False: 40]
  ------------------
  175|     43|            return (pj_uint16_t)http_default_port[i];
  176|     43|        }
  177|     83|    }
  178|      0|    return 0;
  179|     43|}

pj_scan_init:
  120|    217|{
  121|    217|    PJ_CHECK_STACK();
  122|       |
  123|    217|    scanner->begin = scanner->curptr = bufstart;
  124|    217|    scanner->end = bufstart + buflen;
  125|    217|    scanner->line = 1;
  126|    217|    scanner->start_line = scanner->begin;
  127|    217|    scanner->callback = callback;
  128|    217|    scanner->skip_ws = options;
  129|       |
  130|    217|    if (scanner->skip_ws) 
  ------------------
  |  Branch (130:9): [True: 0, False: 217]
  ------------------
  131|      0|        pj_scan_skip_whitespace(scanner);
  132|    217|}
pj_scan_fini:
  136|    217|{
  137|    217|    PJ_CHECK_STACK();
  138|    217|    PJ_UNUSED_ARG(scanner);
  ------------------
  |  | 1537|    217|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  139|    217|}
pj_scan_skip_whitespace:
  142|    217|{
  143|    217|    register char *s = scanner->curptr;
  144|       |
  145|  2.00k|    while (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_SPACE(*s)) {
  ------------------
  |  |   33|  4.01k|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 1.99k, False: 9]
  |  |  ------------------
  ------------------
                  while (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_SPACE(*s)) {
  ------------------
  |  |   30|  1.99k|#define PJ_SCAN_IS_SPACE(c)             ((c)==' ' || (c)=='\t')
  |  |  ------------------
  |  |  |  Branch (30:42): [True: 793, False: 1.20k]
  |  |  |  Branch (30:54): [True: 996, False: 208]
  |  |  ------------------
  ------------------
  146|  1.78k|        ++s;
  147|  1.78k|    }
  148|       |
  149|    217|    if (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_NEWLINE(*s) &&
  ------------------
  |  |   33|    434|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 208, False: 9]
  |  |  ------------------
  ------------------
                  if (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_NEWLINE(*s) &&
  ------------------
  |  |   31|    425|#define PJ_SCAN_IS_NEWLINE(c)           ((c)=='\r' || (c)=='\n')
  |  |  ------------------
  |  |  |  Branch (31:42): [True: 5, False: 203]
  |  |  |  Branch (31:55): [True: 4, False: 199]
  |  |  ------------------
  ------------------
  150|      9|        (scanner->skip_ws & PJ_SCAN_AUTOSKIP_NEWLINE))
  ------------------
  |  Branch (150:9): [True: 0, False: 9]
  ------------------
  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|    217|    if (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_NEWLINE(*s) &&
  ------------------
  |  |   33|    434|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 208, False: 9]
  |  |  ------------------
  ------------------
                  if (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_NEWLINE(*s) &&
  ------------------
  |  |   31|    425|#define PJ_SCAN_IS_NEWLINE(c)           ((c)=='\r' || (c)=='\n')
  |  |  ------------------
  |  |  |  Branch (31:42): [True: 5, False: 203]
  |  |  |  Branch (31:55): [True: 4, False: 199]
  |  |  ------------------
  ------------------
  174|      9|        (scanner->skip_ws & PJ_SCAN_AUTOSKIP_WS_HEADER)==
  ------------------
  |  Branch (174:9): [True: 0, False: 9]
  ------------------
  175|      9|         PJ_SCAN_AUTOSKIP_WS_HEADER)
  176|      0|    {
  177|       |        /* Check for header continuation. */
  178|      0|        scanner->curptr = s;
  179|       |
  180|      0|        if (*s == '\r') {
  ------------------
  |  Branch (180:13): [True: 0, False: 0]
  ------------------
  181|      0|            ++s;
  182|      0|        }
  183|      0|        if (PJ_SCAN_CHECK_EOF(s) && *s == '\n') {
  ------------------
  |  |   33|      0|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (183:37): [True: 0, False: 0]
  ------------------
  184|      0|            ++s;
  185|      0|        }
  186|      0|        scanner->start_line = s;
  187|       |
  188|      0|        if (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]
  |  |  ------------------
  ------------------
                      if (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]
  |  |  ------------------
  ------------------
  189|      0|            register char *t = s;
  190|      0|            do {
  191|      0|                ++t;
  192|      0|            } while (PJ_SCAN_CHECK_EOF(t) && PJ_SCAN_IS_SPACE(*t));
  ------------------
  |  |   33|      0|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 0, False: 0]
  |  |  ------------------
  ------------------
                          } while (PJ_SCAN_CHECK_EOF(t) && PJ_SCAN_IS_SPACE(*t));
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  193|       |
  194|      0|            ++scanner->line;
  195|      0|            scanner->curptr = t;
  196|      0|        }
  197|    217|    } else {
  198|    217|        scanner->curptr = s;
  199|    217|    }
  200|    217|}
pj_scan_get_char:
  459|     27|{
  460|     27|    register char *s = scanner->curptr;
  461|     27|    int chr;
  462|       |
  463|     27|    if (s >= scanner->end || !*s) {
  ------------------
  |  Branch (463:9): [True: 0, False: 27]
  |  Branch (463:30): [True: 0, False: 27]
  ------------------
  464|      0|        pj_scan_syntax_err(scanner);
  465|      0|        return 0;
  466|      0|    }
  467|       |
  468|     27|    chr = *s;
  469|       |
  470|     27|    ++s;
  471|     27|    scanner->curptr = s;
  472|     27|    if (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_PROBABLY_SPACE(*s) &&
  ------------------
  |  |   33|     54|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 26, False: 1]
  |  |  ------------------
  ------------------
                  if (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_PROBABLY_SPACE(*s) &&
  ------------------
  |  |   32|     53|#define PJ_SCAN_IS_PROBABLY_SPACE(c)    ((c) <= 32)
  |  |  ------------------
  |  |  |  Branch (32:41): [True: 16, False: 10]
  |  |  ------------------
  ------------------
  473|     16|        scanner->skip_ws)
  ------------------
  |  Branch (473:9): [True: 0, False: 16]
  ------------------
  474|      0|    {
  475|      0|        pj_scan_skip_whitespace(scanner);
  476|      0|    }
  477|     27|    return chr;
  478|     27|}
pj_scan_get_until_ch:
  547|    263|{
  548|    263|    register char *s = scanner->curptr;
  549|       |
  550|    263|    if (s >= scanner->end) {
  ------------------
  |  Branch (550:9): [True: 10, False: 253]
  ------------------
  551|     10|        pj_scan_syntax_err(scanner);
  552|     10|        return;
  553|     10|    }
  554|       |
  555|  9.85k|    while (PJ_SCAN_CHECK_EOF(s) && *s != until_char) {
  ------------------
  |  |   33|  19.7k|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 9.75k, False: 99]
  |  |  ------------------
  ------------------
  |  Branch (555:36): [True: 9.60k, False: 154]
  ------------------
  556|  9.60k|        ++s;
  557|  9.60k|    }
  558|       |
  559|    253|    pj_strset3(out, scanner->curptr, s);
  560|       |
  561|    253|    scanner->curptr = s;
  562|       |
  563|    253|    if (!pj_scan_is_eof(scanner) && PJ_SCAN_IS_PROBABLY_SPACE(*s) &&
  ------------------
  |  |   32|    407|#define PJ_SCAN_IS_PROBABLY_SPACE(c)    ((c) <= 32)
  |  |  ------------------
  |  |  |  Branch (32:41): [True: 0, False: 154]
  |  |  ------------------
  ------------------
  |  Branch (563:9): [True: 154, False: 99]
  ------------------
  564|      0|        scanner->skip_ws)
  ------------------
  |  Branch (564:9): [True: 0, False: 0]
  ------------------
  565|      0|    {
  566|      0|        pj_scan_skip_whitespace(scanner);
  567|      0|    }
  568|    253|}
pj_scan_get_until_chr:
  573|    130|{
  574|    130|    register char *s = scanner->curptr;
  575|    130|    pj_size_t speclen;
  576|       |
  577|    130|    if (s >= scanner->end) {
  ------------------
  |  Branch (577:9): [True: 12, False: 118]
  ------------------
  578|     12|        pj_scan_syntax_err(scanner);
  579|     12|        return;
  580|     12|    }
  581|       |
  582|    118|    speclen = strlen(until_spec);
  583|  3.04k|    while (PJ_SCAN_CHECK_EOF(s) && !memchr(until_spec, *s, speclen)) {
  ------------------
  |  |   33|  6.08k|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 3.00k, False: 39]
  |  |  ------------------
  ------------------
  |  Branch (583:36): [True: 2.92k, False: 79]
  ------------------
  584|  2.92k|        ++s;
  585|  2.92k|    }
  586|       |
  587|    118|    pj_strset3(out, scanner->curptr, s);
  588|       |
  589|    118|    scanner->curptr = s;
  590|       |
  591|    118|    if (!pj_scan_is_eof(scanner) && PJ_SCAN_IS_PROBABLY_SPACE(*s) &&
  ------------------
  |  |   32|    197|#define PJ_SCAN_IS_PROBABLY_SPACE(c)    ((c) <= 32)
  |  |  ------------------
  |  |  |  Branch (32:41): [True: 0, False: 79]
  |  |  ------------------
  ------------------
  |  Branch (591:9): [True: 79, False: 39]
  ------------------
  592|      0|        scanner->skip_ws)
  ------------------
  |  Branch (592:9): [True: 0, False: 0]
  ------------------
  593|      0|    {
  594|      0|        pj_scan_skip_whitespace(scanner);
  595|      0|    }
  596|    118|}
pj_scan_advance_n:
  600|    149|{
  601|    149|    if (scanner->curptr + N > scanner->end) {
  ------------------
  |  Branch (601:9): [True: 0, False: 149]
  ------------------
  602|      0|        pj_scan_syntax_err(scanner);
  603|      0|        return;
  604|      0|    }
  605|       |
  606|    149|    scanner->curptr += N;
  607|       |
  608|    149|    if (!pj_scan_is_eof(scanner) && 
  ------------------
  |  Branch (608:9): [True: 137, False: 12]
  ------------------
  609|    137|        PJ_SCAN_IS_PROBABLY_SPACE(*scanner->curptr) && skip_ws)
  ------------------
  |  |   32|    286|#define PJ_SCAN_IS_PROBABLY_SPACE(c)    ((c) <= 32)
  |  |  ------------------
  |  |  |  Branch (32:41): [True: 48, False: 89]
  |  |  ------------------
  ------------------
  |  Branch (609:56): [True: 0, False: 48]
  ------------------
  610|      0|    {
  611|      0|        pj_scan_skip_whitespace(scanner);
  612|      0|    }
  613|    149|}
pj_scan_strcmp:
  617|    121|{
  618|    121|    if (scanner->curptr + len > scanner->end) {
  ------------------
  |  Branch (618:9): [True: 1, False: 120]
  ------------------
  619|      1|        pj_scan_syntax_err(scanner);
  620|      1|        return -1;
  621|      1|    }
  622|    120|    return strncmp(scanner->curptr, s, len);
  623|    121|}
scanner.c:pj_scan_syntax_err:
   45|     23|{
   46|     23|    (*scanner->callback)(scanner);
   47|     23|}

string.c:pj_isdigit:
   74|    487|PJ_INLINE(int) pj_isdigit(unsigned char c) { return isdigit(c); }

pool.c:pj_list_init:
   88|    217|{
   89|    217|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|    217|}
pool_caching.c:pj_list_init:
   88|  3.68k|{
   89|  3.68k|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|  3.68k|}

pj_list_insert_after:
   29|    217|{
   30|    217|    ((pj_list*)node)->prev = pos;
   31|    217|    ((pj_list*)node)->next = ((pj_list*)pos)->next;
   32|    217|    ((pj_list*) ((pj_list*)pos)->next) ->prev = node;
   33|    217|    ((pj_list*)pos)->next = node;
   34|    217|}

pj_pool_alloc_from_block:
   45|    434|{
   46|    434|    unsigned char *ptr;
   47|       |
   48|    434|    pj_assert(PJ_IS_POWER_OF_TWO(alignment));
  ------------------
  |  |   65|    434|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (48:5): [True: 0, False: 434]
  |  Branch (48:5): [True: 0, False: 0]
  |  Branch (48:5): [True: 434, False: 0]
  |  Branch (48:5): [True: 434, 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|    434|    ptr = PJ_POOL_ALIGN_PTR(block->cur, alignment);
  ------------------
  |  |   23|    434|#define PJ_POOL_ALIGN_PTR(PTR,ALIGNMENT)    (PTR + (-(pj_ssize_t)(PTR) & (ALIGNMENT-1)))
  ------------------
   61|    434|    if (block->cur <= ptr && /* check pointer overflow */
  ------------------
  |  Branch (61:9): [True: 434, False: 0]
  ------------------
   62|    434|        block->end - ptr >= (pj_ssize_t)size) /* check available size */
  ------------------
  |  Branch (62:9): [True: 434, False: 0]
  ------------------
   63|    434|    {
   64|       |    //if (ptr + size <= block->end &&
   65|       |    //    /* here we check pointer overflow */
   66|       |    //    block->cur <= ptr && ptr <= ptr + size) {
   67|    434|        block->cur = ptr + size;
   68|    434|        return ptr;
   69|    434|    }
   70|      0|    return NULL;
   71|    434|}
pj_pool_alloc:
   74|    434|{
   75|    434|    return pj_pool_aligned_alloc(pool, 0, size);
   76|    434|}
pj_pool_aligned_alloc:
   80|    434|{
   81|    434|    void *ptr;
   82|       |
   83|    434|    PJ_ASSERT_RETURN(!alignment || PJ_IS_POWER_OF_TWO(alignment), NULL);
  ------------------
  |  |   97|    434|            do { \
  |  |   98|    434|                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: 434, False: 0]
  |  |  ------------------
  |  |   99|    434|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 434]
  |  |  ------------------
  ------------------
  |  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|    434|    if (!alignment)
  ------------------
  |  Branch (85:9): [True: 434, False: 0]
  ------------------
   86|    434|        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|    434|    ptr = pj_pool_alloc_from_block(pool->block_list.next, 
  102|    434|                                   alignment, size);
  103|    434|    if (!ptr)
  ------------------
  |  Branch (103:9): [True: 0, False: 434]
  ------------------
  104|      0|        ptr = pj_pool_allocate_find(pool, alignment, size);
  105|    434|    return ptr;
  106|    434|}

http_client.c:pj_cstr:
  101|     73|{
  102|     73|    str->ptr = (char*)s;
  103|     73|    str->slen = s ? (pj_ssize_t)strlen(s) : 0;
  ------------------
  |  Branch (103:17): [True: 73, False: 0]
  ------------------
  104|     73|    return str;
  105|     73|}
http_client.c:pj_bzero:
  820|    217|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|    217|    memset(dst, 0, size);
  825|    217|#endif
  826|    217|}
http_client.c:pj_strset2:
  133|    121|{
  134|    121|    str->ptr = src;
  135|    121|    str->slen = src ? (pj_ssize_t)strlen(src) : 0;
  ------------------
  |  Branch (135:17): [True: 121, False: 0]
  ------------------
  136|    121|    return str;
  137|    121|}
scanner.c:pj_strset3:
  149|    371|{
  150|    371|    str->ptr = begin;
  151|    371|    str->slen = (pj_ssize_t)(end-begin);
  152|    371|    return str;
  153|    371|}
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|}
lock.c:pj_memcpy:
  853|    217|{
  854|    217|    return memcpy(dst, src, size);
  855|    217|}
pool.c:pj_bzero:
  820|    217|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|    217|    memset(dst, 0, size);
  825|    217|#endif
  826|    217|}
pool_caching.c:pj_bzero:
  820|    217|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|    217|    memset(dst, 0, size);
  825|    217|#endif
  826|    217|}
pool_caching.c:pj_memcpy:
  853|    217|{
  854|    217|    return memcpy(dst, src, size);
  855|    217|}

pj_str:
   24|      1|{
   25|      1|    pj_str_t dst;
   26|      1|    dst.ptr = str;
   27|      1|    dst.slen = str ? pj_ansi_strlen(str) : 0;
  ------------------
  |  |   69|      1|#define pj_ansi_strlen          strlen
  ------------------
  |  Branch (27:16): [True: 1, False: 0]
  ------------------
   28|      1|    return dst;
   29|      1|}
pj_strassign:
  105|     91|{
  106|     91|    dst->ptr = src->ptr;
  107|     91|    dst->slen = src->slen;
  108|     91|    return dst;
  109|     91|}
pj_stricmp:
  236|    657|{
  237|    657|    pj_assert(str1->slen >= 0);
  ------------------
  |  |   65|    657|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (237:5): [True: 0, False: 657]
  |  Branch (237:5): [True: 657, False: 0]
  ------------------
  238|    657|    pj_assert(str2->slen >= 0);
  ------------------
  |  |   65|    657|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (238:5): [True: 0, False: 657]
  |  Branch (238:5): [True: 657, False: 0]
  ------------------
  239|       |
  240|    657|    if (str1->slen <= 0) {
  ------------------
  |  Branch (240:9): [True: 4, False: 653]
  ------------------
  241|      4|        return str2->slen<=0 ? 0 : -1;
  ------------------
  |  Branch (241:16): [True: 0, False: 4]
  ------------------
  242|    653|    } else if (str2->slen <= 0) {
  ------------------
  |  Branch (242:16): [True: 0, False: 653]
  ------------------
  243|      0|        return 1;
  244|    653|    } else {
  245|    653|        pj_size_t min = (str1->slen < str2->slen)? str1->slen : str2->slen;
  ------------------
  |  Branch (245:25): [True: 142, False: 511]
  ------------------
  246|    653|        int res = pj_ansi_strnicmp(str1->ptr, str2->ptr, min);
  ------------------
  |  |   96|    653|#define pj_ansi_strnicmp        strncasecmp
  ------------------
  247|    653|        if (res == 0) {
  ------------------
  |  Branch (247:13): [True: 225, False: 428]
  ------------------
  248|    225|            return (str1->slen < str2->slen) ? -1 :
  ------------------
  |  Branch (248:20): [True: 2, False: 223]
  ------------------
  249|    225|                    (str1->slen == str2->slen ? 0 : 1);
  ------------------
  |  Branch (249:22): [True: 164, False: 59]
  ------------------
  250|    428|        } else {
  251|    428|            return res;
  252|    428|        }
  253|    653|    }
  254|    657|}
pj_stricmp2:
  328|    657|{
  329|    657|    pj_str_t copy2;
  330|       |
  331|    657|    if (str2) {
  ------------------
  |  Branch (331:9): [True: 657, False: 0]
  ------------------
  332|    657|        copy2.ptr = (char*)str2;
  333|    657|        copy2.slen = pj_ansi_strlen(str2);
  ------------------
  |  |   69|    657|#define pj_ansi_strlen          strlen
  ------------------
  334|    657|    } else {
  335|      0|        copy2.ptr = NULL;
  336|      0|        copy2.slen = 0;
  337|      0|    }
  338|       |
  339|    657|    return pj_stricmp(str1, &copy2);
  340|    657|}

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

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_lock_create_simple_mutex:
   87|    217|{
   88|    217|    return create_mutex_lock(pool, name, PJ_MUTEX_SIMPLE, lock);
   89|    217|}
pj_lock_create_null_mutex:
  120|    217|{
  121|    217|    PJ_UNUSED_ARG(name);
  ------------------
  |  | 1537|    217|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  122|    217|    PJ_UNUSED_ARG(pool);
  ------------------
  |  | 1537|    217|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  123|       |
  124|    217|    PJ_ASSERT_RETURN(lock, PJ_EINVAL);
  ------------------
  |  |   97|    217|            do { \
  |  |   98|    217|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 217]
  |  |  ------------------
  |  |   99|    217|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 217]
  |  |  ------------------
  ------------------
  |  Branch (124:5): [True: 0, False: 0]
  |  Branch (124:5): [True: 0, False: 0]
  ------------------
  125|       |
  126|    217|    *lock = &null_lock_template;
  127|    217|    return PJ_SUCCESS;
  128|    217|}
pj_lock_destroy:
  195|    217|{
  196|    217|    PJ_ASSERT_RETURN(lock != NULL, PJ_EINVAL);
  ------------------
  |  |   97|    217|            do { \
  |  |   98|    217|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 217]
  |  |  ------------------
  |  |   99|    217|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 217]
  |  |  ------------------
  ------------------
  |  Branch (196:5): [True: 0, False: 0]
  |  Branch (196:5): [True: 0, False: 0]
  ------------------
  197|    217|    return (*lock->destroy)(lock->lock_object);
  198|    217|}
lock.c:create_mutex_lock:
   62|    217|{
   63|    217|    pj_lock_t *p_lock;
   64|    217|    pj_mutex_t *mutex;
   65|    217|    pj_status_t rc;
   66|       |
   67|    217|    PJ_ASSERT_RETURN(pool && lock, PJ_EINVAL);
  ------------------
  |  |   97|    217|            do { \
  |  |   98|    434|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 217, False: 0]
  |  |  |  Branch (98:23): [True: 217, False: 0]
  |  |  ------------------
  |  |   99|    217|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 217]
  |  |  ------------------
  ------------------
  |  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|    217|    p_lock = PJ_POOL_ALLOC_T(pool, pj_lock_t);
  ------------------
  |  |  569|    217|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
   70|    217|    if (!p_lock)
  ------------------
  |  Branch (70:9): [True: 0, False: 217]
  ------------------
   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|    217|    pj_memcpy(p_lock, &mutex_lock_template, sizeof(pj_lock_t));
   74|    217|    rc = pj_mutex_create(pool, name, type, &mutex);
   75|    217|    if (rc != PJ_SUCCESS)
  ------------------
  |  Branch (75:9): [True: 0, False: 217]
  ------------------
   76|      0|        return rc;
   77|       |
   78|    217|    p_lock->lock_object = mutex;
   79|    217|    *lock = p_lock;
   80|    217|    return PJ_SUCCESS;
   81|    217|}

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|    217|{
  253|    217|    pj_log_max_level = level;
  254|    217|}
pj_log_get_level:
  258|      1|{
  259|      1|    return pj_log_max_level;
  260|      1|}
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|    217|{
  203|    217|    char dummy_guid[PJ_GUID_MAX_LENGTH];
  204|    217|    pj_str_t guid;
  205|    217|    pj_status_t rc;
  206|       |
  207|       |    /* Check if PJLIB have been initialized */
  208|    217|    if (initialized) {
  ------------------
  |  Branch (208:9): [True: 216, False: 1]
  ------------------
  209|    216|        ++initialized;
  210|    216|        return PJ_SUCCESS;
  211|    216|    }
  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|      5|{
  968|      5|#if PJ_HAS_THREADS
  969|      5|    pj_thread_t *rec = (pj_thread_t*)pj_thread_local_get(thread_tls_id);
  970|       |
  971|      5|    if (rec == NULL) {
  ------------------
  |  Branch (971:9): [True: 0, False: 5]
  ------------------
  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|      5|    return rec;
  984|       |#else
  985|       |    pj_assert(!"Threading is not enabled!");
  986|       |    return NULL;
  987|       |#endif
  988|      5|}
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|    871|{
 1423|       |    //Can't check stack because this function is called in the
 1424|       |    //beginning before main thread is initialized.
 1425|       |    //PJ_CHECK_STACK();
 1426|    871|#if PJ_HAS_THREADS
 1427|    871|    int rc=pthread_setspecific(index, value);
 1428|    871|    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: 871, False: 0]
  ------------------
 1429|       |#else
 1430|       |    pj_assert(index >= 0 && index < MAX_THREADS);
 1431|       |    tls[index] = value;
 1432|       |    return PJ_SUCCESS;
 1433|       |#endif
 1434|    871|}
pj_thread_local_get:
 1437|    790|{
 1438|       |    //Can't check stack because this function is called
 1439|       |    //by PJ_CHECK_STACK() itself!!!
 1440|       |    //PJ_CHECK_STACK();
 1441|    790|#if PJ_HAS_THREADS
 1442|    790|    return pthread_getspecific(index);
 1443|       |#else
 1444|       |    pj_assert(index >= 0 && index < MAX_THREADS);
 1445|       |    return tls[index];
 1446|       |#endif
 1447|    790|}
pj_enter_critical_section:
 1451|      2|{
 1452|      2|#if PJ_HAS_THREADS
 1453|      2|    pj_mutex_lock(&critical_section);
 1454|      2|#endif
 1455|      2|}
pj_leave_critical_section:
 1458|      2|{
 1459|      2|#if PJ_HAS_THREADS
 1460|      2|    pj_mutex_unlock(&critical_section);
 1461|      2|#endif
 1462|      2|}
pj_mutex_create:
 1562|    217|{
 1563|    217|#if PJ_HAS_THREADS
 1564|    217|    pj_status_t rc;
 1565|    217|    pj_mutex_t *mutex;
 1566|       |
 1567|    217|    PJ_ASSERT_RETURN(pool && ptr_mutex, PJ_EINVAL);
  ------------------
  |  |   97|    217|            do { \
  |  |   98|    434|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 217, False: 0]
  |  |  |  Branch (98:23): [True: 217, False: 0]
  |  |  ------------------
  |  |   99|    217|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 217]
  |  |  ------------------
  ------------------
  |  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|    217|    mutex = PJ_POOL_ALLOC_T(pool, pj_mutex_t);
  ------------------
  |  |  569|    217|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
 1570|    217|    PJ_ASSERT_RETURN(mutex, PJ_ENOMEM);
  ------------------
  |  |   97|    217|            do { \
  |  |   98|    217|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 217]
  |  |  ------------------
  |  |   99|    217|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 217]
  |  |  ------------------
  ------------------
  |  Branch (1570:5): [True: 0, False: 0]
  |  Branch (1570:5): [True: 0, False: 0]
  ------------------
 1571|       |
 1572|    217|    if ((rc=init_mutex(mutex, name, type)) != PJ_SUCCESS)
  ------------------
  |  Branch (1572:9): [True: 0, False: 217]
  ------------------
 1573|      0|        return rc;
 1574|       |
 1575|    217|    *ptr_mutex = mutex;
 1576|    217|    return PJ_SUCCESS;
 1577|       |#else /* PJ_HAS_THREADS */
 1578|       |    *ptr_mutex = (pj_mutex_t*)1;
 1579|       |    return PJ_SUCCESS;
 1580|       |#endif
 1581|    217|}
pj_mutex_lock:
 1607|      2|{
 1608|      2|#if PJ_HAS_THREADS
 1609|      2|    pj_status_t status;
 1610|       |
 1611|      2|    PJ_CHECK_STACK();
 1612|      2|    PJ_ASSERT_RETURN(mutex, PJ_EINVAL);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (1612:5): [True: 0, False: 0]
  |  Branch (1612:5): [True: 0, False: 0]
  ------------------
 1613|       |
 1614|      2|#if PJ_DEBUG
 1615|      2|    PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s is waiting (mutex owner=%s)",
  ------------------
  |  |  106|      2|#define PJ_LOG(level,arg)       do { \
  |  |  107|      2|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      4|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 2]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|      2|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 2]
  |  |  ------------------
  ------------------
 1616|      2|                                pj_thread_this()->obj_name,
 1617|      2|                                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|      2|    status = pthread_mutex_lock( &mutex->mutex );
 1624|       |
 1625|       |
 1626|      2|#if PJ_DEBUG
 1627|      2|    if (status == PJ_SUCCESS) {
  ------------------
  |  Branch (1627:9): [True: 2, False: 0]
  ------------------
 1628|      2|        mutex->owner = pj_thread_this();
 1629|      2|        pj_ansi_strxcpy(mutex->owner_name, mutex->owner->obj_name,
 1630|      2|                        sizeof(mutex->owner_name));
 1631|      2|        ++mutex->nesting_level;
 1632|      2|    }
 1633|       |
 1634|      2|    PJ_LOG(6,(mutex->obj_name,
  ------------------
  |  |  106|      2|#define PJ_LOG(level,arg)       do { \
  |  |  107|      2|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      4|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 2]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|      2|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 2]
  |  |  ------------------
  ------------------
 1635|      2|              (status==0 ?
 1636|      2|                "Mutex acquired by thread %s (level=%d)" :
 1637|      2|                "Mutex acquisition FAILED by %s (level=%d)"),
 1638|      2|              pj_thread_this()->obj_name,
 1639|      2|              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|      2|    if (status == 0)
  ------------------
  |  Branch (1646:9): [True: 2, False: 0]
  ------------------
 1647|      2|        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|      2|}
pj_mutex_unlock:
 1660|      2|{
 1661|      2|#if PJ_HAS_THREADS
 1662|      2|    pj_status_t status;
 1663|       |
 1664|      2|    PJ_CHECK_STACK();
 1665|      2|    PJ_ASSERT_RETURN(mutex, PJ_EINVAL);
  ------------------
  |  |   97|      2|            do { \
  |  |   98|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   99|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (1665:5): [True: 0, False: 0]
  |  Branch (1665:5): [True: 0, False: 0]
  ------------------
 1666|       |
 1667|      2|#if PJ_DEBUG
 1668|      2|    pj_assert(mutex->owner == pj_thread_this());
  ------------------
  |  |   65|      2|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (1668:5): [True: 0, False: 2]
  |  Branch (1668:5): [True: 2, False: 0]
  ------------------
 1669|      2|    if (--mutex->nesting_level == 0) {
  ------------------
  |  Branch (1669:9): [True: 2, False: 0]
  ------------------
 1670|      2|        mutex->owner = NULL;
 1671|      2|        mutex->owner_name[0] = '\0';
 1672|      2|    }
 1673|       |
 1674|      2|    PJ_LOG(6,(mutex->obj_name, "Mutex released by thread %s (level=%d)",
  ------------------
  |  |  106|      2|#define PJ_LOG(level,arg)       do { \
  |  |  107|      2|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|      4|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 2]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|      2|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 2]
  |  |  ------------------
  ------------------
 1675|      2|                                pj_thread_this()->obj_name,
 1676|      2|                                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|      2|    status = pthread_mutex_unlock( &mutex->mutex );
 1683|      2|    if (status == 0)
  ------------------
  |  Branch (1683:9): [True: 2, False: 0]
  ------------------
 1684|      2|        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|      2|}
pj_mutex_destroy:
 1743|    217|{
 1744|    217|    enum { RETRY = 4 };
 1745|    217|    int status = 0;
 1746|    217|    unsigned retry;
 1747|       |
 1748|    217|    PJ_CHECK_STACK();
 1749|    217|    PJ_ASSERT_RETURN(mutex, PJ_EINVAL);
  ------------------
  |  |   97|    217|            do { \
  |  |   98|    217|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 217]
  |  |  ------------------
  |  |   99|    217|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 217]
  |  |  ------------------
  ------------------
  |  Branch (1749:5): [True: 0, False: 0]
  |  Branch (1749:5): [True: 0, False: 0]
  ------------------
 1750|       |
 1751|    217|#if PJ_HAS_THREADS
 1752|    217|    PJ_LOG(6,(mutex->obj_name, "Mutex destroyed by thread %s",
  ------------------
  |  |  106|    217|#define PJ_LOG(level,arg)       do { \
  |  |  107|    217|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|    434|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 217]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|    217|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 217]
  |  |  ------------------
  ------------------
 1753|    217|                               pj_thread_this()->obj_name));
 1754|       |
 1755|    217|    for (retry=0; retry<RETRY; ++retry) {
  ------------------
  |  Branch (1755:19): [True: 217, False: 0]
  ------------------
 1756|    217|        status = pthread_mutex_destroy( &mutex->mutex );
 1757|    217|        if (status == PJ_SUCCESS)
  ------------------
  |  Branch (1757:13): [True: 217, False: 0]
  ------------------
 1758|    217|            break;
 1759|      0|        else if (retry<RETRY-1 && status == EBUSY)
  ------------------
  |  Branch (1759:18): [True: 0, False: 0]
  |  Branch (1759:35): [True: 0, False: 0]
  ------------------
 1760|      0|            pthread_mutex_unlock(&mutex->mutex);
 1761|    217|    }
 1762|       |
 1763|    217|    if (status == 0)
  ------------------
  |  Branch (1763:9): [True: 217, False: 0]
  ------------------
 1764|    217|        return PJ_SUCCESS;
 1765|      0|    else {
 1766|      0|        return PJ_RETURN_OS_ERROR(status);
  ------------------
  |  |  319|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (319:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  320|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  334|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  528|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  521|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  509|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  515|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (334:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1767|      0|    }
 1768|       |#else
 1769|       |    pj_assert( mutex == (pj_mutex_t*)1 );
 1770|       |    status = PJ_SUCCESS;
 1771|       |    return status;
 1772|       |#endif
 1773|    217|}
os_core_unix.c:init_mutex:
 1473|    218|{
 1474|    218|#if PJ_HAS_THREADS
 1475|    218|    pthread_mutexattr_t attr;
 1476|    218|    int rc;
 1477|       |
 1478|    218|    PJ_CHECK_STACK();
 1479|       |
 1480|    218|    rc = pthread_mutexattr_init(&attr);
 1481|    218|    if (rc != 0)
  ------------------
  |  Branch (1481:9): [True: 0, False: 218]
  ------------------
 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|    218|    if (type == PJ_MUTEX_SIMPLE) {
  ------------------
  |  Branch (1484:9): [True: 217, False: 1]
  ------------------
 1485|    217|#if (defined(PJ_LINUX) && PJ_LINUX!=0) || \
 1486|    217|    defined(PJ_HAS_PTHREAD_MUTEXATTR_SETTYPE)
 1487|    217|        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|    217|    } else {
 1495|      1|#if (defined(PJ_LINUX) && PJ_LINUX!=0) || \
 1496|      1|     defined(PJ_HAS_PTHREAD_MUTEXATTR_SETTYPE)
 1497|      1|        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|      1|    }
 1514|       |
 1515|    218|    if (rc != 0) {
  ------------------
  |  Branch (1515:9): [True: 0, False: 218]
  ------------------
 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|    218|    rc = pthread_mutex_init(&mutex->mutex, &attr);
 1520|    218|    if (rc != 0) {
  ------------------
  |  Branch (1520:9): [True: 0, False: 218]
  ------------------
 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|    218|    rc = pthread_mutexattr_destroy(&attr);
 1525|    218|    if (rc != 0) {
  ------------------
  |  Branch (1525:9): [True: 0, False: 218]
  ------------------
 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|    218|#if PJ_DEBUG
 1532|       |    /* Set owner. */
 1533|    218|    mutex->nesting_level = 0;
 1534|    218|    mutex->owner = NULL;
 1535|    218|    mutex->owner_name[0] = '\0';
 1536|    218|#endif
 1537|       |
 1538|       |    /* Set name. */
 1539|    218|    if (!name) {
  ------------------
  |  Branch (1539:9): [True: 0, False: 218]
  ------------------
 1540|      0|        name = "mtx%p";
 1541|      0|    }
 1542|    218|    if (strchr(name, '%')) {
  ------------------
  |  Branch (1542:9): [True: 0, False: 218]
  ------------------
 1543|      0|        pj_ansi_snprintf(mutex->obj_name, PJ_MAX_OBJ_NAME, name, mutex);
  ------------------
  |  |  114|      0|#define pj_ansi_snprintf        snprintf
  ------------------
                      pj_ansi_snprintf(mutex->obj_name, PJ_MAX_OBJ_NAME, name, mutex);
  ------------------
  |  |  320|      0|#define PJ_MAX_OBJ_NAME 32
  ------------------
 1544|    218|    } else {
 1545|    218|        pj_ansi_strxcpy(mutex->obj_name, name, PJ_MAX_OBJ_NAME);
  ------------------
  |  |  320|    218|#define PJ_MAX_OBJ_NAME 32
  ------------------
 1546|    218|    }
 1547|       |
 1548|    218|    PJ_LOG(6, (mutex->obj_name, "Mutex created"));
  ------------------
  |  |  106|    218|#define PJ_LOG(level,arg)       do { \
  |  |  107|    218|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  |  417|    436|#  define PJ_LOG_MAX_LEVEL   5
  |  |  ------------------
  |  |  |  Branch (107:41): [Folded, False: 218]
  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|    218|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded, False: 218]
  |  |  ------------------
  ------------------
 1549|    218|    return PJ_SUCCESS;
 1550|       |#else /* PJ_HAS_THREADS */
 1551|       |    return PJ_SUCCESS;
 1552|       |#endif
 1553|    218|}

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_get_timestamp:
  228|      1|{
  229|      1|    struct timespec tp;
  230|       |
  231|      1|    if (clock_gettime(CLOCK_MONOTONIC, &tp) != 0) {
  ------------------
  |  Branch (231:9): [True: 0, False: 1]
  ------------------
  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|      1|    ts->u64 = tp.tv_sec;
  236|      1|    ts->u64 *= NSEC_PER_SEC;
  ------------------
  |  |  225|      1|#define NSEC_PER_SEC    1000000000
  ------------------
  237|      1|    ts->u64 += tp.tv_nsec;
  238|       |
  239|      1|    return PJ_SUCCESS;
  240|      1|}

pj_pool_init_int:
  176|    217|{
  177|       |
  178|    217|    PJ_CHECK_STACK();
  179|    217|    pj_assert(!alignment || PJ_IS_POWER_OF_TWO(alignment));
  ------------------
  |  |   65|    217|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (179:5): [True: 0, False: 0]
  |  Branch (179:5): [True: 0, False: 0]
  |  Branch (179:5): [True: 217, False: 0]
  |  Branch (179:5): [True: 217, False: 0]
  |  Branch (179:5): [True: 217, False: 0]
  |  Branch (179:5): [True: 0, False: 217]
  ------------------
  180|       |
  181|    217|    pool->increment_size = increment_size;
  182|    217|    pool->callback = callback;
  183|    217|    pool->alignment = !alignment ? PJ_POOL_ALIGNMENT : alignment;
  ------------------
  |  |  182|      0|#define PJ_POOL_ALIGNMENT 8
  ------------------
  |  Branch (183:23): [True: 0, False: 217]
  ------------------
  184|       |
  185|    217|    if (name) {
  ------------------
  |  Branch (185:9): [True: 217, False: 0]
  ------------------
  186|    217|        char *p = pj_ansi_strchr(name, '%');
  ------------------
  |  |   92|    217|#define pj_ansi_strchr          strchr
  ------------------
  187|    217|        if (p && *(p+1)=='p' && *(p+2)=='\0') {
  ------------------
  |  Branch (187:13): [True: 0, False: 217]
  |  Branch (187:18): [True: 0, False: 0]
  |  Branch (187:33): [True: 0, False: 0]
  ------------------
  188|       |            /* Special name with "%p" suffix */
  189|      0|            pj_ansi_snprintf(pool->obj_name, sizeof(pool->obj_name), 
  ------------------
  |  |  114|      0|#define pj_ansi_snprintf        snprintf
  ------------------
  190|      0|                             name, pool);
  191|    217|        } else {
  192|    217|            pj_ansi_strxcpy(pool->obj_name, name, PJ_MAX_OBJ_NAME);
  ------------------
  |  |  320|    217|#define PJ_MAX_OBJ_NAME 32
  ------------------
  193|    217|        }
  194|    217|    } else {
  195|      0|        pool->obj_name[0] = '\0';
  196|      0|    }
  197|    217|}
pj_pool_create_int:
  207|    217|{
  208|    217|    pj_pool_t *pool;
  209|    217|    pj_pool_block *block;
  210|    217|    pj_uint8_t *buffer;
  211|       |
  212|    217|    PJ_CHECK_STACK();
  213|       |
  214|       |    /* Size must be at least sizeof(pj_pool)+sizeof(pj_pool_block) */
  215|    217|    PJ_ASSERT_RETURN(initial_size >= sizeof(pj_pool_t)+sizeof(pj_pool_block),
  ------------------
  |  |   97|    217|            do { \
  |  |   98|    217|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 217]
  |  |  ------------------
  |  |   99|    217|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 217]
  |  |  ------------------
  ------------------
  |  Branch (215:5): [True: 0, False: 0]
  |  Branch (215:5): [True: 0, False: 0]
  ------------------
  216|    217|                     NULL);
  217|    217|    PJ_ASSERT_RETURN(!alignment || PJ_IS_POWER_OF_TWO(alignment), NULL);
  ------------------
  |  |   97|    217|            do { \
  |  |   98|    868|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 217, False: 0]
  |  |  |  Branch (98:23): [True: 217, False: 0]
  |  |  |  Branch (98:23): [True: 0, False: 217]
  |  |  ------------------
  |  |   99|    217|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 217]
  |  |  ------------------
  ------------------
  |  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|    217|    if (callback == NULL)
  ------------------
  |  Branch (220:9): [True: 0, False: 217]
  ------------------
  221|      0|        callback = f->policy.callback;
  222|       |
  223|       |    /* Allocate initial block */
  224|    217|    buffer = (pj_uint8_t*) (*f->policy.block_alloc)(f, initial_size);
  225|    217|    if (!buffer)
  ------------------
  |  Branch (225:9): [True: 0, False: 217]
  ------------------
  226|      0|        return NULL;
  227|       |
  228|       |    /* Set pool administrative data. */
  229|    217|    pool = (pj_pool_t*)buffer;
  230|    217|    pj_bzero(pool, sizeof(*pool));
  231|       |
  232|    217|    pj_list_init(&pool->block_list);
  233|    217|    pool->factory = f;
  234|       |
  235|       |    /* Create the first block from the memory. */
  236|    217|    block = (pj_pool_block*) (buffer + sizeof(*pool));
  237|    217|    block->buf = ((unsigned char*)block) + sizeof(pj_pool_block);
  238|    217|    block->end = buffer + initial_size;
  239|       |
  240|       |    /* Set the start pointer, unaligned! */
  241|    217|    block->cur = block->buf;
  242|       |
  243|    217|    pj_list_insert_after(&pool->block_list, block);
  244|       |
  245|    217|    pj_pool_init_int(pool, name, increment_size, alignment, callback);
  246|       |
  247|       |    /* Pool initial capacity and used size */
  248|    217|    pool->capacity = initial_size;
  249|       |
  250|    217|    LOG((pool->obj_name, "pool created, size=%lu",
  ------------------
  |  |   33|    217|#define LOG(expr)                   PJ_LOG(6,expr)
  |  |  ------------------
  |  |  |  |  106|    217|#define PJ_LOG(level,arg)       do { \
  |  |  |  |  107|    217|                                    if (level <= PJ_LOG_MAX_LEVEL && level <= pj_log_get_level()) { \
  |  |  |  |  ------------------
  |  |  |  |  |  |  417|    434|#  define PJ_LOG_MAX_LEVEL   5
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:41): [Folded, False: 217]
  |  |  |  |  |  Branch (107:70): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  |  |  109|      0|                                    } \
  |  |  |  |  110|    217|                                } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (110:42): [Folded, False: 217]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  251|    217|                         (unsigned long)pool->capacity));
  252|    217|    return pool;
  253|    217|}

pj_pool_create_on_buf:
   82|    217|{
   83|    217|#if PJ_HAS_POOL_ALT_API == 0
   84|    217|    struct creation_param param;
   85|    217|    pj_size_t align_diff;
   86|       |
   87|    217|    PJ_ASSERT_RETURN(buf && size, NULL);
  ------------------
  |  |   97|    217|            do { \
  |  |   98|    434|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 217, False: 0]
  |  |  |  Branch (98:23): [True: 217, False: 0]
  |  |  ------------------
  |  |   99|    217|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 217]
  |  |  ------------------
  ------------------
  |  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|    217|    if (!is_initialized) {
  ------------------
  |  Branch (89:9): [True: 1, False: 216]
  ------------------
   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|    217|    align_diff = (pj_size_t)buf;
   97|    217|    if (align_diff & (PJ_POOL_ALIGNMENT-1)) {
  ------------------
  |  |  182|    217|#define PJ_POOL_ALIGNMENT 8
  ------------------
  |  Branch (97:9): [True: 0, False: 217]
  ------------------
   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|    217|    param.stack_buf = buf;
  104|    217|    param.size = size;
  105|    217|    pj_thread_local_set(tls, &param);
  106|       |
  107|    217|    return pj_pool_create_int(&stack_based_factory, name, size, 0, 
  108|    217|                              PJ_POOL_ALIGNMENT,
  ------------------
  |  |  182|    217|#define PJ_POOL_ALIGNMENT 8
  ------------------
  109|    217|                              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|    217|}
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|    217|{
   55|    217|    struct creation_param *param;
   56|    217|    void *buf;
   57|       |
   58|    217|    PJ_UNUSED_ARG(factory);
  ------------------
  |  | 1537|    217|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
   59|       |
   60|    217|    param = (struct creation_param*) pj_thread_local_get(tls);
   61|    217|    if (param == NULL) {
  ------------------
  |  Branch (61:9): [True: 0, False: 217]
  ------------------
   62|       |        /* Don't assert(), this is normal no-memory situation */
   63|      0|        return NULL;
   64|      0|    }
   65|       |
   66|    217|    pj_thread_local_set(tls, NULL);
   67|       |
   68|    217|    PJ_ASSERT_RETURN(size <= param->size, NULL);
  ------------------
  |  |   97|    217|            do { \
  |  |   98|    217|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:21): [True: 0, False: 217]
  |  |  ------------------
  |  |   99|    217|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 217]
  |  |  ------------------
  ------------------
  |  Branch (68:5): [True: 0, False: 0]
  |  Branch (68:5): [True: 0, False: 0]
  ------------------
   69|       |
   70|    217|    buf = param->stack_buf;
   71|       |
   72|       |    /* Prevent the buffer from being reused */
   73|    217|    param->stack_buf = NULL;
   74|       |
   75|    217|    return buf;
   76|    217|}

pj_caching_pool_init:
   57|    217|{
   58|    217|    int i;
   59|    217|    pj_pool_t *pool;
   60|    217|    pj_status_t status;
   61|       |
   62|    217|    PJ_CHECK_STACK();
   63|       |
   64|    217|    pj_bzero(cp, sizeof(*cp));
   65|       |    
   66|    217|    cp->max_capacity = max_capacity;
   67|    217|    pj_list_init(&cp->used_list);
   68|  3.68k|    for (i=0; i<PJ_CACHING_POOL_ARRAY_SIZE; ++i)
  ------------------
  |  |  889|  3.68k|#define PJ_CACHING_POOL_ARRAY_SIZE      16
  ------------------
  |  Branch (68:15): [True: 3.47k, False: 217]
  ------------------
   69|  3.47k|        pj_list_init(&cp->free_list[i]);
   70|       |
   71|    217|    if (policy == NULL) {
  ------------------
  |  Branch (71:9): [True: 0, False: 217]
  ------------------
   72|      0|        policy = &pj_pool_factory_default_policy;
   73|      0|    }
   74|       |    
   75|    217|    pj_memcpy(&cp->factory.policy, policy, sizeof(pj_pool_factory_policy));
   76|    217|    cp->factory.create_pool = &cpool_create_pool;
   77|    217|    cp->factory.release_pool = &cpool_release_pool;
   78|    217|    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|    217|    PJ_UNUSED_ARG(cpool_on_block_alloc);
  ------------------
  |  | 1537|    217|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
   86|    217|    PJ_UNUSED_ARG(cpool_on_block_free);
  ------------------
  |  | 1537|    217|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
   87|       |
   88|    217|    pool = pj_pool_create_on_buf("cachingpool", cp->pool_buf, sizeof(cp->pool_buf));
   89|    217|    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|    217|    PJ_ASSERT_ON_FAIL(status==PJ_SUCCESS, return);
  ------------------
  |  |  111|    217|            { \
  |  |  112|    217|                pj_assert(expr); \
  |  |  ------------------
  |  |  |  |   65|    217|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  113|    217|                if (!(expr)) exec_on_fail; \
  |  |  ------------------
  |  |  |  Branch (113:21): [True: 0, False: 217]
  |  |  ------------------
  |  |  114|    217|            }
  ------------------
  |  Branch (92:5): [True: 0, False: 217]
  |  Branch (92:5): [True: 217, False: 0]
  ------------------
   93|    217|}
pj_caching_pool_destroy:
   96|    217|{
   97|    217|    int i;
   98|    217|    pj_pool_t *pool;
   99|       |
  100|    217|    PJ_CHECK_STACK();
  101|       |
  102|       |    /* Delete all pool in free list */
  103|  3.68k|    for (i=0; i < PJ_CACHING_POOL_ARRAY_SIZE; ++i) {
  ------------------
  |  |  889|  3.68k|#define PJ_CACHING_POOL_ARRAY_SIZE      16
  ------------------
  |  Branch (103:15): [True: 3.47k, False: 217]
  ------------------
  104|  3.47k|        pj_pool_t *next;
  105|  3.47k|        pool = (pj_pool_t*) cp->free_list[i].next;
  106|  3.47k|        for (; pool != (void*)&cp->free_list[i]; pool = next) {
  ------------------
  |  Branch (106:16): [True: 0, False: 3.47k]
  ------------------
  107|      0|            next = pool->next;
  108|      0|            pj_list_erase(pool);
  109|      0|            pj_pool_destroy_int(pool);
  110|      0|        }
  111|  3.47k|    }
  112|       |
  113|       |    /* Delete all pools in used list */
  114|    217|    pool = (pj_pool_t*) cp->used_list.next;
  115|    217|    while (pool != (pj_pool_t*) &cp->used_list) {
  ------------------
  |  Branch (115:12): [True: 0, False: 217]
  ------------------
  116|      0|        pj_pool_t *next = pool->next;
  117|      0|        pj_list_erase(pool);
  118|      0|        PJ_LOG(4,(pool->obj_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]
  |  |  ------------------
  ------------------
  119|      0|                  "Pool is not released by application, releasing now"));
  120|      0|        pj_pool_destroy_int(pool);
  121|      0|        pool = next;
  122|      0|    }
  123|       |
  124|    217|    if (cp->lock) {
  ------------------
  |  Branch (124:9): [True: 217, False: 0]
  ------------------
  125|    217|        pj_status_t status;
  126|    217|        pj_lock_destroy(cp->lock);
  127|    217|        status = pj_lock_create_null_mutex(NULL, "cachingpool", &cp->lock);
  128|    217|        PJ_ASSERT_ON_FAIL(status==PJ_SUCCESS, return);
  ------------------
  |  |  111|    217|            { \
  |  |  112|    217|                pj_assert(expr); \
  |  |  ------------------
  |  |  |  |   65|    217|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  113|    217|                if (!(expr)) exec_on_fail; \
  |  |  ------------------
  |  |  |  Branch (113:21): [True: 0, False: 217]
  |  |  ------------------
  |  |  114|    217|            }
  ------------------
  |  Branch (128:9): [True: 0, False: 217]
  |  Branch (128:9): [True: 217, False: 0]
  ------------------
  129|    217|    }
  130|    217|}

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

pj_strtoul:
  328|     45|{
  329|     45|    unsigned long value;
  330|     45|    unsigned i;
  331|       |
  332|     45|    PJ_CHECK_STACK();
  333|       |
  334|     45|    pj_assert(str->slen >= 0);
  ------------------
  |  |   65|     45|#       define pj_assert(expr)   assert(expr)
  ------------------
  |  Branch (334:5): [True: 0, False: 45]
  |  Branch (334:5): [True: 45, False: 0]
  ------------------
  335|       |
  336|     45|    value = 0;
  337|    509|    for (i=0; i<(unsigned)str->slen; ++i) {
  ------------------
  |  Branch (337:15): [True: 487, False: 22]
  ------------------
  338|    487|        if (!pj_isdigit(str->ptr[i]))
  ------------------
  |  Branch (338:13): [True: 23, False: 464]
  ------------------
  339|     23|            break;
  340|    464|        value = value * 10 + (str->ptr[i] - '0');
  341|    464|    }
  342|     45|    return value;
  343|     45|}
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|    437|{
  632|    437|    char *odst = dst;
  633|       |
  634|    437|    PJ_ASSERT_RETURN(dst && src, -PJ_EINVAL);
  ------------------
  |  |   97|    437|            do { \
  |  |   98|    874|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   65|      0|#       define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (98:23): [True: 437, False: 0]
  |  |  |  Branch (98:23): [True: 437, False: 0]
  |  |  ------------------
  |  |   99|    437|            } while (0)
  |  |  ------------------
  |  |  |  Branch (99:22): [Folded, False: 437]
  |  |  ------------------
  ------------------
  |  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|    437|    if (dst_size==0)
  ------------------
  |  Branch (636:9): [True: 0, False: 437]
  ------------------
  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|  5.25k|    while (--dst_size && (*dst=*src) != 0) {
  ------------------
  |  Branch (639:12): [True: 5.25k, False: 0]
  |  Branch (639:26): [True: 4.81k, False: 437]
  ------------------
  640|  4.81k|        ++dst;
  641|  4.81k|        ++src;
  642|  4.81k|    }
  643|       |
  644|    437|    if (!*dst && !*src) {
  ------------------
  |  Branch (644:9): [True: 437, False: 0]
  |  Branch (644:18): [True: 437, False: 0]
  ------------------
  645|    437|        return (int)(dst-odst);
  646|    437|    } 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|    437|}

url_parse:
   30|    217|int url_parse(uint8_t *data, size_t Size) {
   31|       |
   32|    217|    pj_str_t surl;
   33|    217|    pj_http_url hurl;
   34|       |
   35|    217|    surl.ptr = (char *)data;
   36|    217|    surl.slen = Size;
   37|       |
   38|    217|    return pj_http_req_parse_url(&surl, &hurl);
   39|    217|}
LLVMFuzzerTestOneInput:
   43|    231|{
   44|       |
   45|    231|    if (Size < kMinInputLength || Size > kMaxInputLength) {
  ------------------
  |  |   25|    462|#define kMinInputLength 10
  ------------------
                  if (Size < kMinInputLength || Size > kMaxInputLength) {
  ------------------
  |  |   26|    225|#define kMaxInputLength 1024
  ------------------
  |  Branch (45:9): [True: 6, False: 225]
  |  Branch (45:35): [True: 8, False: 217]
  ------------------
   46|     14|        return 1;
   47|     14|    }
   48|       |
   49|    217|    int ret = 0;
   50|    217|    uint8_t *data;
   51|    217|    pj_caching_pool caching_pool;
   52|       |
   53|       |    /* Add NULL byte */
   54|    217|    data = (uint8_t *)calloc((Size+1), sizeof(uint8_t));
   55|    217|    memcpy((void *)data, (void *)Data, Size);
   56|       |
   57|       |    /* init Calls */
   58|    217|    pj_init();
   59|    217|    pj_caching_pool_init( &caching_pool, &pj_pool_factory_default_policy, 0);
   60|    217|    pj_log_set_level(0);
   61|       |
   62|    217|    mem = &caching_pool.factory;
   63|       |
   64|       |    /* Call fuzzer */
   65|    217|    ret = url_parse(data, Size);
   66|       |
   67|    217|    free(data);
   68|    217|    pj_caching_pool_destroy(&caching_pool);
   69|       |
   70|    217|    return ret;
   71|    231|}

