⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 apr_pools.h

📁 Apache V2.0.15 Alpha For Linuxhttpd-2_0_15-alpha.tar.Z
💻 H
📖 第 1 页 / 共 2 页
字号:
/* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in *    the documentation and/or other materials provided with the *    distribution. * * 3. The end-user documentation included with the redistribution, *    if any, must include the following acknowledgment: *       "This product includes software developed by the *        Apache Software Foundation (http://www.apache.org/)." *    Alternately, this acknowledgment may appear in the software itself, *    if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" must *    not be used to endorse or promote products derived from this *    software without prior written permission. For written *    permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", *    nor may "Apache" appear in their name, without prior written *    permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation.  For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */#ifndef APR_POOLS_H#define APR_POOLS_H#ifdef __cplusplusextern "C" {#endif/** * @file apr_pools.h * @brief APR memory allocation * * Resource allocation routines... * * designed so that we don't have to keep track of EVERYTHING so that * it can be explicitly freed later (a fundamentally unsound strategy --- * particularly in the presence of die()). * * Instead, we maintain pools, and allocate items (both memory and I/O * handlers) from the pools --- currently there are two, one for per * transaction info, and one for config info.  When a transaction is over, * we can delete everything in the per-transaction apr_pool_t without fear,  * and without thinking too hard about it either. */#include "apr.h"#include "apr_errno.h"/* Memory allocation/Pool debugging options...  * * Look in the developer documentation for details of what these do. * * NB These should ALL normally be commented out unless you REALLY * need them!! */ /*#define ALLOC_DEBUG#define APR_POOL_DEBUG#define ALLOC_USE_MALLOC#define MAKE_TABLE_PROFILE#define ALLOC_STATS*//** The fundamental pool type */typedef struct apr_pool_t apr_pool_t;/** The memory allocation structure */struct apr_pool_t {    /** The first block in this pool. */    union block_hdr *first;    /** The last block in this pool. */    union block_hdr *last;    /** The list of cleanups to run on pool cleanup. */    struct cleanup *cleanups;    /** A list of processes to kill when this pool is cleared */    struct process_chain *subprocesses;    /** The first sub_pool of this pool */    struct apr_pool_t *sub_pools;    /** The next sibling pool */    struct apr_pool_t *sub_next;    /** The previous sibling pool */    struct apr_pool_t *sub_prev;    /** The parent pool of this pool */    struct apr_pool_t *parent;    /** The first free byte in this pool */    char *free_first_avail;#ifdef ALLOC_USE_MALLOC    /** The allocation list if using malloc */    void *allocation_list;#endif#ifdef APR_POOL_DEBUG    /** a list of joined pools */    struct apr_pool_t *joined;#endif    /** A function to control how pools behave when they receive ENOMEM */    int (*apr_abort)(int retcode);    /** A place to hold user data associated with this pool */    struct apr_hash_t *prog_data;};/* pools have nested lifetimes -- sub_pools are destroyed when the * parent pool is cleared.  We allow certain liberties with operations * on things such as tables (and on other structures in a more general * sense) where we allow the caller to insert values into a table which * were not allocated from the table's pool.  The table's data will * remain valid as long as all the pools from which its values are * allocated remain valid. * * For example, if B is a sub pool of A, and you build a table T in * pool B, then it's safe to insert data allocated in A or B into T * (because B lives at most as long as A does, and T is destroyed when * B is cleared/destroyed).  On the other hand, if S is a table in * pool A, it is safe to insert data allocated in A into S, but it * is *not safe* to insert data allocated from B into S... because * B can be cleared/destroyed before A is (which would leave dangling * pointers in T's data structures). * * In general we say that it is safe to insert data into a table T * if the data is allocated in any ancestor of T's pool.  This is the * basis on which the APR_POOL_DEBUG code works -- it tests these ancestor * relationships for all data inserted into tables.  APR_POOL_DEBUG also * provides tools (apr_find_pool, and apr_pool_is_ancestor) for other * folks to implement similar restrictions for their own data * structures. * * However, sometimes this ancestor requirement is inconvenient -- * sometimes we're forced to create a sub pool (such as through * apr_sub_req_lookup_uri), and the sub pool is guaranteed to have * the same lifetime as the parent pool.  This is a guarantee implemented * by the *caller*, not by the pool code.  That is, the caller guarantees * they won't destroy the sub pool individually prior to destroying the * parent pool. * * In this case the caller must call apr_pool_join() to indicate this * guarantee to the APR_POOL_DEBUG code.  There are a few examples spread * through the standard modules. */#ifdef APR_POOL_DEBUGAPR_DECLARE(void) apr_pool_join(apr_pool_t *p, apr_pool_t *sub);APR_DECLARE(apr_pool_t *) apr_find_pool(const void *ts);/** * Determine if pool a is an ancestor of pool b * @param a The pool to search  * @param b The pool to search for * @return True if a is an ancestor of b, NULL is considered an ancestor *         of all pools. */APR_DECLARE(int) apr_pool_is_ancestor(apr_pool_t *a, apr_pool_t *b);#else# ifdef apr_pool_join#  undef apr_pool_join# endif# define apr_pool_join(a,b)#endif/* * APR memory structure manipulators (pools, tables, and arrays). *//** * Setup all of the internal structures required to use pools * @param globalp The APR global pool, used to allocate APR structures *               before any other pools are created.  This pool should not *               ever be used outside of APR. * @remark Programs do NOT need to call this directly.  APR will call this *      automatically from apr_initialize.  * @internal */APR_DECLARE(apr_status_t) apr_pool_alloc_init(apr_pool_t *globalp);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -