<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>Memory Allocation</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.2.15 --> <center> <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="pages.html">Related Pages</a> </center> <hr><h1>Memory Allocation<br> <small> [<a class="el" href="group__DBus.html">D-BUS message system public API</a>]</small> </h1><a class="el" href="group__DBusMemory.html#a0">dbus_malloc</a>(), <a class="el" href="group__DBusMemory.html#a3">dbus_free</a>(), etc. <a href="#_details">More...</a><table border=0 cellpadding=0 cellspacing=0> <tr><td colspan=2><br><h2>Defines</h2></td></tr> <tr><td nowrap align=right valign=top>#define </td><td valign=bottom><a class="el" href="group__DBusMemory.html#a6">dbus_new</a>(type, count) ((type*)dbus_malloc (sizeof (type) * (count)));</td></tr> <tr><td> </td><td><font size=-1><em>Safe macro for using <a class="el" href="group__DBusMemory.html#a0">dbus_malloc</a>().</em> <a href="#a6">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>#define </td><td valign=bottom><a class="el" href="group__DBusMemory.html#a7">dbus_new0</a>(type, count) ((type*)dbus_malloc0 (sizeof (type) * (count)));</td></tr> <tr><td> </td><td><font size=-1><em>Safe macro for using <a class="el" href="group__DBusMemory.html#a1">dbus_malloc0</a>().</em> <a href="#a7">More...</a><em></em></font><br><br></td></tr> <tr><td colspan=2><br><h2>Typedefs</h2></td></tr> <tr><td nowrap align=right valign=top>typedef void(* </td><td valign=bottom><a class="el" href="group__DBusMemory.html#a8">DBusFreeFunction</a> )(void *memory)</td></tr> <tr><td> </td><td><font size=-1><em>The type of a function which frees a block of memory.</em> <a href="#a8">More...</a><em></em></font><br><br></td></tr> <tr><td colspan=2><br><h2>Functions</h2></td></tr> <tr><td nowrap align=right valign=top>void * </td><td valign=bottom><a class="el" href="group__DBusMemory.html#a0">dbus_malloc</a> (size_t bytes)</td></tr> <tr><td> </td><td><font size=-1><em>Allocates the given number of bytes, as with standard malloc().</em> <a href="#a0">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>void * </td><td valign=bottom><a class="el" href="group__DBusMemory.html#a1">dbus_malloc0</a> (size_t bytes)</td></tr> <tr><td> </td><td><font size=-1><em>Allocates the given number of bytes, as with standard malloc(), but all bytes are initialized to zero as with calloc().</em> <a href="#a1">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>void * </td><td valign=bottom><a class="el" href="group__DBusMemory.html#a2">dbus_realloc</a> (void *memory, size_t bytes)</td></tr> <tr><td> </td><td><font size=-1><em>Resizes a block of memory previously allocated by <a class="el" href="group__DBusMemory.html#a0">dbus_malloc</a>() or <a class="el" href="group__DBusMemory.html#a1">dbus_malloc0</a>().</em> <a href="#a2">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="group__DBusMemory.html#a3">dbus_free</a> (void *memory)</td></tr> <tr><td> </td><td><font size=-1><em>Frees a block of memory previously allocated by <a class="el" href="group__DBusMemory.html#a0">dbus_malloc</a>() or <a class="el" href="group__DBusMemory.html#a1">dbus_malloc0</a>().</em> <a href="#a3">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="group__DBusMemory.html#a4">dbus_free_string_array</a> (char **str_array)</td></tr> <tr><td> </td><td><font size=-1><em>Frees a <a class="el" href="group__DBusMacros.html#a4">NULL</a>-terminated array of strings.</em> <a href="#a4">More...</a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="group__DBusMemory.html#a5">dbus_shutdown</a> (void)</td></tr> <tr><td> </td><td><font size=-1><em>The D-BUS library keeps some internal global variables, for example to cache the username of the current process.</em> <a href="#a5">More...</a><em></em></font><br><br></td></tr> </table> <hr><a name="_details"></a><h2>Detailed Description</h2> <a class="el" href="group__DBusMemory.html#a0">dbus_malloc</a>(), <a class="el" href="group__DBusMemory.html#a3">dbus_free</a>(), etc. <p> <p> Functions and macros related to allocating and releasing blocks of memory. <hr><h2>Define Documentation</h2> <a name="a6" doxytag="dbus-memory.h::dbus_new"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> #define dbus_new</td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">type, <tr> <td></td> <td></td> <td class="md" nowrap>count </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top">) </td> <td class="md" nowrap> ((type*)dbus_malloc (sizeof (type) * (count))); </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Safe macro for using <a class="el" href="group__DBusMemory.html#a0">dbus_malloc</a>(). <p> Accepts the type to allocate and the number of type instances to allocate as arguments, and returns a memory block cast to the desired type, instead of as a void*.<dl compact><dt><b> Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>type</em> </td><td> type name to allocate </td></tr> <tr><td valign=top><em>count</em> </td><td> number of instances in the allocated array </td></tr> </table> </dl><dl compact><dt><b> Returns: </b><dd> the new memory block or <a class="el" href="group__DBusMacros.html#a4">NULL</a> on failure </dl> <p> Definition at line <a class="el" href="dbus-memory_8h-source.html#l00041">41</a> of file <a class="el" href="dbus-memory_8h-source.html">dbus-memory.h</a>. </td> </tr> </table> <a name="a7" doxytag="dbus-memory.h::dbus_new0"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> #define dbus_new0</td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">type, <tr> <td></td> <td></td> <td class="md" nowrap>count </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top">) </td> <td class="md" nowrap> ((type*)dbus_malloc0 (sizeof (type) * (count))); </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Safe macro for using <a class="el" href="group__DBusMemory.html#a1">dbus_malloc0</a>(). <p> Accepts the type to allocate and the number of type instances to allocate as arguments, and returns a memory block cast to the desired type, instead of as a void*. The allocated array is initialized to all-bits-zero.<dl compact><dt><b> Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>type</em> </td><td> type name to allocate </td></tr> <tr><td valign=top><em>count</em> </td><td> number of instances in the allocated array </td></tr> </table> </dl><dl compact><dt><b> Returns: </b><dd> the new memory block or <a class="el" href="group__DBusMacros.html#a4">NULL</a> on failure </dl> <p> Definition at line <a class="el" href="dbus-memory_8h-source.html#l00042">42</a> of file <a class="el" href="dbus-memory_8h-source.html">dbus-memory.h</a>. </td> </tr> </table> <hr><h2>Typedef Documentation</h2> <a name="a8" doxytag="dbus-memory.h::DBusFreeFunction"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> DBusFreeFunction </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> The type of a function which frees a block of memory. <p> <dl compact><dt><b> Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>memory</em> </td><td> the memory to free </td></tr> </table> </dl> <p> Definition at line <a class="el" href="dbus-memory_8h-source.html#l00046">46</a> of file <a class="el" href="dbus-memory_8h-source.html">dbus-memory.h</a>. </td> </tr> </table> <hr><h2>Function Documentation</h2> <a name="a3" doxytag="dbus-memory.c::dbus_free"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> void dbus_free </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">void * </td> <td class="mdname1" valign="top" nowrap> <em>memory</em> </td> <td class="md" valign="top">) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Frees a block of memory previously allocated by <a class="el" href="group__DBusMemory.html#a0">dbus_malloc</a>() or <a class="el" href="group__DBusMemory.html#a1">dbus_malloc0</a>(). <p> If passed <a class="el" href="group__DBusMacros.html#a4">NULL</a>, does nothing.<dl compact><dt><b> Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>memory</em> </td><td> block to be freed </td></tr> </table> </dl> <p> Definition at line <a class="el" href="dbus-memory_8c-source.html#l00605">605</a> of file <a class="el" href="dbus-memory_8c-source.html">dbus-memory.c</a>. </td> </tr> </table> <a name="a4" doxytag="dbus-memory.c::dbus_free_string_array"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> void dbus_free_string_array </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">char ** </td> <td class="mdname1" valign="top" nowrap> <em>str_array</em> </td> <td class="md" valign="top">) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Frees a <a class="el" href="group__DBusMacros.html#a4">NULL</a>-terminated array of strings. <p> If passed <a class="el" href="group__DBusMacros.html#a4">NULL</a>, does nothing.<dl compact><dt><b> Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>str_array</em> </td><td> the array to be freed </td></tr> </table> </dl> <p> Definition at line <a class="el" href="dbus-memory_8c-source.html#l00643">643</a> of file <a class="el" href="dbus-memory_8c-source.html">dbus-memory.c</a>. </td> </tr> </table> <a name="a0" doxytag="dbus-memory.c::dbus_malloc"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> void* dbus_malloc </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">size_t </td> <td class="mdname1" valign="top" nowrap> <em>bytes</em> </td> <td class="md" valign="top">) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Allocates the given number of bytes, as with standard malloc(). <p> Guaranteed to return <a class="el" href="group__DBusMacros.html#a4">NULL</a> if bytes is zero on all platforms. Returns <a class="el" href="group__DBusMacros.html#a4">NULL</a> if the allocation fails. The memory must be released with <a class="el" href="group__DBusMemory.html#a3">dbus_free</a>().<dl compact><dt><b> Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>bytes</em> </td><td> number of bytes to allocate </td></tr> </table> </dl><dl compact><dt><b> Returns: </b><dd> allocated memory, or <a class="el" href="group__DBusMacros.html#a4">NULL</a> if the allocation fails. </dl> <p> Definition at line <a class="el" href="dbus-memory_8c-source.html#l00430">430</a> of file <a class="el" href="dbus-memory_8c-source.html">dbus-memory.c</a>. </td> </tr> </table> <a name="a1" doxytag="dbus-memory.c::dbus_malloc0"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> void* dbus_malloc0 </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">size_t </td> <td class="mdname1" valign="top" nowrap> <em>bytes</em> </td> <td class="md" valign="top">) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Allocates the given number of bytes, as with standard malloc(), but all bytes are initialized to zero as with calloc(). <p> Guaranteed to return <a class="el" href="group__DBusMacros.html#a4">NULL</a> if bytes is zero on all platforms. Returns <a class="el" href="group__DBusMacros.html#a4">NULL</a> if the allocation fails. The memory must be released with <a class="el" href="group__DBusMemory.html#a3">dbus_free</a>().<dl compact><dt><b> Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>bytes</em> </td><td> number of bytes to allocate </td></tr> </table> </dl><dl compact><dt><b> Returns: </b><dd> allocated memory, or <a class="el" href="group__DBusMacros.html#a4">NULL</a> if the allocation fails. </dl> <p> Definition at line <a class="el" href="dbus-memory_8c-source.html#l00481">481</a> of file <a class="el" href="dbus-memory_8c-source.html">dbus-memory.c</a>. </td> </tr> </table> <a name="a2" doxytag="dbus-memory.c::dbus_realloc"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> void* dbus_realloc </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">void * </td> <td class="mdname" nowrap> <em>memory</em>, </td> </tr> <tr> <td></td> <td></td> <td class="md" nowrap>size_t </td> <td class="mdname" nowrap> <em>bytes</em></td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Resizes a block of memory previously allocated by <a class="el" href="group__DBusMemory.html#a0">dbus_malloc</a>() or <a class="el" href="group__DBusMemory.html#a1">dbus_malloc0</a>(). <p> Guaranteed to free the memory and return <a class="el" href="group__DBusMacros.html#a4">NULL</a> if bytes is zero on all platforms. Returns <a class="el" href="group__DBusMacros.html#a4">NULL</a> if the resize fails. If the resize fails, the memory is not freed.<dl compact><dt><b> Parameters: </b><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>memory</em> </td><td> block to be resized </td></tr> <tr><td valign=top><em>bytes</em> </td><td> new size of the memory block </td></tr> </table> </dl><dl compact><dt><b> Returns: </b><dd> allocated memory, or <a class="el" href="group__DBusMacros.html#a4">NULL</a> if the resize fails. </dl> <p> Definition at line <a class="el" href="dbus-memory_8c-source.html#l00532">532</a> of file <a class="el" href="dbus-memory_8c-source.html">dbus-memory.c</a>. </td> </tr> </table> <a name="a5" doxytag="dbus-memory.c::dbus_shutdown"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> void dbus_shutdown </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">void </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top">) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> The D-BUS library keeps some internal global variables, for example to cache the username of the current process. <p> This function is used to free these global variables. It is really useful only for leak-checking cleanliness and the like. WARNING: this function is NOT thread safe, it must be called while NO other threads are using D-BUS. You cannot continue using D-BUS after calling this function, as it does things like free global mutexes created by <a class="el" href="group__DBusThreads.html#a12">dbus_threads_init</a>(). To use a D-BUS function after calling <a class="el" href="group__DBusMemory.html#a5">dbus_shutdown</a>(), you have to start over from scratch, e.g. calling <a class="el" href="group__DBusThreads.html#a12">dbus_threads_init</a>() again. <p> Definition at line <a class="el" href="dbus-memory_8c-source.html#l00749">749</a> of file <a class="el" href="dbus-memory_8c-source.html">dbus-memory.c</a>. <p> References <a class="el" href="dbus-memory_8c-source.html#l00689">ShutdownClosure::data</a>, <a class="el" href="dbus-memory_8c-source.html#l00688">ShutdownClosure::func</a>, and <a class="el" href="dbus-memory_8c-source.html#l00687">ShutdownClosure::next</a>. </td> </tr> </table> <hr><address align="right"><small>Generated on Wed Jun 9 05:01:28 2004 for D-BUS by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border=0 width=110 height=53></a>1.2.15 </small></address> </body> </html>