📄 apr__pools_8h-source.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Apache Portable Runtime: apr_pools.h Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.7 -->
<div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related Pages</a></div>
<h1>apr_pools.h</h1><a href="apr__pools_8h.html">Go to the documentation of this file.</a><pre class="fragment"><div>00001 <span class="comment">/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as</span>
00002 <span class="comment"> * applicable.</span>
00003 <span class="comment"> *</span>
00004 <span class="comment"> * Licensed under the Apache License, Version 2.0 (the "License");</span>
00005 <span class="comment"> * you may not use this file except in compliance with the License.</span>
00006 <span class="comment"> * You may obtain a copy of the License at</span>
00007 <span class="comment"> *</span>
00008 <span class="comment"> * http://www.apache.org/licenses/LICENSE-2.0</span>
00009 <span class="comment"> *</span>
00010 <span class="comment"> * Unless required by applicable law or agreed to in writing, software</span>
00011 <span class="comment"> * distributed under the License is distributed on an "AS IS" BASIS,</span>
00012 <span class="comment"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span>
00013 <span class="comment"> * See the License for the specific language governing permissions and</span>
00014 <span class="comment"> * limitations under the License.</span>
00015 <span class="comment"> */</span>
00016
00017 <span class="preprocessor">#ifndef APR_POOLS_H</span>
00018 <span class="preprocessor"></span><span class="preprocessor">#define APR_POOLS_H</span>
00019 <span class="preprocessor"></span><span class="comment"></span>
00020 <span class="comment">/**</span>
00021 <span class="comment"> * @file apr_pools.h</span>
00022 <span class="comment"> * @brief APR memory allocation</span>
00023 <span class="comment"> *</span>
00024 <span class="comment"> * Resource allocation routines...</span>
00025 <span class="comment"> *</span>
00026 <span class="comment"> * designed so that we don't have to keep track of EVERYTHING so that</span>
00027 <span class="comment"> * it can be explicitly freed later (a fundamentally unsound strategy ---</span>
00028 <span class="comment"> * particularly in the presence of die()).</span>
00029 <span class="comment"> *</span>
00030 <span class="comment"> * Instead, we maintain pools, and allocate items (both memory and I/O</span>
00031 <span class="comment"> * handlers) from the pools --- currently there are two, one for per</span>
00032 <span class="comment"> * transaction info, and one for config info. When a transaction is over,</span>
00033 <span class="comment"> * we can delete everything in the per-transaction apr_pool_t without fear,</span>
00034 <span class="comment"> * and without thinking too hard about it either.</span>
00035 <span class="comment"> */</span>
00036
00037 <span class="preprocessor">#include "apr.h"</span>
00038 <span class="preprocessor">#include "<a class="code" href="apr__errno_8h.html">apr_errno.h</a>"</span>
00039 <span class="preprocessor">#include "<a class="code" href="apr__general_8h.html">apr_general.h</a>"</span> <span class="comment">/* for APR_STRINGIFY */</span>
<a name="l00040"></a><a class="code" href="apr__pools_8h.html#a0">00040</a> <span class="preprocessor">#define APR_WANT_MEMFUNC </span><span class="comment">/**< for no good reason? */</span>
00041 <span class="preprocessor">#include "<a class="code" href="apr__want_8h.html">apr_want.h</a>"</span>
00042
00043 <span class="preprocessor">#ifdef __cplusplus</span>
00044 <span class="preprocessor"></span><span class="keyword">extern</span> <span class="stringliteral">"C"</span> {
00045 <span class="preprocessor">#endif</span>
00046 <span class="preprocessor"></span><span class="comment"></span>
00047 <span class="comment">/**</span>
00048 <span class="comment"> * @defgroup apr_pools Memory Pool Functions</span>
00049 <span class="comment"> * @ingroup APR </span>
00050 <span class="comment"> * @{</span>
00051 <span class="comment"> */</span>
00052 <span class="comment"></span>
00053 <span class="comment">/** The fundamental pool type */</span>
<a name="l00054"></a><a class="code" href="group__apr__pools.html#ga0">00054</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="group__apr__pools.html#ga0">apr_pool_t</a> <a class="code" href="group__apr__pools.html#ga0">apr_pool_t</a>;
00055
00056 <span class="comment"></span>
00057 <span class="comment">/**</span>
00058 <span class="comment"> * Declaration helper macro to construct apr_foo_pool_get()s.</span>
00059 <span class="comment"> *</span>
00060 <span class="comment"> * This standardized macro is used by opaque (APR) data types to return</span>
00061 <span class="comment"> * the apr_pool_t that is associated with the data type.</span>
00062 <span class="comment"> *</span>
00063 <span class="comment"> * APR_POOL_DECLARE_ACCESSOR() is used in a header file to declare the</span>
00064 <span class="comment"> * accessor function. A typical usage and result would be:</span>
00065 <span class="comment"> * <pre></span>
00066 <span class="comment"> * APR_POOL_DECLARE_ACCESSOR(file);</span>
00067 <span class="comment"> * becomes:</span>
00068 <span class="comment"> * APR_DECLARE(apr_pool_t *) apr_file_pool_get(apr_file_t *ob);</span>
00069 <span class="comment"> * </pre></span>
00070 <span class="comment"> * @remark Doxygen unwraps this macro (via doxygen.conf) to provide </span>
00071 <span class="comment"> * actual help for each specific occurance of apr_foo_pool_get.</span>
00072 <span class="comment"> * @remark the linkage is specified for APR. It would be possible to expand</span>
00073 <span class="comment"> * the macros to support other linkages.</span>
00074 <span class="comment"> */</span>
<a name="l00075"></a><a class="code" href="group__apr__pools.html#ga30">00075</a> <span class="preprocessor">#define APR_POOL_DECLARE_ACCESSOR(type) \</span>
00076 <span class="preprocessor"> APR_DECLARE(apr_pool_t *) apr_##type##_pool_get \</span>
00077 <span class="preprocessor"> (const apr_##type##_t *the##type)</span>
00078 <span class="preprocessor"></span><span class="comment"></span>
00079 <span class="comment">/** </span>
00080 <span class="comment"> * Implementation helper macro to provide apr_foo_pool_get()s.</span>
00081 <span class="comment"> *</span>
00082 <span class="comment"> * In the implementation, the APR_POOL_IMPLEMENT_ACCESSOR() is used to</span>
00083 <span class="comment"> * actually define the function. It assumes the field is named "pool".</span>
00084 <span class="comment"> */</span>
<a name="l00085"></a><a class="code" href="group__apr__pools.html#ga31">00085</a> <span class="preprocessor">#define APR_POOL_IMPLEMENT_ACCESSOR(type) \</span>
00086 <span class="preprocessor"> APR_DECLARE(apr_pool_t *) apr_##type##_pool_get \</span>
00087 <span class="preprocessor"> (const apr_##type##_t *the##type) \</span>
00088 <span class="preprocessor"> { return the##type->pool; }</span>
00089 <span class="preprocessor"></span>
00090 <span class="comment"></span>
00091 <span class="comment">/**</span>
00092 <span class="comment"> * Pool debug levels</span>
00093 <span class="comment"> *</span>
00094 <span class="comment"> * <pre></span>
00095 <span class="comment"> * | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |</span>
00096 <span class="comment"> * ---------------------------------</span>
00097 <span class="comment"> * | | | | | | | | x | General debug code enabled (useful in</span>
00098 <span class="comment"> * combination with --with-efence).</span>
00099 <span class="comment"> *</span>
00100 <span class="comment"> * | | | | | | | x | | Verbose output on stderr (report</span>
00101 <span class="comment"> * CREATE, CLEAR, DESTROY).</span>
00102 <span class="comment"> *</span>
00103 <span class="comment"> * | | | | x | | | | | Verbose output on stderr (report</span>
00104 <span class="comment"> * PALLOC, PCALLOC).</span>
00105 <span class="comment"> *</span>
00106 <span class="comment"> * | | | | | | x | | | Lifetime checking. On each use of a</span>
00107 <span class="comment"> * pool, check its lifetime. If the pool</span>
00108 <span class="comment"> * is out of scope, abort().</span>
00109 <span class="comment"> * In combination with the verbose flag</span>
00110 <span class="comment"> * above, it will output LIFE in such an</span>
00111 <span class="comment"> * event prior to aborting.</span>
00112 <span class="comment"> *</span>
00113 <span class="comment"> * | | | | | x | | | | Pool owner checking. On each use of a</span>
00114 <span class="comment"> * pool, check if the current thread is the</span>
00115 <span class="comment"> * pools owner. If not, abort(). In</span>
00116 <span class="comment"> * combination with the verbose flag above,</span>
00117 <span class="comment"> * it will output OWNER in such an event</span>
00118 <span class="comment"> * prior to aborting. Use the debug</span>
00119 <span class="comment"> * function apr_pool_owner_set() to switch</span>
00120 <span class="comment"> * a pools ownership.</span>
00121 <span class="comment"> *</span>
00122 <span class="comment"> * When no debug level was specified, assume general debug mode.</span>
00123 <span class="comment"> * If level 0 was specified, debugging is switched off</span>
00124 <span class="comment"> * </pre></span>
00125 <span class="comment"> */</span>
00126 <span class="preprocessor">#if defined(APR_POOL_DEBUG)</span>
00127 <span class="preprocessor"></span><span class="comment">/* If APR_POOL_DEBUG is blank, we get 1; if it is a number, we get -1. */</span>
00128 <span class="preprocessor">#if (APR_POOL_DEBUG - APR_POOL_DEBUG -1 == 1)</span>
00129 <span class="preprocessor"></span><span class="preprocessor">#undef APR_POOL_DEBUG</span>
00130 <span class="preprocessor"></span><span class="preprocessor">#define APR_POOL_DEBUG 1</span>
00131 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
00132 <span class="preprocessor"></span><span class="preprocessor">#else</span>
<a name="l00133"></a><a class="code" href="group__apr__pools.html#ga32">00133</a> <span class="preprocessor"></span><span class="preprocessor">#define APR_POOL_DEBUG 0</span>
00134 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
00135 <span class="preprocessor"></span><span class="comment"></span>
00136 <span class="comment">/** the place in the code where the particular function was called */</span>
<a name="l00137"></a><a class="code" href="group__apr__pools.html#ga33">00137</a> <span class="preprocessor">#define APR_POOL__FILE_LINE__ __FILE__ ":" APR_STRINGIFY(__LINE__)</span>
00138 <span class="preprocessor"></span>
00139
00140 <span class="comment"></span>
00141 <span class="comment">/** A function that is called when allocation fails. */</span>
<a name="l00142"></a><a class="code" href="group__apr__pools.html#ga1">00142</a> <span class="keyword">typedef</span> int (*apr_abortfunc_t)(<span class="keywordtype">int</span> retcode);
00143
00144 <span class="comment">/*</span>
00145 <span class="comment"> * APR memory structure manipulators (pools, tables, and arrays).</span>
00146 <span class="comment"> */</span>
00147
00148 <span class="comment">/*</span>
00149 <span class="comment"> * Initialization</span>
00150 <span class="comment"> */</span>
00151 <span class="comment"></span>
00152 <span class="comment">/**</span>
00153 <span class="comment"> * Setup all of the internal structures required to use pools</span>
00154 <span class="comment"> * @remark Programs do NOT need to call this directly. APR will call this</span>
00155 <span class="comment"> * automatically from apr_initialize.</span>
00156 <span class="comment"> * @internal</span>
00157 <span class="comment"> */</span>
00158 APR_DECLARE(apr_status_t) apr_pool_initialize(<span class="keywordtype">void</span>);
00159 <span class="comment"></span>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -