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

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

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

apr_thread_mutex_create:
   40|    226|{
   41|    226|    apr_thread_mutex_t *new_mutex;
   42|    226|    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|    226|    new_mutex = apr_pcalloc(pool, sizeof(apr_thread_mutex_t));
  ------------------
  |  |  454|    226|    apr_pcalloc_debug(p, size, APR_POOL__FILE_LINE__)
  |  |  ------------------
  |  |  |  |  143|    226|#define APR_POOL__FILE_LINE__ __FILE__ ":" APR_STRINGIFY(__LINE__)
  |  |  |  |  ------------------
  |  |  |  |  |  |  153|    226|#define APR_STRINGIFY(n) APR_STRINGIFY_HELPER(n)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  155|    226|#define APR_STRINGIFY_HELPER(n) #n
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   51|    226|    new_mutex->pool = pool;
   52|       |
   53|    226|#ifdef HAVE_PTHREAD_MUTEX_RECURSIVE
   54|    226|    if (flags & APR_THREAD_MUTEX_NESTED) {
  ------------------
  |  |   44|    226|#define APR_THREAD_MUTEX_NESTED   0x1   /**< enable nested (recursive) locks */
  ------------------
  |  Branch (54:9): [True: 226, False: 0]
  ------------------
   55|    226|        pthread_mutexattr_t mattr;
   56|       |
   57|    226|        rv = pthread_mutexattr_init(&mattr);
   58|    226|        if (rv) return rv;
  ------------------
  |  Branch (58:13): [True: 0, False: 226]
  ------------------
   59|       |
   60|    226|        rv = pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_RECURSIVE);
   61|    226|        if (rv) {
  ------------------
  |  Branch (61:13): [True: 0, False: 226]
  ------------------
   62|      0|            pthread_mutexattr_destroy(&mattr);
   63|      0|            return rv;
   64|      0|        }
   65|       |
   66|    226|        rv = pthread_mutex_init(&new_mutex->mutex, &mattr);
   67|       |
   68|    226|        pthread_mutexattr_destroy(&mattr);
   69|    226|    } 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|    226|    if (rv) {
  ------------------
  |  Branch (92:9): [True: 0, False: 226]
  ------------------
   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|    226|    apr_pool_cleanup_register(new_mutex->pool,
  113|    226|                              new_mutex, thread_mutex_cleanup,
  114|    226|                              apr_pool_cleanup_null);
  115|       |
  116|    226|    *mutex = new_mutex;
  117|    226|    return APR_SUCCESS;
  ------------------
  |  |  225|    226|#define APR_SUCCESS 0
  ------------------
  118|    226|}
apr_thread_mutex_lock:
  121|    226|{
  122|    226|    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|    226|    rv = pthread_mutex_lock(&mutex->mutex);
  159|       |#ifdef HAVE_ZOS_PTHREADS
  160|       |    if (rv) {
  161|       |        rv = errno;
  162|       |    }
  163|       |#endif
  164|       |
  165|    226|    return rv;
  166|    226|}
apr_thread_mutex_unlock:
  302|    226|{
  303|    226|    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|    226|    status = pthread_mutex_unlock(&mutex->mutex);
  331|       |#ifdef HAVE_ZOS_PTHREADS
  332|       |    if (status) {
  333|       |        status = errno;
  334|       |    }
  335|       |#endif
  336|       |
  337|    226|    return status;
  338|    226|}
thread_mutex.c:thread_mutex_cleanup:
   24|    226|{
   25|    226|    apr_thread_mutex_t *mutex = data;
   26|    226|    apr_status_t rv;
   27|       |
   28|    226|    rv = pthread_mutex_destroy(&mutex->mutex);
   29|       |#ifdef HAVE_ZOS_PTHREADS
   30|       |    if (rv) {
   31|       |        rv = errno;
   32|       |    }
   33|       |#endif
   34|    226|    return rv;
   35|    226|}

apr_pool_initialize:
 1674|    226|{
 1675|    226|    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|    226|    if (apr_pools_initialized++)
  ------------------
  |  Branch (1681:9): [True: 0, False: 226]
  ------------------
 1682|      0|        return APR_SUCCESS;
  ------------------
  |  |  225|      0|#define APR_SUCCESS 0
  ------------------
 1683|       |
 1684|    226|#if defined(_SC_PAGESIZE)
 1685|    226|    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|    226|    boundary_index = 12;
 1694|    226|    while ( (1 << boundary_index) < boundary_size)
  ------------------
  |  Branch (1694:13): [True: 0, False: 226]
  ------------------
 1695|      0|        boundary_index++;
 1696|    226|    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|    226|    if ((rv = apr_pool_create_ex(&global_pool, NULL, NULL,
  ------------------
  |  |  247|    226|    apr_pool_create_ex_debug(newpool, parent, abort_fn, allocator, \
  |  |  248|    226|                             APR_POOL__FILE_LINE__)
  |  |  ------------------
  |  |  |  |  143|    226|#define APR_POOL__FILE_LINE__ __FILE__ ":" APR_STRINGIFY(__LINE__)
  |  |  |  |  ------------------
  |  |  |  |  |  |  153|    226|#define APR_STRINGIFY(n) APR_STRINGIFY_HELPER(n)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  155|    226|#define APR_STRINGIFY_HELPER(n) #n
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1703:9): [True: 0, False: 226]
  ------------------
 1704|    226|                                 NULL)) != APR_SUCCESS) {
  ------------------
  |  |  225|    226|#define APR_SUCCESS 0
  ------------------
 1705|      0|        return rv;
 1706|      0|    }
 1707|       |
 1708|    226|    apr_pool_tag(global_pool, "APR global pool");
 1709|       |
 1710|    226|    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|    226|    if ((rv = apr_atomic_init(global_pool)) != APR_SUCCESS) {
  ------------------
  |  |  225|    226|#define APR_SUCCESS 0
  ------------------
  |  Branch (1715:9): [True: 0, False: 226]
  ------------------
 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|    226|    return APR_SUCCESS;
  ------------------
  |  |  225|    226|#define APR_SUCCESS 0
  ------------------
 1759|    226|}
apr_pool_terminate:
 1762|    226|{
 1763|    226|    if (!apr_pools_initialized)
  ------------------
  |  Branch (1763:9): [True: 0, False: 226]
  ------------------
 1764|      0|        return;
 1765|       |
 1766|    226|    if (--apr_pools_initialized)
  ------------------
  |  Branch (1766:9): [True: 0, False: 226]
  ------------------
 1767|      0|        return;
 1768|       |
 1769|    226|    apr_pool_destroy(global_pool); /* This will also destroy the mutex */
  ------------------
  |  |  388|    226|    apr_pool_destroy_debug(p, APR_POOL__FILE_LINE__)
  |  |  ------------------
  |  |  |  |  143|    226|#define APR_POOL__FILE_LINE__ __FILE__ ":" APR_STRINGIFY(__LINE__)
  |  |  |  |  ------------------
  |  |  |  |  |  |  153|    226|#define APR_STRINGIFY(n) APR_STRINGIFY_HELPER(n)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  155|    226|#define APR_STRINGIFY_HELPER(n) #n
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1770|    226|    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|    226|}
apr_palloc_debug:
 1823|  2.11k|{
 1824|  2.11k|    void *mem;
 1825|       |
 1826|  2.11k|    apr_pool_check_integrity(pool);
 1827|       |
 1828|  2.11k|    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.11k|    return mem;
 1835|  2.11k|}
apr_pcalloc_debug:
 1839|    226|{
 1840|    226|    void *mem;
 1841|       |
 1842|    226|    apr_pool_check_integrity(pool);
 1843|       |
 1844|    226|    mem = pool_alloc(pool, size);
 1845|    226|    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|    226|    return mem;
 1852|    226|}
apr_pool_destroy_debug:
 1985|    226|{
 1986|    226|#if APR_HAS_THREADS
 1987|    226|    apr_thread_mutex_t *mutex;
 1988|    226|#endif
 1989|       |
 1990|    226|    apr_pool_check_lifetime(pool);
 1991|       |
 1992|    226|    if (pool->joined) {
  ------------------
  |  Branch (1992:9): [True: 0, False: 226]
  ------------------
 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|    226|#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|    226|    mutex = parent_lock(pool);
 2008|    226|#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|    226|    pool_destroy_debug(pool, file_line);
 2015|       |
 2016|    226|#if APR_HAS_THREADS
 2017|       |    /* Unlock the mutex we obtained above */
 2018|    226|    parent_unlock(mutex);
 2019|    226|#endif /* APR_HAS_THREADS */
 2020|    226|}
apr_pool_create_ex_debug:
 2027|    452|{
 2028|    452|    apr_pool_t *pool;
 2029|       |
 2030|    452|    *newpool = NULL;
 2031|       |
 2032|    452|    if (!parent) {
  ------------------
  |  Branch (2032:9): [True: 452, False: 0]
  ------------------
 2033|    452|        parent = global_pool;
 2034|    452|    }
 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|    452|    if (!abort_fn && parent)
  ------------------
  |  Branch (2042:9): [True: 452, False: 0]
  |  Branch (2042:22): [True: 226, False: 226]
  ------------------
 2043|    226|        abort_fn = parent->abort_fn;
 2044|       |
 2045|    452|    if ((pool = malloc(SIZEOF_POOL_T)) == NULL) {
  ------------------
  |  |  618|    452|#define SIZEOF_POOL_T       APR_ALIGN_DEFAULT(sizeof(apr_pool_t))
  |  |  ------------------
  |  |  |  |  143|    452|#define APR_ALIGN_DEFAULT(size) APR_ALIGN(size, 8)
  |  |  |  |  ------------------
  |  |  |  |  |  |  140|    452|    (((size) + ((boundary) - 1)) & ~((boundary) - 1))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2045:9): [True: 0, False: 452]
  ------------------
 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|    452|    memset(pool, 0, SIZEOF_POOL_T);
  ------------------
  |  |  618|    452|#define SIZEOF_POOL_T       APR_ALIGN_DEFAULT(sizeof(apr_pool_t))
  |  |  ------------------
  |  |  |  |  143|    452|#define APR_ALIGN_DEFAULT(size) APR_ALIGN(size, 8)
  |  |  |  |  ------------------
  |  |  |  |  |  |  140|    452|    (((size) + ((boundary) - 1)) & ~((boundary) - 1))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2053|       |
 2054|    452|    pool->allocator = allocator;
 2055|    452|    pool->abort_fn = abort_fn;
 2056|    452|    pool->tag = file_line;
 2057|    452|    pool->file_line = file_line;
 2058|       |
 2059|    452|#if APR_HAS_THREADS
 2060|    452|    if (parent == NULL || parent->allocator != allocator) {
  ------------------
  |  Branch (2060:9): [True: 226, False: 226]
  |  Branch (2060:27): [True: 0, False: 226]
  ------------------
 2061|    226|        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|    226|        if ((rv = apr_thread_mutex_create(&pool->mutex,
  ------------------
  |  Branch (2071:13): [True: 0, False: 226]
  ------------------
 2072|    226|                APR_THREAD_MUTEX_NESTED, pool)) != APR_SUCCESS) {
  ------------------
  |  |   44|    226|#define APR_THREAD_MUTEX_NESTED   0x1   /**< enable nested (recursive) locks */
  ------------------
                              APR_THREAD_MUTEX_NESTED, pool)) != APR_SUCCESS) {
  ------------------
  |  |  225|    226|#define APR_SUCCESS 0
  ------------------
 2073|      0|            free(pool);
 2074|      0|            return rv;
 2075|      0|        }
 2076|    226|    }
 2077|    226|    else {
 2078|    226|        pool->mutex = parent->mutex;
 2079|    226|    }
 2080|    452|#endif /* APR_HAS_THREADS */
 2081|       |
 2082|    452|    if ((pool->parent = parent) != NULL) {
  ------------------
  |  Branch (2082:9): [True: 226, False: 226]
  ------------------
 2083|    226|        pool_lock(parent);
 2084|       |
 2085|    226|        if ((pool->sibling = parent->child) != NULL)
  ------------------
  |  Branch (2085:13): [True: 0, False: 226]
  ------------------
 2086|      0|            pool->sibling->ref = &pool->sibling;
 2087|       |
 2088|    226|        parent->child = pool;
 2089|    226|        pool->ref = &parent->child;
 2090|       |
 2091|    226|        pool_unlock(parent);
 2092|    226|    }
 2093|    226|    else {
 2094|    226|        pool->sibling = NULL;
 2095|    226|        pool->ref = NULL;
 2096|    226|    }
 2097|       |
 2098|    452|#if APR_HAS_THREADS
 2099|    452|    pool->owner = apr_os_thread_current();
 2100|    452|#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|    452|    *newpool = pool;
 2110|       |
 2111|    452|    return APR_SUCCESS;
  ------------------
  |  |  225|    452|#define APR_SUCCESS 0
  ------------------
 2112|    452|}
apr_pool_tag:
 2440|    226|{
 2441|    226|    pool->tag = tag;
 2442|    226|}
apr_pool_cleanup_register:
 2530|    226|{
 2531|    226|    cleanup_t *c = NULL;
 2532|       |
 2533|    226|#if APR_POOL_DEBUG
 2534|    226|    apr_pool_check_integrity(p);
 2535|    226|#endif /* APR_POOL_DEBUG */
 2536|       |
 2537|    226|    if (p != NULL) {
  ------------------
  |  Branch (2537:9): [True: 226, False: 0]
  ------------------
 2538|    226|        if (p->free_cleanups) {
  ------------------
  |  Branch (2538:13): [True: 0, False: 226]
  ------------------
 2539|       |            /* reuse a cleanup structure */
 2540|      0|            c = p->free_cleanups;
 2541|      0|            p->free_cleanups = c->next;
 2542|    226|        } else {
 2543|    226|            c = apr_palloc(p, sizeof(cleanup_t));
  ------------------
  |  |  425|    226|    apr_palloc_debug(p, size, APR_POOL__FILE_LINE__)
  |  |  ------------------
  |  |  |  |  143|    226|#define APR_POOL__FILE_LINE__ __FILE__ ":" APR_STRINGIFY(__LINE__)
  |  |  |  |  ------------------
  |  |  |  |  |  |  153|    226|#define APR_STRINGIFY(n) APR_STRINGIFY_HELPER(n)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  155|    226|#define APR_STRINGIFY_HELPER(n) #n
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2544|    226|        }
 2545|    226|        c->data = data;
 2546|    226|        c->plain_cleanup_fn = plain_cleanup_fn;
 2547|    226|        c->child_cleanup_fn = child_cleanup_fn;
 2548|    226|        c->next = p->cleanups;
 2549|    226|        p->cleanups = c;
 2550|    226|    }
 2551|       |
 2552|    226|#if APR_POOL_DEBUG
 2553|    226|    if (!c || !c->plain_cleanup_fn || !c->child_cleanup_fn) {
  ------------------
  |  Branch (2553:9): [True: 0, False: 226]
  |  Branch (2553:15): [True: 0, False: 226]
  |  Branch (2553:39): [True: 0, False: 226]
  ------------------
 2554|      0|        abort();
 2555|      0|    }
 2556|    226|#endif /* APR_POOL_DEBUG */
 2557|    226|}
apr_pool_create_ex:
 2979|    226|{
 2980|    226|    return apr_pool_create_ex_debug(newpool, parent,
 2981|    226|                                    abort_fn, allocator,
 2982|    226|                                    "undefined");
 2983|    226|}
apr_pools.c:apr_pool_check_integrity:
 1657|  2.56k|{
 1658|  2.56k|    apr_pool_check_lifetime(pool);
 1659|  2.56k|    apr_pool_check_owner(pool);
 1660|  2.56k|}
apr_pools.c:apr_pool_check_owner:
 1642|  3.02k|{
 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.02k|}
apr_pools.c:pool_alloc:
 1783|  2.34k|{
 1784|  2.34k|    debug_node_t *node;
 1785|  2.34k|    void *mem;
 1786|       |
 1787|  2.34k|    if ((mem = malloc(size)) == NULL) {
  ------------------
  |  Branch (1787:9): [True: 0, False: 2.34k]
  ------------------
 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.34k|    node = pool->nodes;
 1795|  2.34k|    if (node == NULL || node->index == 64) {
  ------------------
  |  Branch (1795:9): [True: 452, False: 1.89k]
  |  Branch (1795:25): [True: 0, False: 1.89k]
  ------------------
 1796|    452|        if ((node = malloc(SIZEOF_DEBUG_NODE_T)) == NULL) {
  ------------------
  |  |  562|    452|#define SIZEOF_DEBUG_NODE_T APR_ALIGN_DEFAULT(sizeof(debug_node_t))
  |  |  ------------------
  |  |  |  |  143|    452|#define APR_ALIGN_DEFAULT(size) APR_ALIGN(size, 8)
  |  |  |  |  ------------------
  |  |  |  |  |  |  140|    452|    (((size) + ((boundary) - 1)) & ~((boundary) - 1))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1796:13): [True: 0, False: 452]
  ------------------
 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|    452|        memset(node, 0, SIZEOF_DEBUG_NODE_T);
  ------------------
  |  |  562|    452|#define SIZEOF_DEBUG_NODE_T APR_ALIGN_DEFAULT(sizeof(debug_node_t))
  |  |  ------------------
  |  |  |  |  143|    452|#define APR_ALIGN_DEFAULT(size) APR_ALIGN(size, 8)
  |  |  |  |  ------------------
  |  |  |  |  |  |  140|    452|    (((size) + ((boundary) - 1)) & ~((boundary) - 1))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1805|       |
 1806|    452|        node->next = pool->nodes;
 1807|    452|        pool->nodes = node;
 1808|    452|        node->index = 0;
 1809|    452|    }
 1810|       |
 1811|  2.34k|    node->beginp[node->index] = mem;
 1812|  2.34k|    node->endp[node->index] = (char *)mem + size;
 1813|  2.34k|    node->index++;
 1814|       |
 1815|  2.34k|    pool->stat_alloc++;
 1816|  2.34k|    pool->stat_total_alloc++;
 1817|       |
 1818|  2.34k|    return mem;
 1819|  2.34k|}
apr_pools.c:apr_pool_check_lifetime:
 1616|  2.79k|{
 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.79k|    if (pool == global_pool || global_pool == NULL)
  ------------------
  |  Branch (1622:9): [True: 226, False: 2.56k]
  |  Branch (1622:32): [True: 678, False: 1.89k]
  ------------------
 1623|    904|        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.79k|}
apr_pools.c:parent_lock:
 1491|    226|{
 1492|    226|    if (pool->parent) {
  ------------------
  |  Branch (1492:9): [True: 0, False: 226]
  ------------------
 1493|      0|        apr_thread_mutex_lock(pool->parent->mutex);
 1494|      0|        return pool->parent->mutex;
 1495|      0|    }
 1496|    226|    return NULL;
 1497|    226|}
apr_pools.c:pool_clear_debug:
 1862|    452|{
 1863|    452|    debug_node_t *node;
 1864|    452|    apr_size_t index;
 1865|       |
 1866|       |    /* Run pre destroy cleanups */
 1867|    452|    run_cleanups(&pool->pre_cleanups);
 1868|    452|    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|    452|    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|    678|    while (pool->child)
  ------------------
  |  Branch (1879:12): [True: 226, False: 452]
  ------------------
 1880|    226|        pool_destroy_debug(pool->child, file_line);
 1881|       |
 1882|       |    /* Run cleanups */
 1883|    452|    run_cleanups(&pool->cleanups);
 1884|    452|    pool->free_cleanups = NULL;
 1885|    452|    pool->cleanups = NULL;
 1886|       |
 1887|       |    /* If new child pools showed up, this is a reason to raise a flag */
 1888|    452|    if (pool->child)
  ------------------
  |  Branch (1888:9): [True: 0, False: 452]
  ------------------
 1889|      0|        abort();
 1890|       |
 1891|       |    /* Free subprocesses */
 1892|    452|    free_proc_chain(pool->subprocesses);
 1893|    452|    pool->subprocesses = NULL;
 1894|       |
 1895|       |    /* Clear the user data. */
 1896|    452|    pool->user_data = NULL;
 1897|       |
 1898|       |    /* Free the blocks, scribbling over them first to help highlight
 1899|       |     * use-after-free issues. */
 1900|    904|    while ((node = pool->nodes) != NULL) {
  ------------------
  |  Branch (1900:12): [True: 452, False: 452]
  ------------------
 1901|    452|        pool->nodes = node->next;
 1902|       |
 1903|  2.79k|        for (index = 0; index < node->index; index++) {
  ------------------
  |  Branch (1903:25): [True: 2.34k, False: 452]
  ------------------
 1904|  2.34k|            memset(node->beginp[index], POOL_POISON_BYTE,
  ------------------
  |  | 1859|  2.34k|#define POOL_POISON_BYTE 'A'
  ------------------
 1905|  2.34k|                   (char *)node->endp[index] - (char *)node->beginp[index]);
 1906|  2.34k|            free(node->beginp[index]);
 1907|  2.34k|        }
 1908|       |
 1909|    452|        memset(node, POOL_POISON_BYTE, SIZEOF_DEBUG_NODE_T);
  ------------------
  |  | 1859|    452|#define POOL_POISON_BYTE 'A'
  ------------------
                      memset(node, POOL_POISON_BYTE, SIZEOF_DEBUG_NODE_T);
  ------------------
  |  |  562|    452|#define SIZEOF_DEBUG_NODE_T APR_ALIGN_DEFAULT(sizeof(debug_node_t))
  |  |  ------------------
  |  |  |  |  143|    452|#define APR_ALIGN_DEFAULT(size) APR_ALIGN(size, 8)
  |  |  |  |  ------------------
  |  |  |  |  |  |  140|    452|    (((size) + ((boundary) - 1)) & ~((boundary) - 1))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1910|    452|        free(node);
 1911|    452|    }
 1912|       |
 1913|    452|    pool->stat_alloc = 0;
 1914|    452|    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|    452|}
apr_pools.c:run_cleanups:
 2684|    904|{
 2685|    904|    cleanup_t *c = *cref;
 2686|       |
 2687|  1.13k|    while (c) {
  ------------------
  |  Branch (2687:12): [True: 226, False: 904]
  ------------------
 2688|    226|        *cref = c->next;
 2689|    226|        (*c->plain_cleanup_fn)((void *)c->data);
 2690|    226|        c = *cref;
 2691|    226|    }
 2692|    904|}
apr_pools.c:free_proc_chain:
 2764|    452|{
 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|    452|    struct process_chain *pc;
 2770|    452|    int need_timeout = 0;
 2771|    452|    apr_time_t timeout_interval;
 2772|       |
 2773|    452|    if (!procs)
  ------------------
  |  Branch (2773:9): [True: 452, False: 0]
  ------------------
 2774|    452|        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|    226|{
 1502|    226|    if (mutex) {
  ------------------
  |  Branch (1502:9): [True: 0, False: 226]
  ------------------
 1503|      0|        apr_thread_mutex_unlock(mutex);
 1504|      0|    }
 1505|    226|}
apr_pools.c:pool_destroy_debug:
 1964|    452|{
 1965|    452|    pool_clear_debug(pool, file_line);
 1966|       |
 1967|       |    /* Remove the pool from the parent's child list */
 1968|    452|    if (pool->parent != NULL
  ------------------
  |  Branch (1968:9): [True: 226, False: 226]
  ------------------
 1969|    452|        && (*pool->ref = pool->sibling) != NULL) {
  ------------------
  |  Branch (1969:12): [True: 0, False: 226]
  ------------------
 1970|      0|        pool->sibling->ref = pool->ref;
 1971|      0|    }
 1972|       |
 1973|       |    /* Destroy the allocator if the pool owns it */
 1974|    452|    if (pool->allocator != NULL
  ------------------
  |  Branch (1974:9): [True: 0, False: 452]
  ------------------
 1975|    452|        && 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|    452|    free(pool);
 1981|    452|}
apr_pools.c:pool_lock:
 1474|    226|{
 1475|    226|#if APR_HAS_THREADS
 1476|    226|    apr_thread_mutex_lock(pool->mutex);
 1477|    226|#endif /* APR_HAS_THREADS */
 1478|    226|}
apr_pools.c:pool_unlock:
 1482|    226|{
 1483|    226|#if APR_HAS_THREADS
 1484|    226|    apr_thread_mutex_unlock(pool->mutex);
 1485|    226|#endif /* APR_HAS_THREADS */
 1486|    226|}

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

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

apr_uri_port_of_scheme:
   74|    126|{
   75|    126|    schemes_t *scheme;
   76|       |
   77|    126|    if (scheme_str) {
  ------------------
  |  Branch (77:9): [True: 123, False: 3]
  ------------------
   78|  2.33k|        for (scheme = schemes; scheme->name != NULL; ++scheme) {
  ------------------
  |  Branch (78:32): [True: 2.23k, False: 104]
  ------------------
   79|  2.23k|            if (strcasecmp(scheme_str, scheme->name) == 0) {
  ------------------
  |  Branch (79:17): [True: 19, False: 2.21k]
  ------------------
   80|     19|                return scheme->default_port;
   81|     19|            }
   82|  2.23k|        }
   83|    123|    }
   84|    107|    return 0;
   85|    126|}
apr_uri_unparse:
   93|    195|{
   94|    195|    char *ret = "";
   95|       |
   96|       |    /* If suppressing the site part, omit both user name & scheme://hostname */
   97|    195|    if (!(flags & APR_URI_UNP_OMITSITEPART)) {
  ------------------
  |  |   64|    195|#define APR_URI_UNP_OMITSITEPART    (1U<<0)
  ------------------
  |  Branch (97:9): [True: 195, False: 0]
  ------------------
   98|       |
   99|       |        /* Construct a "user:password@" string, honoring the passed
  100|       |         * APR_URI_UNP_ flags: */
  101|    195|        if (uptr->user || uptr->password) {
  ------------------
  |  Branch (101:13): [True: 36, False: 159]
  |  Branch (101:27): [True: 0, False: 159]
  ------------------
  102|     36|            ret = apr_pstrcat(p,
  103|     36|                      (uptr->user     && !(flags & APR_URI_UNP_OMITUSER))
  ------------------
  |  |   66|     36|#define APR_URI_UNP_OMITUSER        (1U<<1)
  ------------------
  |  Branch (103:24): [True: 36, False: 0]
  |  Branch (103:42): [True: 36, False: 0]
  ------------------
  104|     36|                          ? uptr->user : "",
  105|     36|                      (uptr->password && !(flags & APR_URI_UNP_OMITPASSWORD))
  ------------------
  |  |   68|     13|#define APR_URI_UNP_OMITPASSWORD    (1U<<2)
  ------------------
  |  Branch (105:24): [True: 13, False: 23]
  |  Branch (105:42): [True: 13, False: 0]
  ------------------
  106|     36|                          ? ":" : "",
  107|     36|                      (uptr->password && !(flags & APR_URI_UNP_OMITPASSWORD))
  ------------------
  |  |   68|     13|#define APR_URI_UNP_OMITPASSWORD    (1U<<2)
  ------------------
  |  Branch (107:24): [True: 13, False: 23]
  |  Branch (107:42): [True: 13, False: 0]
  ------------------
  108|     36|                          ? ((flags & APR_URI_UNP_REVEALPASSWORD)
  ------------------
  |  |   73|     13|#define APR_URI_UNP_REVEALPASSWORD  (1U<<3)
  ------------------
  |  Branch (108:30): [True: 0, False: 13]
  ------------------
  109|     13|                              ? uptr->password : "XXXXXXXX")
  110|     36|                          : "",
  111|     36|                      ((uptr->user     && !(flags & APR_URI_UNP_OMITUSER)) ||
  ------------------
  |  |   66|     36|#define APR_URI_UNP_OMITUSER        (1U<<1)
  ------------------
  |  Branch (111:25): [True: 36, False: 0]
  |  Branch (111:43): [True: 36, False: 0]
  ------------------
  112|     36|                       (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|     36|                          ? "@" : "",
  114|     36|                      NULL);
  115|     36|        }
  116|       |
  117|       |        /* Construct scheme://site string */
  118|    195|        if (uptr->hostname) {
  ------------------
  |  Branch (118:13): [True: 141, False: 54]
  ------------------
  119|    141|            int is_default_port;
  120|    141|            const char *lbrk = "", *rbrk = "";
  121|       |
  122|    141|            if (strchr(uptr->hostname, ':')) { /* v6 literal */
  ------------------
  |  Branch (122:17): [True: 5, False: 136]
  ------------------
  123|      5|                lbrk = "[";
  124|      5|                rbrk = "]";
  125|      5|            }
  126|       |
  127|    141|            is_default_port =
  128|    141|                (uptr->port_str == NULL ||
  ------------------
  |  Branch (128:18): [True: 21, False: 120]
  ------------------
  129|    141|                 uptr->port == 0 ||
  ------------------
  |  Branch (129:18): [True: 49, False: 71]
  ------------------
  130|    141|                 uptr->port == apr_uri_port_of_scheme(uptr->scheme));
  ------------------
  |  Branch (130:18): [True: 6, False: 65]
  ------------------
  131|       |
  132|    141|            ret = apr_pstrcat(p, "//", ret, lbrk, uptr->hostname, rbrk,
  133|    141|                        is_default_port ? "" : ":",
  ------------------
  |  Branch (133:25): [True: 76, False: 65]
  ------------------
  134|    141|                        is_default_port ? "" : uptr->port_str,
  ------------------
  |  Branch (134:25): [True: 76, False: 65]
  ------------------
  135|    141|                        NULL);
  136|    141|        }
  137|    195|	if (uptr->scheme) {
  ------------------
  |  Branch (137:6): [True: 143, False: 52]
  ------------------
  138|    143|	    ret = apr_pstrcat(p, uptr->scheme, ":", ret, NULL);
  139|    143|	}
  140|    195|    }
  141|       |
  142|       |    /* Should we suppress all path info? */
  143|    195|    if (!(flags & APR_URI_UNP_OMITPATHINFO)) {
  ------------------
  |  |   75|    195|#define APR_URI_UNP_OMITPATHINFO    (1U<<4)
  ------------------
  |  Branch (143:9): [True: 195, False: 0]
  ------------------
  144|       |        /* Append path, query and fragment strings: */
  145|    195|        ret = apr_pstrcat(p,
  146|    195|                          ret,
  147|    195|                          (uptr->path)
  ------------------
  |  Branch (147:27): [True: 116, False: 79]
  ------------------
  148|    195|                              ? uptr->path : "",
  149|    195|                          (uptr->query    && !(flags & APR_URI_UNP_OMITQUERY))
  ------------------
  |  |   77|     20|#define APR_URI_UNP_OMITQUERY       (1U<<5)
  ------------------
  |  Branch (149:28): [True: 20, False: 175]
  |  Branch (149:46): [True: 20, False: 0]
  ------------------
  150|    195|                              ? "?" : "",
  151|    195|                          (uptr->query    && !(flags & APR_URI_UNP_OMITQUERY))
  ------------------
  |  |   77|     20|#define APR_URI_UNP_OMITQUERY       (1U<<5)
  ------------------
  |  Branch (151:28): [True: 20, False: 175]
  |  Branch (151:46): [True: 20, False: 0]
  ------------------
  152|    195|                              ? uptr->query : "",
  153|    195|                          (uptr->fragment && !(flags & APR_URI_UNP_OMITQUERY))
  ------------------
  |  |   77|     18|#define APR_URI_UNP_OMITQUERY       (1U<<5)
  ------------------
  |  Branch (153:28): [True: 18, False: 177]
  |  Branch (153:46): [True: 18, False: 0]
  ------------------
  154|    195|                              ? "#" : NULL,
  155|    195|                          (uptr->fragment && !(flags & APR_URI_UNP_OMITQUERY))
  ------------------
  |  |   77|     18|#define APR_URI_UNP_OMITQUERY       (1U<<5)
  ------------------
  |  Branch (155:28): [True: 18, False: 177]
  |  Branch (155:46): [True: 18, False: 0]
  ------------------
  156|    195|                              ? uptr->fragment : NULL,
  157|    195|                          NULL);
  158|    195|    }
  159|    195|    return ret;
  160|    195|}
apr_uri_parse:
  724|    226|{
  725|    226|    const char *s;
  726|    226|    const char *s1;
  727|    226|    const char *hostinfo;
  728|    226|    char *endstr;
  729|    226|    int port;
  730|    226|    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|    226|    memset (uptr, '\0', sizeof(*uptr));
  736|    226|    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|    226|    if (uri[0] == '/') {
  ------------------
  |  Branch (742:9): [True: 29, False: 197]
  ------------------
  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|     29|        if (uri[1] == '/' && uri[2] != '/') {
  ------------------
  |  Branch (752:13): [True: 17, False: 12]
  |  Branch (752:30): [True: 16, False: 1]
  ------------------
  753|     16|            s = uri + 2 ;
  754|     16|            goto deal_with_authority ;
  755|     16|        }
  756|       |
  757|    195|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|    195|        s = uri;
  762|  3.08k|        while ((uri_delims[*(unsigned char *)s] & NOTEND_PATH) == 0) {
  ------------------
  |  |  712|  3.08k|#define NOTEND_PATH       (T_QUESTION | T_HASH | T_NUL)
  |  |  ------------------
  |  |  |  |  174|  3.08k|#define T_QUESTION        0x02        /* '?' */
  |  |  ------------------
  |  |               #define NOTEND_PATH       (T_QUESTION | T_HASH | T_NUL)
  |  |  ------------------
  |  |  |  |  175|  3.08k|#define T_HASH            0x04        /* '#' */
  |  |  ------------------
  |  |               #define NOTEND_PATH       (T_QUESTION | T_HASH | T_NUL)
  |  |  ------------------
  |  |  |  |  180|  3.08k|#define T_NUL             0x80        /* '\0' */
  |  |  ------------------
  ------------------
  |  Branch (762:16): [True: 2.88k, False: 195]
  ------------------
  763|  2.88k|            ++s;
  764|  2.88k|        }
  765|    195|        if (s != uri) {
  ------------------
  |  Branch (765:13): [True: 116, False: 79]
  ------------------
  766|    116|            uptr->path = apr_pstrmemdup(p, uri, s - uri);
  767|    116|        }
  768|    195|        if (*s == 0) {
  ------------------
  |  Branch (768:13): [True: 164, False: 31]
  ------------------
  769|    164|            return APR_SUCCESS;
  ------------------
  |  |  225|    164|#define APR_SUCCESS 0
  ------------------
  770|    164|        }
  771|     31|        if (*s == '?') {
  ------------------
  |  Branch (771:13): [True: 20, False: 11]
  ------------------
  772|     20|            ++s;
  773|     20|            s1 = strchr(s, '#');
  774|     20|            if (s1) {
  ------------------
  |  Branch (774:17): [True: 7, False: 13]
  ------------------
  775|      7|                uptr->fragment = apr_pstrdup(p, s1 + 1);
  776|      7|                uptr->query = apr_pstrmemdup(p, s, s1 - s);
  777|      7|            }
  778|     13|            else {
  779|     13|                uptr->query = apr_pstrdup(p, s);
  780|     13|            }
  781|     20|            return APR_SUCCESS;
  ------------------
  |  |  225|     20|#define APR_SUCCESS 0
  ------------------
  782|     20|        }
  783|       |        /* otherwise it's a fragment */
  784|     11|        uptr->fragment = apr_pstrdup(p, s + 1);
  785|     11|        return APR_SUCCESS;
  ------------------
  |  |  225|     11|#define APR_SUCCESS 0
  ------------------
  786|     31|    }
  787|       |
  788|       |    /* find the scheme: */
  789|    197|    s = uri;
  790|       |    /* first char must be letter */
  791|    197|    if (uri_delims[*(unsigned char *)s] & T_ALPHA) {
  ------------------
  |  |  176|    197|#define T_ALPHA           0x08        /* 'A' ... 'Z', 'a' ... 'z' */
  ------------------
  |  Branch (791:9): [True: 165, False: 32]
  ------------------
  792|    165|        ++s;
  793|  1.93k|        while ((uri_delims[*(unsigned char *)s] & (T_ALPHA|T_SCHEME)))
  ------------------
  |  |  176|  1.93k|#define T_ALPHA           0x08        /* 'A' ... 'Z', 'a' ... 'z' */
  ------------------
                      while ((uri_delims[*(unsigned char *)s] & (T_ALPHA|T_SCHEME)))
  ------------------
  |  |  177|  1.93k|#define T_SCHEME          0x10        /* '0' ... '9', '-', '+', '.'
  ------------------
  |  Branch (793:16): [True: 1.77k, False: 165]
  ------------------
  794|  1.77k|            ++s;
  795|    165|    }
  796|       |    /* scheme must be non-empty and followed by : */
  797|    197|    if (s != uri && s[0] == ':') {
  ------------------
  |  Branch (797:9): [True: 165, False: 32]
  |  Branch (797:21): [True: 148, False: 17]
  ------------------
  798|    148|        uptr->scheme = apr_pstrmemdup(p, uri, s - uri);
  799|    148|        s++;
  800|    148|    }
  801|     49|    else {
  802|       |        /* No valid scheme, restart from the beginning */
  803|     49|        s = uri;
  804|     49|    }
  805|       |
  806|    197|    if (s[0] != '/' || s[1] != '/') {
  ------------------
  |  Branch (806:9): [True: 51, False: 146]
  |  Branch (806:24): [True: 11, False: 135]
  ------------------
  807|     62|        if (uri == s) {
  ------------------
  |  Branch (807:13): [True: 49, False: 13]
  ------------------
  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|     49|            char *first_slash = strchr(uri, '/');
  813|     49|            if (first_slash) {
  ------------------
  |  Branch (813:17): [True: 28, False: 21]
  ------------------
  814|    538|                while (s < first_slash) {
  ------------------
  |  Branch (814:24): [True: 523, False: 15]
  ------------------
  815|    523|                    if (s[0] == ':')
  ------------------
  |  Branch (815:25): [True: 13, False: 510]
  ------------------
  816|     13|                        return APR_EGENERAL;
  ------------------
  |  |  313|     13|#define APR_EGENERAL       (APR_OS_START_ERROR + 14)
  |  |  ------------------
  |  |  |  |  117|     13|#define APR_OS_START_ERROR     20000
  |  |  ------------------
  ------------------
  817|    510|                    ++s;
  818|    510|                }
  819|       |                /* no scheme but relative path, e.g. '../image.jpg' */
  820|     28|            }
  821|     21|            else {
  822|     21|                if (strchr(uri, ':') != NULL)
  ------------------
  |  Branch (822:21): [True: 8, False: 13]
  ------------------
  823|      8|                    return APR_EGENERAL;
  ------------------
  |  |  313|      8|#define APR_EGENERAL       (APR_OS_START_ERROR + 14)
  |  |  ------------------
  |  |  |  |  117|      8|#define APR_OS_START_ERROR     20000
  |  |  ------------------
  ------------------
  824|       |                /* no scheme, no slash, but relative path, e.g. 'image.jpg' */
  825|     21|            }
  826|     28|            goto deal_with_path;
  827|     49|        }
  828|       |        /* scheme and relative path */
  829|     13|        uri = s;
  830|     13|        goto deal_with_path;
  831|     62|    }
  832|       |
  833|    135|    s += 2;
  834|       |
  835|    151|deal_with_authority:
  836|    151|    hostinfo = s;
  837|  2.36k|    while ((uri_delims[*(unsigned char *)s] & NOTEND_HOSTINFO) == 0) {
  ------------------
  |  |  711|  2.36k|#define NOTEND_HOSTINFO   (T_SLASH | T_QUESTION | T_HASH | T_NUL)
  |  |  ------------------
  |  |  |  |  173|  2.36k|#define T_SLASH           0x01        /* '/' */
  |  |  ------------------
  |  |               #define NOTEND_HOSTINFO   (T_SLASH | T_QUESTION | T_HASH | T_NUL)
  |  |  ------------------
  |  |  |  |  174|  2.36k|#define T_QUESTION        0x02        /* '?' */
  |  |  ------------------
  |  |               #define NOTEND_HOSTINFO   (T_SLASH | T_QUESTION | T_HASH | T_NUL)
  |  |  ------------------
  |  |  |  |  175|  2.36k|#define T_HASH            0x04        /* '#' */
  |  |  ------------------
  |  |               #define NOTEND_HOSTINFO   (T_SLASH | T_QUESTION | T_HASH | T_NUL)
  |  |  ------------------
  |  |  |  |  180|  2.36k|#define T_NUL             0x80        /* '\0' */
  |  |  ------------------
  ------------------
  |  Branch (837:12): [True: 2.21k, False: 151]
  ------------------
  838|  2.21k|        ++s;
  839|  2.21k|    }
  840|    151|    uri = s;        /* whatever follows hostinfo is start of uri */
  841|    151|    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|  1.87k|    do {
  849|  1.87k|        --s;
  850|  1.87k|    } while (s >= hostinfo && *s != '@');
  ------------------
  |  Branch (850:14): [True: 1.75k, False: 115]
  |  Branch (850:31): [True: 1.72k, False: 36]
  ------------------
  851|    151|    if (s < hostinfo) {
  ------------------
  |  Branch (851:9): [True: 115, False: 36]
  ------------------
  852|       |        /* again we want the common case to be fall through */
  853|    151|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|    151|        if (*hostinfo == '[') {
  ------------------
  |  Branch (858:13): [True: 15, False: 136]
  ------------------
  859|     15|            v6_offset1 = 1;
  860|     15|            v6_offset2 = 2;
  861|     15|            s = memchr(hostinfo, ']', uri - hostinfo);
  862|     15|            if (s == NULL) {
  ------------------
  |  Branch (862:17): [True: 1, False: 14]
  ------------------
  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|     14|            if (*++s != ':') {
  ------------------
  |  Branch (865:17): [True: 11, False: 3]
  ------------------
  866|     11|                s = NULL; /* no port */
  867|     11|            }
  868|     14|        }
  869|    136|        else {
  870|    136|            s = memchr(hostinfo, ':', uri - hostinfo);
  871|    136|        }
  872|    150|        if (s == NULL) {
  ------------------
  |  Branch (872:13): [True: 21, False: 129]
  ------------------
  873|       |            /* we expect the common case to have no port */
  874|     21|            uptr->hostname = apr_pstrmemdup(p,
  875|     21|                                            hostinfo + v6_offset1,
  876|     21|                                            uri - hostinfo - v6_offset2);
  877|     21|            goto deal_with_path;
  878|     21|        }
  879|    129|        uptr->hostname = apr_pstrmemdup(p,
  880|    129|                                        hostinfo + v6_offset1,
  881|    129|                                        s - hostinfo - v6_offset2);
  882|    129|        ++s;
  883|    129|        uptr->port_str = apr_pstrmemdup(p, s, uri - s);
  884|    129|        if (uri != s) {
  ------------------
  |  Branch (884:13): [True: 74, False: 55]
  ------------------
  885|     74|            port = strtol(uptr->port_str, &endstr, 10);
  886|     74|            uptr->port = port;
  887|     74|            if (*endstr == '\0') {
  ------------------
  |  Branch (887:17): [True: 65, False: 9]
  ------------------
  888|     65|                goto deal_with_path;
  889|     65|            }
  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|     74|        }
  893|     55|        uptr->port = apr_uri_port_of_scheme(uptr->scheme);
  894|     55|        goto deal_with_path;
  895|    129|    }
  896|       |
  897|       |    /* first colon delimits username:password */
  898|     36|    s1 = memchr(hostinfo, ':', s - hostinfo);
  899|     36|    if (s1) {
  ------------------
  |  Branch (899:9): [True: 13, False: 23]
  ------------------
  900|     13|        uptr->user = apr_pstrmemdup(p, hostinfo, s1 - hostinfo);
  901|     13|        ++s1;
  902|     13|        uptr->password = apr_pstrmemdup(p, s1, s - s1);
  903|     13|    }
  904|     23|    else {
  905|     23|        uptr->user = apr_pstrmemdup(p, hostinfo, s - hostinfo);
  906|     23|    }
  907|     36|    hostinfo = s + 1;
  908|     36|    goto deal_with_host;
  909|    151|}
apr_uri_parse_hostinfo:
  919|    226|{
  920|    226|    const char *s;
  921|    226|    char *endstr;
  922|    226|    const char *rsb;
  923|    226|    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|    226|    memset(uptr, '\0', sizeof(*uptr));
  929|    226|    uptr->is_initialized = 1;
  930|    226|    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|    226|    if (*hostinfo == '[') {
  ------------------
  |  Branch (935:9): [True: 15, False: 211]
  ------------------
  936|     15|        if ((rsb = strchr(hostinfo, ']')) == NULL ||
  ------------------
  |  Branch (936:13): [True: 1, False: 14]
  ------------------
  937|     15|            *(rsb + 1) != ':') {
  ------------------
  |  Branch (937:13): [True: 13, False: 1]
  ------------------
  938|     14|            return APR_EGENERAL;
  ------------------
  |  |  313|     14|#define APR_EGENERAL       (APR_OS_START_ERROR + 14)
  |  |  ------------------
  |  |  |  |  117|     14|#define APR_OS_START_ERROR     20000
  |  |  ------------------
  ------------------
  939|     14|        }
  940|       |        /* literal IPv6 address */
  941|      1|        s = rsb + 1;
  942|      1|        ++hostinfo;
  943|      1|        v6_offset1 = 1;
  944|      1|    }
  945|    211|    else {
  946|    211|        s = strchr(hostinfo, ':');
  947|    211|    }
  948|    212|    if (s == NULL) {
  ------------------
  |  Branch (948:9): [True: 28, False: 184]
  ------------------
  949|     28|        return APR_EGENERAL;
  ------------------
  |  |  313|     28|#define APR_EGENERAL       (APR_OS_START_ERROR + 14)
  |  |  ------------------
  |  |  |  |  117|     28|#define APR_OS_START_ERROR     20000
  |  |  ------------------
  ------------------
  950|     28|    }
  951|    184|    uptr->hostname = apr_pstrndup(p, hostinfo, s - hostinfo - v6_offset1);
  952|    184|    ++s;
  953|    184|    uptr->port_str = apr_pstrdup(p, s);
  954|    184|    if (*s != '\0') {
  ------------------
  |  Branch (954:9): [True: 180, False: 4]
  ------------------
  955|    180|        uptr->port = (unsigned short) strtol(uptr->port_str, &endstr, 10);
  956|    180|        if (*endstr == '\0') {
  ------------------
  |  Branch (956:13): [True: 1, False: 179]
  ------------------
  957|      1|            return APR_SUCCESS;
  ------------------
  |  |  225|      1|#define APR_SUCCESS 0
  ------------------
  958|      1|        }
  959|       |        /* Invalid characters after ':' found */
  960|    180|    }
  961|    183|    return APR_EGENERAL;
  ------------------
  |  |  313|    183|#define APR_EGENERAL       (APR_OS_START_ERROR + 14)
  |  |  ------------------
  |  |  |  |  117|    183|#define APR_OS_START_ERROR     20000
  |  |  ------------------
  ------------------
  962|    184|}

