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

📄 group__apr__ring.html

📁 apr函数库使用手册
💻 HTML
📖 第 1 页 / 共 5 页
字号:
    </td>
    <td>

<p>
The last element of the ring <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td></td><td valign=top><em>hp</em>&nbsp;</td><td>The head of the ring </td></tr>
  </table>
</dl>
    </td>
  </tr>
</table>
<a class="anchor" name="ga5" doxytag="apr_ring.h::APR_RING_NEXT" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> #define APR_RING_NEXT          </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">ep,         <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>link&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap>&nbsp;&nbsp;&nbsp;(ep)-&gt;link.next</td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
The next element in the ring <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td></td><td valign=top><em>ep</em>&nbsp;</td><td>The current element </td></tr>
    <tr><td></td><td valign=top><em>link</em>&nbsp;</td><td>The name of the APR_RING_ENTRY in the element struct </td></tr>
  </table>
</dl>
    </td>
  </tr>
</table>
<a class="anchor" name="ga19" doxytag="apr_ring.h::APR_RING_PREPEND" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> #define APR_RING_PREPEND          </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">h1,         <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>h2,         <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>elem,         <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>link&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
<b>Value:</b><pre class="fragment"><div><span class="keywordflow">do</span> {                    \
        <span class="keywordflow">if</span> (!<a class="code" href="group__apr__ring.html#ga8">APR_RING_EMPTY</a>((h2), elem, link)) {                        \
            <a class="code" href="group__apr__ring.html#ga11">APR_RING_SPLICE_AFTER</a>(<a class="code" href="group__apr__ring.html#ga2">APR_RING_SENTINEL</a>((h1), elem, link),  \
                                  <a class="code" href="group__apr__ring.html#ga3">APR_RING_FIRST</a>((h2)),                 \
                                  <a class="code" href="group__apr__ring.html#ga4">APR_RING_LAST</a>((h2)), link);           \
            <a class="code" href="group__apr__ring.html#ga7">APR_RING_INIT</a>((h2), elem, link);                            \
        }                                                               \
    } <span class="keywordflow">while</span> (0)
</div></pre>Prepend ring h2 onto the beginning of ring h1, leaving h2 empty. <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td></td><td valign=top><em>h1</em>&nbsp;</td><td>Head of the ring to prepend onto </td></tr>
    <tr><td></td><td valign=top><em>h2</em>&nbsp;</td><td>Head of the ring to prepend </td></tr>
    <tr><td></td><td valign=top><em>elem</em>&nbsp;</td><td>The name of the element struct </td></tr>
    <tr><td></td><td valign=top><em>link</em>&nbsp;</td><td>The name of the APR_RING_ENTRY in the element struct </td></tr>
  </table>
</dl>
    </td>
  </tr>
</table>
<a class="anchor" name="ga6" doxytag="apr_ring.h::APR_RING_PREV" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> #define APR_RING_PREV          </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">ep,         <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>link&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap>&nbsp;&nbsp;&nbsp;(ep)-&gt;link.prev</td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
The previous element in the ring <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td></td><td valign=top><em>ep</em>&nbsp;</td><td>The current element </td></tr>
    <tr><td></td><td valign=top><em>link</em>&nbsp;</td><td>The name of the APR_RING_ENTRY in the element struct </td></tr>
  </table>
</dl>
    </td>
  </tr>
</table>
<a class="anchor" name="ga21" doxytag="apr_ring.h::APR_RING_REMOVE" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> #define APR_RING_REMOVE          </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">ep,         <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>link&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap>&nbsp;&nbsp;&nbsp;APR_RING_UNSPLICE((ep), (ep), link)</td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Remove a single element from a ring <dl compact><dt><b>Warning:</b></dt><dd>The unspliced element is left with dangling pointers at either end </dd></dl>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td></td><td valign=top><em>ep</em>&nbsp;</td><td>Element to remove </td></tr>
    <tr><td></td><td valign=top><em>link</em>&nbsp;</td><td>The name of the APR_RING_ENTRY in the element struct </td></tr>
  </table>
</dl>
    </td>
  </tr>
</table>
<a class="anchor" name="ga2" doxytag="apr_ring.h::APR_RING_SENTINEL" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> #define APR_RING_SENTINEL          </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">hp,         <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>elem,         <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>link&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap>&nbsp;&nbsp;&nbsp;(struct elem *)((char *)(hp) - APR_OFFSETOF(struct elem, link))</td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
The Ring Sentinel<p>
This is the magic pointer value that occurs before the first and after the last elements in the ring, computed from the address of the ring's head. The head itself isn't an element, but in order to get rid of all the special cases when dealing with the ends of the ring, we play typecasting games to make it look like one.<p>
Here is a diagram to illustrate the arrangements of the next and prev pointers of each element in a single ring. Note that they point to the start of each element, not to the APR_RING_ENTRY structure.<p>
<pre>
     +-&gt;+------+&lt;-+  +-&gt;+------+&lt;-+  +-&gt;+------+&lt;-+
     |  |struct|  |  |  |struct|  |  |  |struct|  |
    /   | elem |   \/   | elem |   \/   | elem |  \
 ...    |      |   /\   |      |   /\   |      |   ...
        +------+  |  |  +------+  |  |  +------+
   ...--|prev  |  |  +--|ring  |  |  +--|prev  |
        |  next|--+     | entry|--+     |  next|--...
        +------+        +------+        +------+
        | etc. |        | etc. |        | etc. |
        :      :        :      :        :      :
 </pre><p>
The APR_RING_HEAD is nothing but a bare APR_RING_ENTRY. The prev and next pointers in the first and last elements don't actually point to the head, they point to a phantom place called the sentinel. Its value is such that last-&gt;next-&gt;next == first because the offset from the sentinel to the head's next pointer is the same as the offset from the start of an element to its next pointer. This also works in the opposite direction.<p>
<pre>
        last                            first
     +-&gt;+------+&lt;-+  +-&gt;sentinel&lt;-+  +-&gt;+------+&lt;-+
     |  |struct|  |  |            |  |  |struct|  |
    /   | elem |   \/              \/   | elem |  \
 ...    |      |   /\              /\   |      |   ...
        +------+  |  |  +------+  |  |  +------+
   ...--|prev  |  |  +--|ring  |  |  +--|prev  |
        |  next|--+     |  head|--+     |  next|--...
        +------+        +------+        +------+
        | etc. |                        | etc. |
        :      :                        :      :
 </pre><p>
Note that the offset mentioned above is different for each kind of ring that the element may be on, and each kind of ring has a unique name for its APR_RING_ENTRY in each element, and has its own type for its APR_RING_HEAD.<p>
Note also that if the offset is non-zero (which is required if an element has more than one APR_RING_ENTRY), the unreality of the sentinel may have bad implications on very perverse implementations of C -- see the warning in APR_RING_ENTRY.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td></td><td valign=top><em>hp</em>&nbsp;</td><td>The head of the ring </td></tr>
    <tr><td></td><td valign=top><em>elem</em>&nbsp;</td><td>The name of the element struct </td></tr>
    <tr><td></td><td valign=top><em>link</em>&nbsp;</td><td>The name of the APR_RING_ENTRY in the element struct </td></tr>
  </table>
</dl>
    </td>
  </tr>
</table>
<a class="anchor" name="ga11" doxytag="apr_ring.h::APR_RING_SPLICE_AFTER" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> #define APR_RING_SPLICE_AFTER          </td>

⌨️ 快捷键说明

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