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

pj_http_req_parse_url:
  803|    218|{
  804|    218|    pj_scanner scanner;
  805|    218|    pj_size_t len = url->slen;
  806|    218|    PJ_USE_EXCEPTION;
  ------------------
  |  |  367|    218|#define PJ_USE_EXCEPTION    struct pj_exception_state_t pj_x_except__; int pj_x_code__
  ------------------
  807|       |
  808|    218|    if (!len) return -1;
  ------------------
  |  Branch (808:9): [True: 0, False: 218]
  ------------------
  809|       |    
  810|    218|    pj_bzero(hurl, sizeof(*hurl));
  811|    218|    pj_scan_init(&scanner, url->ptr, url->slen, 0, &on_syntax_error);
  812|       |
  813|    218|    PJ_TRY {
  ------------------
  |  |  373|    218|#define PJ_TRY              if (1) { \
  |  |  ------------------
  |  |  |  Branch (373:33): [Folded - Ignored]
  |  |  ------------------
  |  |  374|    218|                                pj_push_exception_handler_(&pj_x_except__); \
  |  |  375|    218|                                pj_x_code__ = pj_setjmp(pj_x_except__.state); \
  |  |  ------------------
  |  |  |  |   31|    218|#    define pj_setjmp(buf)      setjmp(buf)
  |  |  ------------------
  |  |  376|    218|                                if (pj_x_code__ == 0)
  |  |  ------------------
  |  |  |  Branch (376:37): [True: 218, False: 0]
  |  |  ------------------
  ------------------
  814|    218|        pj_str_t s;
  815|       |
  816|       |        /* Exhaust any whitespaces. */
  817|    218|        pj_scan_skip_whitespace(&scanner);
  818|       |
  819|       |        /* Parse the protocol */
  820|    218|        pj_scan_get_until_ch(&scanner, ':', &s);
  821|    218|        if (!pj_stricmp2(&s, http_protocol_names[PROTOCOL_HTTP])) {
  ------------------
  |  Branch (821:13): [True: 108, False: 110]
  ------------------
  822|    108|            pj_strset2(&hurl->protocol,
  823|    108|                       (char*)http_protocol_names[PROTOCOL_HTTP]);
  824|    110|        } else if (!pj_stricmp2(&s, http_protocol_names[PROTOCOL_HTTPS])) {
  ------------------
  |  Branch (824:20): [True: 1, False: 109]
  ------------------
  825|      1|            pj_strset2(&hurl->protocol,
  826|      1|                       (char*)http_protocol_names[PROTOCOL_HTTPS]);
  827|    109|        } else {
  828|    109|            PJ_THROW(PJ_ENOTSUP); // unsupported protocol
  ------------------
  |  |  402|    109|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
  829|    109|        }
  830|       |
  831|    109|        if (pj_scan_strcmp(&scanner, "://", 3)) {
  ------------------
  |  Branch (831:13): [True: 17, False: 92]
  ------------------
  832|     17|            PJ_THROW(PJLIB_UTIL_EHTTPINURL); // no "://" after protocol name
  ------------------
  |  |  402|     17|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
  833|     17|        }
  834|     92|        pj_scan_advance_n(&scanner, 3, PJ_FALSE);
  835|       |
  836|     92|        if (get_url_at_pos(url->ptr, url->slen)) {
  ------------------
  |  Branch (836:13): [True: 14, False: 78]
  ------------------
  837|       |            /* Parse username and password */
  838|     14|            pj_scan_get_until_chr(&scanner, ":@", &hurl->username);
  839|     14|            if (*scanner.curptr == ':') {
  ------------------
  |  Branch (839:17): [True: 3, False: 11]
  ------------------
  840|      3|                pj_scan_get_char(&scanner);
  841|      3|                pj_scan_get_until_chr(&scanner, "@", &hurl->passwd);
  842|     11|            } else {
  843|     11|                hurl->passwd.slen = 0;
  844|     11|            }
  845|     14|            pj_scan_get_char(&scanner);
  846|     14|        }
  847|       |
  848|       |        /* Parse the host and port number (if any) */
  849|     92|        pj_scan_get_until_chr(&scanner, ":/", &s);
  850|     92|        pj_strassign(&hurl->host, &s);
  851|     92|        if (hurl->host.slen==0)
  ------------------
  |  Branch (851:13): [True: 1, False: 91]
  ------------------
  852|      1|            PJ_THROW(PJ_EINVAL);
  ------------------
  |  |  402|      1|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
  853|     91|        if (pj_scan_is_eof(&scanner) || *scanner.curptr == '/') {
  ------------------
  |  Branch (853:13): [True: 51, False: 40]
  |  Branch (853:41): [True: 1, False: 39]
  ------------------
  854|       |            /* No port number specified */
  855|       |            /* Assume default http/https port number */
  856|     39|            hurl->port = get_http_default_port(&hurl->protocol);
  857|     39|            pj_assert(hurl->port > 0);
  ------------------
  |  |   48|     39|#   define pj_assert(expr)   assert(expr)
  ------------------
  858|     52|        } else {
  859|     52|            pj_scan_advance_n(&scanner, 1, PJ_FALSE);
  860|     52|            pj_scan_get_until_ch(&scanner, '/', &s);
  861|       |            /* Parse the port number */
  862|     52|            hurl->port = (pj_uint16_t)pj_strtoul(&s);
  863|     52|            if (!hurl->port)
  ------------------
  |  Branch (863:17): [True: 3, False: 49]
  ------------------
  864|      3|                PJ_THROW(PJLIB_UTIL_EHTTPINPORT); // invalid port number
  ------------------
  |  |  402|      3|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
  865|     52|        }
  866|       |
  867|     88|        if (!pj_scan_is_eof(&scanner)) {
  ------------------
  |  Branch (867:13): [True: 5, False: 83]
  ------------------
  868|      5|            hurl->path.ptr = scanner.curptr;
  869|      5|            hurl->path.slen = scanner.end - scanner.curptr;
  870|     83|        } else {
  871|       |            /* no path, append '/' */
  872|     83|            pj_cstr(&hurl->path, "/");
  873|     83|        }
  874|     88|    }
  875|      0|    PJ_CATCH_ANY {
  876|      0|        pj_scan_fini(&scanner);
  877|      0|        return PJ_GET_EXCEPTION();
  ------------------
  |  |  409|      0|#define PJ_GET_EXCEPTION()      (pj_x_code__)
  ------------------
  878|      0|    }
  879|     88|    PJ_END;
  ------------------
  |  |  394|     88|#define PJ_END                  pj_pop_exception_handler_(&pj_x_except__); \
  |  |  395|     88|                            } else {}
  ------------------
  880|       |
  881|     88|    pj_scan_fini(&scanner);
  882|     88|    return PJ_SUCCESS;
  883|    218|}
http_client.c:on_syntax_error:
  193|     22|{
  194|     22|    PJ_UNUSED_ARG(scanner);
  ------------------
  |  | 1433|     22|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  195|     22|    PJ_THROW(PJ_EINVAL);  // syntax error
  ------------------
  |  |  402|     22|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
  196|     22|}
http_client.c:get_url_at_pos:
  778|     91|{
  779|     91|    const char *end = str + len;
  780|     91|    const char *p = str;
  781|       |
  782|       |    /* skip scheme: */
  783|  1.89k|    while (p!=end && *p!='/') ++p;
  ------------------
  |  Branch (783:12): [True: 1.89k, False: 0]
  |  Branch (783:22): [True: 1.80k, False: 91]
  ------------------
  784|     91|    if (p!=end && *p=='/') ++p;
  ------------------
  |  Branch (784:9): [True: 91, False: 0]
  |  Branch (784:19): [True: 91, False: 0]
  ------------------
  785|     91|    if (p!=end && *p=='/') ++p;
  ------------------
  |  Branch (785:9): [True: 91, False: 0]
  |  Branch (785:19): [True: 91, False: 0]
  ------------------
  786|     91|    if (p==end) return NULL;
  ------------------
  |  Branch (786:9): [True: 11, False: 80]
  ------------------
  787|       |
  788|  9.82k|    for (; p!=end; ++p) {
  ------------------
  |  Branch (788:12): [True: 9.76k, False: 61]
  ------------------
  789|  9.76k|        switch (*p) {
  ------------------
  |  Branch (789:17): [True: 9.74k, False: 19]
  ------------------
  790|      5|        case '/':
  ------------------
  |  Branch (790:9): [True: 5, False: 9.76k]
  ------------------
  791|      5|            return NULL;
  792|     14|        case '@':
  ------------------
  |  Branch (792:9): [True: 14, False: 9.75k]
  ------------------
  793|     14|            return (char*)p;
  794|  9.76k|        }
  795|  9.76k|    }
  796|       |
  797|     61|    return NULL;
  798|     80|}
http_client.c:get_http_default_port:
  164|     39|{
  165|     39|    int i;
  166|       |
  167|     40|    for (i = 0; i < NUM_PROTOCOL; i++) {
  ------------------
  |  |   44|     40|#define NUM_PROTOCOL            2
  ------------------
  |  Branch (167:17): [True: 40, False: 0]
  ------------------
  168|     40|        if (!pj_stricmp2(protocol, http_protocol_names[i])) {
  ------------------
  |  Branch (168:13): [True: 39, False: 1]
  ------------------
  169|     39|            return (pj_uint16_t)http_default_port[i];
  170|     39|        }
  171|     40|    }
  172|      0|    return 0;
  173|     39|}

pj_scan_init:
  120|    218|{
  121|    218|    PJ_CHECK_STACK();
  122|       |
  123|    218|    scanner->begin = scanner->curptr = bufstart;
  124|    218|    scanner->end = bufstart + buflen;
  125|    218|    scanner->line = 1;
  126|    218|    scanner->start_line = scanner->begin;
  127|    218|    scanner->callback = callback;
  128|    218|    scanner->skip_ws = options;
  129|       |
  130|    218|    if (scanner->skip_ws) 
  ------------------
  |  Branch (130:9): [True: 0, False: 218]
  ------------------
  131|      0|        pj_scan_skip_whitespace(scanner);
  132|    218|}
pj_scan_fini:
  136|    218|{
  137|    218|    PJ_CHECK_STACK();
  138|    218|    PJ_UNUSED_ARG(scanner);
  ------------------
  |  | 1433|    218|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  139|    218|}
pj_scan_skip_whitespace:
  142|    218|{
  143|    218|    register char *s = scanner->curptr;
  144|       |
  145|  2.13k|    while (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_SPACE(*s)) {
  ------------------
  |  |   33|  4.27k|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 2.12k, False: 9]
  |  |  ------------------
  ------------------
                  while (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_SPACE(*s)) {
  ------------------
  |  |   30|  2.12k|#define PJ_SCAN_IS_SPACE(c)             ((c)==' ' || (c)=='\t')
  |  |  ------------------
  |  |  |  Branch (30:42): [True: 1.05k, False: 1.07k]
  |  |  |  Branch (30:54): [True: 865, False: 209]
  |  |  ------------------
  ------------------
  146|  1.91k|        ++s;
  147|  1.91k|    }
  148|       |
  149|    218|    if (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_NEWLINE(*s) &&
  ------------------
  |  |   33|    436|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 209, False: 9]
  |  |  ------------------
  ------------------
                  if (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_NEWLINE(*s) &&
  ------------------
  |  |   31|    427|#define PJ_SCAN_IS_NEWLINE(c)           ((c)=='\r' || (c)=='\n')
  |  |  ------------------
  |  |  |  Branch (31:42): [True: 1, False: 208]
  |  |  |  Branch (31:55): [True: 1, False: 207]
  |  |  ------------------
  ------------------
  150|    218|        (scanner->skip_ws & PJ_SCAN_AUTOSKIP_NEWLINE))
  ------------------
  |  Branch (150:9): [True: 0, False: 2]
  ------------------
  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|    218|    if (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_NEWLINE(*s) &&
  ------------------
  |  |   33|    436|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 209, False: 9]
  |  |  ------------------
  ------------------
                  if (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_NEWLINE(*s) &&
  ------------------
  |  |   31|    427|#define PJ_SCAN_IS_NEWLINE(c)           ((c)=='\r' || (c)=='\n')
  |  |  ------------------
  |  |  |  Branch (31:42): [True: 1, False: 208]
  |  |  |  Branch (31:55): [True: 1, False: 207]
  |  |  ------------------
  ------------------
  174|    218|        (scanner->skip_ws & PJ_SCAN_AUTOSKIP_WS_HEADER)==
  ------------------
  |  Branch (174:9): [True: 0, False: 2]
  ------------------
  175|      2|         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|    218|    } else {
  198|    218|        scanner->curptr = s;
  199|    218|    }
  200|    218|}
pj_scan_get_char:
  459|     17|{
  460|     17|    register char *s = scanner->curptr;
  461|     17|    int chr;
  462|       |
  463|     17|    if (s >= scanner->end || !*s) {
  ------------------
  |  Branch (463:9): [True: 0, False: 17]
  |  Branch (463:30): [True: 0, False: 17]
  ------------------
  464|      0|        pj_scan_syntax_err(scanner);
  465|      0|        return 0;
  466|      0|    }
  467|       |
  468|     17|    chr = *s;
  469|       |
  470|     17|    ++s;
  471|     17|    scanner->curptr = s;
  472|     17|    if (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_PROBABLY_SPACE(*s) &&
  ------------------
  |  |   33|     34|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 16, False: 1]
  |  |  ------------------
  ------------------
                  if (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_PROBABLY_SPACE(*s) &&
  ------------------
  |  |   32|     33|#define PJ_SCAN_IS_PROBABLY_SPACE(c)    ((c) <= 32)
  |  |  ------------------
  |  |  |  Branch (32:41): [True: 13, False: 3]
  |  |  ------------------
  ------------------
  473|     17|        scanner->skip_ws)
  ------------------
  |  Branch (473:9): [True: 0, False: 13]
  ------------------
  474|      0|    {
  475|      0|        pj_scan_skip_whitespace(scanner);
  476|      0|    }
  477|     17|    return chr;
  478|     17|}
pj_scan_get_until_ch:
  547|    257|{
  548|    257|    register char *s = scanner->curptr;
  549|       |
  550|    257|    if (s >= scanner->end) {
  ------------------
  |  Branch (550:9): [True: 9, False: 248]
  ------------------
  551|      9|        pj_scan_syntax_err(scanner);
  552|      9|        return;
  553|      9|    }
  554|       |
  555|  13.2k|    while (PJ_SCAN_CHECK_EOF(s) && *s != until_char) {
  ------------------
  |  |   33|  26.5k|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 13.1k, False: 106]
  |  |  ------------------
  ------------------
  |  Branch (555:36): [True: 13.0k, False: 142]
  ------------------
  556|  13.0k|        ++s;
  557|  13.0k|    }
  558|       |
  559|    248|    pj_strset3(out, scanner->curptr, s);
  560|       |
  561|    248|    scanner->curptr = s;
  562|       |
  563|    248|    if (!pj_scan_is_eof(scanner) && PJ_SCAN_IS_PROBABLY_SPACE(*s) &&
  ------------------
  |  |   32|    390|#define PJ_SCAN_IS_PROBABLY_SPACE(c)    ((c) <= 32)
  |  |  ------------------
  |  |  |  Branch (32:41): [True: 0, False: 142]
  |  |  ------------------
  ------------------
  |  Branch (563:9): [True: 142, False: 106]
  ------------------
  564|    248|        scanner->skip_ws)
  ------------------
  |  Branch (564:9): [True: 0, False: 0]
  ------------------
  565|      0|    {
  566|      0|        pj_scan_skip_whitespace(scanner);
  567|      0|    }
  568|    248|}
pj_scan_get_until_chr:
  573|    108|{
  574|    108|    register char *s = scanner->curptr;
  575|    108|    pj_size_t speclen;
  576|       |
  577|    108|    if (s >= scanner->end) {
  ------------------
  |  Branch (577:9): [True: 12, False: 96]
  ------------------
  578|     12|        pj_scan_syntax_err(scanner);
  579|     12|        return;
  580|     12|    }
  581|       |
  582|     96|    speclen = strlen(until_spec);
  583|  6.49k|    while (PJ_SCAN_CHECK_EOF(s) && !memchr(until_spec, *s, speclen)) {
  ------------------
  |  |   33|  12.9k|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 6.46k, False: 38]
  |  |  ------------------
  ------------------
  |  Branch (583:36): [True: 6.40k, False: 58]
  ------------------
  584|  6.40k|        ++s;
  585|  6.40k|    }
  586|       |
  587|     96|    pj_strset3(out, scanner->curptr, s);
  588|       |
  589|     96|    scanner->curptr = s;
  590|       |
  591|     96|    if (!pj_scan_is_eof(scanner) && PJ_SCAN_IS_PROBABLY_SPACE(*s) &&
  ------------------
  |  |   32|    154|#define PJ_SCAN_IS_PROBABLY_SPACE(c)    ((c) <= 32)
  |  |  ------------------
  |  |  |  Branch (32:41): [True: 0, False: 58]
  |  |  ------------------
  ------------------
  |  Branch (591:9): [True: 58, False: 38]
  ------------------
  592|     96|        scanner->skip_ws)
  ------------------
  |  Branch (592:9): [True: 0, False: 0]
  ------------------
  593|      0|    {
  594|      0|        pj_scan_skip_whitespace(scanner);
  595|      0|    }
  596|     96|}
pj_scan_advance_n:
  600|    130|{
  601|    130|    if (scanner->curptr + N > scanner->end) {
  ------------------
  |  Branch (601:9): [True: 0, False: 130]
  ------------------
  602|      0|        pj_scan_syntax_err(scanner);
  603|      0|        return;
  604|      0|    }
  605|       |
  606|    130|    scanner->curptr += N;
  607|       |
  608|    130|    if (!pj_scan_is_eof(scanner) && 
  ------------------
  |  Branch (608:9): [True: 119, False: 11]
  ------------------
  609|    130|        PJ_SCAN_IS_PROBABLY_SPACE(*scanner->curptr) && skip_ws)
  ------------------
  |  |   32|    249|#define PJ_SCAN_IS_PROBABLY_SPACE(c)    ((c) <= 32)
  |  |  ------------------
  |  |  |  Branch (32:41): [True: 16, False: 103]
  |  |  ------------------
  ------------------
  |  Branch (609:56): [True: 0, False: 16]
  ------------------
  610|      0|    {
  611|      0|        pj_scan_skip_whitespace(scanner);
  612|      0|    }
  613|    130|}
pj_scan_strcmp:
  617|    109|{
  618|    109|    if (scanner->curptr + len > scanner->end) {
  ------------------
  |  Branch (618:9): [True: 1, False: 108]
  ------------------
  619|      1|        pj_scan_syntax_err(scanner);
  620|      1|        return -1;
  621|      1|    }
  622|    108|    return strncmp(scanner->curptr, s, len);
  623|    109|}
scanner.c:pj_scan_syntax_err:
   45|     22|{
   46|     22|    (*scanner->callback)(scanner);
   47|     22|}

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

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

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

pj_pool_alloc_from_block:
   41|    436|{
   42|       |    /* The operation below is valid for size==0. 
   43|       |     * When size==0, the function will return the pointer to the pool
   44|       |     * memory address, but no memory will be allocated.
   45|       |     */
   46|    436|    if (size & (PJ_POOL_ALIGNMENT-1)) {
  ------------------
  |  |  182|    436|#define PJ_POOL_ALIGNMENT 8
  ------------------
  |  Branch (46:9): [True: 0, False: 436]
  ------------------
   47|      0|        size = (size + PJ_POOL_ALIGNMENT) & ~(PJ_POOL_ALIGNMENT-1);
  ------------------
  |  |  182|      0|#define PJ_POOL_ALIGNMENT 8
  ------------------
                      size = (size + PJ_POOL_ALIGNMENT) & ~(PJ_POOL_ALIGNMENT-1);
  ------------------
  |  |  182|      0|#define PJ_POOL_ALIGNMENT 8
  ------------------
   48|      0|    }
   49|    436|    if ((pj_size_t)(block->end - block->cur) >= size) {
  ------------------
  |  Branch (49:9): [True: 436, False: 0]
  ------------------
   50|    436|        void *ptr = block->cur;
   51|    436|        block->cur += size;
   52|    436|        return ptr;
   53|    436|    }
   54|      0|    return NULL;
   55|    436|}
pj_pool_alloc:
   58|    436|{
   59|    436|    void *ptr = pj_pool_alloc_from_block(pool->block_list.next, size);
   60|    436|    if (!ptr)
  ------------------
  |  Branch (60:9): [True: 0, False: 436]
  ------------------
   61|      0|        ptr = pj_pool_allocate_find(pool, size);
   62|    436|    return ptr;
   63|    436|}

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

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|     79|{
  106|     79|    dst->ptr = src->ptr;
  107|     79|    dst->slen = src->slen;
  108|     79|    return dst;
  109|     79|}
pj_stricmp:
  236|    350|{
  237|    350|    pj_assert(str1->slen >= 0);
  ------------------
  |  |   48|    350|#   define pj_assert(expr)   assert(expr)
  ------------------
  238|    350|    pj_assert(str2->slen >= 0);
  ------------------
  |  |   48|    350|#   define pj_assert(expr)   assert(expr)
  ------------------
  239|       |
  240|    350|    if (str1->slen <= 0) {
  ------------------
  |  Branch (240:9): [True: 2, False: 348]
  ------------------
  241|      2|        return str2->slen<=0 ? 0 : -1;
  ------------------
  |  Branch (241:16): [True: 0, False: 2]
  ------------------
  242|    348|    } else if (str2->slen <= 0) {
  ------------------
  |  Branch (242:16): [True: 0, False: 348]
  ------------------
  243|      0|        return 1;
  244|    348|    } else {
  245|    348|        pj_size_t min = (str1->slen < str2->slen)? str1->slen : str2->slen;
  ------------------
  |  Branch (245:25): [True: 21, False: 327]
  ------------------
  246|    348|        int res = pj_ansi_strnicmp(str1->ptr, str2->ptr, min);
  ------------------
  |  |   96|    348|#define pj_ansi_strnicmp        strncasecmp
  ------------------
  247|    348|        if (res == 0) {
  ------------------
  |  Branch (247:13): [True: 205, False: 143]
  ------------------
  248|    205|            return (str1->slen < str2->slen) ? -1 :
  ------------------
  |  Branch (248:20): [True: 2, False: 203]
  ------------------
  249|    205|                    (str1->slen == str2->slen ? 0 : 1);
  ------------------
  |  Branch (249:22): [True: 148, False: 55]
  ------------------
  250|    205|        } else {
  251|    143|            return res;
  252|    143|        }
  253|    348|    }
  254|    350|}
pj_stricmp2:
  328|    350|{
  329|    350|    pj_str_t copy2;
  330|       |
  331|    350|    if (str2) {
  ------------------
  |  Branch (331:9): [True: 350, False: 0]
  ------------------
  332|    350|        copy2.ptr = (char*)str2;
  333|    350|        copy2.slen = pj_ansi_strlen(str2);
  ------------------
  |  |   69|    350|#define pj_ansi_strlen          strlen
  ------------------
  334|    350|    } else {
  335|      0|        copy2.ptr = NULL;
  336|      0|        copy2.slen = 0;
  337|      0|    }
  338|       |
  339|    350|    return pj_stricmp(str1, &copy2);
  340|    350|}

pj_throw_exception_:
   41|    143|{
   42|    143|    struct pj_exception_state_t *handler;
   43|       |
   44|    143|    handler = (struct pj_exception_state_t*) 
   45|    143|              pj_thread_local_get(thread_local_id);
   46|    143|    if (handler == NULL) {
  ------------------
  |  Branch (46:9): [True: 0, False: 143]
  ------------------
   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_get_level()) { \
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded - Ignored]
  |  |  ------------------
  ------------------
   48|      0|                   pj_exception_id_name(exception_id)));
   49|      0|        pj_assert(handler != NULL);
  ------------------
  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  ------------------
   50|       |        /* This will crash the system! */
   51|      0|    }
   52|    143|    pj_pop_exception_handler_(handler);
   53|    143|    pj_longjmp(handler->state, exception_id);
  ------------------
  |  |   34|    143|#    define pj_longjmp(buf,d)   longjmp(buf,d)
  ------------------
   54|    143|}
pj_push_exception_handler_:
   75|    218|{
   76|    218|    struct pj_exception_state_t *parent_handler = NULL;
   77|       |
   78|    218|    if (thread_local_id == -1) {
  ------------------
  |  Branch (78:9): [True: 1, False: 217]
  ------------------
   79|      1|        pj_thread_local_alloc(&thread_local_id);
   80|      1|        pj_assert(thread_local_id != -1);
  ------------------
  |  |   48|      1|#   define pj_assert(expr)   assert(expr)
  ------------------
   81|      1|        pj_atexit(&exception_cleanup);
   82|      1|    }
   83|    218|    parent_handler = (struct pj_exception_state_t *)
   84|    218|                      pj_thread_local_get(thread_local_id);
   85|    218|    rec->prev = parent_handler;
   86|    218|    pj_thread_local_set(thread_local_id, rec);
   87|    218|}
pj_pop_exception_handler_:
   90|    218|{
   91|    218|    struct pj_exception_state_t *handler;
   92|       |
   93|    218|    handler = (struct pj_exception_state_t *)
   94|    218|              pj_thread_local_get(thread_local_id);
   95|    218|    if (handler && handler==rec) {
  ------------------
  |  Branch (95:9): [True: 218, False: 0]
  |  Branch (95:20): [True: 218, False: 0]
  ------------------
   96|    218|        pj_thread_local_set(thread_local_id, handler->prev);
   97|    218|    }
   98|    218|}
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) {
  ------------------
  |  |  895|      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;
  ------------------
  |  |  363|      0|#define PJ_ETOOMANY         (PJ_ERRNO_START_STATUS + 10)/* 70010 */
  |  |  ------------------
  |  |  |  |  456|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  444|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  450|      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);
  ------------------
  |  |   48|      1|#   define pj_assert(expr)   assert(expr)
  ------------------
   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|    218|{
   88|    218|    return create_mutex_lock(pool, name, PJ_MUTEX_SIMPLE, lock);
   89|    218|}
pj_lock_create_null_mutex:
  120|    218|{
  121|    218|    PJ_UNUSED_ARG(name);
  ------------------
  |  | 1433|    218|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  122|    218|    PJ_UNUSED_ARG(pool);
  ------------------
  |  | 1433|    218|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  123|       |
  124|    218|    PJ_ASSERT_RETURN(lock, PJ_EINVAL);
  ------------------
  |  |   59|    218|            do { \
  |  |   60|    218|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:21): [True: 0, False: 218]
  |  |  ------------------
  |  |   61|    218|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
  125|       |
  126|    218|    *lock = &null_lock_template;
  127|    218|    return PJ_SUCCESS;
  128|    218|}
pj_lock_destroy:
  195|    218|{
  196|    218|    PJ_ASSERT_RETURN(lock != NULL, PJ_EINVAL);
  ------------------
  |  |   59|    218|            do { \
  |  |   60|    218|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:21): [True: 0, False: 218]
  |  |  ------------------
  |  |   61|    218|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
  197|    218|    return (*lock->destroy)(lock->lock_object);
  198|    218|}
lock.c:create_mutex_lock:
   62|    218|{
   63|    218|    pj_lock_t *p_lock;
   64|    218|    pj_mutex_t *mutex;
   65|    218|    pj_status_t rc;
   66|       |
   67|    218|    PJ_ASSERT_RETURN(pool && lock, PJ_EINVAL);
  ------------------
  |  |   59|    218|            do { \
  |  |   60|    436|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:23): [True: 218, False: 0]
  |  |  |  Branch (60:23): [True: 218, False: 0]
  |  |  ------------------
  |  |   61|    218|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
   68|       |
   69|    218|    p_lock = PJ_POOL_ALLOC_T(pool, pj_lock_t);
  ------------------
  |  |  506|    218|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
   70|    218|    if (!p_lock)
  ------------------
  |  Branch (70:9): [True: 0, False: 218]
  ------------------
   71|      0|        return PJ_ENOMEM;
  ------------------
  |  |  348|      0|#define PJ_ENOMEM           (PJ_ERRNO_START_STATUS + 7) /* 70007 */
  |  |  ------------------
  |  |  |  |  456|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  444|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  450|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   72|       |
   73|    218|    pj_memcpy(p_lock, &mutex_lock_template, sizeof(pj_lock_t));
   74|    218|    rc = pj_mutex_create(pool, name, type, &mutex);
   75|    218|    if (rc != PJ_SUCCESS)
  ------------------
  |  Branch (75:9): [True: 0, False: 218]
  ------------------
   76|      0|        return rc;
   77|       |
   78|    218|    p_lock->lock_object = mutex;
   79|    218|    *lock = p_lock;
   80|    218|    return PJ_SUCCESS;
   81|    218|}

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|    218|{
  253|    218|    pj_log_max_level = level;
  254|    218|}
pj_log_get_level:
  258|    662|{
  259|    662|    return pj_log_max_level;
  260|    662|}
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:
  544|      1|{
  545|      1|    va_list arg;
  546|      1|    va_start(arg, format);
  547|      1|    pj_log(obj, 4, format, arg);
  548|      1|    va_end(arg);
  549|      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);
  ------------------
  |  | 1433|      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:
  175|    218|{
  176|    218|    char dummy_guid[PJ_GUID_MAX_LENGTH];
  177|    218|    pj_str_t guid;
  178|    218|    pj_status_t rc;
  179|       |
  180|       |    /* Check if PJLIB have been initialized */
  181|    218|    if (initialized) {
  ------------------
  |  Branch (181:9): [True: 217, False: 1]
  ------------------
  182|    217|        ++initialized;
  183|    217|        return PJ_SUCCESS;
  184|    217|    }
  185|       |
  186|       |    /* Init logging */
  187|      1|    pj_log_init();
  188|       |
  189|      1|#if PJ_HAS_THREADS
  190|       |    /* Init this thread's TLS. */
  191|      1|    if ((rc=pj_thread_init()) != 0) {
  ------------------
  |  Branch (191:9): [True: 0, False: 1]
  ------------------
  192|      0|        return rc;
  193|      0|    }
  194|       |
  195|       |    /* Critical section. */
  196|      1|    if ((rc=init_mutex(&critical_section, "critsec", PJ_MUTEX_RECURSE)) != 0)
  ------------------
  |  Branch (196:9): [True: 0, False: 1]
  ------------------
  197|      0|        return rc;
  198|       |
  199|      1|#endif
  200|       |
  201|       |    /* Initialize exception ID for the pool.
  202|       |     * Must do so after critical section is configured.
  203|       |     */
  204|      1|    rc = pj_exception_id_alloc("PJLIB/No memory", &PJ_NO_MEMORY_EXCEPTION);
  205|      1|    if (rc != PJ_SUCCESS)
  ------------------
  |  Branch (205:9): [True: 0, False: 1]
  ------------------
  206|      0|        return rc;
  207|       |
  208|       |    /* Init random seed. */
  209|       |    /* Or probably not. Let application in charge of this */
  210|       |    /* pj_srand( clock() ); */
  211|       |
  212|       |    /* Startup GUID. */
  213|      1|    guid.ptr = dummy_guid;
  214|      1|    pj_generate_unique_string( &guid );
  215|       |
  216|       |    /* Startup timestamp */
  217|      1|#if defined(PJ_HAS_HIGH_RES_TIMER) && PJ_HAS_HIGH_RES_TIMER != 0
  218|      1|    {
  219|      1|        pj_timestamp dummy_ts;
  220|      1|        if ((rc=pj_get_timestamp(&dummy_ts)) != 0) {
  ------------------
  |  Branch (220:13): [True: 0, False: 1]
  ------------------
  221|      0|            return rc;
  222|      0|        }
  223|      1|    }
  224|      1|#endif
  225|       |
  226|       |    /* Flag PJLIB as initialized */
  227|      1|    ++initialized;
  228|      1|    pj_assert(initialized == 1);
  ------------------
  |  |   48|      1|#   define pj_assert(expr)   assert(expr)
  ------------------
  229|       |
  230|      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_get_level()) { \
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 1, False: 0]
  |  |  ------------------
  |  |  108|      1|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      1|                                    } \
  |  |  110|      1|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded - Ignored]
  |  |  ------------------
  ------------------
  231|      1|              PJ_VERSION));
  232|       |
  233|      1|    return PJ_SUCCESS;
  234|      1|}
pj_atexit:
  240|      3|{
  241|      3|    if (atexit_count >= PJ_ARRAY_SIZE(atexit_func))
  ------------------
  |  |  294|      3|#define PJ_ARRAY_SIZE(a)    (sizeof(a)/sizeof(a[0]))
  ------------------
  |  Branch (241:9): [True: 0, False: 3]
  ------------------
  242|      0|        return PJ_ETOOMANY;
  ------------------
  |  |  363|      0|#define PJ_ETOOMANY         (PJ_ERRNO_START_STATUS + 10)/* 70010 */
  |  |  ------------------
  |  |  |  |  456|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  444|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  450|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  243|       |
  244|      3|    atexit_func[atexit_count++] = func;
  245|      3|    return PJ_SUCCESS;
  246|      3|}
pj_thread_register:
  547|      1|{
  548|      1|#if PJ_HAS_THREADS
  549|      1|    char stack_ptr;
  550|      1|    pj_status_t rc;
  551|      1|    pj_thread_t *thread = (pj_thread_t *)desc;
  552|      1|    pj_str_t thread_name = pj_str((char*)cstr_thread_name);
  553|       |
  554|       |    /* Size sanity check. */
  555|      1|    if (sizeof(pj_thread_desc) < sizeof(pj_thread_t)) {
  ------------------
  |  Branch (555:9): [Folded - Ignored]
  ------------------
  556|      0|        pj_assert(!"Not enough pj_thread_desc size!");
  ------------------
  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  ------------------
  557|      0|        return PJ_EBUG;
  ------------------
  |  |  353|      0|#define PJ_EBUG             (PJ_ERRNO_START_STATUS + 8) /* 70008 */
  |  |  ------------------
  |  |  |  |  456|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  444|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  450|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  558|      0|    }
  559|       |
  560|       |    /* Warn if this thread has been registered before */
  561|      1|    if (pj_thread_local_get (thread_tls_id) != 0) {
  ------------------
  |  Branch (561:9): [True: 0, False: 1]
  ------------------
  562|       |        // 2006-02-26 bennylp:
  563|       |        //  This wouldn't work in all cases!.
  564|       |        //  If thread is created by external module (e.g. sound thread),
  565|       |        //  thread may be reused while the pool used for the thread descriptor
  566|       |        //  has been deleted by application.
  567|       |        //*thread_ptr = (pj_thread_t*)pj_thread_local_get (thread_tls_id);
  568|       |        //return PJ_SUCCESS;
  569|      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_get_level()) { \
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded - Ignored]
  |  |  ------------------
  ------------------
  570|      0|                             "thread"));
  571|      0|    }
  572|       |
  573|       |    /* On the other hand, also warn if the thread descriptor buffer seem to
  574|       |     * have been used to register other threads.
  575|       |     */
  576|      1|    pj_assert(thread->signature1 != SIGNATURE1 ||
  ------------------
  |  |   48|      1|#   define pj_assert(expr)   assert(expr)
  ------------------
  577|      1|              thread->signature2 != SIGNATURE2 ||
  578|      1|              (thread->thread == pthread_self()));
  579|       |
  580|       |    /* Initialize and set the thread entry. */
  581|      1|    pj_bzero(desc, sizeof(struct pj_thread_t));
  582|      1|    thread->thread = pthread_self();
  583|      1|    thread->signature1 = SIGNATURE1;
  ------------------
  |  |   60|      1|#define SIGNATURE1  0xDEAFBEEF
  ------------------
  584|      1|    thread->signature2 = SIGNATURE2;
  ------------------
  |  |   61|      1|#define SIGNATURE2  0xDEADC0DE
  ------------------
  585|       |
  586|      1|    if(cstr_thread_name && pj_strlen(&thread_name) < sizeof(thread->obj_name)-1)
  ------------------
  |  Branch (586:8): [True: 1, False: 0]
  |  Branch (586:28): [True: 1, False: 0]
  ------------------
  587|      1|        pj_ansi_snprintf(thread->obj_name, sizeof(thread->obj_name),
  ------------------
  |  |  114|      1|#define pj_ansi_snprintf        snprintf
  ------------------
  588|      1|                         cstr_thread_name, thread->thread);
  589|      0|    else
  590|      0|        pj_ansi_snprintf(thread->obj_name, sizeof(thread->obj_name),
  ------------------
  |  |  114|      0|#define pj_ansi_snprintf        snprintf
  ------------------
  591|      0|                         "thr%p", (void*)thread->thread);
  592|       |
  593|      1|    rc = pj_thread_local_set(thread_tls_id, thread);
  594|      1|    if (rc != PJ_SUCCESS) {
  ------------------
  |  Branch (594:9): [True: 0, False: 1]
  ------------------
  595|      0|        pj_bzero(desc, sizeof(struct pj_thread_t));
  596|      0|        return rc;
  597|      0|    }
  598|       |
  599|       |#if defined(PJ_OS_HAS_CHECK_STACK) && PJ_OS_HAS_CHECK_STACK!=0
  600|       |    thread->stk_start = &stack_ptr;
  601|       |    thread->stk_size = 0xFFFFFFFFUL;
  602|       |    thread->stk_max_usage = 0;
  603|       |#else
  604|      1|    PJ_UNUSED_ARG(stack_ptr);
  ------------------
  |  | 1433|      1|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  605|      1|#endif
  606|       |
  607|      1|    *ptr_thread = thread;
  608|      1|    return PJ_SUCCESS;
  609|       |#else
  610|       |    pj_thread_t *thread = (pj_thread_t*)desc;
  611|       |    *ptr_thread = thread;
  612|       |    return PJ_SUCCESS;
  613|       |#endif
  614|      1|}
pj_thread_init:
  620|      1|{
  621|      1|#if PJ_HAS_THREADS
  622|      1|    pj_status_t rc;
  623|      1|    pj_thread_t *dummy;
  624|       |
  625|      1|    rc = pj_thread_local_alloc(&thread_tls_id );
  626|      1|    if (rc != PJ_SUCCESS) {
  ------------------
  |  Branch (626:9): [True: 0, False: 1]
  ------------------
  627|      0|        return rc;
  628|      0|    }
  629|      1|    return pj_thread_register("thr%p", main_thread_desc, &dummy);
  630|       |#else
  631|       |    PJ_LOG(2,(THIS_FILE, "Thread init error. Threading is not enabled!"));
  632|       |    return PJ_EINVALIDOP;
  633|       |#endif
  634|      1|}
pj_thread_this:
  852|      5|{
  853|      5|#if PJ_HAS_THREADS
  854|      5|    pj_thread_t *rec = (pj_thread_t*)pj_thread_local_get(thread_tls_id);
  855|       |
  856|      5|    if (rec == NULL) {
  ------------------
  |  Branch (856:9): [True: 0, False: 5]
  ------------------
  857|      0|        pj_assert(!"Calling pjlib from unknown/external thread. You must "
  ------------------
  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  ------------------
  858|      0|                   "register external threads with pj_thread_register() "
  859|      0|                   "before calling any pjlib functions.");
  860|      0|    }
  861|       |
  862|       |    /*
  863|       |     * MUST NOT check stack because this function is called
  864|       |     * by PJ_CHECK_STACK() itself!!!
  865|       |     *
  866|       |     */
  867|       |
  868|      5|    return rec;
  869|       |#else
  870|       |    pj_assert(!"Threading is not enabled!");
  871|       |    return NULL;
  872|       |#endif
  873|      5|}
pj_thread_local_alloc:
 1199|      5|{
 1200|      5|#if PJ_HAS_THREADS
 1201|      5|    pthread_key_t key;
 1202|      5|    int rc;
 1203|       |
 1204|      5|    PJ_ASSERT_RETURN(p_index != NULL, PJ_EINVAL);
  ------------------
  |  |   59|      5|            do { \
  |  |   60|      5|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:21): [True: 0, False: 5]
  |  |  ------------------
  |  |   61|      5|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1205|       |
 1206|      5|    pj_assert( sizeof(pthread_key_t) <= sizeof(long));
  ------------------
  |  |   48|      5|#   define pj_assert(expr)   assert(expr)
  ------------------
 1207|      5|    if ((rc=pthread_key_create(&key, NULL)) != 0)
  ------------------
  |  Branch (1207:9): [True: 0, False: 5]
  ------------------
 1208|      0|        return PJ_RETURN_OS_ERROR(rc);
  ------------------
  |  |  259|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (259:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  260|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  274|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  463|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  456|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  444|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  450|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (274:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1209|       |
 1210|      5|    *p_index = key;
 1211|      5|    return PJ_SUCCESS;
 1212|       |#else
 1213|       |    int i;
 1214|       |    for (i=0; i<MAX_THREADS; ++i) {
 1215|       |        if (tls_flag[i] == 0)
 1216|       |            break;
 1217|       |    }
 1218|       |    if (i == MAX_THREADS)
 1219|       |        return PJ_ETOOMANY;
 1220|       |
 1221|       |    tls_flag[i] = 1;
 1222|       |    tls[i] = NULL;
 1223|       |
 1224|       |    *p_index = i;
 1225|       |    return PJ_SUCCESS;
 1226|       |#endif
 1227|      5|}
pj_thread_local_set:
 1246|    875|{
 1247|       |    //Can't check stack because this function is called in the
 1248|       |    //beginning before main thread is initialized.
 1249|       |    //PJ_CHECK_STACK();
 1250|    875|#if PJ_HAS_THREADS
 1251|    875|    int rc=pthread_setspecific(index, value);
 1252|    875|    return rc==0 ? PJ_SUCCESS : PJ_RETURN_OS_ERROR(rc);
  ------------------
  |  |  259|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (259:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  260|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  274|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  463|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  456|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  444|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  450|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (274:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1252:12): [True: 875, False: 0]
  ------------------
 1253|       |#else
 1254|       |    pj_assert(index >= 0 && index < MAX_THREADS);
 1255|       |    tls[index] = value;
 1256|       |    return PJ_SUCCESS;
 1257|       |#endif
 1258|    875|}
pj_thread_local_get:
 1261|    805|{
 1262|       |    //Can't check stack because this function is called
 1263|       |    //by PJ_CHECK_STACK() itself!!!
 1264|       |    //PJ_CHECK_STACK();
 1265|    805|#if PJ_HAS_THREADS
 1266|    805|    return pthread_getspecific(index);
 1267|       |#else
 1268|       |    pj_assert(index >= 0 && index < MAX_THREADS);
 1269|       |    return tls[index];
 1270|       |#endif
 1271|    805|}
pj_enter_critical_section:
 1275|      2|{
 1276|      2|#if PJ_HAS_THREADS
 1277|      2|    pj_mutex_lock(&critical_section);
 1278|      2|#endif
 1279|      2|}
pj_leave_critical_section:
 1282|      2|{
 1283|      2|#if PJ_HAS_THREADS
 1284|      2|    pj_mutex_unlock(&critical_section);
 1285|      2|#endif
 1286|      2|}
pj_mutex_create:
 1386|    218|{
 1387|    218|#if PJ_HAS_THREADS
 1388|    218|    pj_status_t rc;
 1389|    218|    pj_mutex_t *mutex;
 1390|       |
 1391|    218|    PJ_ASSERT_RETURN(pool && ptr_mutex, PJ_EINVAL);
  ------------------
  |  |   59|    218|            do { \
  |  |   60|    436|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:23): [True: 218, False: 0]
  |  |  |  Branch (60:23): [True: 218, False: 0]
  |  |  ------------------
  |  |   61|    218|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1392|       |
 1393|    218|    mutex = PJ_POOL_ALLOC_T(pool, pj_mutex_t);
  ------------------
  |  |  506|    218|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
 1394|    218|    PJ_ASSERT_RETURN(mutex, PJ_ENOMEM);
  ------------------
  |  |   59|    218|            do { \
  |  |   60|    218|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:21): [True: 0, False: 218]
  |  |  ------------------
  |  |   61|    218|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1395|       |
 1396|    218|    if ((rc=init_mutex(mutex, name, type)) != PJ_SUCCESS)
  ------------------
  |  Branch (1396:9): [True: 0, False: 218]
  ------------------
 1397|      0|        return rc;
 1398|       |
 1399|    218|    *ptr_mutex = mutex;
 1400|    218|    return PJ_SUCCESS;
 1401|       |#else /* PJ_HAS_THREADS */
 1402|       |    *ptr_mutex = (pj_mutex_t*)1;
 1403|       |    return PJ_SUCCESS;
 1404|       |#endif
 1405|    218|}
pj_mutex_lock:
 1431|      2|{
 1432|      2|#if PJ_HAS_THREADS
 1433|      2|    pj_status_t status;
 1434|       |
 1435|      2|    PJ_CHECK_STACK();
 1436|      2|    PJ_ASSERT_RETURN(mutex, PJ_EINVAL);
  ------------------
  |  |   59|      2|            do { \
  |  |   60|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   61|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1437|       |
 1438|      2|#if PJ_DEBUG
 1439|      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_get_level()) { \
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, False: 2]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|      2|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1440|      2|                                pj_thread_this()->obj_name,
 1441|      2|                                mutex->owner_name));
 1442|       |#else
 1443|       |    PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s is waiting",
 1444|       |                                pj_thread_this()->obj_name));
 1445|       |#endif
 1446|       |
 1447|      2|    status = pthread_mutex_lock( &mutex->mutex );
 1448|       |
 1449|       |
 1450|      2|#if PJ_DEBUG
 1451|      2|    if (status == PJ_SUCCESS) {
  ------------------
  |  Branch (1451:9): [True: 2, False: 0]
  ------------------
 1452|      2|        mutex->owner = pj_thread_this();
 1453|      2|        pj_ansi_strxcpy(mutex->owner_name, mutex->owner->obj_name,
 1454|      2|                        sizeof(mutex->owner_name));
 1455|      2|        ++mutex->nesting_level;
 1456|      2|    }
 1457|       |
 1458|      2|    PJ_LOG(6,(mutex->obj_name,
  ------------------
  |  |  106|      2|#define PJ_LOG(level,arg)       do { \
  |  |  107|      2|                                    if (level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, False: 2]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|      2|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1459|      2|              (status==0 ?
 1460|      2|                "Mutex acquired by thread %s (level=%d)" :
 1461|      2|                "Mutex acquisition FAILED by %s (level=%d)"),
 1462|      2|              pj_thread_this()->obj_name,
 1463|      2|              mutex->nesting_level));
 1464|       |#else
 1465|       |    PJ_LOG(6,(mutex->obj_name,
 1466|       |              (status==0 ? "Mutex acquired by thread %s" : "FAILED by %s"),
 1467|       |              pj_thread_this()->obj_name));
 1468|       |#endif
 1469|       |
 1470|      2|    if (status == 0)
  ------------------
  |  Branch (1470:9): [True: 2, False: 0]
  ------------------
 1471|      2|        return PJ_SUCCESS;
 1472|      0|    else
 1473|      0|        return PJ_RETURN_OS_ERROR(status);
  ------------------
  |  |  259|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (259:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  260|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  274|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  463|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  456|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  444|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  450|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (274:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1474|       |#else   /* PJ_HAS_THREADS */
 1475|       |    pj_assert( mutex == (pj_mutex_t*)1 );
 1476|       |    return PJ_SUCCESS;
 1477|       |#endif
 1478|      2|}
pj_mutex_unlock:
 1484|      2|{
 1485|      2|#if PJ_HAS_THREADS
 1486|      2|    pj_status_t status;
 1487|       |
 1488|      2|    PJ_CHECK_STACK();
 1489|      2|    PJ_ASSERT_RETURN(mutex, PJ_EINVAL);
  ------------------
  |  |   59|      2|            do { \
  |  |   60|      2|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:21): [True: 0, False: 2]
  |  |  ------------------
  |  |   61|      2|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1490|       |
 1491|      2|#if PJ_DEBUG
 1492|      2|    pj_assert(mutex->owner == pj_thread_this());
  ------------------
  |  |   48|      2|#   define pj_assert(expr)   assert(expr)
  ------------------
 1493|      2|    if (--mutex->nesting_level == 0) {
  ------------------
  |  Branch (1493:9): [True: 2, False: 0]
  ------------------
 1494|      2|        mutex->owner = NULL;
 1495|      2|        mutex->owner_name[0] = '\0';
 1496|      2|    }
 1497|       |
 1498|      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_get_level()) { \
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, False: 2]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|      2|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1499|      2|                                pj_thread_this()->obj_name,
 1500|      2|                                mutex->nesting_level));
 1501|       |#else
 1502|       |    PJ_LOG(6,(mutex->obj_name, "Mutex released by thread %s",
 1503|       |                                pj_thread_this()->obj_name));
 1504|       |#endif
 1505|       |
 1506|      2|    status = pthread_mutex_unlock( &mutex->mutex );
 1507|      2|    if (status == 0)
  ------------------
  |  Branch (1507:9): [True: 2, False: 0]
  ------------------
 1508|      2|        return PJ_SUCCESS;
 1509|      0|    else
 1510|      0|        return PJ_RETURN_OS_ERROR(status);
  ------------------
  |  |  259|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (259:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  260|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  274|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  463|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  456|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  444|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  450|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (274:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1511|       |
 1512|       |#else /* PJ_HAS_THREADS */
 1513|       |    pj_assert( mutex == (pj_mutex_t*)1 );
 1514|       |    return PJ_SUCCESS;
 1515|       |#endif
 1516|      2|}
pj_mutex_destroy:
 1567|    218|{
 1568|    218|    enum { RETRY = 4 };
 1569|    218|    int status = 0;
 1570|    218|    unsigned retry;
 1571|       |
 1572|    218|    PJ_CHECK_STACK();
 1573|    218|    PJ_ASSERT_RETURN(mutex, PJ_EINVAL);
  ------------------
  |  |   59|    218|            do { \
  |  |   60|    218|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:21): [True: 0, False: 218]
  |  |  ------------------
  |  |   61|    218|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1574|       |
 1575|    218|#if PJ_HAS_THREADS
 1576|    218|    PJ_LOG(6,(mutex->obj_name, "Mutex destroyed by thread %s",
  ------------------
  |  |  106|    218|#define PJ_LOG(level,arg)       do { \
  |  |  107|    218|                                    if (level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, False: 218]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|    218|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1577|    218|                               pj_thread_this()->obj_name));
 1578|       |
 1579|    218|    for (retry=0; retry<RETRY; ++retry) {
  ------------------
  |  Branch (1579:19): [True: 218, False: 0]
  ------------------
 1580|    218|        status = pthread_mutex_destroy( &mutex->mutex );
 1581|    218|        if (status == PJ_SUCCESS)
  ------------------
  |  Branch (1581:13): [True: 218, False: 0]
  ------------------
 1582|    218|            break;
 1583|      0|        else if (retry<RETRY-1 && status == EBUSY)
  ------------------
  |  Branch (1583:18): [True: 0, False: 0]
  |  Branch (1583:35): [True: 0, False: 0]
  ------------------
 1584|      0|            pthread_mutex_unlock(&mutex->mutex);
 1585|    218|    }
 1586|       |
 1587|    218|    if (status == 0)
  ------------------
  |  Branch (1587:9): [True: 218, False: 0]
  ------------------
 1588|    218|        return PJ_SUCCESS;
 1589|      0|    else {
 1590|      0|        return PJ_RETURN_OS_ERROR(status);
  ------------------
  |  |  259|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (259:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  260|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  274|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  463|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  456|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  444|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  450|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (274:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1591|      0|    }
 1592|       |#else
 1593|       |    pj_assert( mutex == (pj_mutex_t*)1 );
 1594|       |    status = PJ_SUCCESS;
 1595|       |    return status;
 1596|       |#endif
 1597|    218|}
os_core_unix.c:init_mutex:
 1297|    219|{
 1298|    219|#if PJ_HAS_THREADS
 1299|    219|    pthread_mutexattr_t attr;
 1300|    219|    int rc;
 1301|       |
 1302|    219|    PJ_CHECK_STACK();
 1303|       |
 1304|    219|    rc = pthread_mutexattr_init(&attr);
 1305|    219|    if (rc != 0)
  ------------------
  |  Branch (1305:9): [True: 0, False: 219]
  ------------------
 1306|      0|        return PJ_RETURN_OS_ERROR(rc);
  ------------------
  |  |  259|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (259:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  260|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  274|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  463|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  456|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  444|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  450|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (274:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1307|       |
 1308|    219|    if (type == PJ_MUTEX_SIMPLE) {
  ------------------
  |  Branch (1308:9): [True: 218, False: 1]
  ------------------
 1309|    218|#if (defined(PJ_LINUX) && PJ_LINUX!=0) || \
 1310|    218|    defined(PJ_HAS_PTHREAD_MUTEXATTR_SETTYPE)
 1311|    218|        rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL);
 1312|       |#elif (defined(PJ_RTEMS) && PJ_RTEMS!=0) || \
 1313|       |       defined(PJ_PTHREAD_MUTEXATTR_T_HAS_RECURSIVE)
 1314|       |        /* Nothing to do, default is simple */
 1315|       |#else
 1316|       |        rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL);
 1317|       |#endif
 1318|    218|    } else {
 1319|      1|#if (defined(PJ_LINUX) && PJ_LINUX!=0) || \
 1320|      1|     defined(PJ_HAS_PTHREAD_MUTEXATTR_SETTYPE)
 1321|      1|        rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
 1322|       |#elif (defined(PJ_RTEMS) && PJ_RTEMS!=0) || \
 1323|       |       defined(PJ_PTHREAD_MUTEXATTR_T_HAS_RECURSIVE)
 1324|       |        // Phil Torre <ptorre@zetron.com>:
 1325|       |        // The RTEMS implementation of POSIX mutexes doesn't include
 1326|       |        // pthread_mutexattr_settype(), so what follows is a hack
 1327|       |        // until I get RTEMS patched to support the set/get functions.
 1328|       |        //
 1329|       |        // More info:
 1330|       |        //   newlib's pthread also lacks pthread_mutexattr_settype(),
 1331|       |        //   but it seems to have mutexattr.recursive.
 1332|       |        PJ_TODO(FIX_RTEMS_RECURSIVE_MUTEX_TYPE)
 1333|       |        attr.recursive = 1;
 1334|       |#else
 1335|       |        rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
 1336|       |#endif
 1337|      1|    }
 1338|       |
 1339|    219|    if (rc != 0) {
  ------------------
  |  Branch (1339:9): [True: 0, False: 219]
  ------------------
 1340|      0|        return PJ_RETURN_OS_ERROR(rc);
  ------------------
  |  |  259|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (259:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  260|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  274|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  463|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  456|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  444|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  450|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (274:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1341|      0|    }
 1342|       |
 1343|    219|    rc = pthread_mutex_init(&mutex->mutex, &attr);
 1344|    219|    if (rc != 0) {
  ------------------
  |  Branch (1344:9): [True: 0, False: 219]
  ------------------
 1345|      0|        return PJ_RETURN_OS_ERROR(rc);
  ------------------
  |  |  259|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (259:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  260|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  274|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  463|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  456|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  444|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  450|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (274:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1346|      0|    }
 1347|       |
 1348|    219|    rc = pthread_mutexattr_destroy(&attr);
 1349|    219|    if (rc != 0) {
  ------------------
  |  Branch (1349:9): [True: 0, False: 219]
  ------------------
 1350|      0|        pj_status_t status = PJ_RETURN_OS_ERROR(rc);
  ------------------
  |  |  259|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (259:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  260|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  274|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  463|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  456|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  444|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  450|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (274:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1351|      0|        pthread_mutex_destroy(&mutex->mutex);
 1352|      0|        return status;
 1353|      0|    }
 1354|       |
 1355|    219|#if PJ_DEBUG
 1356|       |    /* Set owner. */
 1357|    219|    mutex->nesting_level = 0;
 1358|    219|    mutex->owner = NULL;
 1359|    219|    mutex->owner_name[0] = '\0';
 1360|    219|#endif
 1361|       |
 1362|       |    /* Set name. */
 1363|    219|    if (!name) {
  ------------------
  |  Branch (1363:9): [True: 0, False: 219]
  ------------------
 1364|      0|        name = "mtx%p";
 1365|      0|    }
 1366|    219|    if (strchr(name, '%')) {
  ------------------
  |  Branch (1366:9): [True: 0, False: 219]
  ------------------
 1367|      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);
  ------------------
  |  |  299|      0|#define PJ_MAX_OBJ_NAME 32
  ------------------
 1368|    219|    } else {
 1369|    219|        pj_ansi_strxcpy(mutex->obj_name, name, PJ_MAX_OBJ_NAME);
  ------------------
  |  |  299|    219|#define PJ_MAX_OBJ_NAME 32
  ------------------
 1370|    219|    }
 1371|       |
 1372|    219|    PJ_LOG(6, (mutex->obj_name, "Mutex created"));
  ------------------
  |  |  106|    219|#define PJ_LOG(level,arg)       do { \
  |  |  107|    219|                                    if (level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, False: 219]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|    219|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1373|    219|    return PJ_SUCCESS;
 1374|       |#else /* PJ_HAS_THREADS */
 1375|       |    return PJ_SUCCESS;
 1376|       |#endif
 1377|    219|}

pj_time_decode:
   29|      1|{
   30|      1|    struct tm local_time;
   31|       |
   32|      1|    PJ_CHECK_STACK();
   33|       |
   34|      1|#if defined(PJ_HAS_LOCALTIME_R) && PJ_HAS_LOCALTIME_R != 0
   35|      1|    localtime_r((time_t*)&tv->sec, &local_time);
   36|       |#else
   37|       |    /* localtime() is NOT thread-safe. */
   38|       |    local_time = *localtime((time_t*)&tv->sec);
   39|       |#endif
   40|       |
   41|      1|    pt->year = local_time.tm_year+1900;
   42|      1|    pt->mon = local_time.tm_mon;
   43|      1|    pt->day = local_time.tm_mday;
   44|      1|    pt->hour = local_time.tm_hour;
   45|      1|    pt->min = local_time.tm_min;
   46|      1|    pt->sec = local_time.tm_sec;
   47|      1|    pt->wday = local_time.tm_wday;
   48|      1|    pt->msec = tv->msec;
   49|       |
   50|      1|    return PJ_SUCCESS;
   51|      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());
  ------------------
  |  |  259|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (259:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  260|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  274|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  463|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  456|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  444|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  450|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (274: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:
  285|      1|{
  286|      1|    struct timespec tp;
  287|       |
  288|      1|    if (clock_gettime(CLOCK_MONOTONIC, &tp) != 0) {
  ------------------
  |  Branch (288:9): [True: 0, False: 1]
  ------------------
  289|      0|        return PJ_RETURN_OS_ERROR(pj_get_native_os_error());
  ------------------
  |  |  259|      0|#   define PJ_RETURN_OS_ERROR(os_code)   (os_code ? \
  |  |  ------------------
  |  |  |  Branch (259:43): [True: 0, False: 0]
  |  |  ------------------
  |  |  260|      0|                                            PJ_STATUS_FROM_OS(os_code) : -1)
  |  |  ------------------
  |  |  |  |  274|      0|#   define PJ_STATUS_FROM_OS(e) (e == 0 ? PJ_SUCCESS : e + PJ_ERRNO_START_SYS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  463|      0|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  456|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  444|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  450|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (274:34): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  290|      0|    }
  291|       |
  292|      1|    ts->u64 = tp.tv_sec;
  293|      1|    ts->u64 *= NSEC_PER_SEC;
  ------------------
  |  |  282|      1|#define NSEC_PER_SEC    1000000000
  ------------------
  294|      1|    ts->u64 += tp.tv_nsec;
  295|       |
  296|      1|    return PJ_SUCCESS;
  297|      1|}

pj_pool_init_int:
  173|    218|{
  174|    218|    PJ_CHECK_STACK();
  175|       |
  176|    218|    pool->increment_size = increment_size;
  177|    218|    pool->callback = callback;
  178|       |
  179|    218|    if (name) {
  ------------------
  |  Branch (179:9): [True: 218, False: 0]
  ------------------
  180|    218|        if (strchr(name, '%') != NULL) {
  ------------------
  |  Branch (180:13): [True: 0, False: 218]
  ------------------
  181|      0|            pj_ansi_snprintf(pool->obj_name, sizeof(pool->obj_name), 
  ------------------
  |  |  114|      0|#define pj_ansi_snprintf        snprintf
  ------------------
  182|      0|                             name, pool);
  183|    218|        } else {
  184|    218|            pj_ansi_strxcpy(pool->obj_name, name, PJ_MAX_OBJ_NAME);
  ------------------
  |  |  299|    218|#define PJ_MAX_OBJ_NAME 32
  ------------------
  185|    218|        }
  186|    218|    } else {
  187|      0|        pool->obj_name[0] = '\0';
  188|      0|    }
  189|    218|}
pj_pool_create_int:
  198|    218|{
  199|    218|    pj_pool_t *pool;
  200|    218|    pj_pool_block *block;
  201|    218|    pj_uint8_t *buffer;
  202|       |
  203|    218|    PJ_CHECK_STACK();
  204|       |
  205|       |    /* Size must be at least sizeof(pj_pool)+sizeof(pj_pool_block) */
  206|    218|    PJ_ASSERT_RETURN(initial_size >= sizeof(pj_pool_t)+sizeof(pj_pool_block),
  ------------------
  |  |   59|    218|            do { \
  |  |   60|    218|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:21): [True: 0, False: 218]
  |  |  ------------------
  |  |   61|    218|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
  207|    218|                     NULL);
  208|       |
  209|       |    /* If callback is NULL, set calback from the policy */
  210|    218|    if (callback == NULL)
  ------------------
  |  Branch (210:9): [True: 0, False: 218]
  ------------------
  211|      0|        callback = f->policy.callback;
  212|       |
  213|       |    /* Allocate initial block */
  214|    218|    buffer = (pj_uint8_t*) (*f->policy.block_alloc)(f, initial_size);
  215|    218|    if (!buffer)
  ------------------
  |  Branch (215:9): [True: 0, False: 218]
  ------------------
  216|      0|        return NULL;
  217|       |
  218|       |    /* Set pool administrative data. */
  219|    218|    pool = (pj_pool_t*)buffer;
  220|    218|    pj_bzero(pool, sizeof(*pool));
  221|       |
  222|    218|    pj_list_init(&pool->block_list);
  223|    218|    pool->factory = f;
  224|       |
  225|       |    /* Create the first block from the memory. */
  226|    218|    block = (pj_pool_block*) (buffer + sizeof(*pool));
  227|    218|    block->buf = ((unsigned char*)block) + sizeof(pj_pool_block);
  228|    218|    block->end = buffer + initial_size;
  229|       |
  230|       |    /* Set the start pointer, aligning it as needed */
  231|    218|    block->cur = ALIGN_PTR(block->buf, PJ_POOL_ALIGNMENT);
  ------------------
  |  |   34|    218|#define ALIGN_PTR(PTR,ALIGNMENT)    (PTR + (-(pj_ssize_t)(PTR) & (ALIGNMENT-1)))
  ------------------
  232|       |
  233|    218|    pj_list_insert_after(&pool->block_list, block);
  234|       |
  235|    218|    pj_pool_init_int(pool, name, increment_size, callback);
  236|       |
  237|       |    /* Pool initial capacity and used size */
  238|    218|    pool->capacity = initial_size;
  239|       |
  240|    218|    LOG((pool->obj_name, "pool created, size=%lu",
  ------------------
  |  |   33|    218|#define LOG(expr)                   PJ_LOG(6,expr)
  |  |  ------------------
  |  |  |  |  106|    218|#define PJ_LOG(level,arg)       do { \
  |  |  |  |  107|    218|                                    if (level <= pj_log_get_level()) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:41): [True: 0, False: 218]
  |  |  |  |  ------------------
  |  |  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  |  |  109|      0|                                    } \
  |  |  |  |  110|    218|                                } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (110:42): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  241|    218|                         (unsigned long)pool->capacity));
  242|    218|    return pool;
  243|    218|}

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

pj_caching_pool_init:
   56|    218|{
   57|    218|    int i;
   58|    218|    pj_pool_t *pool;
   59|    218|    pj_status_t status;
   60|       |
   61|    218|    PJ_CHECK_STACK();
   62|       |
   63|    218|    pj_bzero(cp, sizeof(*cp));
   64|       |    
   65|    218|    cp->max_capacity = max_capacity;
   66|    218|    pj_list_init(&cp->used_list);
   67|  3.70k|    for (i=0; i<PJ_CACHING_POOL_ARRAY_SIZE; ++i)
  ------------------
  |  |  815|  3.70k|#define PJ_CACHING_POOL_ARRAY_SIZE      16
  ------------------
  |  Branch (67:15): [True: 3.48k, False: 218]
  ------------------
   68|  3.48k|        pj_list_init(&cp->free_list[i]);
   69|       |
   70|    218|    if (policy == NULL) {
  ------------------
  |  Branch (70:9): [True: 0, False: 218]
  ------------------
   71|      0|        policy = &pj_pool_factory_default_policy;
   72|      0|    }
   73|       |    
   74|    218|    pj_memcpy(&cp->factory.policy, policy, sizeof(pj_pool_factory_policy));
   75|    218|    cp->factory.create_pool = &cpool_create_pool;
   76|    218|    cp->factory.release_pool = &cpool_release_pool;
   77|    218|    cp->factory.dump_status = &cpool_dump_status;
   78|       |
   79|       |    /* Deprecated, these callbacks are only used for updating cp.used_size &
   80|       |     * cp.peak_used_size which are no longer used.
   81|       |     */
   82|       |    //cp->factory.on_block_alloc = &cpool_on_block_alloc;
   83|       |    //cp->factory.on_block_free = &cpool_on_block_free;
   84|       |
   85|    218|    pool = pj_pool_create_on_buf("cachingpool", cp->pool_buf, sizeof(cp->pool_buf));
   86|    218|    status = pj_lock_create_simple_mutex(pool, "cachingpool", &cp->lock);
   87|       |    /* This mostly serves to silent coverity warning about unchecked 
   88|       |     * return value. There's not much we can do if it fails. */
   89|    218|    PJ_ASSERT_ON_FAIL(status==PJ_SUCCESS, return);
  ------------------
  |  |   73|    218|            { \
  |  |   74|    218|                pj_assert(expr); \
  |  |  ------------------
  |  |  |  |   48|    218|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |   75|    218|                if (!(expr)) exec_on_fail; \
  |  |  ------------------
  |  |  |  Branch (75:21): [True: 0, False: 218]
  |  |  ------------------
  |  |   76|    218|            }
  ------------------
   90|    218|}
pj_caching_pool_destroy:
   93|    218|{
   94|    218|    int i;
   95|    218|    pj_pool_t *pool;
   96|       |
   97|    218|    PJ_CHECK_STACK();
   98|       |
   99|       |    /* Delete all pool in free list */
  100|  3.70k|    for (i=0; i < PJ_CACHING_POOL_ARRAY_SIZE; ++i) {
  ------------------
  |  |  815|  3.70k|#define PJ_CACHING_POOL_ARRAY_SIZE      16
  ------------------
  |  Branch (100:15): [True: 3.48k, False: 218]
  ------------------
  101|  3.48k|        pj_pool_t *next;
  102|  3.48k|        pool = (pj_pool_t*) cp->free_list[i].next;
  103|  3.48k|        for (; pool != (void*)&cp->free_list[i]; pool = next) {
  ------------------
  |  Branch (103:16): [True: 0, False: 3.48k]
  ------------------
  104|      0|            next = pool->next;
  105|      0|            pj_list_erase(pool);
  106|      0|            pj_pool_destroy_int(pool);
  107|      0|        }
  108|  3.48k|    }
  109|       |
  110|       |    /* Delete all pools in used list */
  111|    218|    pool = (pj_pool_t*) cp->used_list.next;
  112|    218|    while (pool != (pj_pool_t*) &cp->used_list) {
  ------------------
  |  Branch (112:12): [True: 0, False: 218]
  ------------------
  113|      0|        pj_pool_t *next = pool->next;
  114|      0|        pj_list_erase(pool);
  115|      0|        PJ_LOG(4,(pool->obj_name, 
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, False: 0]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded - Ignored]
  |  |  ------------------
  ------------------
  116|      0|                  "Pool is not released by application, releasing now"));
  117|      0|        pj_pool_destroy_int(pool);
  118|      0|        pool = next;
  119|      0|    }
  120|       |
  121|    218|    if (cp->lock) {
  ------------------
  |  Branch (121:9): [True: 218, False: 0]
  ------------------
  122|    218|        pj_lock_destroy(cp->lock);
  123|    218|        pj_lock_create_null_mutex(NULL, "cachingpool", &cp->lock);
  124|    218|    }
  125|    218|}

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

pj_strtoul:
  324|     39|{
  325|     39|    unsigned long value;
  326|     39|    unsigned i;
  327|       |
  328|     39|    PJ_CHECK_STACK();
  329|       |
  330|     39|    pj_assert(str->slen >= 0);
  ------------------
  |  |   48|     39|#   define pj_assert(expr)   assert(expr)
  ------------------
  331|       |
  332|     39|    value = 0;
  333|  1.17k|    for (i=0; i<(unsigned)str->slen; ++i) {
  ------------------
  |  Branch (333:15): [True: 1.15k, False: 23]
  ------------------
  334|  1.15k|        if (!pj_isdigit(str->ptr[i]))
  ------------------
  |  Branch (334:13): [True: 16, False: 1.13k]
  ------------------
  335|     16|            break;
  336|  1.13k|        value = value * 10 + (str->ptr[i] - '0');
  337|  1.13k|    }
  338|     39|    return value;
  339|     39|}
pj_utoa_pad:
  557|      4|{
  558|      4|    char *p;
  559|      4|    int len;
  560|       |
  561|      4|    PJ_CHECK_STACK();
  562|       |
  563|      4|    p = buf;
  564|      8|    do {
  565|      8|        unsigned long digval = (unsigned long) (val % 10);
  566|      8|        val /= 10;
  567|      8|        *p++ = (char) (digval + '0');
  568|      8|    } while (val > 0);
  ------------------
  |  Branch (568:14): [True: 4, False: 4]
  ------------------
  569|       |
  570|      4|    len = (int)(p-buf);
  571|      5|    while (len < min_dig) {
  ------------------
  |  Branch (571:12): [True: 1, False: 4]
  ------------------
  572|      1|        *p++ = (char)pad;
  573|      1|        ++len;
  574|      1|    }
  575|      4|    *p-- = '\0';
  576|       |
  577|      4|    do {
  578|      4|        char temp = *p;
  579|      4|        *p = *buf;
  580|      4|        *buf = temp;
  581|      4|        --p;
  582|      4|        ++buf;
  583|      4|    } while (buf < p);
  ------------------
  |  Branch (583:14): [True: 0, False: 4]
  ------------------
  584|       |
  585|      4|    return len;
  586|      4|}
pj_ansi_strxcpy:
  627|    439|{
  628|    439|    char *odst = dst;
  629|       |
  630|    439|    PJ_ASSERT_RETURN(dst && src, -PJ_EINVAL);
  ------------------
  |  |   59|    439|            do { \
  |  |   60|    878|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:23): [True: 439, False: 0]
  |  |  |  Branch (60:23): [True: 439, False: 0]
  |  |  ------------------
  |  |   61|    439|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
  631|       |
  632|    439|    if (dst_size==0)
  ------------------
  |  Branch (632:9): [True: 0, False: 439]
  ------------------
  633|      0|        return -PJ_ETOOBIG;
  ------------------
  |  |  398|      0|#define PJ_ETOOBIG          (PJ_ERRNO_START_STATUS + 17)/* 70017 */
  |  |  ------------------
  |  |  |  |  456|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  444|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  450|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  634|       |
  635|  5.27k|    while (--dst_size && (*dst=*src) != 0) {
  ------------------
  |  Branch (635:12): [True: 5.27k, False: 0]
  |  Branch (635:26): [True: 4.83k, False: 439]
  ------------------
  636|  4.83k|        ++dst;
  637|  4.83k|        ++src;
  638|  4.83k|    }
  639|       |
  640|    439|    if (!*dst && !*src) {
  ------------------
  |  Branch (640:9): [True: 439, False: 0]
  |  Branch (640:18): [True: 439, False: 0]
  ------------------
  641|    439|        return dst-odst;
  642|    439|    } else {
  643|      0|        *dst = '\0';
  644|      0|        return *src? -PJ_ETOOBIG : dst-odst;
  ------------------
  |  |  398|      0|#define PJ_ETOOBIG          (PJ_ERRNO_START_STATUS + 17)/* 70017 */
  |  |  ------------------
  |  |  |  |  456|      0|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  444|      0|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  450|      0|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (644:16): [True: 0, False: 0]
  ------------------
  645|      0|    }
  646|    439|}

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

