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

pj_cis_add_range:
   51|      4|{
   52|       |    /* Can not set zero. This is the requirement of the parser. */
   53|      4|    pj_assert(cstart > 0);
  ------------------
  |  |   48|      4|#   define pj_assert(expr)   assert(expr)
  ------------------
   54|       |
   55|     76|    while (cstart != cend) {
  ------------------
  |  Branch (55:12): [True: 72, False: 4]
  ------------------
   56|     72|        PJ_CIS_SET(cis, cstart);
  ------------------
  |  |   72|     72|#define PJ_CIS_SET(cis,c)   ((cis)->cis_buf[(int)(c)] |= (1 << (cis)->cis_id))
  ------------------
   57|     72|        ++cstart;
   58|     72|    }
   59|      4|}
pj_cis_add_alpha:
   62|      1|{
   63|      1|    pj_cis_add_range( cis, 'a', 'z'+1);
   64|      1|    pj_cis_add_range( cis, 'A', 'Z'+1);
   65|      1|}
pj_cis_add_num:
   68|      2|{
   69|      2|    pj_cis_add_range( cis, '0', '9'+1);
   70|      2|}
pj_cis_add_str:
   73|      1|{
   74|     18|    while (*str) {
  ------------------
  |  Branch (74:12): [True: 17, False: 1]
  ------------------
   75|     17|        PJ_CIS_SET(cis, *str);
  ------------------
  |  |   72|     17|#define PJ_CIS_SET(cis,c)   ((cis)->cis_buf[(int)(c)] |= (1 << (cis)->cis_id))
  ------------------
   76|     17|        ++str;
   77|     17|    }
   78|      1|}
pj_scan_init:
  120|  2.26k|{
  121|  2.26k|    PJ_CHECK_STACK();
  122|       |
  123|  2.26k|    scanner->begin = scanner->curptr = bufstart;
  124|  2.26k|    scanner->end = bufstart + buflen;
  125|  2.26k|    scanner->line = 1;
  126|  2.26k|    scanner->start_line = scanner->begin;
  127|  2.26k|    scanner->callback = callback;
  128|  2.26k|    scanner->skip_ws = options;
  129|       |
  130|  2.26k|    if (scanner->skip_ws) 
  ------------------
  |  Branch (130:9): [True: 0, False: 2.26k]
  ------------------
  131|      0|        pj_scan_skip_whitespace(scanner);
  132|  2.26k|}
pj_scan_fini:
  136|  2.26k|{
  137|  2.26k|    PJ_CHECK_STACK();
  138|  2.26k|    PJ_UNUSED_ARG(scanner);
  ------------------
  |  | 1433|  2.26k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  139|  2.26k|}
pj_scan_skip_line:
  203|  27.8k|{
  204|  27.8k|    char *s;
  205|       |
  206|  27.8k|    if (pj_scan_is_eof(scanner)) {
  ------------------
  |  Branch (206:9): [True: 1.46k, False: 26.3k]
  ------------------
  207|  1.46k|        return;
  208|  1.46k|    }
  209|       |
  210|  26.3k|    s = pj_memchr(scanner->curptr, '\n', scanner->end - scanner->curptr);
  211|  26.3k|    if (!s) {
  ------------------
  |  Branch (211:9): [True: 77, False: 26.2k]
  ------------------
  212|     77|        scanner->curptr = scanner->end;
  213|  26.2k|    } else {
  214|  26.2k|        scanner->curptr = scanner->start_line = s+1;
  215|  26.2k|        scanner->line++;
  216|  26.2k|   }
  217|  26.3k|}
pj_scan_get:
  273|  37.8k|{
  274|  37.8k|    register char *s = scanner->curptr;
  275|       |
  276|  37.8k|    pj_assert(pj_cis_match(spec,0)==0);
  ------------------
  |  |   48|  37.8k|#   define pj_assert(expr)   assert(expr)
  ------------------
  277|       |
  278|  37.8k|    if (pj_scan_is_eof(scanner) || !pj_cis_match(spec, *s)) {
  ------------------
  |  Branch (278:9): [True: 12, False: 37.8k]
  |  Branch (278:36): [True: 5, False: 37.8k]
  ------------------
  279|     17|        pj_scan_syntax_err(scanner);
  280|     17|        return;
  281|     17|    }
  282|       |
  283|   116k|    do {
  284|   116k|        ++s;
  285|   116k|    } while (PJ_SCAN_CHECK_EOF(s) && pj_cis_match(spec, *s));
  ------------------
  |  |   33|   232k|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 115k, False: 576]
  |  |  ------------------
  ------------------
  |  Branch (285:38): [True: 78.1k, False: 37.2k]
  ------------------
  286|       |
  287|  37.8k|    pj_strset3(out, scanner->curptr, s);
  288|       |
  289|  37.8k|    scanner->curptr = s;
  290|       |
  291|  37.8k|    if (!pj_scan_is_eof(scanner) &&
  ------------------
  |  Branch (291:9): [True: 37.2k, False: 576]
  ------------------
  292|  37.8k|        PJ_SCAN_IS_PROBABLY_SPACE(*s) && scanner->skip_ws)
  ------------------
  |  |   32|  75.0k|#define PJ_SCAN_IS_PROBABLY_SPACE(c)    ((c) <= 32)
  |  |  ------------------
  |  |  |  Branch (32:41): [True: 36.1k, False: 1.10k]
  |  |  ------------------
  ------------------
  |  Branch (292:42): [True: 0, False: 36.1k]
  ------------------
  293|      0|    {
  294|      0|        pj_scan_skip_whitespace(scanner);    
  295|      0|    }
  296|  37.8k|}
pj_scan_get_char:
  459|  40.2k|{
  460|  40.2k|    register char *s = scanner->curptr;
  461|  40.2k|    int chr;
  462|       |
  463|  40.2k|    if (s >= scanner->end || !*s) {
  ------------------
  |  Branch (463:9): [True: 159, False: 40.0k]
  |  Branch (463:30): [True: 1, False: 40.0k]
  ------------------
  464|    160|        pj_scan_syntax_err(scanner);
  465|    160|        return 0;
  466|    160|    }
  467|       |
  468|  40.0k|    chr = *s;
  469|       |
  470|  40.0k|    ++s;
  471|  40.0k|    scanner->curptr = s;
  472|  40.0k|    if (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_PROBABLY_SPACE(*s) &&
  ------------------
  |  |   33|  80.1k|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 39.9k, False: 95]
  |  |  ------------------
  ------------------
                  if (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_PROBABLY_SPACE(*s) &&
  ------------------
  |  |   32|  80.0k|#define PJ_SCAN_IS_PROBABLY_SPACE(c)    ((c) <= 32)
  |  |  ------------------
  |  |  |  Branch (32:41): [True: 14.5k, False: 25.4k]
  |  |  ------------------
  ------------------
  473|  40.0k|        scanner->skip_ws)
  ------------------
  |  Branch (473:9): [True: 0, False: 14.5k]
  ------------------
  474|      0|    {
  475|      0|        pj_scan_skip_whitespace(scanner);
  476|      0|    }
  477|  40.0k|    return chr;
  478|  40.2k|}
pj_scan_get_newline:
  482|  1.62k|{
  483|  1.62k|    if (pj_scan_is_eof(scanner) || !PJ_SCAN_IS_NEWLINE(*scanner->curptr)) {
  ------------------
  |  |   31|  1.62k|#define PJ_SCAN_IS_NEWLINE(c)           ((c)=='\r' || (c)=='\n')
  |  |  ------------------
  |  |  |  Branch (31:42): [True: 745, False: 877]
  |  |  |  Branch (31:55): [True: 877, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (483:9): [True: 6, False: 1.62k]
  ------------------
  484|      6|        pj_scan_syntax_err(scanner);
  485|      6|        return;
  486|      6|    }
  487|       |
  488|       |    /* We have checked scanner->curptr validity above */
  489|  1.62k|    if (*scanner->curptr == '\r') {
  ------------------
  |  Branch (489:9): [True: 745, False: 877]
  ------------------
  490|    745|        ++scanner->curptr;
  491|    745|    }
  492|  1.62k|    if (!pj_scan_is_eof(scanner) && *scanner->curptr == '\n') {
  ------------------
  |  Branch (492:9): [True: 1.61k, False: 9]
  |  Branch (492:37): [True: 881, False: 732]
  ------------------
  493|    881|        ++scanner->curptr;
  494|    881|    }
  495|       |
  496|  1.62k|    ++scanner->line;
  497|  1.62k|    scanner->start_line = scanner->curptr;
  498|       |
  499|       |    /**
  500|       |     * This probably is a bug, see PROTOS test #2480.
  501|       |     * This would cause scanner to incorrectly eat two new lines, e.g.
  502|       |     * when parsing:
  503|       |     *   
  504|       |     *  Content-Length: 120\r\n
  505|       |     *  \r\n
  506|       |     *  <space><space><space>...
  507|       |     *
  508|       |     * When pj_scan_get_newline() is called to parse the first newline
  509|       |     * in the Content-Length header, it will eat the second newline
  510|       |     * too because it thinks that it's a header continuation.
  511|       |     *
  512|       |     * if (PJ_SCAN_IS_PROBABLY_SPACE(*scanner->curptr) && scanner->skip_ws) {
  513|       |     *    pj_scan_skip_whitespace(scanner);
  514|       |     * }
  515|       |     */
  516|  1.62k|}
pj_scan_get_until_ch:
  547|  12.1k|{
  548|  12.1k|    register char *s = scanner->curptr;
  549|       |
  550|  12.1k|    if (s >= scanner->end) {
  ------------------
  |  Branch (550:9): [True: 6, False: 12.1k]
  ------------------
  551|      6|        pj_scan_syntax_err(scanner);
  552|      6|        return;
  553|      6|    }
  554|       |
  555|  76.8k|    while (PJ_SCAN_CHECK_EOF(s) && *s != until_char) {
  ------------------
  |  |   33|   153k|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 76.7k, False: 157]
  |  |  ------------------
  ------------------
  |  Branch (555:36): [True: 64.7k, False: 11.9k]
  ------------------
  556|  64.7k|        ++s;
  557|  64.7k|    }
  558|       |
  559|  12.1k|    pj_strset3(out, scanner->curptr, s);
  560|       |
  561|  12.1k|    scanner->curptr = s;
  562|       |
  563|  12.1k|    if (!pj_scan_is_eof(scanner) && PJ_SCAN_IS_PROBABLY_SPACE(*s) &&
  ------------------
  |  |   32|  24.1k|#define PJ_SCAN_IS_PROBABLY_SPACE(c)    ((c) <= 32)
  |  |  ------------------
  |  |  |  Branch (32:41): [True: 9.52k, False: 2.46k]
  |  |  ------------------
  ------------------
  |  Branch (563:9): [True: 11.9k, False: 157]
  ------------------
  564|  12.1k|        scanner->skip_ws)
  ------------------
  |  Branch (564:9): [True: 0, False: 9.52k]
  ------------------
  565|      0|    {
  566|      0|        pj_scan_skip_whitespace(scanner);
  567|      0|    }
  568|  12.1k|}
pj_scan_get_until_chr:
  573|  17.8k|{
  574|  17.8k|    register char *s = scanner->curptr;
  575|  17.8k|    pj_size_t speclen;
  576|       |
  577|  17.8k|    if (s >= scanner->end) {
  ------------------
  |  Branch (577:9): [True: 25, False: 17.7k]
  ------------------
  578|     25|        pj_scan_syntax_err(scanner);
  579|     25|        return;
  580|     25|    }
  581|       |
  582|  17.7k|    speclen = strlen(until_spec);
  583|  89.3k|    while (PJ_SCAN_CHECK_EOF(s) && !memchr(until_spec, *s, speclen)) {
  ------------------
  |  |   33|   178k|#define PJ_SCAN_CHECK_EOF(s)            (s != scanner->end)
  |  |  ------------------
  |  |  |  Branch (33:41): [True: 88.4k, False: 922]
  |  |  ------------------
  ------------------
  |  Branch (583:36): [True: 71.5k, False: 16.8k]
  ------------------
  584|  71.5k|        ++s;
  585|  71.5k|    }
  586|       |
  587|  17.7k|    pj_strset3(out, scanner->curptr, s);
  588|       |
  589|  17.7k|    scanner->curptr = s;
  590|       |
  591|  17.7k|    if (!pj_scan_is_eof(scanner) && PJ_SCAN_IS_PROBABLY_SPACE(*s) &&
  ------------------
  |  |   32|  34.6k|#define PJ_SCAN_IS_PROBABLY_SPACE(c)    ((c) <= 32)
  |  |  ------------------
  |  |  |  Branch (32:41): [True: 16.8k, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (591:9): [True: 16.8k, False: 922]
  ------------------
  592|  17.7k|        scanner->skip_ws)
  ------------------
  |  Branch (592:9): [True: 0, False: 16.8k]
  ------------------
  593|      0|    {
  594|      0|        pj_scan_skip_whitespace(scanner);
  595|      0|    }
  596|  17.7k|}
pj_scan_advance_n:
  600|  29.6k|{
  601|  29.6k|    if (scanner->curptr + N > scanner->end) {
  ------------------
  |  Branch (601:9): [True: 34, False: 29.6k]
  ------------------
  602|     34|        pj_scan_syntax_err(scanner);
  603|     34|        return;
  604|     34|    }
  605|       |
  606|  29.6k|    scanner->curptr += N;
  607|       |
  608|  29.6k|    if (!pj_scan_is_eof(scanner) && 
  ------------------
  |  Branch (608:9): [True: 29.6k, False: 11]
  ------------------
  609|  29.6k|        PJ_SCAN_IS_PROBABLY_SPACE(*scanner->curptr) && skip_ws)
  ------------------
  |  |   32|  59.2k|#define PJ_SCAN_IS_PROBABLY_SPACE(c)    ((c) <= 32)
  |  |  ------------------
  |  |  |  Branch (32:41): [True: 2.82k, False: 26.7k]
  |  |  ------------------
  ------------------
  |  Branch (609:56): [True: 0, False: 2.82k]
  ------------------
  610|      0|    {
  611|      0|        pj_scan_skip_whitespace(scanner);
  612|      0|    }
  613|  29.6k|}
scanner.c:pj_scan_syntax_err:
   45|    248|{
   46|    248|    (*scanner->callback)(scanner);
   47|    248|}

pj_cis_buf_init:
   26|      1|{
   27|      1|    pj_bzero(cis_buf->cis_buf, sizeof(cis_buf->cis_buf));
   28|      1|    cis_buf->use_mask = 0;
   29|      1|}
pj_cis_init:
   32|      2|{
   33|      2|    unsigned i;
   34|       |
   35|      2|    cis->cis_buf = cis_buf->cis_buf;
   36|       |
   37|      3|    for (i=0; i<PJ_CIS_MAX_INDEX; ++i) {
  ------------------
  |  |   44|      3|#define PJ_CIS_MAX_INDEX   (sizeof(pj_cis_elem_t) << 3)
  ------------------
  |  Branch (37:15): [True: 3, False: 0]
  ------------------
   38|      3|        if ((cis_buf->use_mask & (1 << i)) == 0) {
  ------------------
  |  Branch (38:13): [True: 2, False: 1]
  ------------------
   39|      2|            cis->cis_id = i;
   40|      2|            cis_buf->use_mask |= (1 << i);
   41|      2|            return PJ_SUCCESS;
   42|      2|        }
   43|      3|    }
   44|       |
   45|      0|    cis->cis_id = PJ_CIS_MAX_INDEX;
  ------------------
  |  |   44|      0|#define PJ_CIS_MAX_INDEX   (sizeof(pj_cis_elem_t) << 3)
  ------------------
   46|      0|    return PJ_ETOOMANY;
  ------------------
  |  |  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
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   47|      2|}

sdp.c:pj_isdigit:
   74|  2.01k|PJ_INLINE(int) pj_isdigit(unsigned char c) { return isdigit(c); }
string.c:pj_isspace:
   83|  19.1k|PJ_INLINE(int) pj_isspace(unsigned char c) { return isspace(c); }

event.c:pj_list_init:
   88|  4.53k|{
   89|  4.53k|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|  4.53k|}
list.c:pj_list_init:
   88|  14.3k|{
   89|  14.3k|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|  14.3k|}
pool.c:pj_list_init:
   88|  9.07k|{
   89|  9.07k|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|  9.07k|}
pool_caching.c:pj_list_init:
   88|  38.5k|{
   89|  38.5k|    ((pj_list*)node)->next = ((pj_list*)node)->prev = node;
   90|  38.5k|}
pool_caching.c:pj_list_empty:
  102|  6.80k|{
  103|  6.80k|    return ((pj_list*)node)->next == node;
  104|  6.80k|}

pj_list_insert_after:
   29|  23.4k|{
   30|  23.4k|    ((pj_list*)node)->prev = pos;
   31|  23.4k|    ((pj_list*)node)->next = ((pj_list*)pos)->next;
   32|  23.4k|    ((pj_list*) ((pj_list*)pos)->next) ->prev = node;
   33|  23.4k|    ((pj_list*)pos)->next = node;
   34|  23.4k|}
pj_list_insert_before:
   38|  6.80k|{
   39|  6.80k|    pj_list_insert_after(((pj_list*)pos)->prev, node);
   40|  6.80k|}
pj_list_erase:
   93|  14.3k|{
   94|  14.3k|    pj_link_node( ((pj_list*)node)->prev, ((pj_list*)node)->next);
   95|       |
   96|       |    /* It'll be safer to init the next/prev fields to itself, to
   97|       |     * prevent multiple erase() from corrupting the list. See
   98|       |     * ticket #520 for one sample bug.
   99|       |     */
  100|  14.3k|    pj_list_init(node);
  101|  14.3k|}
list.c:pj_link_node:
   23|  14.3k|{
   24|  14.3k|    ((pj_list*)prev)->next = next;
   25|  14.3k|    ((pj_list*)next)->prev = prev;
   26|  14.3k|}

event.c:pj_pool_zalloc:
  489|  2.26k|{
  490|  2.26k|    return pj_pool_calloc(pool, 1, size);
  491|  2.26k|}
sdp.c:pj_pool_zalloc:
  489|  16.3k|{
  490|  16.3k|    return pj_pool_calloc(pool, 1, size);
  491|  16.3k|}
os_core_unix.c:pj_pool_zalloc:
  489|  2.26k|{
  490|  2.26k|    return pj_pool_calloc(pool, 1, size);
  491|  2.26k|}

pj_pool_get_capacity:
   25|  6.80k|{
   26|  6.80k|    return pool->capacity;
   27|  6.80k|}
pj_pool_alloc_from_block:
   41|  78.4k|{
   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|  78.4k|    if (size & (PJ_POOL_ALIGNMENT-1)) {
  ------------------
  |  |  182|  78.4k|#define PJ_POOL_ALIGNMENT 8
  ------------------
  |  Branch (46:9): [True: 0, False: 78.4k]
  ------------------
   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|  78.4k|    if ((pj_size_t)(block->end - block->cur) >= size) {
  ------------------
  |  Branch (49:9): [True: 46.5k, False: 31.9k]
  ------------------
   50|  46.5k|        void *ptr = block->cur;
   51|  46.5k|        block->cur += size;
   52|  46.5k|        return ptr;
   53|  46.5k|    }
   54|  31.9k|    return NULL;
   55|  78.4k|}
pj_pool_alloc:
   58|  46.5k|{
   59|  46.5k|    void *ptr = pj_pool_alloc_from_block(pool->block_list.next, size);
   60|  46.5k|    if (!ptr)
  ------------------
  |  Branch (60:9): [True: 8.84k, False: 37.7k]
  ------------------
   61|  8.84k|        ptr = pj_pool_allocate_find(pool, size);
   62|  46.5k|    return ptr;
   63|  46.5k|}
pj_pool_calloc:
   67|  20.8k|{
   68|  20.8k|    void *buf = pj_pool_alloc( pool, size*count);
   69|  20.8k|    if (buf)
  ------------------
  |  Branch (69:9): [True: 20.8k, False: 0]
  ------------------
   70|  20.8k|        pj_bzero(buf, size * count);
   71|  20.8k|    return buf;
   72|  20.8k|}
pj_pool_create:
   84|  6.80k|{
   85|  6.80k|    return (*f->create_pool)(f, name, initial_size, increment_size, callback);
   86|  6.80k|}
pj_pool_release:
   89|  6.80k|{
   90|       |#if PJ_POOL_RELEASE_WIPE_DATA
   91|       |    pj_pool_block *b;
   92|       |
   93|       |    b = pool->block_list.next;
   94|       |    while (b != &pool->block_list) {
   95|       |        volatile unsigned char *p = b->buf;
   96|       |        while (p < b->end) *p++ = 0;
   97|       |        b = b->next;
   98|       |    }
   99|       |#endif
  100|       |
  101|  6.80k|    if (pool->factory->release_pool)
  ------------------
  |  Branch (101:9): [True: 6.80k, False: 0]
  ------------------
  102|  6.80k|        (*pool->factory->release_pool)(pool->factory, pool);
  103|  6.80k|}

scanner.c:pj_bzero:
  820|      1|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|      1|    memset(dst, 0, size);
  825|      1|#endif
  826|      1|}
scanner.c:pj_memchr:
  896|  26.3k|{
  897|  26.3k|    return (void*)memchr((void*)buf, c, size);
  898|  26.3k|}
scanner.c:pj_strset3:
  149|  67.7k|{
  150|  67.7k|    str->ptr = begin;
  151|  67.7k|    str->slen = (pj_ssize_t)(end-begin);
  152|  67.7k|    return str;
  153|  67.7k|}
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|}
array.c:pj_memmove:
  867|     27|{
  868|     27|    return memmove(dst, src, size);
  869|     27|}
errno.c:pj_memcpy:
  853|  12.3k|{
  854|  12.3k|    return memcpy(dst, src, size);
  855|  12.3k|}
pool.c:pj_bzero:
  820|  29.9k|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|  29.9k|    memset(dst, 0, size);
  825|  29.9k|#endif
  826|  29.9k|}
pool_caching.c:pj_bzero:
  820|  2.26k|{
  821|       |#if defined(PJ_HAS_BZERO) && PJ_HAS_BZERO!=0
  822|       |    bzero(dst, size);
  823|       |#else
  824|  2.26k|    memset(dst, 0, size);
  825|  2.26k|#endif
  826|  2.26k|}
pool_caching.c:pj_memcpy:
  853|  2.26k|{
  854|  2.26k|    return memcpy(dst, src, size);
  855|  2.26k|}
string.c:pj_memcmp:
  881|  27.0k|{
  882|  27.0k|    return memcmp(buf1, buf2, size);
  883|  27.0k|}
lock.c:pj_memcpy:
  853|  2.26k|{
  854|  2.26k|    return memcpy(dst, src, size);
  855|  2.26k|}

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_strcmp:
  162|  27.0k|{
  163|  27.0k|    pj_assert(str1->slen >= 0);
  ------------------
  |  |   48|  27.0k|#   define pj_assert(expr)   assert(expr)
  ------------------
  164|  27.0k|    pj_assert(str2->slen >= 0);
  ------------------
  |  |   48|  27.0k|#   define pj_assert(expr)   assert(expr)
  ------------------
  165|       |
  166|  27.0k|    if (str1->slen <= 0) {
  ------------------
  |  Branch (166:9): [True: 15, False: 27.0k]
  ------------------
  167|     15|        return str2->slen<=0 ? 0 : -1;
  ------------------
  |  Branch (167:16): [True: 0, False: 15]
  ------------------
  168|  27.0k|    } else if (str2->slen <= 0) {
  ------------------
  |  Branch (168:16): [True: 0, False: 27.0k]
  ------------------
  169|      0|        return 1;
  170|  27.0k|    } else {
  171|  27.0k|        pj_size_t min = (str1->slen < str2->slen)? str1->slen : str2->slen;
  ------------------
  |  Branch (171:25): [True: 21.1k, False: 5.85k]
  ------------------
  172|  27.0k|        int res = pj_memcmp(str1->ptr, str2->ptr, min);
  173|  27.0k|        if (res == 0) {
  ------------------
  |  Branch (173:13): [True: 9.33k, False: 17.6k]
  ------------------
  174|  9.33k|            return (str1->slen < str2->slen) ? -1 :
  ------------------
  |  Branch (174:20): [True: 4.76k, False: 4.57k]
  ------------------
  175|  9.33k|                    (str1->slen == str2->slen ? 0 : 1);
  ------------------
  |  Branch (175:22): [True: 4.48k, False: 83]
  ------------------
  176|  17.6k|        } else {
  177|  17.6k|            return res;
  178|  17.6k|        }
  179|  27.0k|    }
  180|  27.0k|}
pj_strcmp2:
  221|  3.55k|{
  222|  3.55k|    pj_str_t copy2;
  223|       |
  224|  3.55k|    if (str2) {
  ------------------
  |  Branch (224:9): [True: 3.55k, False: 0]
  ------------------
  225|  3.55k|        copy2.ptr = (char*)str2;
  226|  3.55k|        copy2.slen = pj_ansi_strlen(str2);
  ------------------
  |  |   69|  3.55k|#define pj_ansi_strlen          strlen
  ------------------
  227|  3.55k|    } else {
  228|      0|        copy2.ptr = NULL;
  229|      0|        copy2.slen = 0;
  230|      0|    }
  231|       |
  232|  3.55k|    return pj_strcmp(str1, &copy2);
  233|  3.55k|}

pj_array_erase:
   42|    188|{
   43|    188|    pj_assert(count != 0);
  ------------------
  |  |   48|    188|#   define pj_assert(expr)   assert(expr)
  ------------------
   44|    188|    if (pos < count-1) {
  ------------------
  |  Branch (44:9): [True: 27, False: 161]
  ------------------
   45|     27|        pj_memmove( (char*)array + pos*elem_size,
   46|     27|                    (char*)array + (pos+1)*elem_size,
   47|     27|                    (count-pos-1)*(pj_size_t)elem_size);
   48|     27|    }
   49|    188|}

pj_strerror:
  174|  12.9k|{
  175|  12.9k|    int len = -1;
  176|  12.9k|    pj_str_t errstr;
  177|       |
  178|  12.9k|    pj_assert(buf && bufsize);
  ------------------
  |  |   48|  12.9k|#   define pj_assert(expr)   assert(expr)
  ------------------
  179|       |
  180|  12.9k|    if (statcode == PJ_SUCCESS) {
  ------------------
  |  Branch (180:9): [True: 0, False: 12.9k]
  ------------------
  181|      0|        len = pj_ansi_snprintf( buf, bufsize, "Success");
  ------------------
  |  |  114|      0|#define pj_ansi_snprintf        snprintf
  ------------------
  182|       |
  183|  12.9k|    } else if (statcode < PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE) {
  ------------------
  |  |  444|  12.9k|#define PJ_ERRNO_START          20000
  ------------------
                  } else if (statcode < PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE) {
  ------------------
  |  |  450|  12.9k|#define PJ_ERRNO_SPACE_SIZE     50000
  ------------------
  |  Branch (183:16): [True: 0, False: 12.9k]
  ------------------
  184|      0|        len = pj_ansi_snprintf( buf, bufsize, "Unknown error %d", statcode);
  ------------------
  |  |  114|      0|#define pj_ansi_snprintf        snprintf
  ------------------
  185|       |
  186|  12.9k|    } else if (statcode < PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE) {
  ------------------
  |  |  456|  12.9k|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  ------------------
  |  |  |  |  444|  12.9k|#define PJ_ERRNO_START          20000
  |  |  ------------------
  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  ------------------
  |  |  |  |  450|  12.9k|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  ------------------
  ------------------
                  } else if (statcode < PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE) {
  ------------------
  |  |  450|  12.9k|#define PJ_ERRNO_SPACE_SIZE     50000
  ------------------
  |  Branch (186:16): [True: 12.3k, False: 634]
  ------------------
  187|  12.3k|        len = pjlib_error(statcode, buf, bufsize);
  188|       |
  189|  12.3k|    } else if (statcode < PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE) {
  ------------------
  |  |  463|    634|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  ------------------
  |  |  |  |  456|    634|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  444|    634|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  450|    634|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  ------------------
  |  |  |  |  450|    634|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  ------------------
  ------------------
                  } else if (statcode < PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE) {
  ------------------
  |  |  450|    634|#define PJ_ERRNO_SPACE_SIZE     50000
  ------------------
  |  Branch (189:16): [True: 0, False: 634]
  ------------------
  190|      0|        len = platform_strerror(PJ_STATUS_TO_OS(statcode), buf, bufsize);
  ------------------
  |  |  290|      0|#   define PJ_STATUS_TO_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 (290:32): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  191|       |
  192|    634|    } else {
  193|    634|        unsigned i;
  194|       |
  195|       |        /* Find user handler to get the error message. */
  196|    634|        for (i=0; i<err_msg_hnd_cnt; ++i) {
  ------------------
  |  Branch (196:19): [True: 0, False: 634]
  ------------------
  197|      0|            if (IN_RANGE(statcode, err_msg_hnd[i].begin, err_msg_hnd[i].end)) {
  ------------------
  |  |  115|      0|#define IN_RANGE(val,start,end)     ((val)>=(start) && (val)<(end))
  |  |  ------------------
  |  |  |  Branch (115:38): [True: 0, False: 0]
  |  |  |  Branch (115:56): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  198|      0|                return (*err_msg_hnd[i].strerror)(statcode, buf, bufsize);
  199|      0|            }
  200|      0|        }
  201|       |
  202|       |        /* Handler not found! */
  203|    634|        len = pj_ansi_snprintf( buf, bufsize, "Unknown error %d", statcode);
  ------------------
  |  |  114|    634|#define pj_ansi_snprintf        snprintf
  ------------------
  204|    634|    }
  205|       |
  206|  12.9k|    if (len < 1 || len >= (int)bufsize) {
  ------------------
  |  Branch (206:9): [True: 0, False: 12.9k]
  |  Branch (206:20): [True: 0, False: 12.9k]
  ------------------
  207|      0|        len = (int)(bufsize - 1);
  208|      0|        buf[len] = '\0';
  209|      0|    }
  210|       |
  211|  12.9k|    errstr.ptr = buf;
  212|  12.9k|    errstr.slen = len;
  213|       |
  214|  12.9k|    return errstr;
  215|  12.9k|}
pj_perror_2:
  275|  12.3k|{
  276|  12.3k|    va_list marker;
  277|  12.3k|    va_start(marker, title_fmt);
  278|  12.3k|    pj_perror_imp(2, sender, status, title_fmt, marker);
  279|  12.3k|    va_end(marker);
  280|  12.3k|}
pj_perror_4:
  297|    634|{
  298|    634|    va_list marker;
  299|    634|    va_start(marker, title_fmt);
  300|    634|    pj_perror_imp(4, sender, status, title_fmt, marker);
  301|    634|    va_end(marker);
  302|    634|}
errno.c:pjlib_error:
   92|  12.3k|{
   93|  12.3k|    int len;
   94|       |
   95|  12.3k|#if defined(PJ_HAS_ERROR_STRING) && PJ_HAS_ERROR_STRING!=0
   96|  12.3k|    unsigned i;
   97|       |
   98|   123k|    for (i=0; i<PJ_ARRAY_SIZE(err_str); ++i) {
  ------------------
  |  |  294|   123k|#define PJ_ARRAY_SIZE(a)    (sizeof(a)/sizeof(a[0]))
  ------------------
  |  Branch (98:15): [True: 123k, False: 0]
  ------------------
   99|   123k|        if (err_str[i].code == code) {
  ------------------
  |  Branch (99:13): [True: 12.3k, False: 111k]
  ------------------
  100|  12.3k|            pj_size_t len2 = pj_ansi_strlen(err_str[i].msg);
  ------------------
  |  |   69|  12.3k|#define pj_ansi_strlen          strlen
  ------------------
  101|  12.3k|            if (len2 >= size) len2 = size-1;
  ------------------
  |  Branch (101:17): [True: 0, False: 12.3k]
  ------------------
  102|  12.3k|            pj_memcpy(buf, err_str[i].msg, len2);
  103|  12.3k|            buf[len2] = '\0';
  104|  12.3k|            return (int)len2;
  105|  12.3k|        }
  106|   123k|    }
  107|      0|#endif
  108|       |
  109|      0|    len = pj_ansi_snprintf( buf, size, "Unknown pjlib error %d", code);
  ------------------
  |  |  114|      0|#define pj_ansi_snprintf        snprintf
  ------------------
  110|      0|    if (len < 1 || len >= (int)size)
  ------------------
  |  Branch (110:9): [True: 0, False: 0]
  |  Branch (110:20): [True: 0, False: 0]
  ------------------
  111|      0|        len = (int)(size - 1);
  112|      0|    return len;
  113|  12.3k|}
errno.c:pj_perror_imp:
  229|  12.9k|{
  230|  12.9k|    char titlebuf[PJ_PERROR_TITLE_BUF_SIZE];
  231|  12.9k|    char errmsg[PJ_ERR_MSG_SIZE];
  232|  12.9k|    int len;
  233|       |
  234|       |    /* Build the title */
  235|  12.9k|    len = pj_ansi_vsnprintf(titlebuf, sizeof(titlebuf), title_fmt, marker);
  ------------------
  |  |  122|  12.9k|#define pj_ansi_vsnprintf       vsnprintf
  ------------------
  236|  12.9k|    if (len < 0 || len >= (int)sizeof(titlebuf))
  ------------------
  |  Branch (236:9): [True: 0, False: 12.9k]
  |  Branch (236:20): [True: 181, False: 12.8k]
  ------------------
  237|    181|        pj_ansi_strxcpy(titlebuf, "Error", sizeof(titlebuf));
  238|       |
  239|       |    /* Get the error */
  240|  12.9k|    pj_strerror(status, errmsg, sizeof(errmsg));
  241|       |
  242|       |    /* Send to log */
  243|  12.9k|    invoke_log(sender, log_level, "%s: %s", titlebuf, errmsg);
  244|  12.9k|}
errno.c:invoke_log:
  219|  12.9k|{
  220|  12.9k|    va_list arg;
  221|  12.9k|    va_start(arg, format);
  222|  12.9k|    pj_log(sender, level, format, arg);
  223|  12.9k|    va_end(arg);
  224|  12.9k|}

pj_throw_exception_:
   41|    634|{
   42|    634|    struct pj_exception_state_t *handler;
   43|       |
   44|    634|    handler = (struct pj_exception_state_t*) 
   45|    634|              pj_thread_local_get(thread_local_id);
   46|    634|    if (handler == NULL) {
  ------------------
  |  Branch (46:9): [True: 0, False: 634]
  ------------------
   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|    634|    pj_pop_exception_handler_(handler);
   53|    634|    pj_longjmp(handler->state, exception_id);
  ------------------
  |  |   34|    634|#    define pj_longjmp(buf,d)   longjmp(buf,d)
  ------------------
   54|    634|}
pj_push_exception_handler_:
   75|  2.26k|{
   76|  2.26k|    struct pj_exception_state_t *parent_handler = NULL;
   77|       |
   78|  2.26k|    if (thread_local_id == -1) {
  ------------------
  |  Branch (78:9): [True: 1, False: 2.26k]
  ------------------
   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|  2.26k|    parent_handler = (struct pj_exception_state_t *)
   84|  2.26k|                      pj_thread_local_get(thread_local_id);
   85|  2.26k|    rec->prev = parent_handler;
   86|  2.26k|    pj_thread_local_set(thread_local_id, rec);
   87|  2.26k|}
pj_pop_exception_handler_:
   90|  2.90k|{
   91|  2.90k|    struct pj_exception_state_t *handler;
   92|       |
   93|  2.90k|    handler = (struct pj_exception_state_t *)
   94|  2.90k|              pj_thread_local_get(thread_local_id);
   95|  2.90k|    if (handler && handler==rec) {
  ------------------
  |  Branch (95:9): [True: 2.26k, False: 634]
  |  Branch (95:20): [True: 2.26k, False: 0]
  ------------------
   96|  2.26k|        pj_thread_local_set(thread_local_id, handler->prev);
   97|  2.26k|    }
   98|  2.90k|}
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|  2.26k|{
   88|  2.26k|    return create_mutex_lock(pool, name, PJ_MUTEX_SIMPLE, lock);
   89|  2.26k|}
pj_lock_create_null_mutex:
  120|  2.26k|{
  121|  2.26k|    PJ_UNUSED_ARG(name);
  ------------------
  |  | 1433|  2.26k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  122|  2.26k|    PJ_UNUSED_ARG(pool);
  ------------------
  |  | 1433|  2.26k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  123|       |
  124|  2.26k|    PJ_ASSERT_RETURN(lock, PJ_EINVAL);
  ------------------
  |  |   59|  2.26k|            do { \
  |  |   60|  2.26k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:21): [True: 0, False: 2.26k]
  |  |  ------------------
  |  |   61|  2.26k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
  125|       |
  126|  2.26k|    *lock = &null_lock_template;
  127|  2.26k|    return PJ_SUCCESS;
  128|  2.26k|}
pj_lock_acquire:
  177|  13.6k|{
  178|  13.6k|    PJ_ASSERT_RETURN(lock != NULL, PJ_EINVAL);
  ------------------
  |  |   59|  13.6k|            do { \
  |  |   60|  13.6k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:21): [True: 0, False: 13.6k]
  |  |  ------------------
  |  |   61|  13.6k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
  179|  13.6k|    return (*lock->acquire)(lock->lock_object);
  180|  13.6k|}
pj_lock_release:
  189|  13.6k|{
  190|  13.6k|    PJ_ASSERT_RETURN(lock != NULL, PJ_EINVAL);
  ------------------
  |  |   59|  13.6k|            do { \
  |  |   60|  13.6k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:21): [True: 0, False: 13.6k]
  |  |  ------------------
  |  |   61|  13.6k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
  191|  13.6k|    return (*lock->release)(lock->lock_object);
  192|  13.6k|}
pj_lock_destroy:
  195|  2.26k|{
  196|  2.26k|    PJ_ASSERT_RETURN(lock != NULL, PJ_EINVAL);
  ------------------
  |  |   59|  2.26k|            do { \
  |  |   60|  2.26k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:21): [True: 0, False: 2.26k]
  |  |  ------------------
  |  |   61|  2.26k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
  197|  2.26k|    return (*lock->destroy)(lock->lock_object);
  198|  2.26k|}
lock.c:create_mutex_lock:
   62|  2.26k|{
   63|  2.26k|    pj_lock_t *p_lock;
   64|  2.26k|    pj_mutex_t *mutex;
   65|  2.26k|    pj_status_t rc;
   66|       |
   67|  2.26k|    PJ_ASSERT_RETURN(pool && lock, PJ_EINVAL);
  ------------------
  |  |   59|  2.26k|            do { \
  |  |   60|  4.53k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:23): [True: 2.26k, False: 0]
  |  |  |  Branch (60:23): [True: 2.26k, False: 0]
  |  |  ------------------
  |  |   61|  2.26k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
   68|       |
   69|  2.26k|    p_lock = PJ_POOL_ALLOC_T(pool, pj_lock_t);
  ------------------
  |  |  506|  2.26k|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
   70|  2.26k|    if (!p_lock)
  ------------------
  |  Branch (70:9): [True: 0, False: 2.26k]
  ------------------
   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|  2.26k|    pj_memcpy(p_lock, &mutex_lock_template, sizeof(pj_lock_t));
   74|  2.26k|    rc = pj_mutex_create(pool, name, type, &mutex);
   75|  2.26k|    if (rc != PJ_SUCCESS)
  ------------------
  |  Branch (75:9): [True: 0, False: 2.26k]
  ------------------
   76|      0|        return rc;
   77|       |
   78|  2.26k|    p_lock->lock_object = mutex;
   79|  2.26k|    *lock = p_lock;
   80|  2.26k|    return PJ_SUCCESS;
   81|  2.26k|}

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|  2.26k|{
  253|  2.26k|    pj_log_max_level = level;
  254|  2.26k|}
pj_log_get_level:
  258|   113k|{
  259|   113k|    return pj_log_max_level;
  260|   113k|}
pj_log:
  340|  12.9k|{
  341|  12.9k|    pj_time_val now;
  342|  12.9k|    pj_parsed_time ptime;
  343|  12.9k|    char *pre;
  344|  12.9k|#if PJ_LOG_USE_STACK_BUFFER
  345|  12.9k|    char log_buffer[PJ_LOG_MAX_SIZE];
  346|  12.9k|#endif
  347|  12.9k|    int saved_level, len, print_len;
  348|       |
  349|  12.9k|    PJ_CHECK_STACK();
  350|       |
  351|  12.9k|    if (level > pj_log_max_level)
  ------------------
  |  Branch (351:9): [True: 12.9k, False: 1]
  ------------------
  352|  12.9k|        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|  2.26k|{
  176|  2.26k|    char dummy_guid[PJ_GUID_MAX_LENGTH];
  177|  2.26k|    pj_str_t guid;
  178|  2.26k|    pj_status_t rc;
  179|       |
  180|       |    /* Check if PJLIB have been initialized */
  181|  2.26k|    if (initialized) {
  ------------------
  |  Branch (181:9): [True: 2.26k, False: 1]
  ------------------
  182|  2.26k|        ++initialized;
  183|  2.26k|        return PJ_SUCCESS;
  184|  2.26k|    }
  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_create:
  720|  2.26k|{
  721|  2.26k|#if PJ_HAS_THREADS
  722|  2.26k|    pj_thread_t *rec;
  723|  2.26k|    pthread_attr_t thread_attr;
  724|  2.26k|    void *stack_addr;
  725|  2.26k|    int rc;
  726|       |
  727|  2.26k|    PJ_UNUSED_ARG(stack_addr);
  ------------------
  |  | 1433|  2.26k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  728|       |
  729|  2.26k|    PJ_CHECK_STACK();
  730|  2.26k|    PJ_ASSERT_RETURN(pool && proc && ptr_thread, PJ_EINVAL);
  ------------------
  |  |   59|  2.26k|            do { \
  |  |   60|  9.07k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:23): [True: 2.26k, False: 0]
  |  |  |  Branch (60:23): [True: 2.26k, False: 0]
  |  |  |  Branch (60:23): [True: 2.26k, False: 0]
  |  |  ------------------
  |  |   61|  2.26k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
  731|       |
  732|       |    /* Create thread record and assign name for the thread */
  733|  2.26k|    rec = (struct pj_thread_t*) pj_pool_zalloc(pool, sizeof(pj_thread_t));
  734|  2.26k|    PJ_ASSERT_RETURN(rec, PJ_ENOMEM);
  ------------------
  |  |   59|  2.26k|            do { \
  |  |   60|  2.26k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:21): [True: 0, False: 2.26k]
  |  |  ------------------
  |  |   61|  2.26k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
  735|       |
  736|       |    /* Set name. */
  737|  2.26k|    if (!thread_name)
  ------------------
  |  Branch (737:9): [True: 0, False: 2.26k]
  ------------------
  738|      0|        thread_name = "thr%p";
  739|       |
  740|  2.26k|    if (strchr(thread_name, '%')) {
  ------------------
  |  Branch (740:9): [True: 0, False: 2.26k]
  ------------------
  741|      0|        pj_ansi_snprintf(rec->obj_name, PJ_MAX_OBJ_NAME, thread_name, rec);
  ------------------
  |  |  114|      0|#define pj_ansi_snprintf        snprintf
  ------------------
                      pj_ansi_snprintf(rec->obj_name, PJ_MAX_OBJ_NAME, thread_name, rec);
  ------------------
  |  |  299|      0|#define PJ_MAX_OBJ_NAME 32
  ------------------
  742|  2.26k|    } else {
  743|  2.26k|        pj_ansi_strxcpy(rec->obj_name, thread_name, PJ_MAX_OBJ_NAME);
  ------------------
  |  |  299|  2.26k|#define PJ_MAX_OBJ_NAME 32
  ------------------
  744|  2.26k|    }
  745|       |
  746|       |    /* Set default stack size */
  747|  2.26k|    if (stack_size == 0)
  ------------------
  |  Branch (747:9): [True: 2.26k, False: 0]
  ------------------
  748|  2.26k|        stack_size = PJ_THREAD_DEFAULT_STACK_SIZE;
  ------------------
  |  |  623|  2.26k|#  define PJ_THREAD_DEFAULT_STACK_SIZE    8192
  ------------------
  749|       |
  750|       |#if defined(PJ_OS_HAS_CHECK_STACK) && PJ_OS_HAS_CHECK_STACK!=0
  751|       |    rec->stk_size = stack_size;
  752|       |    rec->stk_max_usage = 0;
  753|       |#endif
  754|       |
  755|       |    /* Emulate suspended thread with mutex. */
  756|  2.26k|    if (flags & PJ_THREAD_SUSPENDED) {
  ------------------
  |  Branch (756:9): [True: 0, False: 2.26k]
  ------------------
  757|      0|        rc = pj_mutex_create_simple(pool, NULL, &rec->suspended_mutex);
  758|      0|        if (rc != PJ_SUCCESS) {
  ------------------
  |  Branch (758:13): [True: 0, False: 0]
  ------------------
  759|      0|            return rc;
  760|      0|        }
  761|       |
  762|      0|        pj_mutex_lock(rec->suspended_mutex);
  763|  2.26k|    } else {
  764|  2.26k|        pj_assert(rec->suspended_mutex == NULL);
  ------------------
  |  |   48|  2.26k|#   define pj_assert(expr)   assert(expr)
  ------------------
  765|  2.26k|    }
  766|       |
  767|       |
  768|       |    /* Init thread attributes */
  769|  2.26k|    pthread_attr_init(&thread_attr);
  770|       |
  771|       |#if defined(PJ_THREAD_SET_STACK_SIZE) && PJ_THREAD_SET_STACK_SIZE!=0
  772|       |    /* Set thread's stack size */
  773|       |    rc = pthread_attr_setstacksize(&thread_attr, stack_size);
  774|       |    if (rc != 0) {
  775|       |        pthread_attr_destroy(&thread_attr);
  776|       |        return PJ_RETURN_OS_ERROR(rc);
  777|       |    }
  778|       |#endif  /* PJ_THREAD_SET_STACK_SIZE */
  779|       |
  780|       |
  781|       |#if defined(PJ_THREAD_ALLOCATE_STACK) && PJ_THREAD_ALLOCATE_STACK!=0
  782|       |    /* Allocate memory for the stack */
  783|       |    stack_addr = pj_pool_alloc(pool, stack_size);
  784|       |    PJ_ASSERT_RETURN(stack_addr, PJ_ENOMEM);
  785|       |
  786|       |    rc = pthread_attr_setstackaddr(&thread_attr, stack_addr);
  787|       |    if (rc != 0) {
  788|       |        pthread_attr_destroy(&thread_attr);
  789|       |        return PJ_RETURN_OS_ERROR(rc);
  790|       |    }
  791|       |#endif  /* PJ_THREAD_ALLOCATE_STACK */
  792|       |
  793|       |
  794|       |    /* Create the thread. */
  795|  2.26k|    rec->proc = proc;
  796|  2.26k|    rec->arg = arg;
  797|  2.26k|    rc = pthread_create( &rec->thread, &thread_attr, &thread_main, rec);
  798|  2.26k|    if (rc != 0) {
  ------------------
  |  Branch (798:9): [True: 0, False: 2.26k]
  ------------------
  799|      0|        pthread_attr_destroy(&thread_attr);
  800|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  801|      0|    }
  802|       |
  803|       |    /* Destroy thread attributes */
  804|  2.26k|    pthread_attr_destroy(&thread_attr);
  805|       |
  806|  2.26k|    *ptr_thread = rec;
  807|       |
  808|  2.26k|    PJ_LOG(6, (rec->obj_name, "Thread created"));
  ------------------
  |  |  106|  2.26k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  2.26k|                                    if (level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, False: 2.26k]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  2.26k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded - Ignored]
  |  |  ------------------
  ------------------
  809|  2.26k|    return PJ_SUCCESS;
  810|       |#else
  811|       |    pj_assert(!"Threading is disabled!");
  812|       |    return PJ_EINVALIDOP;
  813|       |#endif
  814|  2.26k|}
pj_thread_this:
  852|  29.5k|{
  853|  29.5k|#if PJ_HAS_THREADS
  854|  29.5k|    pj_thread_t *rec = (pj_thread_t*)pj_thread_local_get(thread_tls_id);
  855|       |
  856|  29.5k|    if (rec == NULL) {
  ------------------
  |  Branch (856:9): [True: 0, False: 29.5k]
  ------------------
  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|  29.5k|    return rec;
  869|       |#else
  870|       |    pj_assert(!"Threading is not enabled!");
  871|       |    return NULL;
  872|       |#endif
  873|  29.5k|}
pj_thread_join:
  879|  2.26k|{
  880|  2.26k|#if PJ_HAS_THREADS
  881|  2.26k|    pj_thread_t *rec = (pj_thread_t *)p;
  882|  2.26k|    void *ret;
  883|  2.26k|    int result;
  884|       |
  885|  2.26k|    PJ_CHECK_STACK();
  886|       |
  887|  2.26k|    if (p == pj_thread_this())
  ------------------
  |  Branch (887:9): [True: 0, False: 2.26k]
  ------------------
  888|      0|        return PJ_ECANCELLED;
  ------------------
  |  |  383|      0|#define PJ_ECANCELLED       (PJ_ERRNO_START_STATUS + 14)/* 70014 */
  |  |  ------------------
  |  |  |  |  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
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  889|       |
  890|  2.26k|    PJ_LOG(6, (pj_thread_this()->obj_name, "Joining thread %s", p->obj_name));
  ------------------
  |  |  106|  2.26k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  2.26k|                                    if (level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, False: 2.26k]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  2.26k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded - Ignored]
  |  |  ------------------
  ------------------
  891|  2.26k|    result = pthread_join( rec->thread, &ret);
  892|       |
  893|  2.26k|    if (result == 0)
  ------------------
  |  Branch (893:9): [True: 2.26k, False: 0]
  ------------------
  894|  2.26k|        return PJ_SUCCESS;
  895|      0|    else {
  896|       |        /* Calling pthread_join() on a thread that no longer exists and
  897|       |         * getting back ESRCH isn't an error (in this context).
  898|       |         * Thanks Phil Torre <ptorre@zetron.com>.
  899|       |         */
  900|      0|        return result==ESRCH ? PJ_SUCCESS : PJ_RETURN_OS_ERROR(result);
  ------------------
  |  |  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 (900:16): [True: 0, False: 0]
  ------------------
  901|      0|    }
  902|       |#else
  903|       |    PJ_CHECK_STACK();
  904|       |    pj_assert(!"No multithreading support!");
  905|       |    return PJ_EINVALIDOP;
  906|       |#endif
  907|  2.26k|}
pj_thread_destroy:
  913|  2.26k|{
  914|  2.26k|    PJ_CHECK_STACK();
  915|       |
  916|       |    /* Destroy mutex used to suspend thread */
  917|  2.26k|    if (p->suspended_mutex) {
  ------------------
  |  Branch (917:9): [True: 0, False: 2.26k]
  ------------------
  918|      0|        pj_mutex_destroy(p->suspended_mutex);
  919|      0|        p->suspended_mutex = NULL;
  920|      0|    }
  921|       |
  922|  2.26k|    return PJ_SUCCESS;
  923|  2.26k|}
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|  11.3k|{
 1247|       |    //Can't check stack because this function is called in the
 1248|       |    //beginning before main thread is initialized.
 1249|       |    //PJ_CHECK_STACK();
 1250|  11.3k|#if PJ_HAS_THREADS
 1251|  11.3k|    int rc=pthread_setspecific(index, value);
 1252|  11.3k|    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: 11.3k, False: 0]
  ------------------
 1253|       |#else
 1254|       |    pj_assert(index >= 0 && index < MAX_THREADS);
 1255|       |    tls[index] = value;
 1256|       |    return PJ_SUCCESS;
 1257|       |#endif
 1258|  11.3k|}
pj_thread_local_get:
 1261|  37.5k|{
 1262|       |    //Can't check stack because this function is called
 1263|       |    //by PJ_CHECK_STACK() itself!!!
 1264|       |    //PJ_CHECK_STACK();
 1265|  37.5k|#if PJ_HAS_THREADS
 1266|  37.5k|    return pthread_getspecific(index);
 1267|       |#else
 1268|       |    pj_assert(index >= 0 && index < MAX_THREADS);
 1269|       |    return tls[index];
 1270|       |#endif
 1271|  37.5k|}
pj_enter_critical_section:
 1275|      3|{
 1276|      3|#if PJ_HAS_THREADS
 1277|      3|    pj_mutex_lock(&critical_section);
 1278|      3|#endif
 1279|      3|}
pj_leave_critical_section:
 1282|      3|{
 1283|      3|#if PJ_HAS_THREADS
 1284|      3|    pj_mutex_unlock(&critical_section);
 1285|      3|#endif
 1286|      3|}
pj_mutex_create:
 1386|  6.80k|{
 1387|  6.80k|#if PJ_HAS_THREADS
 1388|  6.80k|    pj_status_t rc;
 1389|  6.80k|    pj_mutex_t *mutex;
 1390|       |
 1391|  6.80k|    PJ_ASSERT_RETURN(pool && ptr_mutex, PJ_EINVAL);
  ------------------
  |  |   59|  6.80k|            do { \
  |  |   60|  13.6k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:23): [True: 6.80k, False: 0]
  |  |  |  Branch (60:23): [True: 6.80k, False: 0]
  |  |  ------------------
  |  |   61|  6.80k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1392|       |
 1393|  6.80k|    mutex = PJ_POOL_ALLOC_T(pool, pj_mutex_t);
  ------------------
  |  |  506|  6.80k|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
 1394|  6.80k|    PJ_ASSERT_RETURN(mutex, PJ_ENOMEM);
  ------------------
  |  |   59|  6.80k|            do { \
  |  |   60|  6.80k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:21): [True: 0, False: 6.80k]
  |  |  ------------------
  |  |   61|  6.80k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1395|       |
 1396|  6.80k|    if ((rc=init_mutex(mutex, name, type)) != PJ_SUCCESS)
  ------------------
  |  Branch (1396:9): [True: 0, False: 6.80k]
  ------------------
 1397|      0|        return rc;
 1398|       |
 1399|  6.80k|    *ptr_mutex = mutex;
 1400|  6.80k|    return PJ_SUCCESS;
 1401|       |#else /* PJ_HAS_THREADS */
 1402|       |    *ptr_mutex = (pj_mutex_t*)1;
 1403|       |    return PJ_SUCCESS;
 1404|       |#endif
 1405|  6.80k|}
pj_mutex_create_recursive:
 1423|  4.53k|{
 1424|  4.53k|    return pj_mutex_create(pool, name, PJ_MUTEX_RECURSE, mutex);
 1425|  4.53k|}
pj_mutex_lock:
 1431|  13.6k|{
 1432|  13.6k|#if PJ_HAS_THREADS
 1433|  13.6k|    pj_status_t status;
 1434|       |
 1435|  13.6k|    PJ_CHECK_STACK();
 1436|  13.6k|    PJ_ASSERT_RETURN(mutex, PJ_EINVAL);
  ------------------
  |  |   59|  13.6k|            do { \
  |  |   60|  13.6k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:21): [True: 0, False: 13.6k]
  |  |  ------------------
  |  |   61|  13.6k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1437|       |
 1438|  13.6k|#if PJ_DEBUG
 1439|  13.6k|    PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s is waiting (mutex owner=%s)",
  ------------------
  |  |  106|  13.6k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  13.6k|                                    if (level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, False: 13.6k]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  13.6k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1440|  13.6k|                                pj_thread_this()->obj_name,
 1441|  13.6k|                                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|  13.6k|    status = pthread_mutex_lock( &mutex->mutex );
 1448|       |
 1449|       |
 1450|  13.6k|#if PJ_DEBUG
 1451|  13.6k|    if (status == PJ_SUCCESS) {
  ------------------
  |  Branch (1451:9): [True: 13.6k, False: 0]
  ------------------
 1452|  13.6k|        mutex->owner = pj_thread_this();
 1453|  13.6k|        pj_ansi_strxcpy(mutex->owner_name, mutex->owner->obj_name,
 1454|  13.6k|                        sizeof(mutex->owner_name));
 1455|  13.6k|        ++mutex->nesting_level;
 1456|  13.6k|    }
 1457|       |
 1458|  13.6k|    PJ_LOG(6,(mutex->obj_name,
  ------------------
  |  |  106|  13.6k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  13.6k|                                    if (level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, False: 13.6k]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  13.6k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1459|  13.6k|              (status==0 ?
 1460|  13.6k|                "Mutex acquired by thread %s (level=%d)" :
 1461|  13.6k|                "Mutex acquisition FAILED by %s (level=%d)"),
 1462|  13.6k|              pj_thread_this()->obj_name,
 1463|  13.6k|              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|  13.6k|    if (status == 0)
  ------------------
  |  Branch (1470:9): [True: 13.6k, False: 0]
  ------------------
 1471|  13.6k|        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|  13.6k|}
pj_mutex_unlock:
 1484|  13.6k|{
 1485|  13.6k|#if PJ_HAS_THREADS
 1486|  13.6k|    pj_status_t status;
 1487|       |
 1488|  13.6k|    PJ_CHECK_STACK();
 1489|  13.6k|    PJ_ASSERT_RETURN(mutex, PJ_EINVAL);
  ------------------
  |  |   59|  13.6k|            do { \
  |  |   60|  13.6k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:21): [True: 0, False: 13.6k]
  |  |  ------------------
  |  |   61|  13.6k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1490|       |
 1491|  13.6k|#if PJ_DEBUG
 1492|  13.6k|    pj_assert(mutex->owner == pj_thread_this());
  ------------------
  |  |   48|  13.6k|#   define pj_assert(expr)   assert(expr)
  ------------------
 1493|  13.6k|    if (--mutex->nesting_level == 0) {
  ------------------
  |  Branch (1493:9): [True: 13.6k, False: 0]
  ------------------
 1494|  13.6k|        mutex->owner = NULL;
 1495|  13.6k|        mutex->owner_name[0] = '\0';
 1496|  13.6k|    }
 1497|       |
 1498|  13.6k|    PJ_LOG(6,(mutex->obj_name, "Mutex released by thread %s (level=%d)",
  ------------------
  |  |  106|  13.6k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  13.6k|                                    if (level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, False: 13.6k]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  13.6k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1499|  13.6k|                                pj_thread_this()->obj_name,
 1500|  13.6k|                                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|  13.6k|    status = pthread_mutex_unlock( &mutex->mutex );
 1507|  13.6k|    if (status == 0)
  ------------------
  |  Branch (1507:9): [True: 13.6k, False: 0]
  ------------------
 1508|  13.6k|        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|  13.6k|}
pj_mutex_destroy:
 1567|  6.80k|{
 1568|  6.80k|    enum { RETRY = 4 };
 1569|  6.80k|    int status = 0;
 1570|  6.80k|    unsigned retry;
 1571|       |
 1572|  6.80k|    PJ_CHECK_STACK();
 1573|  6.80k|    PJ_ASSERT_RETURN(mutex, PJ_EINVAL);
  ------------------
  |  |   59|  6.80k|            do { \
  |  |   60|  6.80k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:21): [True: 0, False: 6.80k]
  |  |  ------------------
  |  |   61|  6.80k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1574|       |
 1575|  6.80k|#if PJ_HAS_THREADS
 1576|  6.80k|    PJ_LOG(6,(mutex->obj_name, "Mutex destroyed by thread %s",
  ------------------
  |  |  106|  6.80k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  6.80k|                                    if (level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, False: 6.80k]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  6.80k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1577|  6.80k|                               pj_thread_this()->obj_name));
 1578|       |
 1579|  6.80k|    for (retry=0; retry<RETRY; ++retry) {
  ------------------
  |  Branch (1579:19): [True: 6.80k, False: 0]
  ------------------
 1580|  6.80k|        status = pthread_mutex_destroy( &mutex->mutex );
 1581|  6.80k|        if (status == PJ_SUCCESS)
  ------------------
  |  Branch (1581:13): [True: 6.80k, False: 0]
  ------------------
 1582|  6.80k|            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|  6.80k|    }
 1586|       |
 1587|  6.80k|    if (status == 0)
  ------------------
  |  Branch (1587:9): [True: 6.80k, False: 0]
  ------------------
 1588|  6.80k|        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|  6.80k|}
pj_sem_create:
 1729|  2.26k|{
 1730|  2.26k|#if PJ_HAS_THREADS
 1731|  2.26k|    pj_sem_t *sem;
 1732|  2.26k|    PJ_UNUSED_ARG(max);
  ------------------
  |  | 1433|  2.26k|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1733|       |
 1734|  2.26k|    PJ_CHECK_STACK();
 1735|  2.26k|    PJ_ASSERT_RETURN(pool != NULL && ptr_sem != NULL, PJ_EINVAL);
  ------------------
  |  |   59|  2.26k|            do { \
  |  |   60|  4.53k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:23): [True: 2.26k, False: 0]
  |  |  |  Branch (60:23): [True: 2.26k, False: 0]
  |  |  ------------------
  |  |   61|  2.26k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1736|       |
 1737|  2.26k|    sem = PJ_POOL_ALLOC_T(pool, pj_sem_t);
  ------------------
  |  |  506|  2.26k|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
 1738|  2.26k|    PJ_ASSERT_RETURN(sem, PJ_ENOMEM);
  ------------------
  |  |   59|  2.26k|            do { \
  |  |   60|  2.26k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:21): [True: 0, False: 2.26k]
  |  |  ------------------
  |  |   61|  2.26k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1739|       |
 1740|       |#if defined(PJ_DARWINOS) && PJ_DARWINOS!=0
 1741|       |#   if defined(PJ_SEMAPHORE_USE_DISPATCH_SEM) && PJ_SEMAPHORE_USE_DISPATCH_SEM != 0
 1742|       |    sem->sem = dispatch_semaphore_create(initial);
 1743|       |    if (sem->sem == NULL)
 1744|       |        return PJ_RETURN_OS_ERROR(pj_get_native_os_error());
 1745|       |#   else
 1746|       |    /* MacOS X doesn't support anonymous semaphore */
 1747|       |    {
 1748|       |        char sem_name[PJ_GUID_MAX_LENGTH+1];
 1749|       |        pj_str_t nam;
 1750|       |
 1751|       |        /* We should use SEM_NAME_LEN, but this doesn't seem to be
 1752|       |         * declared anywhere? The value here is just from trial and error
 1753|       |         * to get the longest name supported.
 1754|       |         */
 1755|       |#       define MAX_SEM_NAME_LEN 23
 1756|       |
 1757|       |        /* Create a unique name for the semaphore. */
 1758|       |        if (PJ_GUID_STRING_LENGTH <= MAX_SEM_NAME_LEN) {
 1759|       |            nam.ptr = sem_name;
 1760|       |            pj_generate_unique_string(&nam);
 1761|       |            sem_name[nam.slen] = '\0';
 1762|       |        } else {
 1763|       |            pj_create_random_string(sem_name, MAX_SEM_NAME_LEN);
 1764|       |            sem_name[MAX_SEM_NAME_LEN] = '\0';
 1765|       |        }
 1766|       |
 1767|       |        /* Create semaphore */
 1768|       |        sem->sem = sem_open(sem_name, O_CREAT|O_EXCL, S_IRUSR|S_IWUSR,
 1769|       |                            initial);
 1770|       |        if (sem->sem == SEM_FAILED)
 1771|       |            return PJ_RETURN_OS_ERROR(pj_get_native_os_error());
 1772|       |
 1773|       |        /* And immediately release the name as we don't need it */
 1774|       |        sem_unlink(sem_name);
 1775|       |    }
 1776|       |#   endif
 1777|       |#else
 1778|  2.26k|    sem->sem = PJ_POOL_ALLOC_T(pool, sem_t);
  ------------------
  |  |  506|  2.26k|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
 1779|  2.26k|    if (sem_init( sem->sem, 0, initial) != 0)
  ------------------
  |  Branch (1779:9): [True: 0, False: 2.26k]
  ------------------
 1780|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1781|  2.26k|#endif
 1782|       |
 1783|       |    /* Set name. */
 1784|  2.26k|    if (!name) {
  ------------------
  |  Branch (1784:9): [True: 0, False: 2.26k]
  ------------------
 1785|      0|        name = "sem%p";
 1786|      0|    }
 1787|  2.26k|    if (strchr(name, '%')) {
  ------------------
  |  Branch (1787:9): [True: 0, False: 2.26k]
  ------------------
 1788|      0|        pj_ansi_snprintf(sem->obj_name, PJ_MAX_OBJ_NAME, name, sem);
  ------------------
  |  |  114|      0|#define pj_ansi_snprintf        snprintf
  ------------------
                      pj_ansi_snprintf(sem->obj_name, PJ_MAX_OBJ_NAME, name, sem);
  ------------------
  |  |  299|      0|#define PJ_MAX_OBJ_NAME 32
  ------------------
 1789|  2.26k|    } else {
 1790|  2.26k|        pj_ansi_strxcpy(sem->obj_name, name, PJ_MAX_OBJ_NAME);
  ------------------
  |  |  299|  2.26k|#define PJ_MAX_OBJ_NAME 32
  ------------------
 1791|  2.26k|    }
 1792|       |
 1793|  2.26k|    PJ_LOG(6, (sem->obj_name, "Semaphore created"));
  ------------------
  |  |  106|  2.26k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  2.26k|                                    if (level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, False: 2.26k]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  2.26k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1794|       |
 1795|  2.26k|    *ptr_sem = sem;
 1796|  2.26k|    return PJ_SUCCESS;
 1797|       |#else
 1798|       |    PJ_UNUSED_ARG(pool);
 1799|       |    PJ_UNUSED_ARG(name);
 1800|       |    PJ_UNUSED_ARG(initial);
 1801|       |    PJ_UNUSED_ARG(max);
 1802|       |    *ptr_sem = (pj_sem_t*)1;
 1803|       |    return PJ_SUCCESS;
 1804|       |#endif
 1805|  2.26k|}
pj_sem_wait:
 1811|  2.26k|{
 1812|  2.26k|#if PJ_HAS_THREADS
 1813|  2.26k|    long result;
 1814|       |
 1815|  2.26k|    PJ_CHECK_STACK();
 1816|  2.26k|    PJ_ASSERT_RETURN(sem, PJ_EINVAL);
  ------------------
  |  |   59|  2.26k|            do { \
  |  |   60|  2.26k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:21): [True: 0, False: 2.26k]
  |  |  ------------------
  |  |   61|  2.26k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1817|       |
 1818|  2.26k|    PJ_LOG(6, (sem->obj_name, "Semaphore: thread %s is waiting",
  ------------------
  |  |  106|  2.26k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  2.26k|                                    if (level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, False: 2.26k]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  2.26k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1819|  2.26k|                              pj_thread_this()->obj_name));
 1820|       |
 1821|       |#if defined(PJ_SEMAPHORE_USE_DISPATCH_SEM) && PJ_SEMAPHORE_USE_DISPATCH_SEM != 0
 1822|       |    result = dispatch_semaphore_wait(sem->sem, DISPATCH_TIME_FOREVER);
 1823|       |#else
 1824|  2.26k|    result = sem_wait( sem->sem );
 1825|  2.26k|#endif
 1826|       |
 1827|  2.26k|    if (result == 0) {
  ------------------
  |  Branch (1827:9): [True: 2.26k, False: 0]
  ------------------
 1828|  2.26k|        PJ_LOG(6, (sem->obj_name, "Semaphore acquired by thread %s",
  ------------------
  |  |  106|  2.26k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  2.26k|                                    if (level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, False: 2.26k]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  2.26k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1829|  2.26k|                                  pj_thread_this()->obj_name));
 1830|  2.26k|    } else {
 1831|      0|        PJ_LOG(6, (sem->obj_name, "Semaphore: thread %s FAILED to acquire",
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 1832|      0|                                  pj_thread_this()->obj_name));
 1833|      0|    }
 1834|       |
 1835|  2.26k|    if (result == 0)
  ------------------
  |  Branch (1835:9): [True: 2.26k, False: 0]
  ------------------
 1836|  2.26k|        return PJ_SUCCESS;
 1837|      0|    else
 1838|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1839|       |#else
 1840|       |    pj_assert( sem == (pj_sem_t*) 1 );
 1841|       |    return PJ_SUCCESS;
 1842|       |#endif
 1843|  2.26k|}
pj_sem_post:
 1880|  2.26k|{
 1881|  2.26k|#if PJ_HAS_THREADS
 1882|  2.26k|    int result;
 1883|  2.26k|    PJ_LOG(6, (sem->obj_name, "Semaphore released by thread %s",
  ------------------
  |  |  106|  2.26k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  2.26k|                                    if (level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, False: 2.26k]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  2.26k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1884|  2.26k|                              pj_thread_this()->obj_name));
 1885|       |#if defined(PJ_SEMAPHORE_USE_DISPATCH_SEM) && PJ_SEMAPHORE_USE_DISPATCH_SEM != 0
 1886|       |    dispatch_semaphore_signal(sem->sem);
 1887|       |    result = 0;
 1888|       |#else
 1889|  2.26k|    result = sem_post( sem->sem );
 1890|  2.26k|#endif
 1891|       |
 1892|  2.26k|    if (result == 0)
  ------------------
  |  Branch (1892:9): [True: 2.26k, False: 0]
  ------------------
 1893|  2.26k|        return PJ_SUCCESS;
 1894|      0|    else
 1895|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1896|       |#else
 1897|       |    pj_assert( sem == (pj_sem_t*) 1);
 1898|       |    return PJ_SUCCESS;
 1899|       |#endif
 1900|  2.26k|}
pj_sem_destroy:
 1906|  2.26k|{
 1907|  2.26k|#if PJ_HAS_THREADS
 1908|  2.26k|    int result;
 1909|       |
 1910|  2.26k|    PJ_CHECK_STACK();
 1911|  2.26k|    PJ_ASSERT_RETURN(sem, PJ_EINVAL);
  ------------------
  |  |   59|  2.26k|            do { \
  |  |   60|  2.26k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:21): [True: 0, False: 2.26k]
  |  |  ------------------
  |  |   61|  2.26k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1912|       |
 1913|  2.26k|    PJ_LOG(6, (sem->obj_name, "Semaphore destroyed by thread %s",
  ------------------
  |  |  106|  2.26k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  2.26k|                                    if (level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, False: 2.26k]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  2.26k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1914|  2.26k|                              pj_thread_this()->obj_name));
 1915|       |#if defined(PJ_DARWINOS) && PJ_DARWINOS!=0
 1916|       |#   if defined(PJ_SEMAPHORE_USE_DISPATCH_SEM) && PJ_SEMAPHORE_USE_DISPATCH_SEM != 0
 1917|       |    dispatch_release(sem->sem);
 1918|       |    result = 0;
 1919|       |#   else
 1920|       |    result = sem_close( sem->sem );
 1921|       |#   endif
 1922|       |#else
 1923|  2.26k|    result = sem_destroy( sem->sem );
 1924|  2.26k|#endif
 1925|       |
 1926|  2.26k|    if (result == 0)
  ------------------
  |  Branch (1926:9): [True: 2.26k, False: 0]
  ------------------
 1927|  2.26k|        return PJ_SUCCESS;
 1928|      0|    else
 1929|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1930|       |#else
 1931|       |    pj_assert( sem == (pj_sem_t*) 1 );
 1932|       |    return PJ_SUCCESS;
 1933|       |#endif
 1934|  2.26k|}
os_core_unix.c:thread_main:
  675|  2.26k|{
  676|  2.26k|    pj_thread_t *rec = (pj_thread_t*)param;
  677|  2.26k|    void *result;
  678|  2.26k|    pj_status_t rc;
  679|       |
  680|       |#if defined(PJ_OS_HAS_CHECK_STACK) && PJ_OS_HAS_CHECK_STACK!=0
  681|       |    rec->stk_start = (char*)&rec;
  682|       |#endif
  683|       |
  684|       |    /* Set current thread id. */
  685|  2.26k|    rc = pj_thread_local_set(thread_tls_id, rec);
  686|  2.26k|    if (rc != PJ_SUCCESS) {
  ------------------
  |  Branch (686:9): [True: 0, False: 2.26k]
  ------------------
  687|      0|        pj_assert(!"Thread TLS ID is not set (pj_init() error?)");
  ------------------
  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  ------------------
  688|      0|    }
  689|       |
  690|       |    /* Check if suspension is required. */
  691|  2.26k|    if (rec->suspended_mutex) {
  ------------------
  |  Branch (691:9): [True: 0, False: 2.26k]
  ------------------
  692|      0|        pj_mutex_lock(rec->suspended_mutex);
  693|      0|        pj_mutex_unlock(rec->suspended_mutex);
  694|      0|    }
  695|       |
  696|  2.26k|    PJ_LOG(6,(rec->obj_name, "Thread started"));
  ------------------
  |  |  106|  2.26k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  2.26k|                                    if (level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, False: 2.26k]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  2.26k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded - Ignored]
  |  |  ------------------
  ------------------
  697|       |
  698|  2.26k|    set_thread_display_name(rec->obj_name);
  699|       |
  700|       |    /* Call user's entry! */
  701|  2.26k|    result = (void*)(long)(*rec->proc)(rec->arg);
  702|       |
  703|       |    /* Done. */
  704|  2.26k|    PJ_LOG(6,(rec->obj_name, "Thread quitting"));
  ------------------
  |  |  106|  2.26k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  2.26k|                                    if (level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, False: 2.26k]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  2.26k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded - Ignored]
  |  |  ------------------
  ------------------
  705|       |
  706|  2.26k|    return result;
  707|  2.26k|}
os_core_unix.c:set_thread_display_name:
  643|  2.26k|{
  644|  2.26k|#if (defined(PJ_LINUX) && PJ_LINUX != 0) || \
  645|  2.26k|    (defined(PJ_ANDROID) && PJ_ANDROID != 0)
  646|  2.26k|    char xname[16];
  647|       |    // On linux, thread display name length is restricted to 16 (include '\0')
  648|  2.26k|    if (pj_ansi_strlen(name) >= 16) {
  ------------------
  |  |   69|  2.26k|#define pj_ansi_strlen          strlen
  ------------------
  |  Branch (648:9): [True: 0, False: 2.26k]
  ------------------
  649|      0|        pj_memcpy(xname, name, 15);
  650|      0|        xname[15] = '\0';
  651|      0|        name = xname;
  652|      0|    }
  653|  2.26k|#endif
  654|       |
  655|  2.26k|#if defined(PJ_HAS_PTHREAD_SETNAME_NP) && PJ_HAS_PTHREAD_SETNAME_NP != 0
  656|       |#   if defined(PJ_DARWINOS) && PJ_DARWINOS != 0
  657|       |    pthread_setname_np(name);
  658|       |#   else
  659|  2.26k|    pthread_setname_np(pthread_self(), name);
  660|  2.26k|#   endif
  661|       |#elif defined(PJ_HAS_PTHREAD_SET_NAME_NP) && PJ_HAS_PTHREAD_SET_NAME_NP != 0
  662|       |    pthread_set_name_np(pthread_self(), name);
  663|       |#else
  664|       |// #   warning "OS does not support set thread display name"
  665|       |    PJ_UNUSED_ARG(name);
  666|       |#endif
  667|  2.26k|}
os_core_unix.c:init_mutex:
 1297|  6.80k|{
 1298|  6.80k|#if PJ_HAS_THREADS
 1299|  6.80k|    pthread_mutexattr_t attr;
 1300|  6.80k|    int rc;
 1301|       |
 1302|  6.80k|    PJ_CHECK_STACK();
 1303|       |
 1304|  6.80k|    rc = pthread_mutexattr_init(&attr);
 1305|  6.80k|    if (rc != 0)
  ------------------
  |  Branch (1305:9): [True: 0, False: 6.80k]
  ------------------
 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|  6.80k|    if (type == PJ_MUTEX_SIMPLE) {
  ------------------
  |  Branch (1308:9): [True: 2.26k, False: 4.53k]
  ------------------
 1309|  2.26k|#if (defined(PJ_LINUX) && PJ_LINUX!=0) || \
 1310|  2.26k|    defined(PJ_HAS_PTHREAD_MUTEXATTR_SETTYPE)
 1311|  2.26k|        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|  4.53k|    } else {
 1319|  4.53k|#if (defined(PJ_LINUX) && PJ_LINUX!=0) || \
 1320|  4.53k|     defined(PJ_HAS_PTHREAD_MUTEXATTR_SETTYPE)
 1321|  4.53k|        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|  4.53k|    }
 1338|       |
 1339|  6.80k|    if (rc != 0) {
  ------------------
  |  Branch (1339:9): [True: 0, False: 6.80k]
  ------------------
 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|  6.80k|    rc = pthread_mutex_init(&mutex->mutex, &attr);
 1344|  6.80k|    if (rc != 0) {
  ------------------
  |  Branch (1344:9): [True: 0, False: 6.80k]
  ------------------
 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|  6.80k|    rc = pthread_mutexattr_destroy(&attr);
 1349|  6.80k|    if (rc != 0) {
  ------------------
  |  Branch (1349:9): [True: 0, False: 6.80k]
  ------------------
 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|  6.80k|#if PJ_DEBUG
 1356|       |    /* Set owner. */
 1357|  6.80k|    mutex->nesting_level = 0;
 1358|  6.80k|    mutex->owner = NULL;
 1359|  6.80k|    mutex->owner_name[0] = '\0';
 1360|  6.80k|#endif
 1361|       |
 1362|       |    /* Set name. */
 1363|  6.80k|    if (!name) {
  ------------------
  |  Branch (1363:9): [True: 0, False: 6.80k]
  ------------------
 1364|      0|        name = "mtx%p";
 1365|      0|    }
 1366|  6.80k|    if (strchr(name, '%')) {
  ------------------
  |  Branch (1366:9): [True: 0, False: 6.80k]
  ------------------
 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|  6.80k|    } else {
 1369|  6.80k|        pj_ansi_strxcpy(mutex->obj_name, name, PJ_MAX_OBJ_NAME);
  ------------------
  |  |  299|  6.80k|#define PJ_MAX_OBJ_NAME 32
  ------------------
 1370|  6.80k|    }
 1371|       |
 1372|  6.80k|    PJ_LOG(6, (mutex->obj_name, "Mutex created"));
  ------------------
  |  |  106|  6.80k|#define PJ_LOG(level,arg)       do { \
  |  |  107|  6.80k|                                    if (level <= pj_log_get_level()) { \
  |  |  ------------------
  |  |  |  Branch (107:41): [True: 0, False: 6.80k]
  |  |  ------------------
  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  109|      0|                                    } \
  |  |  110|  6.80k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (110:42): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1373|  6.80k|    return PJ_SUCCESS;
 1374|       |#else /* PJ_HAS_THREADS */
 1375|       |    return PJ_SUCCESS;
 1376|       |#endif
 1377|  6.80k|}

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_allocate_find:
   94|  8.84k|{
   95|  8.84k|    pj_pool_block *block = pool->block_list.next;
   96|  8.84k|    void *p;
   97|  8.84k|    pj_size_t block_size;
   98|  8.84k|    unsigned i = 0;
   99|       |
  100|  8.84k|    PJ_CHECK_STACK();
  101|       |
  102|  29.5k|    while (block != &pool->block_list) {
  ------------------
  |  Branch (102:12): [True: 24.3k, False: 5.20k]
  ------------------
  103|  24.3k|        p = pj_pool_alloc_from_block(block, size);
  104|  24.3k|        if (p != NULL)
  ------------------
  |  Branch (104:13): [True: 1.31k, False: 23.0k]
  ------------------
  105|  1.31k|            return p;
  106|       |
  107|  23.0k|#if PJ_POOL_MAX_SEARCH_BLOCK_COUNT > 0
  108|  23.0k|        if (i >= PJ_POOL_MAX_SEARCH_BLOCK_COUNT) {
  ------------------
  |  |  559|  23.0k|#   define PJ_POOL_MAX_SEARCH_BLOCK_COUNT 5
  ------------------
  |  Branch (108:13): [True: 2.33k, False: 20.7k]
  ------------------
  109|  2.33k|            break;
  110|  2.33k|        }
  111|  20.7k|#endif
  112|       |
  113|  20.7k|        i++;
  114|  20.7k|        block = block->next;
  115|  20.7k|    }
  116|       |    /* No available space in all blocks. */
  117|       |
  118|       |    /* If pool is configured NOT to expand, return error. */
  119|  7.53k|    if (pool->increment_size == 0) {
  ------------------
  |  Branch (119:9): [True: 0, False: 7.53k]
  ------------------
  120|      0|        LOG((pool->obj_name, "Can't expand pool to allocate %lu bytes "
  ------------------
  |  |   33|      0|#define LOG(expr)                   PJ_LOG(6,expr)
  |  |  ------------------
  |  |  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  |  |  107|      0|                                    if (level <= pj_log_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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  121|      0|             "(used=%lu, cap=%lu)",
  122|      0|             (unsigned long)size, (unsigned long)pj_pool_get_used_size(pool),
  123|      0|             (unsigned long)pool->capacity));
  124|      0|        (*pool->callback)(pool, size);
  125|      0|        return NULL;
  126|      0|    }
  127|       |
  128|       |    /* If pool is configured to expand, but the increment size
  129|       |     * is less than the required size, expand the pool by multiple
  130|       |     * increment size. Also count the size wasted due to aligning
  131|       |     * the block.
  132|       |     */
  133|  7.53k|    if (pool->increment_size < 
  ------------------
  |  Branch (133:9): [True: 2.26k, False: 5.26k]
  ------------------
  134|  7.53k|            size + sizeof(pj_pool_block) + PJ_POOL_ALIGNMENT) 
  ------------------
  |  |  182|  7.53k|#define PJ_POOL_ALIGNMENT 8
  ------------------
  135|  2.26k|    {
  136|  2.26k|        pj_size_t count;
  137|  2.26k|        count = (size + pool->increment_size + sizeof(pj_pool_block) +
  138|  2.26k|                 PJ_POOL_ALIGNMENT) / 
  ------------------
  |  |  182|  2.26k|#define PJ_POOL_ALIGNMENT 8
  ------------------
  139|  2.26k|                pool->increment_size;
  140|  2.26k|        block_size = count * pool->increment_size;
  141|       |
  142|  5.26k|    } else {
  143|  5.26k|        block_size = pool->increment_size;
  144|  5.26k|    }
  145|       |
  146|  7.53k|    LOG((pool->obj_name, 
  ------------------
  |  |   33|  7.53k|#define LOG(expr)                   PJ_LOG(6,expr)
  |  |  ------------------
  |  |  |  |  106|  7.53k|#define PJ_LOG(level,arg)       do { \
  |  |  |  |  107|  7.53k|                                    if (level <= pj_log_get_level()) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:41): [True: 0, False: 7.53k]
  |  |  |  |  ------------------
  |  |  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  |  |  109|      0|                                    } \
  |  |  |  |  110|  7.53k|                                } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (110:42): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  147|  7.53k|         "%lu bytes requested, resizing pool by %lu bytes (used=%lu, cap=%lu)",
  148|  7.53k|         (unsigned long)size, (unsigned long)block_size,
  149|  7.53k|         (unsigned long)pj_pool_get_used_size(pool),
  150|  7.53k|         (unsigned long)pool->capacity));
  151|       |
  152|  7.53k|    block = pj_pool_create_block(pool, block_size);
  153|  7.53k|    if (!block)
  ------------------
  |  Branch (153:9): [True: 0, False: 7.53k]
  ------------------
  154|      0|        return NULL;
  155|       |
  156|  7.53k|    p = pj_pool_alloc_from_block(block, size);
  157|  7.53k|    pj_assert(p != NULL);
  ------------------
  |  |   48|  7.53k|#   define pj_assert(expr)   assert(expr)
  ------------------
  158|  7.53k|#if PJ_DEBUG
  159|  7.53k|    if (p == NULL) {
  ------------------
  |  Branch (159:9): [True: 0, False: 7.53k]
  ------------------
  160|      0|        PJ_UNUSED_ARG(p);
  ------------------
  |  | 1433|      0|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
  161|      0|    }
  162|  7.53k|#endif
  163|  7.53k|    return p;
  164|  7.53k|}
pj_pool_init_int:
  173|  9.07k|{
  174|  9.07k|    PJ_CHECK_STACK();
  175|       |
  176|  9.07k|    pool->increment_size = increment_size;
  177|  9.07k|    pool->callback = callback;
  178|       |
  179|  9.07k|    if (name) {
  ------------------
  |  Branch (179:9): [True: 9.07k, False: 0]
  ------------------
  180|  9.07k|        if (strchr(name, '%') != NULL) {
  ------------------
  |  Branch (180:13): [True: 0, False: 9.07k]
  ------------------
  181|      0|            pj_ansi_snprintf(pool->obj_name, sizeof(pool->obj_name), 
  ------------------
  |  |  114|      0|#define pj_ansi_snprintf        snprintf
  ------------------
  182|      0|                             name, pool);
  183|  9.07k|        } else {
  184|  9.07k|            pj_ansi_strxcpy(pool->obj_name, name, PJ_MAX_OBJ_NAME);
  ------------------
  |  |  299|  9.07k|#define PJ_MAX_OBJ_NAME 32
  ------------------
  185|  9.07k|        }
  186|  9.07k|    } else {
  187|      0|        pool->obj_name[0] = '\0';
  188|      0|    }
  189|  9.07k|}
pj_pool_create_int:
  198|  9.07k|{
  199|  9.07k|    pj_pool_t *pool;
  200|  9.07k|    pj_pool_block *block;
  201|  9.07k|    pj_uint8_t *buffer;
  202|       |
  203|  9.07k|    PJ_CHECK_STACK();
  204|       |
  205|       |    /* Size must be at least sizeof(pj_pool)+sizeof(pj_pool_block) */
  206|  9.07k|    PJ_ASSERT_RETURN(initial_size >= sizeof(pj_pool_t)+sizeof(pj_pool_block),
  ------------------
  |  |   59|  9.07k|            do { \
  |  |   60|  9.07k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:21): [True: 0, False: 9.07k]
  |  |  ------------------
  |  |   61|  9.07k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
  207|  9.07k|                     NULL);
  208|       |
  209|       |    /* If callback is NULL, set calback from the policy */
  210|  9.07k|    if (callback == NULL)
  ------------------
  |  Branch (210:9): [True: 0, False: 9.07k]
  ------------------
  211|      0|        callback = f->policy.callback;
  212|       |
  213|       |    /* Allocate initial block */
  214|  9.07k|    buffer = (pj_uint8_t*) (*f->policy.block_alloc)(f, initial_size);
  215|  9.07k|    if (!buffer)
  ------------------
  |  Branch (215:9): [True: 0, False: 9.07k]
  ------------------
  216|      0|        return NULL;
  217|       |
  218|       |    /* Set pool administrative data. */
  219|  9.07k|    pool = (pj_pool_t*)buffer;
  220|  9.07k|    pj_bzero(pool, sizeof(*pool));
  221|       |
  222|  9.07k|    pj_list_init(&pool->block_list);
  223|  9.07k|    pool->factory = f;
  224|       |
  225|       |    /* Create the first block from the memory. */
  226|  9.07k|    block = (pj_pool_block*) (buffer + sizeof(*pool));
  227|  9.07k|    block->buf = ((unsigned char*)block) + sizeof(pj_pool_block);
  228|  9.07k|    block->end = buffer + initial_size;
  229|       |
  230|       |    /* Set the start pointer, aligning it as needed */
  231|  9.07k|    block->cur = ALIGN_PTR(block->buf, PJ_POOL_ALIGNMENT);
  ------------------
  |  |   34|  9.07k|#define ALIGN_PTR(PTR,ALIGNMENT)    (PTR + (-(pj_ssize_t)(PTR) & (ALIGNMENT-1)))
  ------------------
  232|       |
  233|  9.07k|    pj_list_insert_after(&pool->block_list, block);
  234|       |
  235|  9.07k|    pj_pool_init_int(pool, name, increment_size, callback);
  236|       |
  237|       |    /* Pool initial capacity and used size */
  238|  9.07k|    pool->capacity = initial_size;
  239|       |
  240|  9.07k|    LOG((pool->obj_name, "pool created, size=%lu",
  ------------------
  |  |   33|  9.07k|#define LOG(expr)                   PJ_LOG(6,expr)
  |  |  ------------------
  |  |  |  |  106|  9.07k|#define PJ_LOG(level,arg)       do { \
  |  |  |  |  107|  9.07k|                                    if (level <= pj_log_get_level()) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:41): [True: 0, False: 9.07k]
  |  |  |  |  ------------------
  |  |  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  |  |  109|      0|                                    } \
  |  |  |  |  110|  9.07k|                                } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (110:42): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  241|  9.07k|                         (unsigned long)pool->capacity));
  242|  9.07k|    return pool;
  243|  9.07k|}
pj_pool_destroy_int:
  298|  6.80k|{
  299|  6.80k|    pj_size_t initial_size;
  300|       |
  301|  6.80k|    LOG((pool->obj_name, "destroy(): cap=%lu, used=%lu(%lu%%), block0=%p-%p", 
  ------------------
  |  |   33|  6.80k|#define LOG(expr)                   PJ_LOG(6,expr)
  |  |  ------------------
  |  |  |  |  106|  6.80k|#define PJ_LOG(level,arg)       do { \
  |  |  |  |  107|  6.80k|                                    if (level <= pj_log_get_level()) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:41): [True: 0, False: 6.80k]
  |  |  |  |  ------------------
  |  |  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  |  |  109|      0|                                    } \
  |  |  |  |  110|  6.80k|                                } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (110:42): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  302|  6.80k|        (unsigned long)pool->capacity,
  303|  6.80k|        (unsigned long)pj_pool_get_used_size(pool),
  304|  6.80k|        (unsigned long)(pj_pool_get_used_size(pool)*100/pool->capacity),
  305|  6.80k|        ((pj_pool_block*)pool->block_list.next)->buf, 
  306|  6.80k|        ((pj_pool_block*)pool->block_list.next)->end));
  307|       |
  308|  6.80k|    reset_pool(pool);
  309|  6.80k|    initial_size = ((pj_pool_block*)pool->block_list.next)->end - 
  310|  6.80k|                   (unsigned char*)pool;
  311|  6.80k|    if (pool->factory->policy.block_free)
  ------------------
  |  Branch (311:9): [True: 6.80k, False: 0]
  ------------------
  312|  6.80k|        (*pool->factory->policy.block_free)(pool->factory, pool, initial_size);
  313|  6.80k|}
pool.c:pj_pool_create_block:
   49|  7.53k|{
   50|  7.53k|    pj_pool_block *block;
   51|       |
   52|  7.53k|    PJ_CHECK_STACK();
   53|  7.53k|    pj_assert(size >= sizeof(pj_pool_block));
  ------------------
  |  |   48|  7.53k|#   define pj_assert(expr)   assert(expr)
  ------------------
   54|       |
   55|  7.53k|    LOG((pool->obj_name, "create_block(sz=%lu), cur.cap=%lu, cur.used=%lu", 
  ------------------
  |  |   33|  7.53k|#define LOG(expr)                   PJ_LOG(6,expr)
  |  |  ------------------
  |  |  |  |  106|  7.53k|#define PJ_LOG(level,arg)       do { \
  |  |  |  |  107|  7.53k|                                    if (level <= pj_log_get_level()) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:41): [True: 0, False: 7.53k]
  |  |  |  |  ------------------
  |  |  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  |  |  109|      0|                                    } \
  |  |  |  |  110|  7.53k|                                } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (110:42): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   56|  7.53k|         (unsigned long)size, (unsigned long)pool->capacity,
   57|  7.53k|         (unsigned long)pj_pool_get_used_size(pool)));
   58|       |
   59|       |    /* Request memory from allocator. */
   60|  7.53k|    block = (pj_pool_block*) 
   61|  7.53k|        (*pool->factory->policy.block_alloc)(pool->factory, size);
   62|  7.53k|    if (block == NULL) {
  ------------------
  |  Branch (62:9): [True: 0, False: 7.53k]
  ------------------
   63|      0|        (*pool->callback)(pool, size);
   64|      0|        return NULL;
   65|      0|    }
   66|       |
   67|       |    /* Add capacity. */
   68|  7.53k|    pool->capacity += size;
   69|       |
   70|       |    /* Set start and end of buffer. */
   71|  7.53k|    block->buf = ((unsigned char*)block) + sizeof(pj_pool_block);
   72|  7.53k|    block->end = ((unsigned char*)block) + size;
   73|       |
   74|       |    /* Set the start pointer, aligning it as needed */
   75|  7.53k|    block->cur = ALIGN_PTR(block->buf, PJ_POOL_ALIGNMENT);
  ------------------
  |  |   34|  7.53k|#define ALIGN_PTR(PTR,ALIGNMENT)    (PTR + (-(pj_ssize_t)(PTR) & (ALIGNMENT-1)))
  ------------------
   76|       |
   77|       |    /* Insert in the front of the list. */
   78|  7.53k|    pj_list_insert_after(&pool->block_list, block);
   79|       |
   80|  7.53k|    LOG((pool->obj_name," block created, buffer=%p-%p",block->buf, block->end));
  ------------------
  |  |   33|  7.53k|#define LOG(expr)                   PJ_LOG(6,expr)
  |  |  ------------------
  |  |  |  |  106|  7.53k|#define PJ_LOG(level,arg)       do { \
  |  |  |  |  107|  7.53k|                                    if (level <= pj_log_get_level()) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (107:41): [True: 0, False: 7.53k]
  |  |  |  |  ------------------
  |  |  |  |  108|      0|                                        pj_log_wrapper_##level(arg); \
  |  |  |  |  109|      0|                                    } \
  |  |  |  |  110|  7.53k|                                } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (110:42): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   81|       |
   82|  7.53k|    return block;
   83|  7.53k|}
pool.c:reset_pool:
  251|  6.80k|{
  252|  6.80k|    pj_pool_block *block;
  253|       |
  254|  6.80k|    PJ_CHECK_STACK();
  255|       |
  256|  6.80k|    block = pool->block_list.prev;
  257|  6.80k|    if (block == &pool->block_list)
  ------------------
  |  Branch (257:9): [True: 0, False: 6.80k]
  ------------------
  258|      0|        return;
  259|       |
  260|       |    /* Skip the first block because it is occupying the same memory
  261|       |       as the pool itself.
  262|       |    */
  263|  6.80k|    block = block->prev;
  264|       |    
  265|  14.3k|    while (block != &pool->block_list) {
  ------------------
  |  Branch (265:12): [True: 7.53k, False: 6.80k]
  ------------------
  266|  7.53k|        pj_pool_block *prev = block->prev;
  267|  7.53k|        pj_list_erase(block);
  268|  7.53k|        (*pool->factory->policy.block_free)(pool->factory, block, 
  269|  7.53k|                                            block->end - (unsigned char*)block);
  270|  7.53k|        block = prev;
  271|  7.53k|    }
  272|       |
  273|  6.80k|    block = pool->block_list.next;
  274|       |
  275|       |    /* Set the start pointer, aligning it as needed */
  276|  6.80k|    block->cur = ALIGN_PTR(block->buf, PJ_POOL_ALIGNMENT);
  ------------------
  |  |   34|  6.80k|#define ALIGN_PTR(PTR,ALIGNMENT)    (PTR + (-(pj_ssize_t)(PTR) & (ALIGNMENT-1)))
  ------------------
  277|       |
  278|  6.80k|    pool->capacity = block->end - (unsigned char*)pool;
  279|  6.80k|}

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

pj_caching_pool_init:
   56|  2.26k|{
   57|  2.26k|    int i;
   58|  2.26k|    pj_pool_t *pool;
   59|  2.26k|    pj_status_t status;
   60|       |
   61|  2.26k|    PJ_CHECK_STACK();
   62|       |
   63|  2.26k|    pj_bzero(cp, sizeof(*cp));
   64|       |    
   65|  2.26k|    cp->max_capacity = max_capacity;
   66|  2.26k|    pj_list_init(&cp->used_list);
   67|  38.5k|    for (i=0; i<PJ_CACHING_POOL_ARRAY_SIZE; ++i)
  ------------------
  |  |  815|  38.5k|#define PJ_CACHING_POOL_ARRAY_SIZE      16
  ------------------
  |  Branch (67:15): [True: 36.3k, False: 2.26k]
  ------------------
   68|  36.3k|        pj_list_init(&cp->free_list[i]);
   69|       |
   70|  2.26k|    if (policy == NULL) {
  ------------------
  |  Branch (70:9): [True: 0, False: 2.26k]
  ------------------
   71|      0|        policy = &pj_pool_factory_default_policy;
   72|      0|    }
   73|       |    
   74|  2.26k|    pj_memcpy(&cp->factory.policy, policy, sizeof(pj_pool_factory_policy));
   75|  2.26k|    cp->factory.create_pool = &cpool_create_pool;
   76|  2.26k|    cp->factory.release_pool = &cpool_release_pool;
   77|  2.26k|    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|  2.26k|    pool = pj_pool_create_on_buf("cachingpool", cp->pool_buf, sizeof(cp->pool_buf));
   86|  2.26k|    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|  2.26k|    PJ_ASSERT_ON_FAIL(status==PJ_SUCCESS, return);
  ------------------
  |  |   73|  2.26k|            { \
  |  |   74|  2.26k|                pj_assert(expr); \
  |  |  ------------------
  |  |  |  |   48|  2.26k|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |   75|  2.26k|                if (!(expr)) exec_on_fail; \
  |  |  ------------------
  |  |  |  Branch (75:21): [True: 0, False: 2.26k]
  |  |  ------------------
  |  |   76|  2.26k|            }
  ------------------
   90|  2.26k|}
pj_caching_pool_destroy:
   93|  2.26k|{
   94|  2.26k|    int i;
   95|  2.26k|    pj_pool_t *pool;
   96|       |
   97|  2.26k|    PJ_CHECK_STACK();
   98|       |
   99|       |    /* Delete all pool in free list */
  100|  38.5k|    for (i=0; i < PJ_CACHING_POOL_ARRAY_SIZE; ++i) {
  ------------------
  |  |  815|  38.5k|#define PJ_CACHING_POOL_ARRAY_SIZE      16
  ------------------
  |  Branch (100:15): [True: 36.3k, False: 2.26k]
  ------------------
  101|  36.3k|        pj_pool_t *next;
  102|  36.3k|        pool = (pj_pool_t*) cp->free_list[i].next;
  103|  36.3k|        for (; pool != (void*)&cp->free_list[i]; pool = next) {
  ------------------
  |  Branch (103:16): [True: 0, False: 36.3k]
  ------------------
  104|      0|            next = pool->next;
  105|      0|            pj_list_erase(pool);
  106|      0|            pj_pool_destroy_int(pool);
  107|      0|        }
  108|  36.3k|    }
  109|       |
  110|       |    /* Delete all pools in used list */
  111|  2.26k|    pool = (pj_pool_t*) cp->used_list.next;
  112|  2.26k|    while (pool != (pj_pool_t*) &cp->used_list) {
  ------------------
  |  Branch (112:12): [True: 0, False: 2.26k]
  ------------------
  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|  2.26k|    if (cp->lock) {
  ------------------
  |  Branch (121:9): [True: 2.26k, False: 0]
  ------------------
  122|  2.26k|        pj_lock_destroy(cp->lock);
  123|  2.26k|        pj_lock_create_null_mutex(NULL, "cachingpool", &cp->lock);
  124|  2.26k|    }
  125|  2.26k|}
pool_caching.c:cpool_create_pool:
  132|  6.80k|{
  133|  6.80k|    pj_caching_pool *cp = (pj_caching_pool*)pf;
  134|  6.80k|    pj_pool_t *pool;
  135|  6.80k|    int idx;
  136|       |
  137|  6.80k|    PJ_CHECK_STACK();
  138|       |
  139|  6.80k|    pj_lock_acquire(cp->lock);
  140|       |
  141|       |    /* Use pool factory's policy when callback is NULL */
  142|  6.80k|    if (callback == NULL) {
  ------------------
  |  Branch (142:9): [True: 6.80k, False: 0]
  ------------------
  143|  6.80k|        callback = pf->policy.callback;
  144|  6.80k|    }
  145|       |
  146|       |    /* Search the suitable size for the pool. 
  147|       |     * We'll just do linear search to the size array, as the array size itself
  148|       |     * is only a few elements. Binary search I suspect will be less efficient
  149|       |     * for this purpose.
  150|       |     */
  151|  6.80k|    if (initial_size <= pool_sizes[START_SIZE]) {
  ------------------
  |  |   50|  6.80k|#define START_SIZE  5
  ------------------
  |  Branch (151:9): [True: 6.80k, False: 0]
  ------------------
  152|  6.80k|        for (idx=START_SIZE-1; 
  ------------------
  |  |   50|  6.80k|#define START_SIZE  5
  ------------------
  153|  24.9k|             idx >= 0 && pool_sizes[idx] >= initial_size;
  ------------------
  |  Branch (153:14): [True: 24.9k, False: 0]
  |  Branch (153:26): [True: 18.1k, False: 6.80k]
  ------------------
  154|  18.1k|             --idx)
  155|  18.1k|            ;
  156|  6.80k|        ++idx;
  157|  6.80k|    } else {
  158|      0|        for (idx=START_SIZE+1; 
  ------------------
  |  |   50|      0|#define START_SIZE  5
  ------------------
  159|      0|             idx < PJ_CACHING_POOL_ARRAY_SIZE && 
  ------------------
  |  |  815|      0|#define PJ_CACHING_POOL_ARRAY_SIZE      16
  ------------------
  |  Branch (159:14): [True: 0, False: 0]
  ------------------
  160|      0|                  pool_sizes[idx] < initial_size;
  ------------------
  |  Branch (160:19): [True: 0, False: 0]
  ------------------
  161|      0|             ++idx)
  162|      0|            ;
  163|      0|    }
  164|       |
  165|       |    /* Check whether there's a pool in the list. */
  166|  6.80k|    if (idx==PJ_CACHING_POOL_ARRAY_SIZE || pj_list_empty(&cp->free_list[idx])) {
  ------------------
  |  |  815|  13.6k|#define PJ_CACHING_POOL_ARRAY_SIZE      16
  ------------------
  |  Branch (166:9): [True: 0, False: 6.80k]
  |  Branch (166:44): [True: 6.80k, False: 0]
  ------------------
  167|       |        /* No pool is available. */
  168|       |        /* Set minimum size. */
  169|  6.80k|        if (idx < PJ_CACHING_POOL_ARRAY_SIZE)
  ------------------
  |  |  815|  6.80k|#define PJ_CACHING_POOL_ARRAY_SIZE      16
  ------------------
  |  Branch (169:13): [True: 6.80k, False: 0]
  ------------------
  170|  6.80k|            initial_size =  pool_sizes[idx];
  171|       |
  172|       |        /* Create new pool */
  173|  6.80k|        pool = pj_pool_create_int(&cp->factory, name, initial_size, 
  174|  6.80k|                                  increment_sz, callback);
  175|  6.80k|        if (!pool) {
  ------------------
  |  Branch (175:13): [True: 0, False: 6.80k]
  ------------------
  176|      0|            pj_lock_release(cp->lock);
  177|      0|            return NULL;
  178|      0|        }
  179|       |
  180|  6.80k|    } else {
  181|       |        /* Get one pool from the list. */
  182|      0|        pool = (pj_pool_t*) cp->free_list[idx].next;
  183|      0|        pj_list_erase(pool);
  184|       |
  185|       |        /* Initialize the pool. */
  186|      0|        pj_pool_init_int(pool, name, increment_sz, callback);
  187|       |
  188|       |        /* Update pool manager's free capacity. */
  189|      0|        if (cp->capacity > pj_pool_get_capacity(pool)) {
  ------------------
  |  Branch (189:13): [True: 0, False: 0]
  ------------------
  190|      0|            cp->capacity -= pj_pool_get_capacity(pool);
  191|      0|        } else {
  192|      0|            cp->capacity = 0;
  193|      0|        }
  194|       |
  195|      0|        PJ_LOG(6, (pool->obj_name, "pool reused, size=%lu",
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= pj_log_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]
  |  |  ------------------
  ------------------
  196|      0|                   (unsigned long)pool->capacity));
  197|      0|    }
  198|       |
  199|       |    /* Put in used list. */
  200|  6.80k|    pj_list_insert_before( &cp->used_list, pool );
  201|       |
  202|       |    /* Mark factory data */
  203|  6.80k|    pool->factory_data = (void*) (pj_ssize_t) idx;
  204|       |
  205|       |    /* Increment used count. */
  206|  6.80k|    ++cp->used_count;
  207|       |
  208|  6.80k|    pj_lock_release(cp->lock);
  209|  6.80k|    return pool;
  210|  6.80k|}
pool_caching.c:cpool_release_pool:
  213|  6.80k|{
  214|  6.80k|    pj_caching_pool *cp = (pj_caching_pool*)pf;
  215|  6.80k|    pj_size_t pool_capacity;
  216|  6.80k|    unsigned i;
  217|       |
  218|  6.80k|    PJ_CHECK_STACK();
  219|       |
  220|  6.80k|    PJ_ASSERT_ON_FAIL(pf && pool, return);
  ------------------
  |  |   73|  6.80k|            { \
  |  |   74|  6.80k|                pj_assert(expr); \
  |  |  ------------------
  |  |  |  |   48|  6.80k|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |   75|  13.6k|                if (!(expr)) exec_on_fail; \
  |  |  ------------------
  |  |  |  Branch (75:23): [True: 6.80k, False: 0]
  |  |  |  Branch (75:23): [True: 6.80k, False: 0]
  |  |  ------------------
  |  |   76|  6.80k|            }
  ------------------
  221|       |
  222|  6.80k|    pj_lock_acquire(cp->lock);
  223|       |
  224|       |#if PJ_SAFE_POOL
  225|       |    /* Make sure pool is still in our used list */
  226|       |    if (pj_list_find_node(&cp->used_list, pool) != pool) {
  227|       |        pj_lock_release(cp->lock);
  228|       |        pj_assert(!"Attempt to destroy pool that has been destroyed before");
  229|       |        return;
  230|       |    }
  231|       |#endif
  232|       |
  233|       |    /* Erase from the used list. */
  234|  6.80k|    pj_list_erase(pool);
  235|       |
  236|       |    /* Decrement used count. */
  237|  6.80k|    --cp->used_count;
  238|       |
  239|  6.80k|    pool_capacity = pj_pool_get_capacity(pool);
  240|       |
  241|       |    /* Destroy the pool if the size is greater than our size or if the total
  242|       |     * capacity in our recycle list (plus the size of the pool) exceeds 
  243|       |     * maximum capacity.
  244|       |   . */
  245|  6.80k|    if (pool_capacity > pool_sizes[PJ_CACHING_POOL_ARRAY_SIZE-1] ||
  ------------------
  |  |  815|  6.80k|#define PJ_CACHING_POOL_ARRAY_SIZE      16
  ------------------
  |  Branch (245:9): [True: 33, False: 6.77k]
  ------------------
  246|  6.80k|        cp->capacity + pool_capacity > cp->max_capacity)
  ------------------
  |  Branch (246:9): [True: 6.77k, False: 0]
  ------------------
  247|  6.80k|    {
  248|  6.80k|        pj_pool_destroy_int(pool);
  249|  6.80k|        pj_lock_release(cp->lock);
  250|  6.80k|        return;
  251|  6.80k|    }
  252|       |
  253|       |    /* Reset pool. */
  254|      0|    PJ_LOG(6, (pool->obj_name, "recycle(): cap=%lu, used=%lu(%lu%%)", 
  ------------------
  |  |  106|      0|#define PJ_LOG(level,arg)       do { \
  |  |  107|      0|                                    if (level <= pj_log_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]
  |  |  ------------------
  ------------------
  255|      0|               (unsigned long)pool_capacity,
  256|      0|               (unsigned long)pj_pool_get_used_size(pool), 
  257|      0|               (unsigned long)(pj_pool_get_used_size(pool)*100/
  258|      0|                               pool_capacity)));
  259|      0|    pj_pool_reset(pool);
  260|       |
  261|      0|    pool_capacity = pj_pool_get_capacity(pool);
  262|       |
  263|       |    /*
  264|       |     * Otherwise put the pool in our recycle list.
  265|       |     */
  266|      0|    i = (unsigned) (unsigned long) (pj_ssize_t) pool->factory_data;
  267|       |
  268|      0|    pj_assert(i<PJ_CACHING_POOL_ARRAY_SIZE);
  ------------------
  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  ------------------
  269|      0|    if (i >= PJ_CACHING_POOL_ARRAY_SIZE ) {
  ------------------
  |  |  815|      0|#define PJ_CACHING_POOL_ARRAY_SIZE      16
  ------------------
  |  Branch (269:9): [True: 0, False: 0]
  ------------------
  270|       |        /* Something has gone wrong with the pool. */
  271|      0|        pj_pool_destroy_int(pool);
  272|      0|        pj_lock_release(cp->lock);
  273|      0|        return;
  274|      0|    }
  275|       |
  276|      0|    pj_list_insert_after(&cp->free_list[i], pool);
  277|      0|    cp->capacity += pool_capacity;
  278|       |
  279|      0|    pj_lock_release(cp->lock);
  280|      0|}

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

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

pj_strltrim:
  197|  18.8k|{
  198|  18.8k|    char *end = str->ptr + str->slen;
  199|  18.8k|    register char *p = str->ptr;
  200|       |
  201|  18.8k|    pj_assert(str->slen >= 0);
  ------------------
  |  |   48|  18.8k|#   define pj_assert(expr)   assert(expr)
  ------------------
  202|       |
  203|  19.2k|    while (p < end && pj_isspace(*p))
  ------------------
  |  Branch (203:12): [True: 19.1k, False: 14]
  |  Branch (203:23): [True: 395, False: 18.7k]
  ------------------
  204|    395|        ++p;
  205|  18.8k|    str->slen -= (p - str->ptr);
  206|  18.8k|    str->ptr = p;
  207|  18.8k|    return str;
  208|  18.8k|}
pj_strtoul2:
  343|  1.59k|{
  344|  1.59k|    unsigned long value;
  345|  1.59k|    unsigned i;
  346|       |
  347|  1.59k|    PJ_CHECK_STACK();
  348|       |
  349|  1.59k|    pj_assert(str->slen >= 0);
  ------------------
  |  |   48|  1.59k|#   define pj_assert(expr)   assert(expr)
  ------------------
  350|       |
  351|  1.59k|    value = 0;
  352|  1.59k|    if (base <= 10) {
  ------------------
  |  Branch (352:9): [True: 1.59k, False: 0]
  ------------------
  353|  4.02k|        for (i=0; i<(unsigned)str->slen; ++i) {
  ------------------
  |  Branch (353:19): [True: 2.66k, False: 1.35k]
  ------------------
  354|  2.66k|            unsigned c = (str->ptr[i] - '0');
  355|  2.66k|            if (c >= base)
  ------------------
  |  Branch (355:17): [True: 237, False: 2.42k]
  ------------------
  356|    237|                break;
  357|  2.42k|            value = value * base + c;
  358|  2.42k|        }
  359|  1.59k|    } else if (base == 16) {
  ------------------
  |  Branch (359:16): [True: 0, False: 0]
  ------------------
  360|      0|        for (i=0; i<(unsigned)str->slen; ++i) {
  ------------------
  |  Branch (360:19): [True: 0, False: 0]
  ------------------
  361|      0|            if (!pj_isxdigit(str->ptr[i]))
  ------------------
  |  Branch (361:17): [True: 0, False: 0]
  ------------------
  362|      0|                break;
  363|      0|            value = value * 16 + pj_hex_digit_to_val(str->ptr[i]);
  364|      0|        }
  365|      0|    } else {
  366|      0|        pj_assert(!"Unsupported base");
  ------------------
  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  ------------------
  367|      0|        i = 0;
  368|      0|        value = 0xFFFFFFFFUL;
  369|      0|    }
  370|       |
  371|  1.59k|    if (endptr) {
  ------------------
  |  Branch (371:9): [True: 1.59k, False: 0]
  ------------------
  372|  1.59k|        endptr->ptr = str->ptr + i;
  373|  1.59k|        endptr->slen = (str->slen < 0)? 0: (str->slen - i);
  ------------------
  |  Branch (373:24): [True: 0, False: 1.59k]
  ------------------
  374|  1.59k|    }
  375|       |
  376|  1.59k|    return value;
  377|  1.59k|}
pj_strtoul3:
  381|  14.9k|{
  382|  14.9k|    pj_str_t s;
  383|  14.9k|    unsigned i;
  384|       |
  385|  14.9k|    PJ_CHECK_STACK();
  386|       |
  387|  14.9k|    if (!str || !value) {
  ------------------
  |  Branch (387:9): [True: 0, False: 14.9k]
  |  Branch (387:17): [True: 0, False: 14.9k]
  ------------------
  388|      0|        return PJ_EINVAL;
  ------------------
  |  |  333|      0|#define PJ_EINVAL           (PJ_ERRNO_START_STATUS + 4) /* 70004 */
  |  |  ------------------
  |  |  |  |  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
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  389|      0|    }
  390|  14.9k|    PJ_ASSERT_RETURN(str->slen >= 0, PJ_EINVAL);
  ------------------
  |  |   59|  14.9k|            do { \
  |  |   60|  14.9k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:21): [True: 0, False: 14.9k]
  |  |  ------------------
  |  |   61|  14.9k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
  391|       |    
  392|  14.9k|    s = *str;
  393|  14.9k|    pj_strltrim(&s);
  394|       |
  395|  14.9k|    if (s.slen == 0 || s.ptr[0] < '0' ||
  ------------------
  |  Branch (395:9): [True: 5, False: 14.9k]
  |  Branch (395:24): [True: 7, False: 14.9k]
  ------------------
  396|  14.9k|        (base <= 10 && (unsigned)s.ptr[0] > ('0' - 1) + base) ||
  ------------------
  |  Branch (396:10): [True: 14.9k, False: 0]
  |  Branch (396:24): [True: 5, False: 14.9k]
  ------------------
  397|  14.9k|        (base == 16 && !pj_isxdigit(s.ptr[0])))
  ------------------
  |  Branch (397:10): [True: 0, False: 14.9k]
  |  Branch (397:24): [True: 0, False: 0]
  ------------------
  398|     17|    {
  399|     17|        return PJ_EINVAL;
  ------------------
  |  |  333|     17|#define PJ_EINVAL           (PJ_ERRNO_START_STATUS + 4) /* 70004 */
  |  |  ------------------
  |  |  |  |  456|     17|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  444|     17|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  450|     17|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  400|     17|    }
  401|       |
  402|  14.9k|    *value = 0;
  403|  14.9k|    if (base <= 10) {
  ------------------
  |  Branch (403:9): [True: 14.9k, False: 0]
  ------------------
  404|  37.2k|        for (i=0; i<(unsigned)s.slen; ++i) {
  ------------------
  |  Branch (404:19): [True: 22.7k, False: 14.4k]
  ------------------
  405|  22.7k|            unsigned c = s.ptr[i] - '0';
  406|  22.7k|            if (s.ptr[i] < '0' || (unsigned)s.ptr[i] > ('0' - 1) + base) {
  ------------------
  |  Branch (406:17): [True: 270, False: 22.5k]
  |  Branch (406:35): [True: 238, False: 22.2k]
  ------------------
  407|    508|                break;
  408|    508|            }
  409|  22.2k|            if (*value > PJ_MAXULONG / base) {
  ------------------
  |  |   48|  22.2k|#define PJ_MAXULONG     ULONG_MAX
  ------------------
  |  Branch (409:17): [True: 3, False: 22.2k]
  ------------------
  410|      3|                *value = PJ_MAXULONG;
  ------------------
  |  |   48|      3|#define PJ_MAXULONG     ULONG_MAX
  ------------------
  411|      3|                return PJ_ETOOBIG;
  ------------------
  |  |  398|      3|#define PJ_ETOOBIG          (PJ_ERRNO_START_STATUS + 17)/* 70017 */
  |  |  ------------------
  |  |  |  |  456|      3|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  444|      3|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  450|      3|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  412|      3|            }
  413|       |
  414|  22.2k|            *value *= base;
  415|  22.2k|            if ((PJ_MAXULONG - *value) < c) {
  ------------------
  |  |   48|  22.2k|#define PJ_MAXULONG     ULONG_MAX
  ------------------
  |  Branch (415:17): [True: 1, False: 22.2k]
  ------------------
  416|      1|                *value = PJ_MAXULONG;
  ------------------
  |  |   48|      1|#define PJ_MAXULONG     ULONG_MAX
  ------------------
  417|      1|                return PJ_ETOOBIG;
  ------------------
  |  |  398|      1|#define PJ_ETOOBIG          (PJ_ERRNO_START_STATUS + 17)/* 70017 */
  |  |  ------------------
  |  |  |  |  456|      1|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  444|      1|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  450|      1|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  418|      1|            }
  419|  22.2k|            *value += c;
  420|  22.2k|        }
  421|  14.9k|    } else if (base == 16) {
  ------------------
  |  Branch (421:16): [True: 0, False: 0]
  ------------------
  422|      0|        for (i=0; i<(unsigned)s.slen; ++i) {
  ------------------
  |  Branch (422:19): [True: 0, False: 0]
  ------------------
  423|      0|            unsigned c = pj_hex_digit_to_val(s.ptr[i]);
  424|      0|            if (!pj_isxdigit(s.ptr[i]))
  ------------------
  |  Branch (424:17): [True: 0, False: 0]
  ------------------
  425|      0|                break;
  426|       |
  427|      0|            if (*value > PJ_MAXULONG / base) {
  ------------------
  |  |   48|      0|#define PJ_MAXULONG     ULONG_MAX
  ------------------
  |  Branch (427:17): [True: 0, False: 0]
  ------------------
  428|      0|                *value = PJ_MAXULONG;
  ------------------
  |  |   48|      0|#define PJ_MAXULONG     ULONG_MAX
  ------------------
  429|      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
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  430|      0|            }
  431|      0|            *value *= base;
  432|      0|            if ((PJ_MAXULONG - *value) < c) {
  ------------------
  |  |   48|      0|#define PJ_MAXULONG     ULONG_MAX
  ------------------
  |  Branch (432:17): [True: 0, False: 0]
  ------------------
  433|      0|                *value = PJ_MAXULONG;
  ------------------
  |  |   48|      0|#define PJ_MAXULONG     ULONG_MAX
  ------------------
  434|      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
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  435|      0|            }
  436|      0|            *value += c;
  437|      0|        }
  438|      0|    } else {
  439|      0|        pj_assert(!"Unsupported base");
  ------------------
  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  ------------------
  440|      0|        return PJ_EINVAL;
  ------------------
  |  |  333|      0|#define PJ_EINVAL           (PJ_ERRNO_START_STATUS + 4) /* 70004 */
  |  |  ------------------
  |  |  |  |  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
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  441|      0|    }
  442|  14.9k|    return PJ_SUCCESS;
  443|  14.9k|}
pj_strtoul4:
  447|  3.83k|{
  448|  3.83k|    pj_str_t s;
  449|  3.83k|    unsigned i;
  450|       |
  451|  3.83k|    PJ_CHECK_STACK();
  452|       |
  453|  3.83k|    if (!str || !value) {
  ------------------
  |  Branch (453:9): [True: 0, False: 3.83k]
  |  Branch (453:17): [True: 0, False: 3.83k]
  ------------------
  454|      0|        return PJ_EINVAL;
  ------------------
  |  |  333|      0|#define PJ_EINVAL           (PJ_ERRNO_START_STATUS + 4) /* 70004 */
  |  |  ------------------
  |  |  |  |  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
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  455|      0|    }
  456|  3.83k|    PJ_ASSERT_RETURN(str->slen >= 0, PJ_EINVAL);
  ------------------
  |  |   59|  3.83k|            do { \
  |  |   60|  3.83k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:21): [True: 0, False: 3.83k]
  |  |  ------------------
  |  |   61|  3.83k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
  457|       |
  458|  3.83k|    s = *str;
  459|  3.83k|    pj_strltrim(&s);
  460|       |
  461|  3.83k|    if (s.slen == 0 || s.ptr[0] < '0' ||
  ------------------
  |  Branch (461:9): [True: 9, False: 3.82k]
  |  Branch (461:24): [True: 9, False: 3.81k]
  ------------------
  462|  3.83k|        (base <= 10 && (unsigned)s.ptr[0] > ('0' - 1) + base) ||
  ------------------
  |  Branch (462:10): [True: 3.81k, False: 0]
  |  Branch (462:24): [True: 1, False: 3.81k]
  ------------------
  463|  3.83k|        (base == 16 && !pj_isxdigit(s.ptr[0])))
  ------------------
  |  Branch (463:10): [True: 0, False: 3.81k]
  |  Branch (463:24): [True: 0, False: 0]
  ------------------
  464|     19|    {
  465|     19|        return PJ_EINVAL;
  ------------------
  |  |  333|     19|#define PJ_EINVAL           (PJ_ERRNO_START_STATUS + 4) /* 70004 */
  |  |  ------------------
  |  |  |  |  456|     19|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  444|     19|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  450|     19|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  466|     19|    }
  467|       |
  468|  3.81k|    *value = 0;
  469|  3.81k|    if (base <= 10) {
  ------------------
  |  Branch (469:9): [True: 3.81k, False: 0]
  ------------------
  470|  10.0k|        for (i=0; i<(unsigned)s.slen; ++i) {
  ------------------
  |  Branch (470:19): [True: 6.71k, False: 3.28k]
  ------------------
  471|  6.71k|            unsigned c = s.ptr[i] - '0';
  472|  6.71k|            if (s.ptr[i] < '0' || (unsigned)s.ptr[i] > ('0' - 1) + base) {
  ------------------
  |  Branch (472:17): [True: 310, False: 6.40k]
  |  Branch (472:35): [True: 210, False: 6.19k]
  ------------------
  473|    520|                break;
  474|    520|            }
  475|  6.19k|            if (*value > PJ_MAXUINT / base) {
  ------------------
  |  |   52|  6.19k|#  define PJ_MAXUINT    0xffffffffffffffffULL
  ------------------
  |  Branch (475:17): [True: 4, False: 6.18k]
  ------------------
  476|      4|                *value = PJ_MAXUINT;
  ------------------
  |  |   52|      4|#  define PJ_MAXUINT    0xffffffffffffffffULL
  ------------------
  477|      4|                return PJ_ETOOBIG;
  ------------------
  |  |  398|      4|#define PJ_ETOOBIG          (PJ_ERRNO_START_STATUS + 17)/* 70017 */
  |  |  ------------------
  |  |  |  |  456|      4|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  444|      4|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  450|      4|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  478|      4|            }
  479|       |
  480|  6.18k|            *value *= base;
  481|  6.18k|            if ((PJ_MAXUINT - *value) < c) {
  ------------------
  |  |   52|  6.18k|#  define PJ_MAXUINT    0xffffffffffffffffULL
  ------------------
  |  Branch (481:17): [True: 1, False: 6.18k]
  ------------------
  482|      1|                *value = PJ_MAXUINT;
  ------------------
  |  |   52|      1|#  define PJ_MAXUINT    0xffffffffffffffffULL
  ------------------
  483|      1|                return PJ_ETOOBIG;
  ------------------
  |  |  398|      1|#define PJ_ETOOBIG          (PJ_ERRNO_START_STATUS + 17)/* 70017 */
  |  |  ------------------
  |  |  |  |  456|      1|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  444|      1|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  450|      1|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  484|      1|            }
  485|  6.18k|            *value += c;
  486|  6.18k|        }
  487|  3.81k|    } else if (base == 16) {
  ------------------
  |  Branch (487:16): [True: 0, False: 0]
  ------------------
  488|      0|        for (i=0; i<(unsigned)s.slen; ++i) {
  ------------------
  |  Branch (488:19): [True: 0, False: 0]
  ------------------
  489|      0|            unsigned c = pj_hex_digit_to_val(s.ptr[i]);
  490|      0|            if (!pj_isxdigit(s.ptr[i]))
  ------------------
  |  Branch (490:17): [True: 0, False: 0]
  ------------------
  491|      0|                break;
  492|       |
  493|      0|            if (*value > PJ_MAXUINT / base) {
  ------------------
  |  |   52|      0|#  define PJ_MAXUINT    0xffffffffffffffffULL
  ------------------
  |  Branch (493:17): [True: 0, False: 0]
  ------------------
  494|      0|                *value = PJ_MAXUINT;
  ------------------
  |  |   52|      0|#  define PJ_MAXUINT    0xffffffffffffffffULL
  ------------------
  495|      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
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  496|      0|            }
  497|      0|            *value *= base;
  498|      0|            if ((PJ_MAXUINT - *value) < c) {
  ------------------
  |  |   52|      0|#  define PJ_MAXUINT    0xffffffffffffffffULL
  ------------------
  |  Branch (498:17): [True: 0, False: 0]
  ------------------
  499|      0|                *value = PJ_MAXUINT;
  ------------------
  |  |   52|      0|#  define PJ_MAXUINT    0xffffffffffffffffULL
  ------------------
  500|      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
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  501|      0|            }
  502|      0|            *value += c;
  503|      0|        }
  504|      0|    } else {
  505|      0|        pj_assert(!"Unsupported base");
  ------------------
  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  ------------------
  506|      0|        return PJ_EINVAL;
  ------------------
  |  |  333|      0|#define PJ_EINVAL           (PJ_ERRNO_START_STATUS + 4) /* 70004 */
  |  |  ------------------
  |  |  |  |  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
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  507|      0|    }
  508|  3.80k|    return PJ_SUCCESS;
  509|  3.81k|}
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|  34.2k|{
  628|  34.2k|    char *odst = dst;
  629|       |
  630|  34.2k|    PJ_ASSERT_RETURN(dst && src, -PJ_EINVAL);
  ------------------
  |  |   59|  34.2k|            do { \
  |  |   60|  68.4k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:23): [True: 34.2k, False: 0]
  |  |  |  Branch (60:23): [True: 34.2k, False: 0]
  |  |  ------------------
  |  |   61|  34.2k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
  631|       |
  632|  34.2k|    if (dst_size==0)
  ------------------
  |  Branch (632:9): [True: 0, False: 34.2k]
  ------------------
  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|   445k|    while (--dst_size && (*dst=*src) != 0) {
  ------------------
  |  Branch (635:12): [True: 445k, False: 0]
  |  Branch (635:26): [True: 411k, False: 34.2k]
  ------------------
  636|   411k|        ++dst;
  637|   411k|        ++src;
  638|   411k|    }
  639|       |
  640|  34.2k|    if (!*dst && !*src) {
  ------------------
  |  Branch (640:9): [True: 34.2k, False: 0]
  |  Branch (640:18): [True: 34.2k, False: 0]
  ------------------
  641|  34.2k|        return dst-odst;
  642|  34.2k|    } 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|  34.2k|}

pjmedia_event_mgr_create:
  179|  2.26k|{
  180|  2.26k|    pjmedia_event_mgr *mgr;
  181|  2.26k|    pj_status_t status;
  182|       |
  183|  2.26k|    mgr = PJ_POOL_ZALLOC_T(pool, pjmedia_event_mgr);
  ------------------
  |  |  520|  2.26k|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
  184|  2.26k|    mgr->pool = pj_pool_create(pool->factory, "evt mgr",
  185|  2.26k|                            PJMEDIA_POOL_LEN_EVTMGR,
  ------------------
  |  |   64|  2.26k|#   define PJMEDIA_POOL_LEN_EVTMGR              500
  ------------------
  186|  2.26k|                            PJMEDIA_POOL_INC_EVTMGR, NULL);
  ------------------
  |  |   71|  2.26k|#   define PJMEDIA_POOL_INC_EVTMGR              500
  ------------------
  187|  2.26k|    pj_list_init(&mgr->esub_list);
  188|  2.26k|    pj_list_init(&mgr->free_esub_list);
  189|       |
  190|  2.26k|    if (!(options & PJMEDIA_EVENT_MGR_NO_THREAD)) {
  ------------------
  |  Branch (190:9): [True: 2.26k, False: 0]
  ------------------
  191|  2.26k|        status = pj_sem_create(mgr->pool, "ev_sem", 0, MAX_EVENTS + 1,
  ------------------
  |  |   29|  2.26k|#define MAX_EVENTS 16
  ------------------
  192|  2.26k|                               &mgr->sem);
  193|  2.26k|        if (status != PJ_SUCCESS)
  ------------------
  |  Branch (193:13): [True: 0, False: 2.26k]
  ------------------
  194|      0|            return status;
  195|       |
  196|  2.26k|        status = pj_thread_create(mgr->pool, "ev_thread",
  197|  2.26k|                                  &event_worker_thread,
  198|  2.26k|                                  mgr, 0, 0, &mgr->thread);
  199|  2.26k|        if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (199:13): [True: 0, False: 2.26k]
  ------------------
  200|      0|            pjmedia_event_mgr_destroy(mgr);
  201|      0|            return status;
  202|      0|        }
  203|  2.26k|    }
  204|       |
  205|  2.26k|    status = pj_mutex_create_recursive(mgr->pool, "ev_mutex", &mgr->mutex);
  206|  2.26k|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (206:9): [True: 0, False: 2.26k]
  ------------------
  207|      0|        pjmedia_event_mgr_destroy(mgr);
  208|      0|        return status;
  209|      0|    }
  210|       |
  211|  2.26k|    status = pj_mutex_create_recursive(mgr->pool, "ev_cb_mutex",
  212|  2.26k|                                       &mgr->cb_mutex);
  213|  2.26k|    if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (213:9): [True: 0, False: 2.26k]
  ------------------
  214|      0|        pjmedia_event_mgr_destroy(mgr);
  215|      0|        return status;
  216|      0|    }
  217|       |
  218|  2.26k|    if (!event_manager_instance)
  ------------------
  |  Branch (218:9): [True: 2.26k, False: 0]
  ------------------
  219|  2.26k|        event_manager_instance = mgr;
  220|       |
  221|  2.26k|    if (p_mgr)
  ------------------
  |  Branch (221:9): [True: 0, False: 2.26k]
  ------------------
  222|      0|        *p_mgr = mgr;
  223|       |
  224|  2.26k|    return PJ_SUCCESS;
  225|  2.26k|}
pjmedia_event_mgr_instance:
  228|  2.26k|{
  229|  2.26k|    return event_manager_instance;
  230|  2.26k|}
pjmedia_event_mgr_destroy:
  238|  2.26k|{
  239|  2.26k|    if (!mgr) mgr = pjmedia_event_mgr_instance();
  ------------------
  |  Branch (239:9): [True: 0, False: 2.26k]
  ------------------
  240|  2.26k|    PJ_ASSERT_ON_FAIL(mgr != NULL, return);
  ------------------
  |  |   73|  2.26k|            { \
  |  |   74|  2.26k|                pj_assert(expr); \
  |  |  ------------------
  |  |  |  |   48|  2.26k|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |   75|  2.26k|                if (!(expr)) exec_on_fail; \
  |  |  ------------------
  |  |  |  Branch (75:21): [True: 0, False: 2.26k]
  |  |  ------------------
  |  |   76|  2.26k|            }
  ------------------
  241|       |
  242|  2.26k|    if (mgr->thread) {
  ------------------
  |  Branch (242:9): [True: 2.26k, False: 0]
  ------------------
  243|  2.26k|        mgr->is_quitting = PJ_TRUE;
  244|  2.26k|        pj_sem_post(mgr->sem);
  245|  2.26k|        pj_thread_join(mgr->thread);
  246|  2.26k|        pj_thread_destroy(mgr->thread);
  247|  2.26k|        mgr->thread = NULL;
  248|  2.26k|    }
  249|       |
  250|  2.26k|    if (mgr->sem) {
  ------------------
  |  Branch (250:9): [True: 2.26k, False: 0]
  ------------------
  251|  2.26k|        pj_sem_destroy(mgr->sem);
  252|  2.26k|        mgr->sem = NULL;
  253|  2.26k|    }
  254|       |
  255|  2.26k|    if (mgr->mutex) {
  ------------------
  |  Branch (255:9): [True: 2.26k, False: 0]
  ------------------
  256|  2.26k|        pj_mutex_destroy(mgr->mutex);
  257|  2.26k|        mgr->mutex = NULL;
  258|  2.26k|    }
  259|       |
  260|  2.26k|    if (mgr->cb_mutex) {
  ------------------
  |  Branch (260:9): [True: 2.26k, False: 0]
  ------------------
  261|  2.26k|        pj_mutex_destroy(mgr->cb_mutex);
  262|  2.26k|        mgr->cb_mutex = NULL;
  263|  2.26k|    }
  264|       |
  265|  2.26k|    if (mgr->pool)
  ------------------
  |  Branch (265:9): [True: 2.26k, False: 0]
  ------------------
  266|  2.26k|        pj_pool_release(mgr->pool);
  267|       |
  268|  2.26k|    if (event_manager_instance == mgr)
  ------------------
  |  Branch (268:9): [True: 2.26k, False: 0]
  ------------------
  269|  2.26k|        event_manager_instance = NULL;
  270|  2.26k|}
event.c:event_worker_thread:
  157|  2.26k|{
  158|  2.26k|    pjmedia_event_mgr *mgr = (pjmedia_event_mgr *)arg;
  159|       |
  160|  2.26k|    while (1) {
  ------------------
  |  Branch (160:12): [Folded - Ignored]
  ------------------
  161|       |        /* Wait until there is an event. */
  162|  2.26k|        pj_sem_wait(mgr->sem);
  163|       |
  164|  2.26k|        if (mgr->is_quitting)
  ------------------
  |  Branch (164:13): [True: 2.26k, False: 0]
  ------------------
  165|  2.26k|            break;
  166|       |
  167|      0|        pj_mutex_lock(mgr->mutex);
  168|      0|        event_mgr_distribute_events(mgr, &mgr->ev_queue,
  169|      0|                                    &mgr->th_next_sub, PJ_TRUE);
  170|      0|        pj_mutex_unlock(mgr->mutex);
  171|      0|    }
  172|       |
  173|  2.26k|    return 0;
  174|  2.26k|}

pjmedia_sdp_attr_find:
  142|    832|{
  143|    832|    unsigned i;
  144|    832|    unsigned c_pt = 0xFFFF;
  145|    832|    unsigned long ul;
  146|       |
  147|    832|    PJ_ASSERT_RETURN(count <= PJMEDIA_MAX_SDP_ATTR, NULL);
  ------------------
  |  |   59|    832|            do { \
  |  |   60|    832|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:21): [True: 0, False: 832]
  |  |  ------------------
  |  |   61|    832|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
  148|       |
  149|    832|    if (c_fmt) {
  ------------------
  |  Branch (149:9): [True: 832, False: 0]
  ------------------
  150|    832|        if (pj_strtoul3(c_fmt, &ul, 10) != PJ_SUCCESS)
  ------------------
  |  Branch (150:13): [True: 0, False: 832]
  ------------------
  151|      0|            return NULL;
  152|    832|        c_pt = (unsigned)ul;
  153|    832|    }
  154|       |
  155|  2.63k|    for (i=0; i<count; ++i) {
  ------------------
  |  Branch (155:15): [True: 2.46k, False: 163]
  ------------------
  156|  2.46k|        if (pj_strcmp(&attr_array[i]->name, name) == 0) {
  ------------------
  |  Branch (156:13): [True: 1.59k, False: 876]
  ------------------
  157|  1.59k|            const pjmedia_sdp_attr *a = attr_array[i];
  158|  1.59k|            if (c_fmt) {
  ------------------
  |  Branch (158:17): [True: 1.59k, False: 0]
  ------------------
  159|  1.59k|                pj_str_t endptr;
  160|  1.59k|                unsigned pt = (unsigned) pj_strtoul2(&a->value, &endptr, 10);
  161|  1.59k|                if (endptr.ptr != a->value.ptr && pt == c_pt) {
  ------------------
  |  Branch (161:21): [True: 1.08k, False: 510]
  |  Branch (161:51): [True: 669, False: 414]
  ------------------
  162|    669|                    return (pjmedia_sdp_attr*)a;
  163|    669|                }
  164|  1.59k|            } else 
  165|      0|                return (pjmedia_sdp_attr*)a;
  166|  1.59k|        }
  167|  2.46k|    }
  168|    163|    return NULL;
  169|    832|}
pjmedia_sdp_attr_add:
  189|  10.1k|{
  190|  10.1k|    PJ_ASSERT_RETURN(count && attr_array && attr, PJ_EINVAL);
  ------------------
  |  |   59|  10.1k|            do { \
  |  |   60|  40.6k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:23): [True: 10.1k, False: 0]
  |  |  |  Branch (60:23): [True: 10.1k, False: 0]
  |  |  |  Branch (60:23): [True: 10.1k, False: 0]
  |  |  ------------------
  |  |   61|  10.1k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
  191|       |
  192|  10.1k|    if (*count >= PJMEDIA_MAX_SDP_ATTR) {
  ------------------
  |  |   64|  10.1k|#   define PJMEDIA_MAX_SDP_ATTR         (PJMEDIA_MAX_SDP_FMT*2 + 4)
  |  |  ------------------
  |  |  |  |   48|  10.1k|#   define PJMEDIA_MAX_SDP_FMT          32
  |  |  ------------------
  ------------------
  |  Branch (192:9): [True: 36, False: 10.1k]
  ------------------
  193|     36|        PJ_PERROR(2, (THIS_FILE, PJ_ETOOMANY, 
  ------------------
  |  |  175|     36|#define PJ_PERROR(level,arg)    do { \
  |  |  176|     36|                                    pj_perror_wrapper_##level(arg); \
  |  |  177|     36|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (177:42): [Folded - Ignored]
  |  |  ------------------
  ------------------
  194|     36|                  "Error adding SDP attribute %.*s, "
  195|     36|                  "attr is ignored",
  196|     36|                  (int)attr->name.slen, attr->name.ptr));
  197|       |
  198|     36|        return PJ_ETOOMANY;
  ------------------
  |  |  363|     36|#define PJ_ETOOMANY         (PJ_ERRNO_START_STATUS + 10)/* 70010 */
  |  |  ------------------
  |  |  |  |  456|     36|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  444|     36|#define PJ_ERRNO_START          20000
  |  |  |  |  ------------------
  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  450|     36|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  199|     36|    }
  200|       |
  201|  10.1k|    attr_array[*count] = attr;
  202|  10.1k|    (*count)++;
  203|       |
  204|  10.1k|    return PJ_SUCCESS;
  205|  10.1k|}
pjmedia_sdp_attr_remove:
  239|    188|{
  240|    188|    unsigned i, removed=0;
  241|       |
  242|    188|    PJ_ASSERT_RETURN(count && attr_array && attr, PJ_EINVAL);
  ------------------
  |  |   59|    188|            do { \
  |  |   60|    752|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:23): [True: 188, False: 0]
  |  |  |  Branch (60:23): [True: 188, False: 0]
  |  |  |  Branch (60:23): [True: 188, False: 0]
  |  |  ------------------
  |  |   61|    188|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
  243|    188|    PJ_ASSERT_RETURN(*count <= PJMEDIA_MAX_SDP_ATTR, PJ_ETOOMANY);
  ------------------
  |  |   59|    188|            do { \
  |  |   60|    188|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:21): [True: 0, False: 188]
  |  |  ------------------
  |  |   61|    188|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
  244|       |
  245|  1.13k|    for (i=0; i<*count; ) {
  ------------------
  |  Branch (245:15): [True: 942, False: 188]
  ------------------
  246|    942|        if (attr_array[i] == attr) {
  ------------------
  |  Branch (246:13): [True: 188, False: 754]
  ------------------
  247|    188|            pj_array_erase(attr_array, sizeof(pjmedia_sdp_attr*),
  248|    188|                           *count, i);
  249|    188|            --(*count);
  250|    188|            ++removed;
  251|    754|        } else {
  252|    754|            ++i;
  253|    754|        }
  254|    942|    }
  255|       |
  256|    188|    return removed ? PJ_SUCCESS : PJ_ENOTFOUND;
  ------------------
  |  |  343|      0|#define PJ_ENOTFOUND        (PJ_ERRNO_START_STATUS + 6) /* 70006 */
  |  |  ------------------
  |  |  |  |  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 (256:12): [True: 188, False: 0]
  ------------------
  257|    188|}
pjmedia_sdp_media_find_attr:
  849|    832|{
  850|    832|    PJ_ASSERT_RETURN(m && name, NULL);
  ------------------
  |  |   59|    832|            do { \
  |  |   60|  1.66k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:23): [True: 832, False: 0]
  |  |  |  Branch (60:23): [True: 832, False: 0]
  |  |  ------------------
  |  |   61|    832|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
  851|    832|    return pjmedia_sdp_attr_find(m->attr_count, m->attr, name, fmt);
  852|    832|}
pjmedia_sdp_media_add_attr:
  867|  6.47k|{
  868|  6.47k|    return pjmedia_sdp_attr_add(&m->attr_count, m->attr, attr);
  869|  6.47k|}
pjmedia_sdp_session_add_attr:
  873|  3.67k|{
  874|  3.67k|    return pjmedia_sdp_attr_add(&s->attr_count, s->attr, attr);
  875|  3.67k|}
pjmedia_sdp_parse:
 1407|  2.26k|{
 1408|  2.26k|    pj_scanner scanner;
 1409|  2.26k|    pjmedia_sdp_session *session;
 1410|  2.26k|    pjmedia_sdp_media *media = NULL;
 1411|  2.26k|    pjmedia_sdp_attr *attr;
 1412|  2.26k|    pjmedia_sdp_conn *conn;
 1413|  2.26k|    pjmedia_sdp_bandw *bandw;
 1414|  2.26k|    pj_str_t dummy;
 1415|  2.26k|    int cur_name = 254;
 1416|  2.26k|    volatile parse_context ctx;
 1417|  2.26k|    PJ_USE_EXCEPTION;
  ------------------
  |  |  367|  2.26k|#define PJ_USE_EXCEPTION    struct pj_exception_state_t pj_x_except__; int pj_x_code__
  ------------------
 1418|       |
 1419|  2.26k|    ctx.last_error = PJ_SUCCESS;
 1420|       |
 1421|  2.26k|    init_sdp_parser();
 1422|       |
 1423|  2.26k|    pj_scan_init(&scanner, buf, len, 0, &on_scanner_error);
 1424|  2.26k|    session = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_session);
  ------------------
  |  |  520|  2.26k|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
 1425|  2.26k|    PJ_ASSERT_RETURN(session != NULL, PJ_ENOMEM);
  ------------------
  |  |   59|  2.26k|            do { \
  |  |   60|  2.26k|                if (!(expr)) { pj_assert(expr); return retval; } \
  |  |  ------------------
  |  |  |  |   48|      0|#   define pj_assert(expr)   assert(expr)
  |  |  ------------------
  |  |  |  Branch (60:21): [True: 0, False: 2.26k]
  |  |  ------------------
  |  |   61|  2.26k|            } while (0)
  |  |  ------------------
  |  |  |  Branch (61:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1426|       |
 1427|       |    /* Ignore leading newlines */
 1428|  3.06k|    while (*scanner.curptr=='\r' || *scanner.curptr=='\n')
  ------------------
  |  Branch (1428:12): [True: 461, False: 2.60k]
  |  Branch (1428:37): [True: 334, False: 2.26k]
  ------------------
 1429|    795|        pj_scan_get_char(&scanner);
 1430|       |
 1431|  2.26k|    PJ_TRY {
  ------------------
  |  |  373|  2.26k|#define PJ_TRY              if (1) { \
  |  |  ------------------
  |  |  |  Branch (373:33): [Folded - Ignored]
  |  |  ------------------
  |  |  374|  2.26k|                                pj_push_exception_handler_(&pj_x_except__); \
  |  |  375|  2.26k|                                pj_x_code__ = pj_setjmp(pj_x_except__.state); \
  |  |  ------------------
  |  |  |  |   31|  2.26k|#    define pj_setjmp(buf)      setjmp(buf)
  |  |  ------------------
  |  |  376|  2.26k|                                if (pj_x_code__ == 0)
  |  |  ------------------
  |  |  |  Branch (376:37): [True: 2.26k, False: 0]
  |  |  ------------------
  ------------------
 1432|  31.7k|        while (!pj_scan_is_eof(&scanner)) {
  ------------------
  |  Branch (1432:16): [True: 30.0k, False: 1.63k]
  ------------------
 1433|  30.0k|                cur_name = *scanner.curptr;
 1434|  30.0k|                switch (cur_name) {
 1435|  12.0k|                case 'a':
  ------------------
  |  Branch (1435:17): [True: 12.0k, False: 18.0k]
  ------------------
 1436|  12.0k|                    attr = parse_attr(pool, &scanner, &ctx);
 1437|  12.0k|                    if (attr) {
  ------------------
  |  Branch (1437:25): [True: 12.0k, False: 57]
  ------------------
 1438|  12.0k|                        if (media) {
  ------------------
  |  Branch (1438:29): [True: 6.53k, False: 5.50k]
  ------------------
 1439|  6.53k|                            if (media->attr_count < PJMEDIA_MAX_SDP_ATTR)
  ------------------
  |  |   64|  6.53k|#   define PJMEDIA_MAX_SDP_ATTR         (PJMEDIA_MAX_SDP_FMT*2 + 4)
  |  |  ------------------
  |  |  |  |   48|  6.53k|#   define PJMEDIA_MAX_SDP_FMT          32
  |  |  ------------------
  ------------------
  |  Branch (1439:33): [True: 6.23k, False: 301]
  ------------------
 1440|  6.23k|                                pjmedia_sdp_media_add_attr(media, attr);
 1441|    301|                            else
 1442|    301|                                PJ_PERROR(2, (THIS_FILE, PJ_ETOOMANY,
  ------------------
  |  |  175|    301|#define PJ_PERROR(level,arg)    do { \
  |  |  176|    301|                                    pj_perror_wrapper_##level(arg); \
  |  |  177|    301|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (177:42): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1443|  6.53k|                                              "Error adding media attribute, "
 1444|  6.53k|                                              "attribute is ignored"));
 1445|  6.53k|                        } else {
 1446|  5.50k|                            if (session->attr_count < PJMEDIA_MAX_SDP_ATTR)
  ------------------
  |  |   64|  5.50k|#   define PJMEDIA_MAX_SDP_ATTR         (PJMEDIA_MAX_SDP_FMT*2 + 4)
  |  |  ------------------
  |  |  |  |   48|  5.50k|#   define PJMEDIA_MAX_SDP_FMT          32
  |  |  ------------------
  ------------------
  |  Branch (1446:33): [True: 3.67k, False: 1.82k]
  ------------------
 1447|  3.67k|                                pjmedia_sdp_session_add_attr(session, attr);
 1448|  1.82k|                            else
 1449|  1.82k|                                PJ_PERROR(2, (THIS_FILE, PJ_ETOOMANY,
  ------------------
  |  |  175|  1.82k|#define PJ_PERROR(level,arg)    do { \
  |  |  176|  1.82k|                                    pj_perror_wrapper_##level(arg); \
  |  |  177|  1.82k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (177:42): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1450|  5.50k|                                              "Error adding session attribute"
 1451|  5.50k|                                              ", attribute is ignored"));
 1452|  5.50k|                        }
 1453|  12.0k|                    }
 1454|  12.0k|                    break;
 1455|  1.14k|                case 'o':
  ------------------
  |  Branch (1455:17): [True: 1.14k, False: 28.9k]
  ------------------
 1456|  1.14k|                    parse_origin(&scanner, session, &ctx);
 1457|  1.14k|                    break;
 1458|  1.03k|                case 's':
  ------------------
  |  Branch (1458:17): [True: 1.03k, False: 29.0k]
  ------------------
 1459|  1.03k|                    parse_generic_line(&scanner, &session->name, &ctx);
 1460|  1.03k|                    break;
 1461|  1.62k|                case 'c':
  ------------------
  |  Branch (1461:17): [True: 1.62k, False: 28.4k]
  ------------------
 1462|  1.62k|                    conn = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_conn);
  ------------------
  |  |  520|  1.62k|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
 1463|  1.62k|                    parse_connection_info(&scanner, conn, &ctx);
 1464|  1.62k|                    if (media) {
  ------------------
  |  Branch (1464:25): [True: 990, False: 632]
  ------------------
 1465|    990|                        media->conn = conn;
 1466|    990|                    } else {
 1467|    632|                        session->conn = conn;
 1468|    632|                    }
 1469|  1.62k|                    break;
 1470|    873|                case 't':
  ------------------
  |  Branch (1470:17): [True: 873, False: 29.2k]
  ------------------
 1471|    873|                    parse_time(&scanner, session, &ctx);
 1472|    873|                    break;
 1473|  9.92k|                case 'm':
  ------------------
  |  Branch (1473:17): [True: 9.92k, False: 20.1k]
  ------------------
 1474|  9.92k|                    media = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_media);
  ------------------
  |  |  520|  9.92k|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
 1475|  9.92k|                    parse_media(&scanner, media, &ctx);
 1476|  9.92k|                    if (session->media_count < PJMEDIA_MAX_SDP_MEDIA)
  ------------------
  |  |   72|  9.92k|#   define PJMEDIA_MAX_SDP_MEDIA        16
  ------------------
  |  Branch (1476:25): [True: 2.79k, False: 7.13k]
  ------------------
 1477|  2.79k|                        session->media[ session->media_count++ ] = media;
 1478|  7.13k|                    else
 1479|  7.13k|                        PJ_PERROR(2,(THIS_FILE, PJ_ETOOMANY,
  ------------------
  |  |  175|  7.13k|#define PJ_PERROR(level,arg)    do { \
  |  |  176|  7.13k|                                    pj_perror_wrapper_##level(arg); \
  |  |  177|  7.13k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (177:42): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1480|  9.92k|                                     "Error adding media, media is ignored"));
 1481|  9.92k|                    break;
 1482|    235|                case 'v':
  ------------------
  |  Branch (1482:17): [True: 235, False: 29.8k]
  ------------------
 1483|    235|                    parse_version(&scanner, &ctx);
 1484|    235|                    break;
 1485|     21|                case 13:
  ------------------
  |  Branch (1485:17): [True: 21, False: 30.0k]
  ------------------
 1486|     34|                case 10:
  ------------------
  |  Branch (1486:17): [True: 13, False: 30.0k]
  ------------------
 1487|     34|                    pj_scan_get_char(&scanner);
 1488|       |                    /* Allow empty newlines at the end of the message */
 1489|    636|                    while (!pj_scan_is_eof(&scanner)) {
  ------------------
  |  Branch (1489:28): [True: 602, False: 34]
  ------------------
 1490|    602|                        if (*scanner.curptr != 13 && *scanner.curptr != 10) {
  ------------------
  |  Branch (1490:29): [True: 222, False: 380]
  |  Branch (1490:54): [True: 9, False: 213]
  ------------------
 1491|      9|                            ctx.last_error = PJMEDIA_SDP_EINSDP;
  ------------------
  |  |   92|      9|#define PJMEDIA_SDP_EINSDP          (PJMEDIA_ERRNO_START+20)    /* 220020 */
  |  |  ------------------
  |  |  |  |   44|      9|#define PJMEDIA_ERRNO_START       (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  470|      9|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  463|      9|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  456|      9|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  444|      9|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  450|      9|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  450|      9|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|      9|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJMEDIA_ERRNO_START       (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  450|      9|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1492|      9|                            on_scanner_error(&scanner);
 1493|      9|                        }
 1494|    602|                        pj_scan_get_char(&scanner);
 1495|    602|                    }
 1496|     34|                    break;
 1497|  2.48k|                case 'b':
  ------------------
  |  Branch (1497:17): [True: 2.48k, False: 27.6k]
  ------------------
 1498|  2.48k|                    bandw = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_bandw);
  ------------------
  |  |  520|  2.48k|            ((type*)pj_pool_zalloc(pool, sizeof(type)))
  ------------------
 1499|  2.48k|                    parse_bandwidth_info(&scanner, bandw, &ctx);
 1500|  2.48k|                    if (media) {
  ------------------
  |  Branch (1500:25): [True: 687, False: 1.79k]
  ------------------
 1501|    687|                        if (media->bandw_count < PJMEDIA_MAX_SDP_BANDW)
  ------------------
  |  |   56|    687|#   define PJMEDIA_MAX_SDP_BANDW        4
  ------------------
  |  Branch (1501:29): [True: 259, False: 428]
  ------------------
 1502|    259|                            media->bandw[media->bandw_count++] = bandw;
 1503|    428|                        else
 1504|    428|                            PJ_PERROR(2, (THIS_FILE, PJ_ETOOMANY,
  ------------------
  |  |  175|    428|#define PJ_PERROR(level,arg)    do { \
  |  |  176|    428|                                    pj_perror_wrapper_##level(arg); \
  |  |  177|    428|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (177:42): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1505|    687|                                          "Error adding media bandwidth "
 1506|    687|                                          "info, info is ignored"));
 1507|  1.79k|                    } else {
 1508|  1.79k|                        if (session->bandw_count < PJMEDIA_MAX_SDP_BANDW)
  ------------------
  |  |   56|  1.79k|#   define PJMEDIA_MAX_SDP_BANDW        4
  ------------------
  |  Branch (1508:29): [True: 282, False: 1.51k]
  ------------------
 1509|    282|                            session->bandw[session->bandw_count++] = bandw;
 1510|  1.51k|                        else
 1511|  1.51k|                            PJ_PERROR(2, (THIS_FILE, PJ_ETOOMANY,
  ------------------
  |  |  175|  1.51k|#define PJ_PERROR(level,arg)    do { \
  |  |  176|  1.51k|                                    pj_perror_wrapper_##level(arg); \
  |  |  177|  1.51k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (177:42): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1512|  1.79k|                                          "Error adding session bandwidth "
 1513|  1.79k|                                          "info, info is ignored"));
 1514|  1.79k|                    }
 1515|  2.48k|                    break;
 1516|    650|                default:
  ------------------
  |  Branch (1516:17): [True: 650, False: 29.4k]
  ------------------
 1517|    650|                    if (cur_name >= 'a' && cur_name <= 'z')
  ------------------
  |  Branch (1517:25): [True: 630, False: 20]
  |  Branch (1517:44): [True: 629, False: 1]
  ------------------
 1518|    629|                        parse_generic_line(&scanner, &dummy, &ctx);
 1519|     21|                    else  {
 1520|     21|                        ctx.last_error = PJMEDIA_SDP_EINSDP;
  ------------------
  |  |   92|     21|#define PJMEDIA_SDP_EINSDP          (PJMEDIA_ERRNO_START+20)    /* 220020 */
  |  |  ------------------
  |  |  |  |   44|     21|#define PJMEDIA_ERRNO_START       (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  470|     21|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  463|     21|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  456|     21|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  444|     21|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  450|     21|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  450|     21|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|     21|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJMEDIA_ERRNO_START       (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  450|     21|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1521|     21|                        on_scanner_error(&scanner);
 1522|     21|                    }
 1523|    650|                    break;
 1524|  30.0k|                }
 1525|  30.0k|        }
 1526|       |
 1527|  1.63k|        ctx.last_error = PJ_SUCCESS;
 1528|       |
 1529|  1.63k|    }
 1530|      0|    PJ_CATCH_ANY {              
 1531|      0|        PJ_PERROR(4, (THIS_FILE, ctx.last_error,
  ------------------
  |  |  175|      0|#define PJ_PERROR(level,arg)    do { \
  |  |  176|      0|                                    pj_perror_wrapper_##level(arg); \
  |  |  177|      0|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (177:42): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1532|      0|                      "Error parsing SDP in line %d col %d",
 1533|      0|                      scanner.line, pj_scan_get_col(&scanner)));
 1534|       |
 1535|      0|        session = NULL;
 1536|       |
 1537|       |        // pj_assert(ctx.last_error != PJ_SUCCESS);
 1538|      0|    }
 1539|  1.63k|    PJ_END;
  ------------------
  |  |  394|  1.63k|#define PJ_END                  pj_pop_exception_handler_(&pj_x_except__); \
  |  |  395|  1.63k|                            } else {}
  ------------------
 1540|       |
 1541|  1.63k|    pj_scan_fini(&scanner);
 1542|       |
 1543|  1.63k|    if (session)
  ------------------
  |  Branch (1543:9): [True: 1.63k, False: 0]
  ------------------
 1544|  1.63k|        apply_media_direction(session);
 1545|       |
 1546|  1.63k|    *p_sdp = session;
 1547|  1.63k|    return ctx.last_error;
 1548|  2.26k|}
pjmedia_sdp_validate:
 1639|  1.63k|{
 1640|  1.63k|    return pjmedia_sdp_validate2(sdp, PJ_TRUE);
 1641|  1.63k|}
pjmedia_sdp_validate2:
 1647|  1.63k|{
 1648|  1.63k|    unsigned i;
 1649|  1.63k|    const pj_str_t STR_RTPMAP = { "rtpmap", 6 };
 1650|       |
 1651|  1.63k|    CHECK( sdp != NULL, PJ_EINVAL);
  ------------------
  |  | 1617|  1.63k|#define CHECK(exp,ret)  do {                    \
  |  | 1618|  1.63k|                            /*pj_assert(exp);*/ \
  |  | 1619|  1.63k|                            if (!(exp))         \
  |  |  ------------------
  |  |  |  Branch (1619:33): [True: 0, False: 1.63k]
  |  |  ------------------
  |  | 1620|  1.63k|                                return ret;     \
  |  | 1621|  1.63k|                        } while (0)
  |  |  ------------------
  |  |  |  Branch (1621:34): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1652|       |
 1653|       |    /* Validate origin line. */
 1654|  1.63k|    CHECK( sdp->origin.user.slen != 0, PJMEDIA_SDP_EINORIGIN);
  ------------------
  |  | 1617|  1.63k|#define CHECK(exp,ret)  do {                    \
  |  | 1618|  1.63k|                            /*pj_assert(exp);*/ \
  |  | 1619|  1.63k|                            if (!(exp))         \
  |  |  ------------------
  |  |  |  Branch (1619:33): [True: 848, False: 787]
  |  |  ------------------
  |  | 1620|  1.63k|                                return ret;     \
  |  | 1621|  1.63k|                        } while (0)
  |  |  ------------------
  |  |  |  Branch (1621:34): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1655|    787|    CHECK( pj_strcmp2(&sdp->origin.net_type, "IN")==0, 
  ------------------
  |  | 1617|    787|#define CHECK(exp,ret)  do {                    \
  |  | 1618|    787|                            /*pj_assert(exp);*/ \
  |  | 1619|    787|                            if (!(exp))         \
  |  |  ------------------
  |  |  |  Branch (1619:33): [True: 91, False: 696]
  |  |  ------------------
  |  | 1620|    787|                                return ret;     \
  |  | 1621|    787|                        } while (0)
  |  |  ------------------
  |  |  |  Branch (1621:34): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1656|    787|           PJMEDIA_SDP_EINORIGIN);
 1657|    696|    CHECK( pj_strcmp2(&sdp->origin.addr_type, "IP4")==0 ||
  ------------------
  |  | 1617|    696|#define CHECK(exp,ret)  do {                    \
  |  | 1618|    696|                            /*pj_assert(exp);*/ \
  |  | 1619|  1.00k|                            if (!(exp))         \
  |  |  ------------------
  |  |  |  Branch (1619:35): [True: 391, False: 305]
  |  |  |  Branch (1619:35): [True: 261, False: 44]
  |  |  ------------------
  |  | 1620|    696|                                return ret;     \
  |  | 1621|    696|                        } while (0)
  |  |  ------------------
  |  |  |  Branch (1621:34): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1658|    696|           pj_strcmp2(&sdp->origin.addr_type, "IP6")==0, 
 1659|    696|           PJMEDIA_SDP_EINORIGIN);
 1660|    652|    CHECK( sdp->origin.addr.slen != 0, PJMEDIA_SDP_EINORIGIN);
  ------------------
  |  | 1617|    652|#define CHECK(exp,ret)  do {                    \
  |  | 1618|    652|                            /*pj_assert(exp);*/ \
  |  | 1619|    652|                            if (!(exp))         \
  |  |  ------------------
  |  |  |  Branch (1619:33): [True: 1, False: 651]
  |  |  ------------------
  |  | 1620|    652|                                return ret;     \
  |  | 1621|    652|                        } while (0)
  |  |  ------------------
  |  |  |  Branch (1621:34): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1661|       |
 1662|       |    /* Validate subject line. */
 1663|    651|    CHECK( sdp->name.slen != 0, PJMEDIA_SDP_EINNAME);
  ------------------
  |  | 1617|    651|#define CHECK(exp,ret)  do {                    \
  |  | 1618|    651|                            /*pj_assert(exp);*/ \
  |  | 1619|    651|                            if (!(exp))         \
  |  |  ------------------
  |  |  |  Branch (1619:33): [True: 13, False: 638]
  |  |  ------------------
  |  | 1620|    651|                                return ret;     \
  |  | 1621|    651|                        } while (0)
  |  |  ------------------
  |  |  |  Branch (1621:34): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1664|       |
 1665|       |    /* Ignore start and stop time. */
 1666|       |
 1667|       |    /* If session level connection info is present, validate it. */
 1668|    638|    if (sdp->conn) {
  ------------------
  |  Branch (1668:9): [True: 402, False: 236]
  ------------------
 1669|    402|        pj_status_t status = validate_sdp_conn(sdp->conn);
 1670|    402|        if (status != PJ_SUCCESS)
  ------------------
  |  Branch (1670:13): [True: 79, False: 323]
  ------------------
 1671|     79|            return status;
 1672|    402|    }
 1673|       |
 1674|       |    /* Validate each media. */
 1675|    902|    for (i=0; i<sdp->media_count; ++i) {
  ------------------
  |  Branch (1675:15): [True: 765, False: 137]
  ------------------
 1676|    765|        const pjmedia_sdp_media *m = sdp->media[i];
 1677|    765|        unsigned j;
 1678|       |
 1679|       |        /* Validate the m= line. */
 1680|    765|        CHECK( m->desc.media.slen != 0, PJMEDIA_SDP_EINMEDIA);
  ------------------
  |  | 1617|    765|#define CHECK(exp,ret)  do {                    \
  |  | 1618|    765|                            /*pj_assert(exp);*/ \
  |  | 1619|    765|                            if (!(exp))         \
  |  |  ------------------
  |  |  |  Branch (1619:33): [True: 0, False: 765]
  |  |  ------------------
  |  | 1620|    765|                                return ret;     \
  |  | 1621|    765|                        } while (0)
  |  |  ------------------
  |  |  |  Branch (1621:34): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1681|    765|        CHECK( m->desc.transport.slen != 0, PJMEDIA_SDP_EINMEDIA);
  ------------------
  |  | 1617|    765|#define CHECK(exp,ret)  do {                    \
  |  | 1618|    765|                            /*pj_assert(exp);*/ \
  |  | 1619|    765|                            if (!(exp))         \
  |  |  ------------------
  |  |  |  Branch (1619:33): [True: 13, False: 752]
  |  |  ------------------
  |  | 1620|    765|                                return ret;     \
  |  | 1621|    765|                        } while (0)
  |  |  ------------------
  |  |  |  Branch (1621:34): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1682|    752|        CHECK( m->desc.fmt_count != 0 || m->desc.port==0, PJMEDIA_SDP_ENOFMT);
  ------------------
  |  | 1617|    752|#define CHECK(exp,ret)  do {                    \
  |  | 1618|    752|                            /*pj_assert(exp);*/ \
  |  | 1619|  1.06k|                            if (!(exp))         \
  |  |  ------------------
  |  |  |  Branch (1619:35): [True: 439, False: 313]
  |  |  |  Branch (1619:35): [True: 287, False: 26]
  |  |  ------------------
  |  | 1620|    752|                                return ret;     \
  |  | 1621|    752|                        } while (0)
  |  |  ------------------
  |  |  |  Branch (1621:34): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1683|       |
 1684|       |        /* If media level connection info is present, validate it. */
 1685|    726|        if (m->conn) {
  ------------------
  |  Branch (1685:13): [True: 322, False: 404]
  ------------------
 1686|    322|            pj_status_t status = validate_sdp_conn(m->conn);
 1687|    322|            if (status != PJ_SUCCESS)
  ------------------
  |  Branch (1687:17): [True: 100, False: 222]
  ------------------
 1688|    100|                return status;
 1689|    322|        }
 1690|       |
 1691|       |        /* If media doesn't have connection info, then connection info
 1692|       |         * must be present in the session.
 1693|       |         */
 1694|    626|        if (m->conn == NULL) {
  ------------------
  |  Branch (1694:13): [True: 404, False: 222]
  ------------------
 1695|    404|            if (sdp->conn == NULL)
  ------------------
  |  Branch (1695:17): [True: 8, False: 396]
  ------------------
 1696|      8|                if (strict || m->desc.port != 0)
  ------------------
  |  Branch (1696:21): [True: 8, False: 0]
  |  Branch (1696:31): [True: 0, False: 0]
  ------------------
 1697|      8|                    return PJMEDIA_SDP_EMISSINGCONN;
  ------------------
  |  |  122|      8|#define PJMEDIA_SDP_EMISSINGCONN    (PJMEDIA_ERRNO_START+26)    /* 220026 */
  |  |  ------------------
  |  |  |  |   44|      8|#define PJMEDIA_ERRNO_START       (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  470|      8|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  463|      8|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  456|      8|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  444|      8|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  450|      8|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  450|      8|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|      8|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJMEDIA_ERRNO_START       (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  450|      8|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1698|    404|        }
 1699|       |
 1700|       |        /* Verify payload type. */
 1701|  2.36k|        for (j=0; j<m->desc.fmt_count; ++j) {
  ------------------
  |  Branch (1701:19): [True: 2.01k, False: 343]
  ------------------
 1702|       |
 1703|       |            /* Arrgh noo!! Payload type can be non-numeric!!
 1704|       |             * RTC based programs sends "null" for instant messaging!
 1705|       |             */
 1706|  2.01k|            if (pj_isdigit(*m->desc.fmt[j].ptr)) {
  ------------------
  |  Branch (1706:17): [True: 1.61k, False: 406]
  ------------------
 1707|  1.61k|                unsigned long pt;
 1708|  1.61k|                pj_status_t status = pj_strtoul3(&m->desc.fmt[j], &pt, 10);
 1709|       |
 1710|       |                /* Payload type is between 0 and 127. 
 1711|       |                 */
 1712|  1.61k|                CHECK( status == PJ_SUCCESS && pt <= 127, PJMEDIA_SDP_EINPT);
  ------------------
  |  | 1617|  1.61k|#define CHECK(exp,ret)  do {                    \
  |  | 1618|  1.61k|                            /*pj_assert(exp);*/ \
  |  | 1619|  3.22k|                            if (!(exp))         \
  |  |  ------------------
  |  |  |  Branch (1619:35): [True: 1.61k, False: 1]
  |  |  |  Branch (1619:35): [True: 1.50k, False: 111]
  |  |  ------------------
  |  | 1620|  1.61k|                                return ret;     \
  |  | 1621|  1.61k|                        } while (0)
  |  |  ------------------
  |  |  |  Branch (1621:34): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1713|       |
 1714|       |                /* If port is not zero, then for each dynamic payload type, an
 1715|       |                 * rtpmap attribute must be specified.
 1716|       |                 */
 1717|  1.50k|                if (m->desc.port != 0 && pt >= 96) {
  ------------------
  |  Branch (1717:21): [True: 1.25k, False: 249]
  |  Branch (1717:42): [True: 832, False: 419]
  ------------------
 1718|    832|                    const pjmedia_sdp_attr *a;
 1719|       |
 1720|    832|                    a = pjmedia_sdp_media_find_attr(m, &STR_RTPMAP, 
 1721|    832|                                                    &m->desc.fmt[j]);
 1722|    832|                    CHECK( a != NULL, PJMEDIA_SDP_EMISSINGRTPMAP);
  ------------------
  |  | 1617|    832|#define CHECK(exp,ret)  do {                    \
  |  | 1618|    832|                            /*pj_assert(exp);*/ \
  |  | 1619|    832|                            if (!(exp))         \
  |  |  ------------------
  |  |  |  Branch (1619:33): [True: 163, False: 669]
  |  |  ------------------
  |  | 1620|    832|                                return ret;     \
  |  | 1621|    832|                        } while (0)
  |  |  ------------------
  |  |  |  Branch (1621:34): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1723|    832|                }
 1724|  1.50k|            }
 1725|  2.01k|        }
 1726|    618|    }
 1727|       |
 1728|       |    /* Looks good. */
 1729|    137|    return PJ_SUCCESS;
 1730|    559|}
sdp.c:init_sdp_parser:
   77|  2.26k|{
   78|  2.26k|    if (is_initialized != 0)
  ------------------
  |  Branch (78:9): [True: 2.26k, False: 1]
  ------------------
   79|  2.26k|        return;
   80|       |
   81|      1|    pj_enter_critical_section();
   82|       |
   83|      1|    if (is_initialized != 0) {
  ------------------
  |  Branch (83:9): [True: 0, False: 1]
  ------------------
   84|      0|        pj_leave_critical_section();
   85|      0|        return;
   86|      0|    }
   87|       |    
   88|      1|    pj_cis_buf_init(&cis_buf);
   89|       |
   90|      1|    pj_cis_init(&cis_buf, &cs_token);
   91|      1|    pj_cis_add_alpha(&cs_token);
   92|      1|    pj_cis_add_num(&cs_token);
   93|      1|    pj_cis_add_str(&cs_token, TOKEN);
  ------------------
  |  |   37|      1|#define TOKEN           "!#$%&'*+-.^_`{|}~"
  ------------------
   94|       |
   95|      1|    pj_cis_init(&cis_buf, &cs_digit);
   96|      1|    pj_cis_add_num(&cs_digit);
   97|       |
   98|      1|    is_initialized = 1;
   99|      1|    pj_leave_critical_section();
  100|      1|}
sdp.c:on_scanner_error:
 1290|    634|{
 1291|    634|    PJ_UNUSED_ARG(scanner);
  ------------------
  |  | 1433|    634|#define PJ_UNUSED_ARG(arg)  (void)arg
  ------------------
 1292|       |
 1293|    634|    PJ_THROW(SYNTAX_ERROR);
  ------------------
  |  |  402|    634|#define PJ_THROW(exception_id)  pj_throw_exception_(exception_id)
  ------------------
 1294|    634|}
sdp.c:parse_attr:
 1298|  12.0k|{
 1299|  12.0k|    pjmedia_sdp_attr *attr;
 1300|       |
 1301|  12.0k|    ctx->last_error = PJMEDIA_SDP_EINATTR;
  ------------------
  |  |  127|  12.0k|#define PJMEDIA_SDP_EINATTR         (PJMEDIA_ERRNO_START+27)    /* 220027 */
  |  |  ------------------
  |  |  |  |   44|  12.0k|#define PJMEDIA_ERRNO_START       (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  470|  12.0k|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  463|  12.0k|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  456|  12.0k|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  444|  12.0k|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  450|  12.0k|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  450|  12.0k|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|  12.0k|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJMEDIA_ERRNO_START       (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  450|  12.0k|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1302|       |
 1303|  12.0k|    attr = PJ_POOL_ALLOC_T(pool, pjmedia_sdp_attr);
  ------------------
  |  |  506|  12.0k|            ((type*)pj_pool_alloc(pool, sizeof(type)))
  ------------------
 1304|       |
 1305|       |    /* check equal sign */
 1306|  12.0k|    if (scanner->curptr+1 >= scanner->end || *(scanner->curptr+1) != '=') {
  ------------------
  |  Branch (1306:9): [True: 46, False: 12.0k]
  |  Branch (1306:46): [True: 11, False: 12.0k]
  ------------------
 1307|     57|        on_scanner_error(scanner);
 1308|     57|        return NULL;
 1309|     57|    }
 1310|       |
 1311|       |    /* skip a= */
 1312|  12.0k|    pj_scan_advance_n(scanner, 2, SKIP_WS);
 1313|       |    
 1314|       |    /* get attr name. */
 1315|  12.0k|    pj_scan_get(scanner, &cs_token, &attr->name);
 1316|       |
 1317|  12.0k|    if (*scanner->curptr && *scanner->curptr != '\r' && 
  ------------------
  |  Branch (1317:9): [True: 11.4k, False: 565]
  |  Branch (1317:29): [True: 11.2k, False: 197]
  ------------------
 1318|  12.0k|        *scanner->curptr != '\n') 
  ------------------
  |  Branch (1318:9): [True: 1.00k, False: 10.2k]
  ------------------
 1319|  1.00k|    {
 1320|       |        /* skip ':' if present. */
 1321|  1.00k|        if (*scanner->curptr == ':')
  ------------------
  |  Branch (1321:13): [True: 629, False: 378]
  ------------------
 1322|    629|            pj_scan_get_char(scanner);
 1323|       |
 1324|       |        /* get value */
 1325|  1.00k|        if (!pj_scan_is_eof(scanner) && *scanner->curptr != '\r' && *scanner->curptr != '\n') {
  ------------------
  |  Branch (1325:13): [True: 1.00k, False: 6]
  |  Branch (1325:41): [True: 805, False: 196]
  |  Branch (1325:69): [True: 549, False: 256]
  ------------------
 1326|    549|            pj_scan_get_until_chr(scanner, "\r\n", &attr->value);
 1327|    549|        } else {
 1328|    458|            attr->value.ptr = NULL;
 1329|    458|            attr->value.slen = 0;
 1330|    458|        }
 1331|       |
 1332|  11.0k|    } else {
 1333|  11.0k|        attr->value.ptr = NULL;
 1334|  11.0k|        attr->value.slen = 0;
 1335|  11.0k|    }
 1336|       |
 1337|       |    /* We've got what we're looking for, skip anything until newline */
 1338|  12.0k|    pj_scan_skip_line(scanner);
 1339|       |
 1340|  12.0k|    return attr;
 1341|  12.0k|}
sdp.c:parse_origin:
 1025|  1.14k|{
 1026|  1.14k|    pj_str_t str;
 1027|  1.14k|    pj_uint_t ui;
 1028|       |
 1029|  1.14k|    ctx->last_error = PJMEDIA_SDP_EINORIGIN;
  ------------------
  |  |  102|  1.14k|#define PJMEDIA_SDP_EINORIGIN       (PJMEDIA_ERRNO_START+22)    /* 220022 */
  |  |  ------------------
  |  |  |  |   44|  1.14k|#define PJMEDIA_ERRNO_START       (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  470|  1.14k|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  463|  1.14k|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  456|  1.14k|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  444|  1.14k|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  450|  1.14k|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  450|  1.14k|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|  1.14k|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJMEDIA_ERRNO_START       (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  450|  1.14k|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1030|       |
 1031|       |    /* check equal sign */
 1032|  1.14k|    if (scanner->curptr+1 >= scanner->end || *(scanner->curptr+1) != '=') {
  ------------------
  |  Branch (1032:9): [True: 1, False: 1.14k]
  |  Branch (1032:46): [True: 10, False: 1.13k]
  ------------------
 1033|     11|        on_scanner_error(scanner);
 1034|     11|        return;
 1035|     11|    }
 1036|       |
 1037|       |    /* o= */
 1038|  1.13k|    pj_scan_advance_n(scanner, 2, SKIP_WS);
 1039|       |
 1040|       |    /* username. */
 1041|  1.13k|    pj_scan_get_until_ch(scanner, ' ', &ses->origin.user);
 1042|  1.13k|    pj_scan_get_char(scanner);
 1043|       |
 1044|       |    /* id */
 1045|  1.13k|    pj_scan_get_until_ch(scanner, ' ', &str);
 1046|  1.13k|    if (pj_strtoul4(&str, &ui, 10) != PJ_SUCCESS){
  ------------------
  |  Branch (1046:9): [True: 4, False: 1.12k]
  ------------------
 1047|      4|        on_scanner_error(scanner);
 1048|      4|        return;
 1049|      4|    }
 1050|  1.12k|    ses->origin.id = (pj_uint_t)ui;
 1051|  1.12k|    pj_scan_get_char(scanner);
 1052|       |
 1053|       |    /* version */
 1054|  1.12k|    pj_scan_get_until_ch(scanner, ' ', &str);
 1055|  1.12k|    if (pj_strtoul4(&str, &ui, 10) != PJ_SUCCESS){
  ------------------
  |  Branch (1055:9): [True: 5, False: 1.12k]
  ------------------
 1056|      5|        on_scanner_error(scanner);
 1057|      5|        return;
 1058|      5|    }
 1059|  1.12k|    ses->origin.version = (pj_uint_t)ui;
 1060|  1.12k|    pj_scan_get_char(scanner);
 1061|       |
 1062|       |    /* network-type */
 1063|  1.12k|    pj_scan_get_until_ch(scanner, ' ', &ses->origin.net_type);
 1064|  1.12k|    pj_scan_get_char(scanner);
 1065|       |
 1066|       |    /* addr-type */
 1067|  1.12k|    pj_scan_get_until_ch(scanner, ' ', &ses->origin.addr_type);
 1068|  1.12k|    pj_scan_get_char(scanner);
 1069|       |
 1070|       |    /* address */
 1071|  1.12k|    pj_scan_get_until_chr(scanner, " \t\r\n", &ses->origin.addr);
 1072|       |
 1073|       |    /* We've got what we're looking for, skip anything until newline */
 1074|  1.12k|    pj_scan_skip_line(scanner);
 1075|       |
 1076|  1.12k|}
sdp.c:parse_generic_line:
 1119|  1.65k|{
 1120|  1.65k|    ctx->last_error = PJMEDIA_SDP_EINSDP;
  ------------------
  |  |   92|  1.65k|#define PJMEDIA_SDP_EINSDP          (PJMEDIA_ERRNO_START+20)    /* 220020 */
  |  |  ------------------
  |  |  |  |   44|  1.65k|#define PJMEDIA_ERRNO_START       (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  470|  1.65k|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  463|  1.65k|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  456|  1.65k|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  444|  1.65k|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  450|  1.65k|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  450|  1.65k|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|  1.65k|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJMEDIA_ERRNO_START       (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  450|  1.65k|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1121|       |
 1122|       |    /* check equal sign */
 1123|  1.65k|    if ((scanner->curptr+1 >= scanner->end) || *(scanner->curptr+1) != '=') {
  ------------------
  |  Branch (1123:9): [True: 2, False: 1.65k]
  |  Branch (1123:48): [True: 20, False: 1.63k]
  ------------------
 1124|     22|        on_scanner_error(scanner);
 1125|     22|        return;
 1126|     22|    }
 1127|       |
 1128|       |    /* x= */
 1129|  1.63k|    pj_scan_advance_n(scanner, 2, SKIP_WS);
 1130|       |
 1131|       |    /* get anything until newline (including whitespaces). */
 1132|  1.63k|    pj_scan_get_until_chr(scanner, "\r\n", str);
 1133|       |
 1134|       |    /* newline. */
 1135|  1.63k|    pj_scan_get_newline(scanner);
 1136|  1.63k|}
sdp.c:parse_connection_info:
 1140|  1.62k|{
 1141|  1.62k|    ctx->last_error = PJMEDIA_SDP_EINCONN;
  ------------------
  |  |  117|  1.62k|#define PJMEDIA_SDP_EINCONN         (PJMEDIA_ERRNO_START+25)    /* 220025 */
  |  |  ------------------
  |  |  |  |   44|  1.62k|#define PJMEDIA_ERRNO_START       (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  470|  1.62k|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  463|  1.62k|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  456|  1.62k|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  444|  1.62k|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  450|  1.62k|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  450|  1.62k|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|  1.62k|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJMEDIA_ERRNO_START       (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  450|  1.62k|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1142|       |
 1143|       |    /* c= */
 1144|  1.62k|    pj_scan_advance_n(scanner, 2, SKIP_WS);
 1145|       |
 1146|       |    /* network-type */
 1147|  1.62k|    pj_scan_get_until_ch(scanner, ' ', &conn->net_type);
 1148|  1.62k|    pj_scan_get_char(scanner);
 1149|       |
 1150|       |    /* addr-type */
 1151|  1.62k|    pj_scan_get_until_ch(scanner, ' ', &conn->addr_type);
 1152|  1.62k|    pj_scan_get_char(scanner);
 1153|       |
 1154|       |    /* address. */
 1155|  1.62k|    pj_scan_get_until_chr(scanner, "/ \t\r\n", &conn->addr);
 1156|       |    /* Parse multicast details, if any. */
 1157|  1.62k|    if (*scanner->curptr == '/') {
  ------------------
  |  Branch (1157:9): [True: 1, False: 1.62k]
  ------------------
 1158|      1|        pj_str_t str;
 1159|      1|        unsigned long ul;
 1160|       |
 1161|      1|        pj_scan_get_until_chr(scanner, "/ \t\r\n", &str);
 1162|      1|        if (*scanner->curptr == '/') {
  ------------------
  |  Branch (1162:13): [True: 1, False: 0]
  ------------------
 1163|      1|            if ((pj_strtoul3(&str, &ul, 10) != PJ_SUCCESS) || ul > 255) {
  ------------------
  |  Branch (1163:17): [True: 1, False: 0]
  |  Branch (1163:63): [True: 0, False: 0]
  ------------------
 1164|      1|                on_scanner_error(scanner);
 1165|      1|                return;
 1166|      1|            }
 1167|       |
 1168|      0|            conn->ttl = (pj_uint8_t)ul;
 1169|      0|        }        
 1170|       |
 1171|      0|        if ((pj_strtoul3(&str, &ul, 10) != PJ_SUCCESS) || ul > 255) {
  ------------------
  |  Branch (1171:13): [True: 0, False: 0]
  |  Branch (1171:59): [True: 0, False: 0]
  ------------------
 1172|      0|            on_scanner_error(scanner);
 1173|      0|            return;
 1174|      0|        }
 1175|      0|        conn->no_addr = (pj_uint8_t)ul;
 1176|       |
 1177|      0|    }
 1178|       |
 1179|       |    /* We've got what we're looking for, skip anything until newline */
 1180|  1.62k|    pj_scan_skip_line(scanner);
 1181|  1.62k|}
sdp.c:parse_time:
 1080|    873|{
 1081|    873|    pj_str_t str;
 1082|    873|    pj_uint_t ui;
 1083|       |
 1084|    873|    ctx->last_error = PJMEDIA_SDP_EINTIME;
  ------------------
  |  |  107|    873|#define PJMEDIA_SDP_EINTIME         (PJMEDIA_ERRNO_START+23)    /* 220023 */
  |  |  ------------------
  |  |  |  |   44|    873|#define PJMEDIA_ERRNO_START       (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  470|    873|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  463|    873|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  456|    873|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  444|    873|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  450|    873|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  450|    873|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|    873|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJMEDIA_ERRNO_START       (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  450|    873|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1085|       |
 1086|       |    /* check equal sign */
 1087|    873|    if (scanner->curptr+1 >= scanner->end || *(scanner->curptr+1) != '=') {
  ------------------
  |  Branch (1087:9): [True: 1, False: 872]
  |  Branch (1087:46): [True: 9, False: 863]
  ------------------
 1088|     10|        on_scanner_error(scanner);
 1089|     10|        return;
 1090|     10|    }
 1091|       |
 1092|       |    /* t= */
 1093|    863|    pj_scan_advance_n(scanner, 2, SKIP_WS);
 1094|       |
 1095|       |    /* start time */
 1096|    863|    pj_scan_get_until_ch(scanner, ' ', &str);
 1097|    863|    if (pj_strtoul4(&str, &ui, 10) != PJ_SUCCESS){
  ------------------
  |  Branch (1097:9): [True: 11, False: 852]
  ------------------
 1098|     11|        on_scanner_error(scanner);
 1099|     11|        return;
 1100|     11|    }
 1101|    852|    ses->time.start = (pj_uint_t)ui;
 1102|       |
 1103|    852|    pj_scan_get_char(scanner);
 1104|       |
 1105|       |    /* stop time */
 1106|    852|    pj_scan_get_until_chr(scanner, " \t\r\n", &str);
 1107|    852|    if (pj_strtoul4(&str, &ui, 10) != PJ_SUCCESS){
  ------------------
  |  Branch (1107:9): [True: 4, False: 848]
  ------------------
 1108|      4|        on_scanner_error(scanner);
 1109|      4|        return;
 1110|      4|    }
 1111|    848|    ses->time.stop = (pj_uint_t)ui;
 1112|       |
 1113|       |    /* We've got what we're looking for, skip anything until newline */
 1114|    848|    pj_scan_skip_line(scanner);
 1115|    848|}
sdp.c:parse_media:
 1212|  9.92k|{
 1213|  9.92k|    pj_str_t str;
 1214|  9.92k|    unsigned long num;
 1215|  9.92k|    pj_status_t status;
 1216|       |
 1217|  9.92k|    ctx->last_error = PJMEDIA_SDP_EINMEDIA;
  ------------------
  |  |  147|  9.92k|#define PJMEDIA_SDP_EINMEDIA        (PJMEDIA_ERRNO_START+31)    /* 220031 */
  |  |  ------------------
  |  |  |  |   44|  9.92k|#define PJMEDIA_ERRNO_START       (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  470|  9.92k|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  463|  9.92k|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  456|  9.92k|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  444|  9.92k|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  450|  9.92k|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  450|  9.92k|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|  9.92k|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJMEDIA_ERRNO_START       (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  450|  9.92k|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1218|       |
 1219|       |    /* check the equal sign */
 1220|  9.92k|    if (scanner->curptr+1 >= scanner->end || *(scanner->curptr+1) != '=') {
  ------------------
  |  Branch (1220:9): [True: 52, False: 9.87k]
  |  Branch (1220:46): [True: 10, False: 9.86k]
  ------------------
 1221|     62|        on_scanner_error(scanner);
 1222|     62|        return;
 1223|     62|    }
 1224|       |
 1225|       |    /* m= */
 1226|  9.86k|    pj_scan_advance_n(scanner, 2, SKIP_WS);
 1227|       |
 1228|       |    /* type */
 1229|  9.86k|    pj_scan_get(scanner, &cs_token, &med->desc.media);
 1230|       |
 1231|  9.86k|    if (pj_scan_get_char(scanner) != ' ') {
  ------------------
  |  Branch (1231:9): [True: 11, False: 9.85k]
  ------------------
 1232|     11|        on_scanner_error(scanner);
 1233|     11|    }
 1234|       |
 1235|       |    /* port */
 1236|  9.86k|    pj_scan_get(scanner, &cs_token, &str);
 1237|  9.86k|    status = pj_strtoul3(&str, &num, 10);
 1238|  9.86k|    if (status != PJ_SUCCESS || pj_scan_is_eof(scanner) || num > 0xFFFF) {
  ------------------
  |  Branch (1238:9): [True: 13, False: 9.85k]
  |  Branch (1238:33): [True: 1, False: 9.85k]
  |  Branch (1238:60): [True: 94, False: 9.75k]
  ------------------
 1239|     96|        on_scanner_error(scanner);
 1240|     96|        return;
 1241|     96|    }
 1242|  9.77k|    med->desc.port = (unsigned short)num;
 1243|  9.77k|    if (*scanner->curptr == '/') {
  ------------------
  |  Branch (1243:9): [True: 217, False: 9.55k]
  ------------------
 1244|       |        /* port count */
 1245|    217|        pj_scan_get_char(scanner);
 1246|    217|        pj_scan_get(scanner, &cs_token, &str);
 1247|    217|        status = pj_strtoul3(&str, &num, 10);
 1248|    217|        if (status != PJ_SUCCESS) {
  ------------------
  |  Branch (1248:13): [True: 4, False: 213]
  ------------------
 1249|      4|            on_scanner_error(scanner);
 1250|      4|            return;
 1251|      4|        }
 1252|    213|        med->desc.port_count = (unsigned)num;
 1253|  9.55k|    } else {
 1254|  9.55k|        med->desc.port_count = 0;
 1255|  9.55k|    }
 1256|       |
 1257|  9.76k|    if (pj_scan_get_char(scanner) != ' ') {
  ------------------
  |  Branch (1257:9): [True: 23, False: 9.74k]
  ------------------
 1258|     23|        on_scanner_error(scanner);
 1259|     23|    }
 1260|       |
 1261|       |    /* transport */
 1262|  9.76k|    pj_scan_get_until_chr(scanner, " \t\r\n", &med->desc.transport);
 1263|       |
 1264|       |    /* format list */
 1265|  9.76k|    med->desc.fmt_count = 0;
 1266|  15.6k|    while (scanner->curptr < scanner->end && *scanner->curptr == ' ') {
  ------------------
  |  Branch (1266:12): [True: 15.3k, False: 310]
  |  Branch (1266:46): [True: 6.24k, False: 9.06k]
  ------------------
 1267|  6.24k|        pj_str_t fmt;
 1268|       |
 1269|  6.24k|        pj_scan_get_char(scanner);
 1270|       |
 1271|       |        /* Check again for the end of the line */
 1272|  6.24k|        if ((*scanner->curptr == '\r') || (*scanner->curptr == '\n'))
  ------------------
  |  Branch (1272:13): [True: 194, False: 6.04k]
  |  Branch (1272:43): [True: 199, False: 5.85k]
  ------------------
 1273|    393|                break;
 1274|       |
 1275|  5.85k|        pj_scan_get(scanner, &cs_token, &fmt);
 1276|  5.85k|        if (med->desc.fmt_count < PJMEDIA_MAX_SDP_FMT)
  ------------------
  |  |   48|  5.85k|#   define PJMEDIA_MAX_SDP_FMT          32
  ------------------
  |  Branch (1276:13): [True: 4.43k, False: 1.41k]
  ------------------
 1277|  4.43k|            med->desc.fmt[med->desc.fmt_count++] = fmt;
 1278|  1.41k|        else
 1279|  1.41k|            PJ_PERROR(2,(THIS_FILE, PJ_ETOOMANY, 
  ------------------
  |  |  175|  1.41k|#define PJ_PERROR(level,arg)    do { \
  |  |  176|  1.41k|                                    pj_perror_wrapper_##level(arg); \
  |  |  177|  1.41k|                                } while (0)
  |  |  ------------------
  |  |  |  Branch (177:42): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1280|  5.85k|                         "Error adding SDP media format %.*s, "
 1281|  5.85k|                         "format is ignored",
 1282|  5.85k|                         (int)fmt.slen, fmt.ptr));
 1283|  5.85k|    }
 1284|       |
 1285|       |    /* We've got what we're looking for, skip anything until newline */
 1286|  9.76k|    pj_scan_skip_line(scanner);
 1287|  9.76k|}
sdp.c:parse_version:
 1004|    235|{
 1005|    235|    ctx->last_error = PJMEDIA_SDP_EINVER;
  ------------------
  |  |   97|    235|#define PJMEDIA_SDP_EINVER          (PJMEDIA_ERRNO_START+21)    /* 220021 */
  |  |  ------------------
  |  |  |  |   44|    235|#define PJMEDIA_ERRNO_START       (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  470|    235|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  463|    235|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  456|    235|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  444|    235|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  450|    235|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  450|    235|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|    235|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJMEDIA_ERRNO_START       (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  450|    235|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1006|       |
 1007|       |    /* check equal sign */
 1008|    235|    if (scanner->curptr+1 >= scanner->end || *(scanner->curptr+1) != '=') {
  ------------------
  |  Branch (1008:9): [True: 1, False: 234]
  |  Branch (1008:46): [True: 9, False: 225]
  ------------------
 1009|     10|        on_scanner_error(scanner);
 1010|     10|        return;
 1011|     10|    }
 1012|       |
 1013|       |    /* check version is 0 */
 1014|    225|    if (scanner->curptr+2 >= scanner->end || *(scanner->curptr+2) != '0') {
  ------------------
  |  Branch (1014:9): [True: 1, False: 224]
  |  Branch (1014:46): [True: 10, False: 214]
  ------------------
 1015|     11|        on_scanner_error(scanner);
 1016|     11|        return;
 1017|     11|    }
 1018|       |
 1019|       |    /* We've got what we're looking for, skip anything until newline */
 1020|    214|    pj_scan_skip_line(scanner);
 1021|    214|}
sdp.c:parse_bandwidth_info:
 1185|  2.48k|{
 1186|  2.48k|    pj_str_t str;
 1187|  2.48k|    unsigned long ul;
 1188|       |
 1189|  2.48k|    ctx->last_error = PJMEDIA_SDP_EINBANDW;
  ------------------
  |  |  177|  2.48k|#define PJMEDIA_SDP_EINBANDW        (PJMEDIA_ERRNO_START+37)    /* 220037 */
  |  |  ------------------
  |  |  |  |   44|  2.48k|#define PJMEDIA_ERRNO_START       (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  470|  2.48k|#define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  463|  2.48k|#define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  456|  2.48k|#define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  444|  2.48k|#define PJ_ERRNO_START          20000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_STATUS   (PJ_ERRNO_START + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  450|  2.48k|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |               #define PJ_ERRNO_START_SYS      (PJ_ERRNO_START_STATUS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  450|  2.48k|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               #define PJ_ERRNO_START_USER     (PJ_ERRNO_START_SYS + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|  2.48k|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define PJMEDIA_ERRNO_START       (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  450|  2.48k|#define PJ_ERRNO_SPACE_SIZE     50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1190|       |
 1191|       |    /* b= */
 1192|  2.48k|    pj_scan_advance_n(scanner, 2, SKIP_WS);
 1193|       |
 1194|       |    /* modifier */
 1195|  2.48k|    pj_scan_get_until_ch(scanner, ':', &bandw->modifier);
 1196|  2.48k|    pj_scan_get_char(scanner);
 1197|       |
 1198|       |    /* value */
 1199|  2.48k|    pj_scan_get_until_chr(scanner, " \t\r\n", &str);
 1200|  2.48k|    if (pj_strtoul3(&str, &ul, 10) != PJ_SUCCESS){
  ------------------
  |  Branch (1200:9): [True: 14, False: 2.46k]
  ------------------
 1201|     14|        on_scanner_error(scanner);
 1202|     14|        return;
 1203|     14|    }
 1204|  2.46k|    bandw->value = (pj_uint32_t)ul;
 1205|       |
 1206|       |    /* We've got what we're looking for, skip anything until newline */
 1207|  2.46k|    pj_scan_skip_line(scanner);
 1208|  2.46k|}
sdp.c:apply_media_direction:
 1348|  1.63k|{
 1349|  1.63k|    pjmedia_sdp_attr *dir_attr = NULL;
 1350|  1.63k|    unsigned i;
 1351|       |
 1352|  1.63k|    const pj_str_t inactive = { "inactive", 8 };
 1353|  1.63k|    const pj_str_t sendonly = { "sendonly", 8 };
 1354|  1.63k|    const pj_str_t recvonly = { "recvonly", 8 };
 1355|  1.63k|    const pj_str_t sendrecv = { "sendrecv", 8 };
 1356|       |
 1357|       |    /* Find direction attribute in session, don't need to find default 
 1358|       |     * direction "sendrecv".
 1359|       |     */
 1360|  4.05k|    for (i = 0; i < sdp->attr_count && !dir_attr; ++i) {
  ------------------
  |  Branch (1360:17): [True: 2.44k, False: 1.60k]
  |  Branch (1360:40): [True: 2.42k, False: 27]
  ------------------
 1361|  2.42k|        if (!pj_strcmp(&sdp->attr[i]->name, &sendonly) ||
  ------------------
  |  Branch (1361:13): [True: 22, False: 2.39k]
  ------------------
 1362|  2.42k|            !pj_strcmp(&sdp->attr[i]->name, &recvonly) ||
  ------------------
  |  Branch (1362:13): [True: 132, False: 2.26k]
  ------------------
 1363|  2.42k|            !pj_strcmp(&sdp->attr[i]->name, &inactive)) 
  ------------------
  |  Branch (1363:13): [True: 34, False: 2.23k]
  ------------------
 1364|    188|        {
 1365|    188|            dir_attr = sdp->attr[i];
 1366|    188|        }
 1367|  2.42k|    }
 1368|       |
 1369|       |    /* Found the direction attribute */
 1370|  1.63k|    if (dir_attr) {
  ------------------
  |  Branch (1370:9): [True: 188, False: 1.44k]
  ------------------
 1371|       |        /* Remove the direction attribute in session */
 1372|    188|        pjmedia_sdp_attr_remove(&sdp->attr_count, sdp->attr, dir_attr);
 1373|       |
 1374|       |        /* Apply the direction attribute to all media, but not overriding it
 1375|       |         * if media already has direction attribute.
 1376|       |         */
 1377|    579|        for (i = 0; i < sdp->media_count; ++i) {
  ------------------
  |  Branch (1377:21): [True: 391, False: 188]
  ------------------
 1378|    391|            pjmedia_sdp_media *m;
 1379|    391|            unsigned j;
 1380|       |
 1381|       |            /* Find direction attribute in this media */
 1382|    391|            m = sdp->media[i];
 1383|  3.78k|            for (j = 0; j < m->attr_count; ++j) {
  ------------------
  |  Branch (1383:25): [True: 3.53k, False: 244]
  ------------------
 1384|  3.53k|                if (!pj_strcmp(&m->attr[j]->name, &sendrecv) ||
  ------------------
  |  Branch (1384:21): [True: 34, False: 3.50k]
  ------------------
 1385|  3.53k|                    !pj_strcmp(&m->attr[j]->name, &sendonly) ||
  ------------------
  |  Branch (1385:21): [True: 35, False: 3.46k]
  ------------------
 1386|  3.53k|                    !pj_strcmp(&m->attr[j]->name, &recvonly) ||
  ------------------
  |  Branch (1386:21): [True: 44, False: 3.42k]
  ------------------
 1387|  3.53k|                    !pj_strcmp(&m->attr[j]->name, &inactive)) 
  ------------------
  |  Branch (1387:21): [True: 34, False: 3.39k]
  ------------------
 1388|    147|                {
 1389|    147|                    break;
 1390|    147|                }
 1391|  3.53k|            }
 1392|       |
 1393|       |            /* Not found, apply direction attribute from session */
 1394|    391|            if (j == m->attr_count)
  ------------------
  |  Branch (1394:17): [True: 244, False: 147]
  ------------------
 1395|    244|                pjmedia_sdp_media_add_attr(m, dir_attr);
 1396|    391|        }
 1397|    188|    }
 1398|  1.63k|}
sdp.c:validate_sdp_conn:
 1625|    724|{
 1626|    724|    CHECK( c, PJ_EINVAL);
  ------------------
  |  | 1617|    724|#define CHECK(exp,ret)  do {                    \
  |  | 1618|    724|                            /*pj_assert(exp);*/ \
  |  | 1619|    724|                            if (!(exp))         \
  |  |  ------------------
  |  |  |  Branch (1619:33): [True: 0, False: 724]
  |  |  ------------------
  |  | 1620|    724|                                return ret;     \
  |  | 1621|    724|                        } while (0)
  |  |  ------------------
  |  |  |  Branch (1621:34): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1627|    724|    CHECK( pj_strcmp2(&c->net_type, "IN")==0, PJMEDIA_SDP_EINCONN);
  ------------------
  |  | 1617|    724|#define CHECK(exp,ret)  do {                    \
  |  | 1618|    724|                            /*pj_assert(exp);*/ \
  |  | 1619|    724|                            if (!(exp))         \
  |  |  ------------------
  |  |  |  Branch (1619:33): [True: 75, False: 649]
  |  |  ------------------
  |  | 1620|    724|                                return ret;     \
  |  | 1621|    724|                        } while (0)
  |  |  ------------------
  |  |  |  Branch (1621:34): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1628|    649|    CHECK( pj_strcmp2(&c->addr_type, "IP4")==0 ||
  ------------------
  |  | 1617|    649|#define CHECK(exp,ret)  do {                    \
  |  | 1618|    649|                            /*pj_assert(exp);*/ \
  |  | 1619|  1.03k|                            if (!(exp))         \
  |  |  ------------------
  |  |  |  Branch (1619:35): [True: 260, False: 389]
  |  |  |  Branch (1619:35): [True: 302, False: 87]
  |  |  ------------------
  |  | 1620|    649|                                return ret;     \
  |  | 1621|    649|                        } while (0)
  |  |  ------------------
  |  |  |  Branch (1621:34): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1629|    649|           pj_strcmp2(&c->addr_type, "IP6")==0, 
 1630|    649|           PJMEDIA_SDP_EINCONN);
 1631|    562|    CHECK( c->addr.slen != 0, PJMEDIA_SDP_EINCONN);
  ------------------
  |  | 1617|    562|#define CHECK(exp,ret)  do {                    \
  |  | 1618|    562|                            /*pj_assert(exp);*/ \
  |  | 1619|    562|                            if (!(exp))         \
  |  |  ------------------
  |  |  |  Branch (1619:33): [True: 17, False: 545]
  |  |  ------------------
  |  | 1620|    562|                                return ret;     \
  |  | 1621|    562|                        } while (0)
  |  |  ------------------
  |  |  |  Branch (1621:34): [Folded - Ignored]
  |  |  ------------------
  ------------------
 1632|       |
 1633|    545|    return PJ_SUCCESS;
 1634|    562|}

sdp_parser:
   34|  2.26k|int sdp_parser(char *DataFx,size_t Size){
   35|       |
   36|  2.26k|    int ret = 0;
   37|  2.26k|	pj_pool_t *pool;
   38|  2.26k|    pjmedia_sdp_session *sdp;
   39|  2.26k|    pj_status_t status;
   40|       |
   41|  2.26k|    pool = pj_pool_create(mem, "sdp_neg_test", 4000, 4000, NULL);
   42|       |
   43|  2.26k|    status = pjmedia_sdp_parse(pool, DataFx, Size,&sdp);
   44|       |
   45|  2.26k|    if (status != PJ_SUCCESS){
  ------------------
  |  Branch (45:9): [True: 634, False: 1.63k]
  ------------------
   46|    634|        ret = 1;
   47|    634|        goto end;
   48|    634|    }
   49|       |
   50|  1.63k|    status = pjmedia_sdp_validate(sdp);
   51|       |
   52|  2.26k|end:
   53|  2.26k|    pj_pool_release(pool);
   54|       |
   55|  2.26k|    return ret;
   56|  1.63k|}
LLVMFuzzerTestOneInput:
   60|  2.29k|{/*pjproject/pjmedia/src/test/sdp_neg_test.c*/
   61|       |
   62|  2.29k|    if (Size < kMinInputLength || Size > kMaxInputLength){
  ------------------
  |  |   29|  4.58k|#define kMinInputLength 10
  ------------------
                  if (Size < kMinInputLength || Size > kMaxInputLength){
  ------------------
  |  |   30|  2.28k|#define kMaxInputLength 5120
  ------------------
  |  Branch (62:9): [True: 6, False: 2.28k]
  |  Branch (62:35): [True: 19, False: 2.26k]
  ------------------
   63|     25|        return 1;
   64|     25|    }
   65|       |
   66|       |/*Add Extra byte */
   67|  2.26k|    char *DataFx;
   68|  2.26k|    DataFx = (char *)calloc((Size+1),sizeof(char));
   69|  2.26k|    memcpy((void *)DataFx,(void *)Data,Size);
   70|       |
   71|       |/*init*/
   72|  2.26k|    int ret = 0;
   73|  2.26k|    pj_caching_pool caching_pool;
   74|  2.26k|    pj_pool_t *pool;
   75|       |
   76|  2.26k|    pj_init();
   77|  2.26k|    pj_caching_pool_init(&caching_pool, &pj_pool_factory_default_policy, 0);
   78|  2.26k|    pool = pj_pool_create(&caching_pool.factory, "test", 1000, 512, NULL);
   79|       |
   80|  2.26k|    pj_log_set_level(0);
   81|       |
   82|  2.26k|    mem = &caching_pool.factory;
   83|       |
   84|  2.26k|    pjmedia_event_mgr_create(pool, 0, NULL);
   85|       |
   86|       |/*Call*/
   87|  2.26k|    ret = sdp_parser(DataFx,Size);
   88|       |
   89|       |/*Free*/
   90|  2.26k|    pjmedia_event_mgr_destroy(pjmedia_event_mgr_instance());
   91|  2.26k|    pj_pool_release(pool);
   92|  2.26k|    pj_caching_pool_destroy(&caching_pool);
   93|       |
   94|  2.26k|    free(DataFx);
   95|  2.26k|    return ret;
   96|  2.29k|}

