svn: /phpdoc/en/trunk/internals2/memory/ persistence.xml
| From: | Joe Watkins | Date: | Tue, 09 Apr 2013 00:16:42 +0000 |
| Subject: | svn: /phpdoc/en/trunk/internals2/memory/ persistence.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-11173@lists.php.net to get a copy of this message | ||
krakjoe Tue, 09 Apr 2013 00:16:42 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=330034
Log:
start to write up more of internals doc
Changed paths:
U phpdoc/en/trunk/internals2/memory/persistence.xml
Modified: phpdoc/en/trunk/internals2/memory/persistence.xml
===================================================================
--- phpdoc/en/trunk/internals2/memory/persistence.xml 2013-04-08 23:29:28 UTC (rev 330033)
+++ phpdoc/en/trunk/internals2/memory/persistence.xml 2013-04-09 00:16:42 UTC (rev 330034)
@@ -1,9 +1,96 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
- <sect1 xml:id="internals2.memory.persistence" xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink">
- <title>Data persistence</title>
-
+<sect1 xml:id="internals2.memory.persistence" xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink">
+ <title>Data persistence</title>
+
+ <simpara>
+ In the context of PHP, data persistence is taken to mean any data that is intended to survive the
current request.
+ </simpara>
+
+ <simpara>
+ Persistence can be used, for example, to keep conntections to a database server for multiple
requests, Zend provides a sub-api of its emalloc/efree mechanisms, predictably name pemalloc/pefree
etc
+ </simpara>
+
+ <note>
<simpara>
+ All of the following functions take the additional persistent parameter, should this be false,
Zend will use it's regular allocators and the memory should not be considered persistent. Where
memory is allocated as persistent, system allocators are invoked, under most circumstances they are
still not able to return NULL pointers just as the Main memory APIs.
</simpara>
-
- </sect1>
+ </note>
+
+ <table xml:id="internals2.memory.management.papis">
+ <title>Persistent memory APIs</title>
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>Prototype</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+
+ <row>
+ <entry><code>void *pemalloc(size_t size, zend_bool
persistent)</code></entry>
+ <entry>Allocate <code>size</code> bytes of memory.</entry>
+ </row>
+
+ <row>
+ <entry><code>void *pecalloc(size_t nmemb, size_t size, zend_bool
persistent)</code></entry>
+ <entry>
+ Allocate a buffer for <code>nmemb</code> elements of
+ <code>size</code> bytes and makes sure it is initialized with zeros.
+ </entry>
+ </row>
+
+ <row>
+ <entry><code>void *perealloc(void *ptr, size_t size, zend_bool
persistent)</code></entry>
+ <entry>
+ Resize the buffer <code>ptr</code>, which was allocated using
+ <code>emalloc</code> to hold <code>size</code> bytes of memory.
+ </entry>
+ </row>
+
+ <row>
+ <entry><code>void pefree(void *ptr, zend_bool
persistent)</code></entry>
+ <entry>
+ Free the buffer pointed by <code>ptr</code>. The buffer had to be
+ allocated by <code>pemalloc</code>.
+ </entry>
+ </row>
+
+ <row>
+ <entry>
+ <code>void *safe_pemalloc(size_t nmemb, size_t size, size_t offset, zend_bool
persistent)</code>
+ </entry>
+ <entry>
+ Allocate a buffer for holding <code>nmemb</code> blocks of each
+ <code>size</code> bytes and an additional <code>offset</code> bytes.
+ This is similar to <code>emalloc(nmemb * size + offset)</code> but adds
+ a special protection against overflows.
+ </entry>
+ </row>
+
+ <row>
+ <entry><code>char *pestrdup(const char *s, zend_bool
persistent)</code></entry>
+ <entry>
+ Allocate a buffer that can hold the NULL-terminated string
+ <code>s</code> and copy the <code>s</code> into that buffer.
+ </entry>
+ </row>
+
+ <row>
+ <entry>
+ <code>char *pestrndup(const char *s, unsigned int length, zend_bool
persistent)</code>
+ </entry>
+ <entry>
+ Similar to <code>pestrdup</code> while the length of the
+ NULL-terminated string is already known.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <caution>
+ It is important to remember that memory allocated to be persistent is not optimized or tracked by
the Zend engine; it is not subject to memory_limit.
+ </caution>
+</sect1>