af_gb_init:
   15|    253|void af_gb_init() {
   16|    253|  pointer_idx = 0;
   17|       |
   18|  25.5k|   for (int i = 0; i < GB_SIZE; i++) {
  ------------------
  |  |    8|  25.5k|#define GB_SIZE 100
  ------------------
  |  Branch (18:20): [True: 25.3k, False: 253]
  ------------------
   19|  25.3k|     pointer_arr[i] = NULL;
   20|  25.3k|   }
   21|    253|}
af_gb_cleanup:
   23|    253|void af_gb_cleanup() {
   24|  25.5k|  for(int i = 0; i < GB_SIZE; i++) {
  ------------------
  |  |    8|  25.5k|#define GB_SIZE 100
  ------------------
  |  Branch (24:18): [True: 25.3k, False: 253]
  ------------------
   25|  25.3k|    if (pointer_arr[i] != NULL) {
  ------------------
  |  Branch (25:9): [True: 240, False: 25.0k]
  ------------------
   26|    240|      free(pointer_arr[i]);
   27|    240|    }
   28|  25.3k|  }
   29|    253|}
af_get_null_terminated:
   31|    253|char *af_get_null_terminated(const uint8_t **data, size_t *size) {
   32|    253|#define STR_SIZE 75
   33|    253|  if (*size < STR_SIZE || (int)*size < 0) {
  ------------------
  |  |   32|    506|#define STR_SIZE 75
  ------------------
  |  Branch (33:7): [True: 13, False: 240]
  |  Branch (33:27): [True: 0, False: 240]
  ------------------
   34|     13|    return NULL;
   35|     13|  }
   36|       |
   37|    240|  char *new_s = malloc(STR_SIZE + 1);
  ------------------
  |  |   32|    240|#define STR_SIZE 75
  ------------------
   38|    240|  memcpy(new_s, *data, STR_SIZE);
  ------------------
  |  |   32|    240|#define STR_SIZE 75
  ------------------
   39|    240|  new_s[STR_SIZE] = '\0';
  ------------------
  |  |   32|    240|#define STR_SIZE 75
  ------------------
   40|       |
   41|    240|  *data = *data+STR_SIZE;
  ------------------
  |  |   32|    240|#define STR_SIZE 75
  ------------------
   42|    240|  *size -= STR_SIZE;
  ------------------
  |  |   32|    240|#define STR_SIZE 75
  ------------------
   43|    240|  return new_s;
   44|    253|}
af_gb_get_null_terminated:
   62|    253|char *af_gb_get_null_terminated(const uint8_t **data, size_t *size) {
   63|       |
   64|    253|  char *nstr = af_get_null_terminated(data, size);
   65|    253|  if (nstr == NULL) {
  ------------------
  |  Branch (65:7): [True: 13, False: 240]
  ------------------
   66|     13|    return NULL;
   67|     13|  }
   68|    240|  pointer_arr[pointer_idx++] = (void*)nstr;
   69|    240|  return nstr;
   70|    253|}

LLVMFuzzerTestOneInput:
   40|    253|int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
   41|    253|  af_gb_init();
   42|    253|  const uint8_t *data2 = data;
   43|    253|  size_t size2 = size;
   44|       |
   45|       |  // Get a NULL terminated string
   46|    253|  char *cstr = af_gb_get_null_terminated(&data2, &size2);
   47|       |
   48|       |  // Fuzz URI routines
   49|    253|  if (cstr && apr_pool_initialize() == APR_SUCCESS) {
  ------------------
  |  |  225|    240|#define APR_SUCCESS 0
  ------------------
  |  Branch (49:7): [True: 240, False: 13]
  |  Branch (49:15): [True: 240, False: 0]
  ------------------
   50|    240|    apr_pool_t *pool = NULL;
   51|    240|    apr_pool_create(&pool, NULL);
  ------------------
  |  |  301|    240|    apr_pool_create_ex(newpool, parent, NULL, NULL)
  ------------------
   52|       |
   53|    240|    apr_uri_t tmp_uri;
   54|    240|    if (apr_uri_parse(pool, cstr, &tmp_uri) == APR_SUCCESS) {
  ------------------
  |  |  225|    240|#define APR_SUCCESS 0
  ------------------
  |  Branch (54:9): [True: 209, False: 31]
  ------------------
   55|    209|      apr_uri_unparse(pool, &tmp_uri, 0);
   56|    209|    }
   57|    240|    apr_uri_parse_hostinfo(pool, cstr, &tmp_uri);
   58|       |
   59|       |    // Cleanup
   60|    240|    apr_pool_terminate();
   61|    240|  }
   62|       |
   63|    253|  af_gb_cleanup();
   64|    253|  return 0;
   65|    253|}

apr_atomic_init:
   29|    240|{
   30|       |#if defined (USE_ATOMICS_GENERIC64)
   31|       |    return apr__atomic_generic64_init(p);
   32|       |#else
   33|    240|    return APR_SUCCESS;
  ------------------
  |  |  225|    240|#define APR_SUCCESS 0
  ------------------
   34|    240|#endif
   35|    240|}

apr_thread_mutex_create:
   40|    240|{
   41|    240|    apr_thread_mutex_t *new_mutex;
   42|    240|    apr_status_t rv;
   43|       |
   44|       |#ifndef HAVE_PTHREAD_MUTEX_RECURSIVE
   45|       |    if (flags & APR_THREAD_MUTEX_NESTED) {
   46|       |        return APR_ENOTIMPL;
   47|       |    }
   48|       |#endif
   49|       |
   50|    240|    new_mutex = apr_pcalloc(pool, sizeof(apr_thread_mutex_t));
  ------------------
  |  |  454|    240|    apr_pcalloc_debug(p, size, APR_POOL__FILE_LINE__)
  |  |  ------------------
  |  |  |  |  143|    240|#define APR_POOL__FILE_LINE__ __FILE__ ":" APR_STRINGIFY(__LINE__)
  |  |  |  |  ------------------
  |  |  |  |  |  |  153|    240|#define APR_STRINGIFY(n) APR_STRINGIFY_HELPER(n)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  155|    240|#define APR_STRINGIFY_HELPER(n) #n
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   51|    240|    new_mutex->pool = pool;
   52|       |
   53|    240|#ifdef HAVE_PTHREAD_MUTEX_RECURSIVE
   54|    240|    if (flags & APR_THREAD_MUTEX_NESTED) {
  ------------------
  |  |   44|    240|#define APR_THREAD_MUTEX_NESTED   0x1   /**< enable nested (recursive) locks */
  ------------------
  |  Branch (54:9): [True: 240, False: 0]
  ------------------
   55|    240|        pthread_mutexattr_t mattr;
   56|       |
   57|    240|        rv = pthread_mutexattr_init(&mattr);
   58|    240|        if (rv) return rv;
  ------------------
  |  Branch (58:13): [True: 0, False: 240]
  ------------------
   59|       |
   60|    240|        rv = pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_RECURSIVE);
   61|    240|        if (rv) {
  ------------------
  |  Branch (61:13): [True: 0, False: 240]
  ------------------
   62|      0|            pthread_mutexattr_destroy(&mattr);
   63|      0|            return rv;
   64|      0|        }
   65|       |
   66|    240|        rv = pthread_mutex_init(&new_mutex->mutex, &mattr);
   67|       |
   68|    240|        pthread_mutexattr_destroy(&mattr);
   69|    240|    } else
   70|      0|#endif
   71|      0|    {
   72|       |#if defined(APR_THREAD_DEBUG)
   73|       |        pthread_mutexattr_t mattr;
   74|       |
   75|       |        rv = pthread_mutexattr_init(&mattr);
   76|       |        if (rv) return rv;
   77|       |
   78|       |        rv = pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_ERRORCHECK);
   79|       |        if (rv) {
   80|       |            pthread_mutexattr_destroy(&mattr);
   81|       |            return rv;
   82|       |        }
   83|       |
   84|       |        rv = pthread_mutex_init(&new_mutex->mutex, &mattr);
   85|       |
   86|       |        pthread_mutexattr_destroy(&mattr);
   87|       |#else
   88|      0|        rv = pthread_mutex_init(&new_mutex->mutex, NULL);
   89|      0|#endif
   90|      0|    }
   91|       |
   92|    240|    if (rv) {
  ------------------
  |  Branch (92:9): [True: 0, False: 240]
  ------------------
   93|       |#ifdef HAVE_ZOS_PTHREADS
   94|       |        rv = errno;
   95|       |#endif
   96|      0|        return rv;
   97|      0|    }
   98|       |
   99|       |#ifndef HAVE_PTHREAD_MUTEX_TIMEDLOCK
  100|       |    if (flags & APR_THREAD_MUTEX_TIMED) {
  101|       |        rv = apr_thread_cond_create(&new_mutex->cond, pool);
  102|       |        if (rv) {
  103|       |#ifdef HAVE_ZOS_PTHREADS
  104|       |            rv = errno;
  105|       |#endif
  106|       |            pthread_mutex_destroy(&new_mutex->mutex);
  107|       |            return rv;
  108|       |        }
  109|       |    }
  110|       |#endif
  111|       |
  112|    240|    apr_pool_cleanup_register(new_mutex->pool,
  113|    240|                              new_mutex, thread_mutex_cleanup,
  114|    240|                              apr_pool_cleanup_null);
  115|       |
  116|    240|    *mutex = new_mutex;
  117|    240|    return APR_SUCCESS;
  ------------------
  |  |  225|    240|#define APR_SUCCESS 0
  ------------------
  118|    240|}
apr_thread_mutex_lock:
  121|    240|{
  122|    240|    apr_status_t rv;
  123|       |
  124|       |#ifndef HAVE_PTHREAD_MUTEX_TIMEDLOCK
  125|       |    if (mutex->cond) {
  126|       |        apr_status_t rv2;
  127|       |
  128|       |        rv = pthread_mutex_lock(&mutex->mutex);
  129|       |        if (rv) {
  130|       |#ifdef HAVE_ZOS_PTHREADS
  131|       |            rv = errno;
  132|       |#endif
  133|       |            return rv;
  134|       |        }
  135|       |
  136|       |        if (mutex->locked) {
  137|       |            mutex->num_waiters++;
  138|       |            rv = apr_thread_cond_wait(mutex->cond, mutex);
  139|       |            mutex->num_waiters--;
  140|       |        }
  141|       |        else {
  142|       |            mutex->locked = 1;
  143|       |        }
  144|       |
  145|       |        rv2 = pthread_mutex_unlock(&mutex->mutex);
  146|       |        if (rv2 && !rv) {
  147|       |#ifdef HAVE_ZOS_PTHREADS
  148|       |            rv = errno;
  149|       |#else
  150|       |            rv = rv2;
  151|       |#endif
  152|       |        }
  153|       |
  154|       |        return rv;
  155|       |    }
  156|       |#endif
  157|       |
  158|    240|    rv = pthread_mutex_lock(&mutex->mutex);
  159|       |#ifdef HAVE_ZOS_PTHREADS
  160|       |    if (rv) {
  161|       |        rv = errno;
  162|       |    }
  163|       |#endif
  164|       |
  165|    240|    return rv;
  166|    240|}
apr_thread_mutex_unlock:
  302|    240|{
  303|    240|    apr_status_t status;
  304|       |
  305|       |#ifndef HAVE_PTHREAD_MUTEX_TIMEDLOCK
  306|       |    if (mutex->cond) {
  307|       |        status = pthread_mutex_lock(&mutex->mutex);
  308|       |        if (status) {
  309|       |#ifdef HAVE_ZOS_PTHREADS
  310|       |            status = errno;
  311|       |#endif
  312|       |            return status;
  313|       |        }
  314|       |
  315|       |        if (!mutex->locked) {
  316|       |            status = APR_EINVAL;
  317|       |        }
  318|       |        else if (mutex->num_waiters) {
  319|       |            status = apr_thread_cond_signal(mutex->cond);
  320|       |        }
  321|       |        if (status) {
  322|       |            pthread_mutex_unlock(&mutex->mutex);
  323|       |            return status;
  324|       |        }
  325|       |
  326|       |        mutex->locked = 0;
  327|       |    }
  328|       |#endif
  329|       |
  330|    240|    status = pthread_mutex_unlock(&mutex->mutex);
  331|       |#ifdef HAVE_ZOS_PTHREADS
  332|       |    if (status) {
  333|       |        status = errno;
  334|       |    }
  335|       |#endif
  336|       |
  337|    240|    return status;
  338|    240|}
thread_mutex.c:thread_mutex_cleanup:
   24|    240|{
   25|    240|    apr_thread_mutex_t *mutex = data;
   26|    240|    apr_status_t rv;
   27|       |
   28|    240|    rv = pthread_mutex_destroy(&mutex->mutex);
   29|       |#ifdef HAVE_ZOS_PTHREADS
   30|       |    if (rv) {
   31|       |        rv = errno;
   32|       |    }
   33|       |#endif
   34|    240|    return rv;
   35|    240|}

apr_pool_initialize:
 1674|    240|{
 1675|    240|    apr_status_t rv;
 1676|       |#if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL)
 1677|       |    char *logpath;
 1678|       |    apr_file_t *debug_log = NULL;
 1679|       |#endif
 1680|       |
 1681|    240|    if (apr_pools_initialized++)
  ------------------
  |  Branch (1681:9): [True: 0, False: 240]
  ------------------
 1682|      0|        return APR_SUCCESS;
  ------------------
  |  |  225|      0|#define APR_SUCCESS 0
  ------------------
 1683|       |
 1684|    240|#if defined(_SC_PAGESIZE)
 1685|    240|    boundary_size = sysconf(_SC_PAGESIZE);
 1686|       |#elif defined(WIN32)
 1687|       |    {
 1688|       |        SYSTEM_INFO si;
 1689|       |        GetSystemInfo(&si);
 1690|       |        boundary_size = si.dwPageSize;
 1691|       |    }
 1692|       |#endif
 1693|    240|    boundary_index = 12;
 1694|    240|    while ( (1 << boundary_index) < boundary_size)
  ------------------
  |  Branch (1694:13): [True: 0, False: 240]
  ------------------
 1695|      0|        boundary_index++;
 1696|    240|    boundary_size = (1 << boundary_index);
 1697|       |
 1698|       |    /* Since the debug code works a bit differently then the
 1699|       |     * regular pools code, we ask for a lock here.  The regular
 1700|       |     * pools code has got this lock embedded in the global
 1701|       |     * allocator, a concept unknown to debug mode.
 1702|       |     */
 1703|    240|    if ((rv = apr_pool_create_ex(&global_pool, NULL, NULL,
  ------------------
  |  |  247|    240|    apr_pool_create_ex_debug(newpool, parent, abort_fn, allocator, \
  |  |  248|    240|                             APR_POOL__FILE_LINE__)
  |  |  ------------------
  |  |  |  |  143|    240|#define APR_POOL__FILE_LINE__ __FILE__ ":" APR_STRINGIFY(__LINE__)
  |  |  |  |  ------------------
  |  |  |  |  |  |  153|    240|#define APR_STRINGIFY(n) APR_STRINGIFY_HELPER(n)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  155|    240|#define APR_STRINGIFY_HELPER(n) #n
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1703:9): [True: 0, False: 240]
  ------------------
 1704|    240|                                 NULL)) != APR_SUCCESS) {
  ------------------
  |  |  225|    240|#define APR_SUCCESS 0
  ------------------
 1705|      0|        return rv;
 1706|      0|    }
 1707|       |
 1708|    240|    apr_pool_tag(global_pool, "APR global pool");
 1709|       |
 1710|    240|    apr_pools_initialized = 1;
 1711|       |
 1712|       |    /* This has to happen here because mutexes might be backed by
 1713|       |     * atomics.  It used to be snug and safe in apr_initialize().
 1714|       |     */
 1715|    240|    if ((rv = apr_atomic_init(global_pool)) != APR_SUCCESS) {
  ------------------
  |  |  225|    240|#define APR_SUCCESS 0
  ------------------
  |  Branch (1715:9): [True: 0, False: 240]
  ------------------
 1716|      0|        return rv;
 1717|      0|    }
 1718|       |
 1719|       |#if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL)
 1720|       |    rv = apr_env_get(&logpath, "APR_POOL_DEBUG_LOG", global_pool);
 1721|       |
 1722|       |    /* Don't pass file_stderr directly to apr_file_open() here, since
 1723|       |     * apr_file_open() can call back to apr_pool_log_event() and that
 1724|       |     * may attempt to use then then non-NULL but partially set up file
 1725|       |     * object. */
 1726|       |    if (rv == APR_SUCCESS) {
 1727|       |        apr_file_open(&debug_log, logpath,
 1728|       |                      APR_FOPEN_APPEND|APR_FOPEN_WRITE|APR_FOPEN_CREATE,
 1729|       |                      APR_FPROT_OS_DEFAULT, global_pool);
 1730|       |    }
 1731|       |    else {
 1732|       |        apr_file_open_stderr(&debug_log, global_pool);
 1733|       |    }
 1734|       |
 1735|       |    /* debug_log is now a file handle. */
 1736|       |    file_stderr = debug_log;
 1737|       |
 1738|       |    if (file_stderr) {
 1739|       |        apr_file_printf(file_stderr,
 1740|       |            "POOL DEBUG: [PID"
 1741|       |#if APR_HAS_THREADS
 1742|       |            "/TID"
 1743|       |#endif /* APR_HAS_THREADS */
 1744|       |            "] ACTION  (SIZE      /POOL SIZE /TOTAL SIZE) "
 1745|       |            "POOL       \"TAG\" <__FILE__:__LINE__> PARENT     (ALLOCS/TOTAL ALLOCS/CLEARS)\n");
 1746|       |
 1747|       |        apr_pool_log_event(global_pool, "GLOBAL", __FILE__ ":apr_pool_initialize", 0);
 1748|       |
 1749|       |        /* Add a cleanup handler that sets the debug log file handle
 1750|       |         * to NULL, otherwise we'll try to log the global pool
 1751|       |         * destruction event with predictably disastrous results. */
 1752|       |        apr_pool_cleanup_register(global_pool, NULL,
 1753|       |                                  apr_pool_cleanup_file_stderr,
 1754|       |                                  apr_pool_cleanup_null);
 1755|       |    }
 1756|       |#endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) */
 1757|       |
 1758|    240|    return APR_SUCCESS;
  ------------------
  |  |  225|    240|#define APR_SUCCESS 0
  ------------------
 1759|    240|}
apr_pool_terminate:
 1762|    240|{
 1763|    240|    if (!apr_pools_initialized)
  ------------------
  |  Branch (1763:9): [True: 0, False: 240]
  ------------------
 1764|      0|        return;
 1765|       |
 1766|    240|    if (--apr_pools_initialized)
  ------------------
  |  Branch (1766:9): [True: 0, False: 240]
  ------------------
 1767|      0|        return;
 1768|       |
 1769|    240|    apr_pool_destroy(global_pool); /* This will also destroy the mutex */
  ------------------
  |  |  388|    240|    apr_pool_destroy_debug(p, APR_POOL__FILE_LINE__)
  |  |  ------------------
  |  |  |  |  143|    240|#define APR_POOL__FILE_LINE__ __FILE__ ":" APR_STRINGIFY(__LINE__)
  |  |  |  |  ------------------
  |  |  |  |  |  |  153|    240|#define APR_STRINGIFY(n) APR_STRINGIFY_HELPER(n)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  155|    240|#define APR_STRINGIFY_HELPER(n) #n
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1770|    240|    global_pool = NULL;
 1771|       |
 1772|       |#if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL)
 1773|       |    file_stderr = NULL;
 1774|       |#endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) */
 1775|    240|}
apr_palloc_debug:
 1823|  2.27k|{
 1824|  2.27k|    void *mem;
 1825|       |
 1826|  2.27k|    apr_pool_check_integrity(pool);
 1827|       |
 1828|  2.27k|    mem = pool_alloc(pool, size);
 1829|       |
 1830|       |#if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALLOC)
 1831|       |    apr_pool_log_event(pool, "PALLOC", file_line, 1);
 1832|       |#endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALLOC) */
 1833|       |
 1834|  2.27k|    return mem;
 1835|  2.27k|}
apr_pcalloc_debug:
 1839|    240|{
 1840|    240|    void *mem;
 1841|       |
 1842|    240|    apr_pool_check_integrity(pool);
 1843|       |
 1844|    240|    mem = pool_alloc(pool, size);
 1845|    240|    memset(mem, 0, size);
 1846|       |
 1847|       |#if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALLOC)
 1848|       |    apr_pool_log_event(pool, "PCALLOC", file_line, 1);
 1849|       |#endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALLOC) */
 1850|       |
 1851|    240|    return mem;
 1852|    240|}
apr_pool_destroy_debug:
 1985|    240|{
 1986|    240|#if APR_HAS_THREADS
 1987|    240|    apr_thread_mutex_t *mutex;
 1988|    240|#endif
 1989|       |
 1990|    240|    apr_pool_check_lifetime(pool);
 1991|       |
 1992|    240|    if (pool->joined) {
  ------------------
  |  Branch (1992:9): [True: 0, False: 240]
  ------------------
 1993|       |        /* Joined pools must not be explicitly destroyed; the caller
 1994|       |         * has broken the guarantee. */
 1995|       |#if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL)
 1996|       |        apr_pool_log_event(pool, "LIFE",
 1997|       |                           __FILE__ ":apr_pool_destroy abort on joined", 0);
 1998|       |#endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) */
 1999|       |
 2000|      0|        abort();
 2001|      0|    }
 2002|       |
 2003|    240|#if APR_HAS_THREADS
 2004|       |    /* Lock the parent mutex before destroying so that it's not accessed
 2005|       |     * concurrently by apr_pool_walk_tree.
 2006|       |     */
 2007|    240|    mutex = parent_lock(pool);
 2008|    240|#endif
 2009|       |
 2010|       |#if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE)
 2011|       |    apr_pool_log_event(pool, "DESTROY", file_line, 1);
 2012|       |#endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE) */
 2013|       |
 2014|    240|    pool_destroy_debug(pool, file_line);
 2015|       |
 2016|    240|#if APR_HAS_THREADS
 2017|       |    /* Unlock the mutex we obtained above */
 2018|    240|    parent_unlock(mutex);
 2019|    240|#endif /* APR_HAS_THREADS */
 2020|    240|}
apr_pool_create_ex_debug:
 2027|    480|{
 2028|    480|    apr_pool_t *pool;
 2029|       |
 2030|    480|    *newpool = NULL;
 2031|       |
 2032|    480|    if (!parent) {
  ------------------
  |  Branch (2032:9): [True: 480, False: 0]
  ------------------
 2033|    480|        parent = global_pool;
 2034|    480|    }
 2035|      0|    else {
 2036|      0|       apr_pool_check_lifetime(parent);
 2037|       |
 2038|      0|       if (!allocator)
  ------------------
  |  Branch (2038:12): [True: 0, False: 0]
  ------------------
 2039|      0|           allocator = parent->allocator;
 2040|      0|    }
 2041|       |
 2042|    480|    if (!abort_fn && parent)
  ------------------
  |  Branch (2042:9): [True: 480, False: 0]
  |  Branch (2042:22): [True: 240, False: 240]
  ------------------
 2043|    240|        abort_fn = parent->abort_fn;
 2044|       |
 2045|    480|    if ((pool = malloc(SIZEOF_POOL_T)) == NULL) {
  ------------------
  |  |  618|    480|#define SIZEOF_POOL_T       APR_ALIGN_DEFAULT(sizeof(apr_pool_t))
  |  |  ------------------
  |  |  |  |  143|    480|#define APR_ALIGN_DEFAULT(size) APR_ALIGN(size, 8)
  |  |  |  |  ------------------
  |  |  |  |  |  |  140|    480|    (((size) + ((boundary) - 1)) & ~((boundary) - 1))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2045:9): [True: 0, False: 480]
  ------------------
 2046|      0|        if (abort_fn)
  ------------------
  |  Branch (2046:13): [True: 0, False: 0]
  ------------------
 2047|      0|            abort_fn(APR_ENOMEM);
  ------------------
  |  |  687|      0|#define APR_ENOMEM ENOMEM
  ------------------
 2048|       |
 2049|      0|         return APR_ENOMEM;
  ------------------
  |  |  687|      0|#define APR_ENOMEM ENOMEM
  ------------------
 2050|      0|    }
 2051|       |
 2052|    480|    memset(pool, 0, SIZEOF_POOL_T);
  ------------------
  |  |  618|    480|#define SIZEOF_POOL_T       APR_ALIGN_DEFAULT(sizeof(apr_pool_t))
  |  |  ------------------
  |  |  |  |  143|    480|#define APR_ALIGN_DEFAULT(size) APR_ALIGN(size, 8)
  |  |  |  |  ------------------
  |  |  |  |  |  |  140|    480|    (((size) + ((boundary) - 1)) & ~((boundary) - 1))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2053|       |
 2054|    480|    pool->allocator = allocator;
 2055|    480|    pool->abort_fn = abort_fn;
 2056|    480|    pool->tag = file_line;
 2057|    480|    pool->file_line = file_line;
 2058|       |
 2059|    480|#if APR_HAS_THREADS
 2060|    480|    if (parent == NULL || parent->allocator != allocator) {
  ------------------
  |  Branch (2060:9): [True: 240, False: 240]
  |  Branch (2060:27): [True: 0, False: 240]
  ------------------
 2061|    240|        apr_status_t rv;
 2062|       |
 2063|       |        /* No matter what the creation flags say, always create
 2064|       |         * a lock.  Without it integrity_check and apr_pool_num_bytes
 2065|       |         * blow up (because they traverse pools child lists that
 2066|       |         * possibly belong to another thread, in combination with
 2067|       |         * the pool having no lock).  However, this might actually
 2068|       |         * hide problems like creating a child pool of a pool
 2069|       |         * belonging to another thread.
 2070|       |         */
 2071|    240|        if ((rv = apr_thread_mutex_create(&pool->mutex,
  ------------------
  |  Branch (2071:13): [True: 0, False: 240]
  ------------------
 2072|    240|                APR_THREAD_MUTEX_NESTED, pool)) != APR_SUCCESS) {
  ------------------
  |  |   44|    240|#define APR_THREAD_MUTEX_NESTED   0x1   /**< enable nested (recursive) locks */
  ------------------
                              APR_THREAD_MUTEX_NESTED, pool)) != APR_SUCCESS) {
  ------------------
  |  |  225|    240|#define APR_SUCCESS 0
  ------------------
 2073|      0|            free(pool);
 2074|      0|            return rv;
 2075|      0|        }
 2076|    240|    }
 2077|    240|    else {
 2078|    240|        pool->mutex = parent->mutex;
 2079|    240|    }
 2080|    480|#endif /* APR_HAS_THREADS */
 2081|       |
 2082|    480|    if ((pool->parent = parent) != NULL) {
  ------------------
  |  Branch (2082:9): [True: 240, False: 240]
  ------------------
 2083|    240|        pool_lock(parent);
 2084|       |
 2085|    240|        if ((pool->sibling = parent->child) != NULL)
  ------------------
  |  Branch (2085:13): [True: 0, False: 240]
  ------------------
 2086|      0|            pool->sibling->ref = &pool->sibling;
 2087|       |
 2088|    240|        parent->child = pool;
 2089|    240|        pool->ref = &parent->child;
 2090|       |
 2091|    240|        pool_unlock(parent);
 2092|    240|    }
 2093|    240|    else {
 2094|    240|        pool->sibling = NULL;
 2095|    240|        pool->ref = NULL;
 2096|    240|    }
 2097|       |
 2098|    480|#if APR_HAS_THREADS
 2099|    480|    pool->owner = apr_os_thread_current();
 2100|    480|#endif /* APR_HAS_THREADS */
 2101|       |#ifdef NETWARE
 2102|       |    pool->owner_proc = (apr_os_proc_t)getnlmhandle();
 2103|       |#endif /* defined(NETWARE) */
 2104|       |
 2105|       |#if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE)
 2106|       |    apr_pool_log_event(pool, "CREATE", file_line, 1);
 2107|       |#endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE) */
 2108|       |
 2109|    480|    *newpool = pool;
 2110|       |
 2111|    480|    return APR_SUCCESS;
  ------------------
  |  |  225|    480|#define APR_SUCCESS 0
  ------------------
 2112|    480|}
apr_pool_tag:
 2440|    240|{
 2441|    240|    pool->tag = tag;
 2442|    240|}
apr_pool_cleanup_register:
 2530|    240|{
 2531|    240|    cleanup_t *c = NULL;
 2532|       |
 2533|    240|#if APR_POOL_DEBUG
 2534|    240|    apr_pool_check_integrity(p);
 2535|    240|#endif /* APR_POOL_DEBUG */
 2536|       |
 2537|    240|    if (p != NULL) {
  ------------------
  |  Branch (2537:9): [True: 240, False: 0]
  ------------------
 2538|    240|        if (p->free_cleanups) {
  ------------------
  |  Branch (2538:13): [True: 0, False: 240]
  ------------------
 2539|       |            /* reuse a cleanup structure */
 2540|      0|            c = p->free_cleanups;
 2541|      0|            p->free_cleanups = c->next;
 2542|    240|        } else {
 2543|    240|            c = apr_palloc(p, sizeof(cleanup_t));
  ------------------
  |  |  425|    240|    apr_palloc_debug(p, size, APR_POOL__FILE_LINE__)
  |  |  ------------------
  |  |  |  |  143|    240|#define APR_POOL__FILE_LINE__ __FILE__ ":" APR_STRINGIFY(__LINE__)
  |  |  |  |  ------------------
  |  |  |  |  |  |  153|    240|#define APR_STRINGIFY(n) APR_STRINGIFY_HELPER(n)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  155|    240|#define APR_STRINGIFY_HELPER(n) #n
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2544|    240|        }
 2545|    240|        c->data = data;
 2546|    240|        c->plain_cleanup_fn = plain_cleanup_fn;
 2547|    240|        c->child_cleanup_fn = child_cleanup_fn;
 2548|    240|        c->next = p->cleanups;
 2549|    240|        p->cleanups = c;
 2550|    240|    }
 2551|       |
 2552|    240|#if APR_POOL_DEBUG
 2553|    240|    if (!c || !c->plain_cleanup_fn || !c->child_cleanup_fn) {
  ------------------
  |  Branch (2553:9): [True: 0, False: 240]
  |  Branch (2553:15): [True: 0, False: 240]
  |  Branch (2553:39): [True: 0, False: 240]
  ------------------
 2554|      0|        abort();
 2555|      0|    }
 2556|    240|#endif /* APR_POOL_DEBUG */
 2557|    240|}
apr_pool_create_ex:
 2979|    240|{
 2980|    240|    return apr_pool_create_ex_debug(newpool, parent,
 2981|    240|                                    abort_fn, allocator,
 2982|    240|                                    "undefined");
 2983|    240|}
apr_pools.c:apr_pool_check_integrity:
 1657|  2.75k|{
 1658|  2.75k|    apr_pool_check_lifetime(pool);
 1659|  2.75k|    apr_pool_check_owner(pool);
 1660|  2.75k|}
apr_pools.c:apr_pool_check_owner:
 1642|  3.23k|{
 1643|       |#if (APR_POOL_DEBUG & APR_POOL_DEBUG_OWNER)
 1644|       |#if APR_HAS_THREADS
 1645|       |    if (!apr_os_thread_equal(pool->owner, apr_os_thread_current())) {
 1646|       |#if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL)
 1647|       |        apr_pool_log_event(pool, "THREAD",
 1648|       |                           __FILE__ ":apr_pool_integrity check [owner]", 0);
 1649|       |#endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) */
 1650|       |        abort();
 1651|       |    }
 1652|       |#endif /* APR_HAS_THREADS */
 1653|       |#endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_OWNER) */
 1654|  3.23k|}
apr_pools.c:pool_alloc:
 1783|  2.51k|{
 1784|  2.51k|    debug_node_t *node;
 1785|  2.51k|    void *mem;
 1786|       |
 1787|  2.51k|    if ((mem = malloc(size)) == NULL) {
  ------------------
  |  Branch (1787:9): [True: 0, False: 2.51k]
  ------------------
 1788|      0|        if (pool->abort_fn)
  ------------------
  |  Branch (1788:13): [True: 0, False: 0]
  ------------------
 1789|      0|            pool->abort_fn(APR_ENOMEM);
  ------------------
  |  |  687|      0|#define APR_ENOMEM ENOMEM
  ------------------
 1790|       |
 1791|      0|        return NULL;
 1792|      0|    }
 1793|       |
 1794|  2.51k|    node = pool->nodes;
 1795|  2.51k|    if (node == NULL || node->index == 64) {
  ------------------
  |  Branch (1795:9): [True: 480, False: 2.03k]
  |  Branch (1795:25): [True: 0, False: 2.03k]
  ------------------
 1796|    480|        if ((node = malloc(SIZEOF_DEBUG_NODE_T)) == NULL) {
  ------------------
  |  |  562|    480|#define SIZEOF_DEBUG_NODE_T APR_ALIGN_DEFAULT(sizeof(debug_node_t))
  |  |  ------------------
  |  |  |  |  143|    480|#define APR_ALIGN_DEFAULT(size) APR_ALIGN(size, 8)
  |  |  |  |  ------------------
  |  |  |  |  |  |  140|    480|    (((size) + ((boundary) - 1)) & ~((boundary) - 1))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1796:13): [True: 0, False: 480]
  ------------------
 1797|      0|            free(mem);
 1798|      0|            if (pool->abort_fn)
  ------------------
  |  Branch (1798:17): [True: 0, False: 0]
  ------------------
 1799|      0|                pool->abort_fn(APR_ENOMEM);
  ------------------
  |  |  687|      0|#define APR_ENOMEM ENOMEM
  ------------------
 1800|       |
 1801|      0|            return NULL;
 1802|      0|        }
 1803|       |
 1804|    480|        memset(node, 0, SIZEOF_DEBUG_NODE_T);
  ------------------
  |  |  562|    480|#define SIZEOF_DEBUG_NODE_T APR_ALIGN_DEFAULT(sizeof(debug_node_t))
  |  |  ------------------
  |  |  |  |  143|    480|#define APR_ALIGN_DEFAULT(size) APR_ALIGN(size, 8)
  |  |  |  |  ------------------
  |  |  |  |  |  |  140|    480|    (((size) + ((boundary) - 1)) & ~((boundary) - 1))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1805|       |
 1806|    480|        node->next = pool->nodes;
 1807|    480|        pool->nodes = node;
 1808|    480|        node->index = 0;
 1809|    480|    }
 1810|       |
 1811|  2.51k|    node->beginp[node->index] = mem;
 1812|  2.51k|    node->endp[node->index] = (char *)mem + size;
 1813|  2.51k|    node->index++;
 1814|       |
 1815|  2.51k|    pool->stat_alloc++;
 1816|  2.51k|    pool->stat_total_alloc++;
 1817|       |
 1818|  2.51k|    return mem;
 1819|  2.51k|}
apr_pools.c:apr_pool_check_lifetime:
 1616|  2.99k|{
 1617|       |    /* Rule of thumb: use of the global pool is always
 1618|       |     * ok, since the only user is apr_pools.c.  Unless
 1619|       |     * people have searched for the top level parent and
 1620|       |     * started to use that...
 1621|       |     */
 1622|  2.99k|    if (pool == global_pool || global_pool == NULL)
  ------------------
  |  Branch (1622:9): [True: 240, False: 2.75k]
  |  Branch (1622:32): [True: 720, False: 2.03k]
  ------------------
 1623|    960|        return;
 1624|       |
 1625|       |    /* Lifetime
 1626|       |     * This basically checks to see if the pool being used is still
 1627|       |     * a relative to the global pool.  If not it was previously
 1628|       |     * destroyed, in which case we abort().
 1629|       |     */
 1630|       |#if (APR_POOL_DEBUG & APR_POOL_DEBUG_LIFETIME)
 1631|       |    if (!apr_pool_is_child_of(pool, global_pool)) {
 1632|       |#if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL)
 1633|       |        apr_pool_log_event(pool, "LIFE",
 1634|       |                           __FILE__ ":apr_pool_integrity check [lifetime]", 0);
 1635|       |#endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) */
 1636|       |        abort();
 1637|       |    }
 1638|       |#endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_LIFETIME) */
 1639|  2.99k|}
apr_pools.c:parent_lock:
 1491|    240|{
 1492|    240|    if (pool->parent) {
  ------------------
  |  Branch (1492:9): [True: 0, False: 240]
  ------------------
 1493|      0|        apr_thread_mutex_lock(pool->parent->mutex);
 1494|      0|        return pool->parent->mutex;
 1495|      0|    }
 1496|    240|    return NULL;
 1497|    240|}
apr_pools.c:pool_clear_debug:
 1862|    480|{
 1863|    480|    debug_node_t *node;
 1864|    480|    apr_size_t index;
 1865|       |
 1866|       |    /* Run pre destroy cleanups */
 1867|    480|    run_cleanups(&pool->pre_cleanups);
 1868|    480|    pool->pre_cleanups = NULL;
 1869|       |
 1870|       |    /*
 1871|       |     * Now that we have given the pre cleanups the chance to kill of any
 1872|       |     * threads using the pool, the owner must be correct.
 1873|       |     */
 1874|    480|    apr_pool_check_owner(pool);
 1875|       |
 1876|       |    /* Destroy the subpools.  The subpools will detach themselves from
 1877|       |     * this pool thus this loop is safe and easy.
 1878|       |     */
 1879|    720|    while (pool->child)
  ------------------
  |  Branch (1879:12): [True: 240, False: 480]
  ------------------
 1880|    240|        pool_destroy_debug(pool->child, file_line);
 1881|       |
 1882|       |    /* Run cleanups */
 1883|    480|    run_cleanups(&pool->cleanups);
 1884|    480|    pool->free_cleanups = NULL;
 1885|    480|    pool->cleanups = NULL;
 1886|       |
 1887|       |    /* If new child pools showed up, this is a reason to raise a flag */
 1888|    480|    if (pool->child)
  ------------------
  |  Branch (1888:9): [True: 0, False: 480]
  ------------------
 1889|      0|        abort();
 1890|       |
 1891|       |    /* Free subprocesses */
 1892|    480|    free_proc_chain(pool->subprocesses);
 1893|    480|    pool->subprocesses = NULL;
 1894|       |
 1895|       |    /* Clear the user data. */
 1896|    480|    pool->user_data = NULL;
 1897|       |
 1898|       |    /* Free the blocks, scribbling over them first to help highlight
 1899|       |     * use-after-free issues. */
 1900|    960|    while ((node = pool->nodes) != NULL) {
  ------------------
  |  Branch (1900:12): [True: 480, False: 480]
  ------------------
 1901|    480|        pool->nodes = node->next;
 1902|       |
 1903|  2.99k|        for (index = 0; index < node->index; index++) {
  ------------------
  |  Branch (1903:25): [True: 2.51k, False: 480]
  ------------------
 1904|  2.51k|            memset(node->beginp[index], POOL_POISON_BYTE,
  ------------------
  |  | 1859|  2.51k|#define POOL_POISON_BYTE 'A'
  ------------------
 1905|  2.51k|                   (char *)node->endp[index] - (char *)node->beginp[index]);
 1906|  2.51k|            free(node->beginp[index]);
 1907|  2.51k|        }
 1908|       |
 1909|    480|        memset(node, POOL_POISON_BYTE, SIZEOF_DEBUG_NODE_T);
  ------------------
  |  | 1859|    480|#define POOL_POISON_BYTE 'A'
  ------------------
                      memset(node, POOL_POISON_BYTE, SIZEOF_DEBUG_NODE_T);
  ------------------
  |  |  562|    480|#define SIZEOF_DEBUG_NODE_T APR_ALIGN_DEFAULT(sizeof(debug_node_t))
  |  |  ------------------
  |  |  |  |  143|    480|#define APR_ALIGN_DEFAULT(size) APR_ALIGN(size, 8)
  |  |  |  |  ------------------
  |  |  |  |  |  |  140|    480|    (((size) + ((boundary) - 1)) & ~((boundary) - 1))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1910|    480|        free(node);
 1911|    480|    }
 1912|       |
 1913|    480|    pool->stat_alloc = 0;
 1914|    480|    pool->stat_clear++;
 1915|       |
 1916|       |#if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE)
 1917|       |    apr_pool_log_event(pool, "CLEARED", file_line, 1);
 1918|       |#endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE) */
 1919|    480|}
apr_pools.c:run_cleanups:
 2684|    960|{
 2685|    960|    cleanup_t *c = *cref;
 2686|       |
 2687|  1.20k|    while (c) {
  ------------------
  |  Branch (2687:12): [True: 240, False: 960]
  ------------------
 2688|    240|        *cref = c->next;
 2689|    240|        (*c->plain_cleanup_fn)((void *)c->data);
 2690|    240|        c = *cref;
 2691|    240|    }
 2692|    960|}
apr_pools.c:free_proc_chain:
 2764|    480|{
 2765|       |    /* Dispose of the subprocesses we've spawned off in the course of
 2766|       |     * whatever it was we're cleaning up now.  This may involve killing
 2767|       |     * some of them off...
 2768|       |     */
 2769|    480|    struct process_chain *pc;
 2770|    480|    int need_timeout = 0;
 2771|    480|    apr_time_t timeout_interval;
 2772|       |
 2773|    480|    if (!procs)
  ------------------
  |  Branch (2773:9): [True: 480, False: 0]
  ------------------
 2774|    480|        return; /* No work.  Whew! */
 2775|       |
 2776|       |    /* First, check to see if we need to do the SIGTERM, sleep, SIGKILL
 2777|       |     * dance with any of the processes we're cleaning up.  If we've got
 2778|       |     * any kill-on-sight subprocesses, ditch them now as well, so they
 2779|       |     * don't waste any more cycles doing whatever it is that they shouldn't
 2780|       |     * be doing anymore.
 2781|       |     */
 2782|       |
 2783|      0|#ifndef NEED_WAITPID
 2784|       |    /* Pick up all defunct processes */
 2785|      0|    for (pc = procs; pc; pc = pc->next) {
  ------------------
  |  Branch (2785:22): [True: 0, False: 0]
  ------------------
 2786|      0|        if (apr_proc_wait(pc->proc, NULL, NULL, APR_NOWAIT) != APR_CHILD_NOTDONE)
  ------------------
  |  |  454|      0|#define APR_CHILD_NOTDONE  (APR_OS_START_STATUS + 6)
  |  |  ------------------
  |  |  |  |  136|      0|#define APR_OS_START_STATUS    (APR_OS_START_ERROR + APR_OS_ERRSPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  117|      0|#define APR_OS_START_ERROR     20000
  |  |  |  |  ------------------
  |  |  |  |               #define APR_OS_START_STATUS    (APR_OS_START_ERROR + APR_OS_ERRSPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  123|      0|#define APR_OS_ERRSPACE_SIZE 50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2786:13): [True: 0, False: 0]
  ------------------
 2787|      0|            pc->kill_how = APR_KILL_NEVER;
 2788|      0|    }
 2789|      0|#endif /* !defined(NEED_WAITPID) */
 2790|       |
 2791|      0|    for (pc = procs; pc; pc = pc->next) {
  ------------------
  |  Branch (2791:22): [True: 0, False: 0]
  ------------------
 2792|      0|#ifndef WIN32
 2793|      0|        if ((pc->kill_how == APR_KILL_AFTER_TIMEOUT)
  ------------------
  |  Branch (2793:13): [True: 0, False: 0]
  ------------------
 2794|      0|            || (pc->kill_how == APR_KILL_ONLY_ONCE)) {
  ------------------
  |  Branch (2794:16): [True: 0, False: 0]
  ------------------
 2795|       |            /*
 2796|       |             * Subprocess may be dead already.  Only need the timeout if not.
 2797|       |             * Note: apr_proc_kill on Windows is TerminateProcess(), which is
 2798|       |             * similar to a SIGKILL, so always give the process a timeout
 2799|       |             * under Windows before killing it.
 2800|       |             */
 2801|      0|            if (apr_proc_kill(pc->proc, SIGTERM) == APR_SUCCESS)
  ------------------
  |  |  225|      0|#define APR_SUCCESS 0
  ------------------
  |  Branch (2801:17): [True: 0, False: 0]
  ------------------
 2802|      0|                need_timeout = 1;
 2803|      0|        }
 2804|      0|        else if (pc->kill_how == APR_KILL_ALWAYS) {
  ------------------
  |  Branch (2804:18): [True: 0, False: 0]
  ------------------
 2805|       |#else /* WIN32 knows only one fast, clean method of killing processes today */
 2806|       |        if (pc->kill_how != APR_KILL_NEVER) {
 2807|       |            need_timeout = 1;
 2808|       |            pc->kill_how = APR_KILL_ALWAYS;
 2809|       |#endif
 2810|      0|            apr_proc_kill(pc->proc, SIGKILL);
 2811|      0|        }
 2812|      0|    }
 2813|       |
 2814|       |    /* Sleep only if we have to. The sleep algorithm grows
 2815|       |     * by a factor of two on each iteration. TIMEOUT_INTERVAL
 2816|       |     * is equal to TIMEOUT_USECS / 64.
 2817|       |     */
 2818|      0|    if (need_timeout) {
  ------------------
  |  Branch (2818:9): [True: 0, False: 0]
  ------------------
 2819|      0|        timeout_interval = TIMEOUT_INTERVAL;
  ------------------
  |  |  106|      0|#define TIMEOUT_INTERVAL   46875
  ------------------
 2820|      0|        apr_sleep(timeout_interval);
 2821|       |
 2822|      0|        do {
 2823|       |            /* check the status of the subprocesses */
 2824|      0|            need_timeout = 0;
 2825|      0|            for (pc = procs; pc; pc = pc->next) {
  ------------------
  |  Branch (2825:30): [True: 0, False: 0]
  ------------------
 2826|      0|                if (pc->kill_how == APR_KILL_AFTER_TIMEOUT) {
  ------------------
  |  Branch (2826:21): [True: 0, False: 0]
  ------------------
 2827|      0|                    if (apr_proc_wait(pc->proc, NULL, NULL, APR_NOWAIT)
  ------------------
  |  Branch (2827:25): [True: 0, False: 0]
  ------------------
 2828|      0|                            == APR_CHILD_NOTDONE)
  ------------------
  |  |  454|      0|#define APR_CHILD_NOTDONE  (APR_OS_START_STATUS + 6)
  |  |  ------------------
  |  |  |  |  136|      0|#define APR_OS_START_STATUS    (APR_OS_START_ERROR + APR_OS_ERRSPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  117|      0|#define APR_OS_START_ERROR     20000
  |  |  |  |  ------------------
  |  |  |  |               #define APR_OS_START_STATUS    (APR_OS_START_ERROR + APR_OS_ERRSPACE_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  123|      0|#define APR_OS_ERRSPACE_SIZE 50000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2829|      0|                        need_timeout = 1;		/* subprocess is still active */
 2830|      0|                    else
 2831|      0|                        pc->kill_how = APR_KILL_NEVER;	/* subprocess has exited */
 2832|      0|                }
 2833|      0|            }
 2834|      0|            if (need_timeout) {
  ------------------
  |  Branch (2834:17): [True: 0, False: 0]
  ------------------
 2835|      0|                if (timeout_interval >= TIMEOUT_USECS) {
  ------------------
  |  |  105|      0|#define TIMEOUT_USECS    3000000
  ------------------
  |  Branch (2835:21): [True: 0, False: 0]
  ------------------
 2836|      0|                    break;
 2837|      0|                }
 2838|      0|                apr_sleep(timeout_interval);
 2839|      0|                timeout_interval *= 2;
 2840|      0|            }
 2841|      0|        } while (need_timeout);
  ------------------
  |  Branch (2841:18): [True: 0, False: 0]
  ------------------
 2842|      0|    }
 2843|       |
 2844|       |    /* OK, the scripts we just timed out for have had a chance to clean up
 2845|       |     * --- now, just get rid of them, and also clean up the system accounting
 2846|       |     * goop...
 2847|       |     */
 2848|      0|    for (pc = procs; pc; pc = pc->next) {
  ------------------
  |  Branch (2848:22): [True: 0, False: 0]
  ------------------
 2849|      0|        if (pc->kill_how == APR_KILL_AFTER_TIMEOUT)
  ------------------
  |  Branch (2849:13): [True: 0, False: 0]
  ------------------
 2850|      0|            apr_proc_kill(pc->proc, SIGKILL);
 2851|      0|    }
 2852|       |
 2853|       |    /* Now wait for all the signaled processes to die */
 2854|      0|    for (pc = procs; pc; pc = pc->next) {
  ------------------
  |  Branch (2854:22): [True: 0, False: 0]
  ------------------
 2855|      0|        if (pc->kill_how != APR_KILL_NEVER)
  ------------------
  |  Branch (2855:13): [True: 0, False: 0]
  ------------------
 2856|      0|            (void)apr_proc_wait(pc->proc, NULL, NULL, APR_WAIT);
 2857|      0|    }
 2858|      0|}
apr_pools.c:parent_unlock:
 1501|    240|{
 1502|    240|    if (mutex) {
  ------------------
  |  Branch (1502:9): [True: 0, False: 240]
  ------------------
 1503|      0|        apr_thread_mutex_unlock(mutex);
 1504|      0|    }
 1505|    240|}
apr_pools.c:pool_destroy_debug:
 1964|    480|{
 1965|    480|    pool_clear_debug(pool, file_line);
 1966|       |
 1967|       |    /* Remove the pool from the parent's child list */
 1968|    480|    if (pool->parent != NULL
  ------------------
  |  Branch (1968:9): [True: 240, False: 240]
  ------------------
 1969|    480|        && (*pool->ref = pool->sibling) != NULL) {
  ------------------
  |  Branch (1969:12): [True: 0, False: 240]
  ------------------
 1970|      0|        pool->sibling->ref = pool->ref;
 1971|      0|    }
 1972|       |
 1973|       |    /* Destroy the allocator if the pool owns it */
 1974|    480|    if (pool->allocator != NULL
  ------------------
  |  Branch (1974:9): [True: 0, False: 480]
  ------------------
 1975|    480|        && apr_allocator_owner_get(pool->allocator) == pool) {
  ------------------
  |  Branch (1975:12): [True: 0, False: 0]
  ------------------
 1976|      0|        apr_allocator_destroy(pool->allocator);
 1977|      0|    }
 1978|       |
 1979|       |    /* Free the pool itself */
 1980|    480|    free(pool);
 1981|    480|}
apr_pools.c:pool_lock:
 1474|    240|{
 1475|    240|#if APR_HAS_THREADS
 1476|    240|    apr_thread_mutex_lock(pool->mutex);
 1477|    240|#endif /* APR_HAS_THREADS */
 1478|    240|}
apr_pools.c:pool_unlock:
 1482|    240|{
 1483|    240|#if APR_HAS_THREADS
 1484|    240|    apr_thread_mutex_unlock(pool->mutex);
 1485|    240|#endif /* APR_HAS_THREADS */
 1486|    240|}

apr_pstrdup:
   70|    480|{
   71|    480|    char *res;
   72|    480|    apr_size_t len;
   73|       |
   74|    480|    if (s == NULL) {
  ------------------
  |  Branch (74:9): [True: 0, False: 480]
  ------------------
   75|      0|        return NULL;
   76|      0|    }
   77|    480|    len = strlen(s) + 1;
   78|    480|    res = apr_pmemdup(a, s, len);
   79|    480|    return res;
   80|    480|}
apr_pstrndup:
   83|    208|{
   84|    208|    char *res;
   85|    208|    const char *end;
   86|       |
   87|    208|    if (s == NULL) {
  ------------------
  |  Branch (87:9): [True: 0, False: 208]
  ------------------
   88|      0|        return NULL;
   89|      0|    }
   90|    208|    end = memchr(s, '\0', n);
   91|    208|    if (end != NULL)
  ------------------
  |  Branch (91:9): [True: 0, False: 208]
  ------------------
   92|      0|        n = end - s;
   93|    208|    res = apr_palloc(a, n + 1);
  ------------------
  |  |  425|    208|    apr_palloc_debug(p, size, APR_POOL__FILE_LINE__)
  |  |  ------------------
  |  |  |  |  143|    208|#define APR_POOL__FILE_LINE__ __FILE__ ":" APR_STRINGIFY(__LINE__)
  |  |  |  |  ------------------
  |  |  |  |  |  |  153|    208|#define APR_STRINGIFY(n) APR_STRINGIFY_HELPER(n)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  155|    208|#define APR_STRINGIFY_HELPER(n) #n
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   94|    208|    memcpy(res, s, n);
   95|    208|    res[n] = '\0';
   96|    208|    return res;
   97|    208|}
apr_pstrmemdup:
  100|    804|{
  101|    804|    char *res;
  102|       |
  103|    804|    if (s == NULL) {
  ------------------
  |  Branch (103:9): [True: 0, False: 804]
  ------------------
  104|      0|        return NULL;
  105|      0|    }
  106|    804|    res = apr_palloc(a, n + 1);
  ------------------
  |  |  425|    804|    apr_palloc_debug(p, size, APR_POOL__FILE_LINE__)
  |  |  ------------------
  |  |  |  |  143|    804|#define APR_POOL__FILE_LINE__ __FILE__ ":" APR_STRINGIFY(__LINE__)
  |  |  |  |  ------------------
  |  |  |  |  |  |  153|    804|#define APR_STRINGIFY(n) APR_STRINGIFY_HELPER(n)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  155|    804|#define APR_STRINGIFY_HELPER(n) #n
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  107|    804|    memcpy(res, s, n);
  108|    804|    res[n] = '\0';
  109|    804|    return res;
  110|    804|}
apr_pmemdup:
  113|    480|{
  114|    480|    void *res;
  115|       |
  116|    480|    if (m == NULL)
  ------------------
  |  Branch (116:9): [True: 0, False: 480]
  ------------------
  117|      0|	return NULL;
  118|    480|    res = apr_palloc(a, n);
  ------------------
  |  |  425|    480|    apr_palloc_debug(p, size, APR_POOL__FILE_LINE__)
  |  |  ------------------
  |  |  |  |  143|    480|#define APR_POOL__FILE_LINE__ __FILE__ ":" APR_STRINGIFY(__LINE__)
  |  |  |  |  ------------------
  |  |  |  |  |  |  153|    480|#define APR_STRINGIFY(n) APR_STRINGIFY_HELPER(n)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  155|    480|#define APR_STRINGIFY_HELPER(n) #n
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  119|    480|    memcpy(res, m, n);
  120|    480|    return res;
  121|    480|}
apr_pstrcat:
  124|    544|{
  125|    544|    char *cp, *argp, *res;
  126|    544|    apr_size_t saved_lengths[MAX_SAVED_LENGTHS];
  127|    544|    int nargs = 0;
  128|       |
  129|       |    /* Pass one --- find length of required string */
  130|       |
  131|    544|    apr_size_t len = 0;
  132|    544|    va_list adummy;
  133|       |
  134|    544|    va_start(adummy, a);
  135|       |
  136|  3.07k|    while ((cp = va_arg(adummy, char *)) != NULL) {
  ------------------
  |  Branch (136:12): [True: 2.52k, False: 544]
  ------------------
  137|  2.52k|        apr_size_t cplen = strlen(cp);
  138|  2.52k|        if (nargs < MAX_SAVED_LENGTHS) {
  ------------------
  |  |   67|  2.52k|#define MAX_SAVED_LENGTHS  6
  ------------------
  |  Branch (138:13): [True: 2.37k, False: 154]
  ------------------
  139|  2.37k|            saved_lengths[nargs++] = cplen;
  140|  2.37k|        }
  141|  2.52k|        len += cplen;
  142|  2.52k|    }
  143|       |
  144|    544|    va_end(adummy);
  145|       |
  146|       |    /* Allocate the required string */
  147|       |
  148|    544|    res = (char *) apr_palloc(a, len + 1);
  ------------------
  |  |  425|    544|    apr_palloc_debug(p, size, APR_POOL__FILE_LINE__)
  |  |  ------------------
  |  |  |  |  143|    544|#define APR_POOL__FILE_LINE__ __FILE__ ":" APR_STRINGIFY(__LINE__)
  |  |  |  |  ------------------
  |  |  |  |  |  |  153|    544|#define APR_STRINGIFY(n) APR_STRINGIFY_HELPER(n)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  155|    544|#define APR_STRINGIFY_HELPER(n) #n
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  149|    544|    cp = res;
  150|       |
  151|       |    /* Pass two --- copy the argument strings into the result space */
  152|       |
  153|    544|    va_start(adummy, a);
  154|       |
  155|    544|    nargs = 0;
  156|  3.07k|    while ((argp = va_arg(adummy, char *)) != NULL) {
  ------------------
  |  Branch (156:12): [True: 2.52k, False: 544]
  ------------------
  157|  2.52k|        if (nargs < MAX_SAVED_LENGTHS) {
  ------------------
  |  |   67|  2.52k|#define MAX_SAVED_LENGTHS  6
  ------------------
  |  Branch (157:13): [True: 2.37k, False: 154]
  ------------------
  158|  2.37k|            len = saved_lengths[nargs++];
  159|  2.37k|        }
  160|    154|        else {
  161|    154|            len = strlen(argp);
  162|    154|        }
  163|       |
  164|  2.52k|        memcpy(cp, argp, len);
  165|  2.52k|        cp += len;
  166|  2.52k|    }
  167|       |
  168|    544|    va_end(adummy);
  169|       |
  170|       |    /* Return the result string */
  171|       |
  172|    544|    *cp = '\0';
  173|       |
  174|    544|    return res;
  175|    544|}

apr_os_thread_current:
  340|    480|{
  341|    480|    return pthread_self();
  342|    480|}

apr_uri_port_of_scheme:
   74|    139|{
   75|    139|    schemes_t *scheme;
   76|       |
   77|    139|    if (scheme_str) {
  ------------------
  |  Branch (77:9): [True: 133, False: 6]
  ------------------
   78|  2.46k|        for (scheme = schemes; scheme->name != NULL; ++scheme) {
  ------------------
  |  Branch (78:32): [True: 2.35k, False: 110]
  ------------------
   79|  2.35k|            if (strcasecmp(scheme_str, scheme->name) == 0) {
  ------------------
  |  Branch (79:17): [True: 23, False: 2.33k]
  ------------------
   80|     23|                return scheme->default_port;
   81|     23|            }
   82|  2.35k|        }
   83|    133|    }
   84|    116|    return 0;
   85|    139|}
apr_uri_unparse:
   93|    209|{
   94|    209|    char *ret = "";
   95|       |
   96|       |    /* If suppressing the site part, omit both user name & scheme://hostname */
   97|    209|    if (!(flags & APR_URI_UNP_OMITSITEPART)) {
  ------------------
  |  |   64|    209|#define APR_URI_UNP_OMITSITEPART    (1U<<0)
  ------------------
  |  Branch (97:9): [True: 209, False: 0]
  ------------------
   98|       |
   99|       |        /* Construct a "user:password@" string, honoring the passed
  100|       |         * APR_URI_UNP_ flags: */
  101|    209|        if (uptr->user || uptr->password) {
  ------------------
  |  Branch (101:13): [True: 23, False: 186]
  |  Branch (101:27): [True: 0, False: 186]
  ------------------
  102|     23|            ret = apr_pstrcat(p,
  103|     23|                      (uptr->user     && !(flags & APR_URI_UNP_OMITUSER))
  ------------------
  |  |   66|     23|#define APR_URI_UNP_OMITUSER        (1U<<1)
  ------------------
  |  Branch (103:24): [True: 23, False: 0]
  |  Branch (103:42): [True: 23, False: 0]
  ------------------
  104|     23|                          ? uptr->user : "",
  105|     23|                      (uptr->password && !(flags & APR_URI_UNP_OMITPASSWORD))
  ------------------
  |  |   68|      9|#define APR_URI_UNP_OMITPASSWORD    (1U<<2)
  ------------------
  |  Branch (105:24): [True: 9, False: 14]
  |  Branch (105:42): [True: 9, False: 0]
  ------------------
  106|     23|                          ? ":" : "",
  107|     23|                      (uptr->password && !(flags & APR_URI_UNP_OMITPASSWORD))
  ------------------
  |  |   68|      9|#define APR_URI_UNP_OMITPASSWORD    (1U<<2)
  ------------------
  |  Branch (107:24): [True: 9, False: 14]
  |  Branch (107:42): [True: 9, False: 0]
  ------------------
  108|     23|                          ? ((flags & APR_URI_UNP_REVEALPASSWORD)
  ------------------
  |  |   73|      9|#define APR_URI_UNP_REVEALPASSWORD  (1U<<3)
  ------------------
  |  Branch (108:30): [True: 0, False: 9]
  ------------------
  109|      9|                              ? uptr->password : "XXXXXXXX")
  110|     23|                          : "",
  111|     23|                      ((uptr->user     && !(flags & APR_URI_UNP_OMITUSER)) ||
  ------------------
  |  |   66|     23|#define APR_URI_UNP_OMITUSER        (1U<<1)
  ------------------
  |  Branch (111:25): [True: 23, False: 0]
  |  Branch (111:43): [True: 23, False: 0]
  ------------------
  112|     23|                       (uptr->password && !(flags & APR_URI_UNP_OMITPASSWORD)))
  ------------------
  |  |   68|      0|#define APR_URI_UNP_OMITPASSWORD    (1U<<2)
  ------------------
  |  Branch (112:25): [True: 0, False: 0]
  |  Branch (112:43): [True: 0, False: 0]
  ------------------
  113|     23|                          ? "@" : "",
  114|     23|                      NULL);
  115|     23|        }
  116|       |
  117|       |        /* Construct scheme://site string */
  118|    209|        if (uptr->hostname) {
  ------------------
  |  Branch (118:13): [True: 154, False: 55]
  ------------------
  119|    154|            int is_default_port;
  120|    154|            const char *lbrk = "", *rbrk = "";
  121|       |
  122|    154|            if (strchr(uptr->hostname, ':')) { /* v6 literal */
  ------------------
  |  Branch (122:17): [True: 4, False: 150]
  ------------------
  123|      4|                lbrk = "[";
  124|      4|                rbrk = "]";
  125|      4|            }
  126|       |
  127|    154|            is_default_port =
  128|    154|                (uptr->port_str == NULL ||
  ------------------
  |  Branch (128:18): [True: 22, False: 132]
  ------------------
  129|    154|                 uptr->port == 0 ||
  ------------------
  |  Branch (129:18): [True: 54, False: 78]
  ------------------
  130|    154|                 uptr->port == apr_uri_port_of_scheme(uptr->scheme));
  ------------------
  |  Branch (130:18): [True: 7, False: 71]
  ------------------
  131|       |
  132|    154|            ret = apr_pstrcat(p, "//", ret, lbrk, uptr->hostname, rbrk,
  133|    154|                        is_default_port ? "" : ":",
  ------------------
  |  Branch (133:25): [True: 83, False: 71]
  ------------------
  134|    154|                        is_default_port ? "" : uptr->port_str,
  ------------------
  |  Branch (134:25): [True: 83, False: 71]
  ------------------
  135|    154|                        NULL);
  136|    154|        }
  137|    209|	if (uptr->scheme) {
  ------------------
  |  Branch (137:6): [True: 158, False: 51]
  ------------------
  138|    158|	    ret = apr_pstrcat(p, uptr->scheme, ":", ret, NULL);
  139|    158|	}
  140|    209|    }
  141|       |
  142|       |    /* Should we suppress all path info? */
  143|    209|    if (!(flags & APR_URI_UNP_OMITPATHINFO)) {
  ------------------
  |  |   75|    209|#define APR_URI_UNP_OMITPATHINFO    (1U<<4)
  ------------------
  |  Branch (143:9): [True: 209, False: 0]
  ------------------
  144|       |        /* Append path, query and fragment strings: */
  145|    209|        ret = apr_pstrcat(p,
  146|    209|                          ret,
  147|    209|                          (uptr->path)
  ------------------
  |  Branch (147:27): [True: 133, False: 76]
  ------------------
  148|    209|                              ? uptr->path : "",
  149|    209|                          (uptr->query    && !(flags & APR_URI_UNP_OMITQUERY))
  ------------------
  |  |   77|     13|#define APR_URI_UNP_OMITQUERY       (1U<<5)
  ------------------
  |  Branch (149:28): [True: 13, False: 196]
  |  Branch (149:46): [True: 13, False: 0]
  ------------------
  150|    209|                              ? "?" : "",
  151|    209|                          (uptr->query    && !(flags & APR_URI_UNP_OMITQUERY))
  ------------------
  |  |   77|     13|#define APR_URI_UNP_OMITQUERY       (1U<<5)
  ------------------
  |  Branch (151:28): [True: 13, False: 196]
  |  Branch (151:46): [True: 13, False: 0]
  ------------------
  152|    209|                              ? uptr->query : "",
  153|    209|                          (uptr->fragment && !(flags & APR_URI_UNP_OMITQUERY))
  ------------------
  |  |   77|     24|#define APR_URI_UNP_OMITQUERY       (1U<<5)
  ------------------
  |  Branch (153:28): [True: 24, False: 185]
  |  Branch (153:46): [True: 24, False: 0]
  ------------------
  154|    209|                              ? "#" : NULL,
  155|    209|                          (uptr->fragment && !(flags & APR_URI_UNP_OMITQUERY))
  ------------------
  |  |   77|     24|#define APR_URI_UNP_OMITQUERY       (1U<<5)
  ------------------
  |  Branch (155:28): [True: 24, False: 185]
  |  Branch (155:46): [True: 24, False: 0]
  ------------------
  156|    209|                              ? uptr->fragment : NULL,
  157|    209|                          NULL);
  158|    209|    }
  159|    209|    return ret;
  160|    209|}
apr_uri_parse:
  724|    240|{
  725|    240|    const char *s;
  726|    240|    const char *s1;
  727|    240|    const char *hostinfo;
  728|    240|    char *endstr;
  729|    240|    int port;
  730|    240|    int v6_offset1 = 0, v6_offset2 = 0;
  731|       |
  732|       |    /* Initialize the structure. parse_uri() and parse_uri_components()
  733|       |     * can be called more than once per request.
  734|       |     */
  735|    240|    memset (uptr, '\0', sizeof(*uptr));
  736|    240|    uptr->is_initialized = 1;
  737|       |
  738|       |    /* We assume the processor has a branch predictor like most --
  739|       |     * it assumes forward branches are untaken and backwards are taken.  That's
  740|       |     * the reason for the gotos.  -djg
  741|       |     */
  742|    240|    if (uri[0] == '/') {
  ------------------
  |  Branch (742:9): [True: 30, False: 210]
  ------------------
  743|       |        /* RFC2396 #4.3 says that two leading slashes mean we have an
  744|       |         * authority component, not a path!  Fixing this looks scary
  745|       |         * with the gotos here.  But if the existing logic is valid,
  746|       |         * then presumably a goto pointing to deal_with_authority works.
  747|       |         *
  748|       |         * RFC2396 describes this as resolving an ambiguity.  In the
  749|       |         * case of three or more slashes there would seem to be no
  750|       |         * ambiguity, so it is a path after all.
  751|       |         */
  752|     30|        if (uri[1] == '/' && uri[2] != '/') {
  ------------------
  |  Branch (752:13): [True: 18, False: 12]
  |  Branch (752:30): [True: 17, False: 1]
  ------------------
  753|     17|            s = uri + 2 ;
  754|     17|            goto deal_with_authority ;
  755|     17|        }
  756|       |
  757|    209|deal_with_path:
  758|       |        /* we expect uri to point to first character of path ... remember
  759|       |         * that the path could be empty -- http://foobar?query for example
  760|       |         */
  761|    209|        s = uri;
  762|  3.48k|        while ((uri_delims[*(unsigned char *)s] & NOTEND_PATH) == 0) {
  ------------------
  |  |  712|  3.48k|#define NOTEND_PATH       (T_QUESTION | T_HASH | T_NUL)
  |  |  ------------------
  |  |  |  |  174|  3.48k|#define T_QUESTION        0x02        /* '?' */
  |  |  ------------------
  |  |               #define NOTEND_PATH       (T_QUESTION | T_HASH | T_NUL)
  |  |  ------------------
  |  |  |  |  175|  3.48k|#define T_HASH            0x04        /* '#' */
  |  |  ------------------
  |  |               #define NOTEND_PATH       (T_QUESTION | T_HASH | T_NUL)
  |  |  ------------------
  |  |  |  |  180|  3.48k|#define T_NUL             0x80        /* '\0' */
  |  |  ------------------
  ------------------
  |  Branch (762:16): [True: 3.27k, False: 209]
  ------------------
  763|  3.27k|            ++s;
  764|  3.27k|        }
  765|    209|        if (s != uri) {
  ------------------
  |  Branch (765:13): [True: 133, False: 76]
  ------------------
  766|    133|            uptr->path = apr_pstrmemdup(p, uri, s - uri);
  767|    133|        }
  768|    209|        if (*s == 0) {
  ------------------
  |  Branch (768:13): [True: 177, False: 32]
  ------------------
  769|    177|            return APR_SUCCESS;
  ------------------
  |  |  225|    177|#define APR_SUCCESS 0
  ------------------
  770|    177|        }
  771|     32|        if (*s == '?') {
  ------------------
  |  Branch (771:13): [True: 13, False: 19]
  ------------------
  772|     13|            ++s;
  773|     13|            s1 = strchr(s, '#');
  774|     13|            if (s1) {
  ------------------
  |  Branch (774:17): [True: 5, False: 8]
  ------------------
  775|      5|                uptr->fragment = apr_pstrdup(p, s1 + 1);
  776|      5|                uptr->query = apr_pstrmemdup(p, s, s1 - s);
  777|      5|            }
  778|      8|            else {
  779|      8|                uptr->query = apr_pstrdup(p, s);
  780|      8|            }
  781|     13|            return APR_SUCCESS;
  ------------------
  |  |  225|     13|#define APR_SUCCESS 0
  ------------------
  782|     13|        }
  783|       |        /* otherwise it's a fragment */
  784|     19|        uptr->fragment = apr_pstrdup(p, s + 1);
  785|     19|        return APR_SUCCESS;
  ------------------
  |  |  225|     19|#define APR_SUCCESS 0
  ------------------
  786|     32|    }
  787|       |
  788|       |    /* find the scheme: */
  789|    210|    s = uri;
  790|       |    /* first char must be letter */
  791|    210|    if (uri_delims[*(unsigned char *)s] & T_ALPHA) {
  ------------------
  |  |  176|    210|#define T_ALPHA           0x08        /* 'A' ... 'Z', 'a' ... 'z' */
  ------------------
  |  Branch (791:9): [True: 185, False: 25]
  ------------------
  792|    185|        ++s;
  793|  2.57k|        while ((uri_delims[*(unsigned char *)s] & (T_ALPHA|T_SCHEME)))
  ------------------
  |  |  176|  2.57k|#define T_ALPHA           0x08        /* 'A' ... 'Z', 'a' ... 'z' */
  ------------------
                      while ((uri_delims[*(unsigned char *)s] & (T_ALPHA|T_SCHEME)))
  ------------------
  |  |  177|  2.57k|#define T_SCHEME          0x10        /* '0' ... '9', '-', '+', '.'
  ------------------
  |  Branch (793:16): [True: 2.39k, False: 185]
  ------------------
  794|  2.39k|            ++s;
  795|    185|    }
  796|       |    /* scheme must be non-empty and followed by : */
  797|    210|    if (s != uri && s[0] == ':') {
  ------------------
  |  Branch (797:9): [True: 185, False: 25]
  |  Branch (797:21): [True: 164, False: 21]
  ------------------
  798|    164|        uptr->scheme = apr_pstrmemdup(p, uri, s - uri);
  799|    164|        s++;
  800|    164|    }
  801|     46|    else {
  802|       |        /* No valid scheme, restart from the beginning */
  803|     46|        s = uri;
  804|     46|    }
  805|       |
  806|    210|    if (s[0] != '/' || s[1] != '/') {
  ------------------
  |  Branch (806:9): [True: 50, False: 160]
  |  Branch (806:24): [True: 13, False: 147]
  ------------------
  807|     63|        if (uri == s) {
  ------------------
  |  Branch (807:13): [True: 46, False: 17]
  ------------------
  808|       |            /*
  809|       |             * RFC 3986 3.3: If we have no scheme and no authority,
  810|       |             * the leading segment of a relative path must not contain a ':'.
  811|       |             */
  812|     46|            char *first_slash = strchr(uri, '/');
  813|     46|            if (first_slash) {
  ------------------
  |  Branch (813:17): [True: 30, False: 16]
  ------------------
  814|    445|                while (s < first_slash) {
  ------------------
  |  Branch (814:24): [True: 431, False: 14]
  ------------------
  815|    431|                    if (s[0] == ':')
  ------------------
  |  Branch (815:25): [True: 16, False: 415]
  ------------------
  816|     16|                        return APR_EGENERAL;
  ------------------
  |  |  313|     16|#define APR_EGENERAL       (APR_OS_START_ERROR + 14)
  |  |  ------------------
  |  |  |  |  117|     16|#define APR_OS_START_ERROR     20000
  |  |  ------------------
  ------------------
  817|    415|                    ++s;
  818|    415|                }
  819|       |                /* no scheme but relative path, e.g. '../image.jpg' */
  820|     30|            }
  821|     16|            else {
  822|     16|                if (strchr(uri, ':') != NULL)
  ------------------
  |  Branch (822:21): [True: 5, False: 11]
  ------------------
  823|      5|                    return APR_EGENERAL;
  ------------------
  |  |  313|      5|#define APR_EGENERAL       (APR_OS_START_ERROR + 14)
  |  |  ------------------
  |  |  |  |  117|      5|#define APR_OS_START_ERROR     20000
  |  |  ------------------
  ------------------
  824|       |                /* no scheme, no slash, but relative path, e.g. 'image.jpg' */
  825|     16|            }
  826|     25|            goto deal_with_path;
  827|     46|        }
  828|       |        /* scheme and relative path */
  829|     17|        uri = s;
  830|     17|        goto deal_with_path;
  831|     63|    }
  832|       |
  833|    147|    s += 2;
  834|       |
  835|    164|deal_with_authority:
  836|    164|    hostinfo = s;
  837|  3.42k|    while ((uri_delims[*(unsigned char *)s] & NOTEND_HOSTINFO) == 0) {
  ------------------
  |  |  711|  3.42k|#define NOTEND_HOSTINFO   (T_SLASH | T_QUESTION | T_HASH | T_NUL)
  |  |  ------------------
  |  |  |  |  173|  3.42k|#define T_SLASH           0x01        /* '/' */
  |  |  ------------------
  |  |               #define NOTEND_HOSTINFO   (T_SLASH | T_QUESTION | T_HASH | T_NUL)
  |  |  ------------------
  |  |  |  |  174|  3.42k|#define T_QUESTION        0x02        /* '?' */
  |  |  ------------------
  |  |               #define NOTEND_HOSTINFO   (T_SLASH | T_QUESTION | T_HASH | T_NUL)
  |  |  ------------------
  |  |  |  |  175|  3.42k|#define T_HASH            0x04        /* '#' */
  |  |  ------------------
  |  |               #define NOTEND_HOSTINFO   (T_SLASH | T_QUESTION | T_HASH | T_NUL)
  |  |  ------------------
  |  |  |  |  180|  3.42k|#define T_NUL             0x80        /* '\0' */
  |  |  ------------------
  ------------------
  |  Branch (837:12): [True: 3.25k, False: 164]
  ------------------
  838|  3.25k|        ++s;
  839|  3.25k|    }
  840|    164|    uri = s;        /* whatever follows hostinfo is start of uri */
  841|    164|    uptr->hostinfo = apr_pstrmemdup(p, hostinfo, uri - hostinfo);
  842|       |
  843|       |    /* If there's a username:password@host:port, the @ we want is the last @...
  844|       |     * too bad there's no memrchr()... For the C purists, note that hostinfo
  845|       |     * is definitely not the first character of the original uri so therefore
  846|       |     * &hostinfo[-1] < &hostinfo[0] ... and this loop is valid C.
  847|       |     */
  848|  2.97k|    do {
  849|  2.97k|        --s;
  850|  2.97k|    } while (s >= hostinfo && *s != '@');
  ------------------
  |  Branch (850:14): [True: 2.83k, False: 139]
  |  Branch (850:31): [True: 2.81k, False: 25]
  ------------------
  851|    164|    if (s < hostinfo) {
  ------------------
  |  Branch (851:9): [True: 139, False: 25]
  ------------------
  852|       |        /* again we want the common case to be fall through */
  853|    164|deal_with_host:
  854|       |        /* We expect hostinfo to point to the first character of
  855|       |         * the hostname.  If there's a port it is the first colon,
  856|       |         * except with IPv6.
  857|       |         */
  858|    164|        if (*hostinfo == '[') {
  ------------------
  |  Branch (858:13): [True: 19, False: 145]
  ------------------
  859|     19|            v6_offset1 = 1;
  860|     19|            v6_offset2 = 2;
  861|     19|            s = memchr(hostinfo, ']', uri - hostinfo);
  862|     19|            if (s == NULL) {
  ------------------
  |  Branch (862:17): [True: 1, False: 18]
  ------------------
  863|      1|                return APR_EGENERAL;
  ------------------
  |  |  313|      1|#define APR_EGENERAL       (APR_OS_START_ERROR + 14)
  |  |  ------------------
  |  |  |  |  117|      1|#define APR_OS_START_ERROR     20000
  |  |  ------------------
  ------------------
  864|      1|            }
  865|     18|            if (*++s != ':') {
  ------------------
  |  Branch (865:17): [True: 12, False: 6]
  ------------------
  866|     12|                s = NULL; /* no port */
  867|     12|            }
  868|     18|        }
  869|    145|        else {
  870|    145|            s = memchr(hostinfo, ':', uri - hostinfo);
  871|    145|        }
  872|    163|        if (s == NULL) {
  ------------------
  |  Branch (872:13): [True: 22, False: 141]
  ------------------
  873|       |            /* we expect the common case to have no port */
  874|     22|            uptr->hostname = apr_pstrmemdup(p,
  875|     22|                                            hostinfo + v6_offset1,
  876|     22|                                            uri - hostinfo - v6_offset2);
  877|     22|            goto deal_with_path;
  878|     22|        }
  879|    141|        uptr->hostname = apr_pstrmemdup(p,
  880|    141|                                        hostinfo + v6_offset1,
  881|    141|                                        s - hostinfo - v6_offset2);
  882|    141|        ++s;
  883|    141|        uptr->port_str = apr_pstrmemdup(p, s, uri - s);
  884|    141|        if (uri != s) {
  ------------------
  |  Branch (884:13): [True: 80, False: 61]
  ------------------
  885|     80|            port = strtol(uptr->port_str, &endstr, 10);
  886|     80|            uptr->port = port;
  887|     80|            if (*endstr == '\0') {
  ------------------
  |  Branch (887:17): [True: 71, False: 9]
  ------------------
  888|     71|                goto deal_with_path;
  889|     71|            }
  890|       |            /* Invalid characters after ':' found */
  891|      9|            return APR_EGENERAL;
  ------------------
  |  |  313|      9|#define APR_EGENERAL       (APR_OS_START_ERROR + 14)
  |  |  ------------------
  |  |  |  |  117|      9|#define APR_OS_START_ERROR     20000
  |  |  ------------------
  ------------------
  892|     80|        }
  893|     61|        uptr->port = apr_uri_port_of_scheme(uptr->scheme);
  894|     61|        goto deal_with_path;
  895|    141|    }
  896|       |
  897|       |    /* first colon delimits username:password */
  898|     25|    s1 = memchr(hostinfo, ':', s - hostinfo);
  899|     25|    if (s1) {
  ------------------
  |  Branch (899:9): [True: 9, False: 16]
  ------------------
  900|      9|        uptr->user = apr_pstrmemdup(p, hostinfo, s1 - hostinfo);
  901|      9|        ++s1;
  902|      9|        uptr->password = apr_pstrmemdup(p, s1, s - s1);
  903|      9|    }
  904|     16|    else {
  905|     16|        uptr->user = apr_pstrmemdup(p, hostinfo, s - hostinfo);
  906|     16|    }
  907|     25|    hostinfo = s + 1;
  908|     25|    goto deal_with_host;
  909|    164|}
apr_uri_parse_hostinfo:
  919|    240|{
  920|    240|    const char *s;
  921|    240|    char *endstr;
  922|    240|    const char *rsb;
  923|    240|    int v6_offset1 = 0;
  924|       |
  925|       |    /* Initialize the structure. parse_uri() and parse_uri_components()
  926|       |     * can be called more than once per request.
  927|       |     */
  928|    240|    memset(uptr, '\0', sizeof(*uptr));
  929|    240|    uptr->is_initialized = 1;
  930|    240|    uptr->hostinfo = apr_pstrdup(p, hostinfo);
  931|       |
  932|       |    /* We expect hostinfo to point to the first character of
  933|       |     * the hostname.  There must be a port, separated by a colon
  934|       |     */
  935|    240|    if (*hostinfo == '[') {
  ------------------
  |  Branch (935:9): [True: 14, False: 226]
  ------------------
  936|     14|        if ((rsb = strchr(hostinfo, ']')) == NULL ||
  ------------------
  |  Branch (936:13): [True: 2, False: 12]
  ------------------
  937|     14|            *(rsb + 1) != ':') {
  ------------------
  |  Branch (937:13): [True: 11, False: 1]
  ------------------
  938|     13|            return APR_EGENERAL;
  ------------------
  |  |  313|     13|#define APR_EGENERAL       (APR_OS_START_ERROR + 14)
  |  |  ------------------
  |  |  |  |  117|     13|#define APR_OS_START_ERROR     20000
  |  |  ------------------
  ------------------
  939|     13|        }
  940|       |        /* literal IPv6 address */
  941|      1|        s = rsb + 1;
  942|      1|        ++hostinfo;
  943|      1|        v6_offset1 = 1;
  944|      1|    }
  945|    226|    else {
  946|    226|        s = strchr(hostinfo, ':');
  947|    226|    }
  948|    227|    if (s == NULL) {
  ------------------
  |  Branch (948:9): [True: 19, False: 208]
  ------------------
  949|     19|        return APR_EGENERAL;
  ------------------
  |  |  313|     19|#define APR_EGENERAL       (APR_OS_START_ERROR + 14)
  |  |  ------------------
  |  |  |  |  117|     19|#define APR_OS_START_ERROR     20000
  |  |  ------------------
  ------------------
  950|     19|    }
  951|    208|    uptr->hostname = apr_pstrndup(p, hostinfo, s - hostinfo - v6_offset1);
  952|    208|    ++s;
  953|    208|    uptr->port_str = apr_pstrdup(p, s);
  954|    208|    if (*s != '\0') {
  ------------------
  |  Branch (954:9): [True: 205, False: 3]
  ------------------
  955|    205|        uptr->port = (unsigned short) strtol(uptr->port_str, &endstr, 10);
  956|    205|        if (*endstr == '\0') {
  ------------------
  |  Branch (956:13): [True: 5, False: 200]
  ------------------
  957|      5|            return APR_SUCCESS;
  ------------------
  |  |  225|      5|#define APR_SUCCESS 0
  ------------------
  958|      5|        }
  959|       |        /* Invalid characters after ':' found */
  960|    205|    }
  961|    203|    return APR_EGENERAL;
  ------------------
  |  |  313|    203|#define APR_EGENERAL       (APR_OS_START_ERROR + 14)
  |  |  ------------------
  |  |  |  |  117|    203|#define APR_OS_START_ERROR     20000
  |  |  ------------------
  ------------------
  962|    208|}

