Sophie

Sophie

distrib > Mandriva > 10.0 > i586 > by-pkgid > ef9bad9e14fc2a68cb7c992c11d75f5e > files > 3167

libboost1-devel-1.31.0-1mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<HTML>
<HEAD>
<TITLE>Simple Segregated Storage Implementation</TITLE>
<LINK HREF="../pool.css" REL="stylesheet" TYPE="text/css">
</HEAD>
<BODY>

<IMG SRC="../../../../c++boost.gif" WIDTH=276 HEIGHT=86 ALT="C++ Boost">

<H1 ALIGN=CENTER>Simple Segregated Storage Implementation</H1>

<P>
<H2>Dependencies</H2>

<P>
Includes the system headers <SPAN CLASS="code">&lt;cstddef&gt;</SPAN> and <SPAN CLASS="code">&lt;functional&gt;</SPAN>.

<P>
<H2>Protected Interface</H2>

<P>
<H3>Synopsis</H3>

<PRE CLASS="code">template &lt;typename SizeType = std::size_t&gt;
class simple_segregated_storage
{
  ... // Public interface

  protected:
    void * first;
    static void * & nextof(void * const ptr);
    void * find_prev(void * ptr);
};</PRE>

<P>
<H3 CLASS="code">void * first;</H3>

<P>
This data member is the free list.  It points to the first chunk in the free list, or is equal to 0 if the free list is empty.

<P>
<H3 CLASS="code">static void * & nextof(void * const ptr);</H3>

<P>
This is a convenience function.  It helps clean up code dealing with the free list by making it more readable.  The return value is just <SPAN CLASS="code">*ptr</SPAN> cast to the appropriate type.  <SPAN CLASS="code">ptr</SPAN> must not be 0.

<P>
As an example, let us assume that we want to truncate the free list after the first chunk.  That is, we want to set <SPAN CLASS="code">*first</SPAN> to 0; this will result in a free list with only one entry.  The normal way to do this is to first cast <SPAN CLASS="code">first</SPAN> to a pointer to a pointer to void, and then dereference and assign (<SPAN CLASS="code">*static_cast&lt;void **&gt;(first) = 0;</SPAN>).  This can be done more easily through the use of this convenience function (<SPAN CLASS="code">nextof(first) = 0;</SPAN>).

<P>
<H3 CLASS="code">void * find_prev(void * ptr);</H3>

<P>
Traverses the free list referred to by <SPAN CLASS="code">first</SPAN>, and returns the pointer previous to where <SPAN CLASS="code">ptr</SPAN> would go if it was in the free list.  Returns 0 if <SPAN CLASS="code">ptr</SPAN> would go at the beginning of the free list (i.e., before <SPAN CLASS="code">first</SPAN>).

<P>
Note that this function finds the location previous to where <SPAN CLASS="code">ptr</SPAN> <STRONG>would</STRONG> go <STRONG>if it was</STRONG> in the free list.  It does <STRONG>not</STRONG> find the entry in the free list before <SPAN CLASS="code">ptr</SPAN> (unless <SPAN CLASS="code">ptr</SPAN> is already in the free list).  Specifically, <SPAN CLASS="code">find_prev(0)</SPAN> will return 0, <STRONG>not</STRONG> the last entry in the free list.

<P>
<H2><A HREF="../interfaces/simple_segregated_storage.html">Interface Description</A></H2>

<P>
<HR>

<P>
Copyright &copy; 2000, 2001 Stephen Cleary (scleary AT jerviswebb DOT com)

<P>
This file can be redistributed and/or modified under the terms found in <A HREF="../copyright.html">copyright.html</A>

<P>
This software and its documentation is provided &quot;as is&quot; without express or implied warranty, and with no claim as to its suitability for any purpose.

</BODY>
</HTML>