af_gb_init:
   17|    245|void af_gb_init() {
   18|    245|  pointer_idx = 0;
   19|       |
   20|  24.7k|   for (int i = 0; i < GB_SIZE; i++) {
  ------------------
  |  |   10|  24.7k|#define GB_SIZE 100
  ------------------
  |  Branch (20:20): [True: 24.5k, False: 245]
  ------------------
   21|  24.5k|     pointer_arr[i] = NULL;
   22|  24.5k|   }
   23|    245|}
af_gb_cleanup:
   25|    245|void af_gb_cleanup() {
   26|  24.7k|  for(int i = 0; i < GB_SIZE; i++) {
  ------------------
  |  |   10|  24.7k|#define GB_SIZE 100
  ------------------
  |  Branch (26:18): [True: 24.5k, False: 245]
  ------------------
   27|  24.5k|    if (pointer_arr[i] != NULL) {
  ------------------
  |  Branch (27:9): [True: 232, False: 24.2k]
  ------------------
   28|    232|      free(pointer_arr[i]);
   29|    232|    }
   30|  24.5k|  }
   31|    245|}
af_get_null_terminated:
   33|    245|char *af_get_null_terminated(const uint8_t **data, size_t *size) {
   34|    245|#define STR_SIZE 75
   35|    245|  if (*size < STR_SIZE || (int)*size < 0) {
  ------------------
  |  |   34|    490|#define STR_SIZE 75
  ------------------
  |  Branch (35:7): [True: 13, False: 232]
  |  Branch (35:27): [True: 0, False: 232]
  ------------------
   36|     13|    return NULL;
   37|     13|  }
   38|       |
   39|    232|  char *new_s = malloc(STR_SIZE + 1);
  ------------------
  |  |   34|    232|#define STR_SIZE 75
  ------------------
   40|    232|  memcpy(new_s, *data, STR_SIZE);
  ------------------
  |  |   34|    232|#define STR_SIZE 75
  ------------------
   41|    232|  new_s[STR_SIZE] = '\0';
  ------------------
  |  |   34|    232|#define STR_SIZE 75
  ------------------
   42|       |
   43|    232|  *data = *data+STR_SIZE;
  ------------------
  |  |   34|    232|#define STR_SIZE 75
  ------------------
   44|    232|  *size -= STR_SIZE;
  ------------------
  |  |   34|    232|#define STR_SIZE 75
  ------------------
   45|    232|  return new_s;
   46|    245|}
af_gb_get_null_terminated:
   64|    245|char *af_gb_get_null_terminated(const uint8_t **data, size_t *size) {
   65|       |
   66|    245|  char *nstr = af_get_null_terminated(data, size);
   67|    245|  if (nstr == NULL) {
  ------------------
  |  Branch (67:7): [True: 13, False: 232]
  ------------------
   68|     13|    return NULL;
   69|     13|  }
   70|    232|  pointer_arr[pointer_idx++] = (void*)nstr;
   71|    232|  return nstr;
   72|    245|}

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

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

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

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

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

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

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

