|
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17 System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64 User : nobody ( 99) PHP Version : 5.2.17 Disable Function : NONE Directory : /usr/share/devhelp/books/dbus/api/ |
Upload File : |
<!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>D-Bus: dbus-hash.c Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.7 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="annotated.html"><span>Data Structures</span></a></li>
<li id="current"><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related Pages</span></a></li>
</ul></div>
<h1>dbus-hash.c</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */</span>
<a name="l00002"></a>00002 <span class="comment">/* dbus-hash.c Generic hash table utility (internal to D-Bus implementation)</span>
<a name="l00003"></a>00003 <span class="comment"> * </span>
<a name="l00004"></a>00004 <span class="comment"> * Copyright (C) 2002 Red Hat, Inc.</span>
<a name="l00005"></a>00005 <span class="comment"> * Copyright (c) 1991-1993 The Regents of the University of California.</span>
<a name="l00006"></a>00006 <span class="comment"> * Copyright (c) 1994 Sun Microsystems, Inc.</span>
<a name="l00007"></a>00007 <span class="comment"> * </span>
<a name="l00008"></a>00008 <span class="comment"> * Hash table implementation based on generic/tclHash.c from the Tcl</span>
<a name="l00009"></a>00009 <span class="comment"> * source code. The original Tcl license applies to portions of the</span>
<a name="l00010"></a>00010 <span class="comment"> * code from tclHash.c; the Tcl license follows this standad D-Bus </span>
<a name="l00011"></a>00011 <span class="comment"> * license information.</span>
<a name="l00012"></a>00012 <span class="comment"> *</span>
<a name="l00013"></a>00013 <span class="comment"> * Licensed under the Academic Free License version 2.1</span>
<a name="l00014"></a>00014 <span class="comment"> * </span>
<a name="l00015"></a>00015 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
<a name="l00016"></a>00016 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<a name="l00017"></a>00017 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00018"></a>00018 <span class="comment"> * (at your option) any later version.</span>
<a name="l00019"></a>00019 <span class="comment"> *</span>
<a name="l00020"></a>00020 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
<a name="l00021"></a>00021 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00022"></a>00022 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00023"></a>00023 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00024"></a>00024 <span class="comment"> * </span>
<a name="l00025"></a>00025 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00026"></a>00026 <span class="comment"> * along with this program; if not, write to the Free Software</span>
<a name="l00027"></a>00027 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
<a name="l00028"></a>00028 <span class="comment"> *</span>
<a name="l00029"></a>00029 <span class="comment"> */</span>
<a name="l00030"></a>00030 <span class="comment">/* </span>
<a name="l00031"></a>00031 <span class="comment"> * The following copyright applies to code from the Tcl distribution.</span>
<a name="l00032"></a>00032 <span class="comment"> *</span>
<a name="l00033"></a>00033 <span class="comment"> * Copyright (c) 1991-1993 The Regents of the University of California.</span>
<a name="l00034"></a>00034 <span class="comment"> * Copyright (c) 1994 Sun Microsystems, Inc.</span>
<a name="l00035"></a>00035 <span class="comment"> *</span>
<a name="l00036"></a>00036 <span class="comment"> * This software is copyrighted by the Regents of the University of</span>
<a name="l00037"></a>00037 <span class="comment"> * California, Sun Microsystems, Inc., Scriptics Corporation, and</span>
<a name="l00038"></a>00038 <span class="comment"> * other parties. The following terms apply to all files associated</span>
<a name="l00039"></a>00039 <span class="comment"> * with the software unless explicitly disclaimed in individual files.</span>
<a name="l00040"></a>00040 <span class="comment"> * </span>
<a name="l00041"></a>00041 <span class="comment"> * The authors hereby grant permission to use, copy, modify,</span>
<a name="l00042"></a>00042 <span class="comment"> * distribute, and license this software and its documentation for any</span>
<a name="l00043"></a>00043 <span class="comment"> * purpose, provided that existing copyright notices are retained in</span>
<a name="l00044"></a>00044 <span class="comment"> * all copies and that this notice is included verbatim in any</span>
<a name="l00045"></a>00045 <span class="comment"> * distributions. No written agreement, license, or royalty fee is</span>
<a name="l00046"></a>00046 <span class="comment"> * required for any of the authorized uses. Modifications to this</span>
<a name="l00047"></a>00047 <span class="comment"> * software may be copyrighted by their authors and need not follow</span>
<a name="l00048"></a>00048 <span class="comment"> * the licensing terms described here, provided that the new terms are</span>
<a name="l00049"></a>00049 <span class="comment"> * clearly indicated on the first page of each file where they apply.</span>
<a name="l00050"></a>00050 <span class="comment"> * </span>
<a name="l00051"></a>00051 <span class="comment"> * IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY</span>
<a name="l00052"></a>00052 <span class="comment"> * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL</span>
<a name="l00053"></a>00053 <span class="comment"> * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION,</span>
<a name="l00054"></a>00054 <span class="comment"> * OR ANY DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED</span>
<a name="l00055"></a>00055 <span class="comment"> * OF THE POSSIBILITY OF SUCH DAMAGE.</span>
<a name="l00056"></a>00056 <span class="comment"> * </span>
<a name="l00057"></a>00057 <span class="comment"> * THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,</span>
<a name="l00058"></a>00058 <span class="comment"> * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF</span>
<a name="l00059"></a>00059 <span class="comment"> * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND</span>
<a name="l00060"></a>00060 <span class="comment"> * NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,</span>
<a name="l00061"></a>00061 <span class="comment"> * AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE</span>
<a name="l00062"></a>00062 <span class="comment"> * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.</span>
<a name="l00063"></a>00063 <span class="comment"> * </span>
<a name="l00064"></a>00064 <span class="comment"> * GOVERNMENT USE: If you are acquiring this software on behalf of the</span>
<a name="l00065"></a>00065 <span class="comment"> * U.S. government, the Government shall have only "Restricted Rights"</span>
<a name="l00066"></a>00066 <span class="comment"> * in the software and related documentation as defined in the Federal</span>
<a name="l00067"></a>00067 <span class="comment"> * Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you</span>
<a name="l00068"></a>00068 <span class="comment"> * are acquiring the software on behalf of the Department of Defense,</span>
<a name="l00069"></a>00069 <span class="comment"> * the software shall be classified as "Commercial Computer Software"</span>
<a name="l00070"></a>00070 <span class="comment"> * and the Government shall have only "Restricted Rights" as defined</span>
<a name="l00071"></a>00071 <span class="comment"> * in Clause 252.227-7013 (c) (1) of DFARs. Notwithstanding the</span>
<a name="l00072"></a>00072 <span class="comment"> * foregoing, the authors grant the U.S. Government and others acting</span>
<a name="l00073"></a>00073 <span class="comment"> * in its behalf permission to use and distribute the software in</span>
<a name="l00074"></a>00074 <span class="comment"> * accordance with the terms specified in this license.</span>
<a name="l00075"></a>00075 <span class="comment"> */</span>
<a name="l00076"></a>00076
<a name="l00077"></a>00077 <span class="preprocessor">#include "dbus-hash.h"</span>
<a name="l00078"></a>00078 <span class="preprocessor">#include "dbus-internals.h"</span>
<a name="l00079"></a>00079 <span class="preprocessor">#include "dbus-mempool.h"</span>
<a name="l00080"></a>00080
<a name="l00103"></a><a class="code" href="group__DBusHashTableInternals.html#g8c6d6296d450e37074dbd8c15638b499">00103</a> <span class="preprocessor">#define REBUILD_MULTIPLIER 3</span>
<a name="l00104"></a>00104 <span class="preprocessor"></span>
<a name="l00121"></a><a class="code" href="group__DBusHashTableInternals.html#g9dc8fd5a9e25bd2b229366a683ff78f9">00121</a> <span class="preprocessor">#define RANDOM_INDEX(table, i) \</span>
<a name="l00122"></a>00122 <span class="preprocessor"> (((((long) (i))*1103515245) >> (table)->down_shift) & (table)->mask)</span>
<a name="l00123"></a>00123 <span class="preprocessor"></span>
<a name="l00129"></a><a class="code" href="group__DBusHashTableInternals.html#g4518324f3c3caacf5694065f4f6071d8">00129</a> <span class="preprocessor">#define DBUS_SMALL_HASH_TABLE 4</span>
<a name="l00130"></a>00130 <span class="preprocessor"></span>
<a name="l00134"></a><a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">00134</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structDBusHashEntry.html">DBusHashEntry</a> <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a>;
<a name="l00135"></a>00135
<a name="l00142"></a><a class="code" href="structDBusHashEntry.html">00142</a> <span class="keyword">struct </span><a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a>
<a name="l00143"></a>00143 {
<a name="l00144"></a><a class="code" href="structDBusHashEntry.html#e986e25c0b24237f9848ff43aa1d8501">00144</a> <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *<a class="code" href="structDBusHashEntry.html#e986e25c0b24237f9848ff43aa1d8501">next</a>;
<a name="l00148"></a><a class="code" href="structDBusHashEntry.html#efd9bbdcbc7d15c906e2c289c8d2e894">00148</a> <span class="keywordtype">void</span> *<a class="code" href="structDBusHashEntry.html#efd9bbdcbc7d15c906e2c289c8d2e894">key</a>;
<a name="l00149"></a><a class="code" href="structDBusHashEntry.html#d792e9c81cc3a23859b2c60b3b00af3e">00149</a> <span class="keywordtype">void</span> *<a class="code" href="structDBusHashEntry.html#d792e9c81cc3a23859b2c60b3b00af3e">value</a>;
<a name="l00150"></a>00150 };
<a name="l00151"></a>00151
<a name="l00155"></a><a class="code" href="group__DBusHashTableInternals.html#gf7aa30377ff1074657bfef5e834bf931">00155</a> <span class="keyword">typedef</span> <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a>* (* DBusFindEntryFunction) (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table,
<a name="l00156"></a>00156 <span class="keywordtype">void</span> *key,
<a name="l00157"></a>00157 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a> create_if_not_found,
<a name="l00158"></a>00158 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> ***bucket,
<a name="l00159"></a>00159 <a class="code" href="group__DBusHashTable.html#g175dc6ab841ed32bb6acf6e4c0df36a8">DBusPreallocatedHash</a> *preallocated);
<a name="l00160"></a>00160
<a name="l00167"></a><a class="code" href="structDBusHashTable.html">00167</a> <span class="keyword">struct </span><a class="code" href="structDBusHashTable.html">DBusHashTable</a> {
<a name="l00168"></a><a class="code" href="structDBusHashTable.html#cb2b7bcba65da77f7ecf67da355ff770">00168</a> <span class="keywordtype">int</span> <a class="code" href="structDBusHashTable.html#cb2b7bcba65da77f7ecf67da355ff770">refcount</a>;
<a name="l00170"></a><a class="code" href="structDBusHashTable.html#1f974e2cb3038685b3edf493406ad99d">00170</a> <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> **<a class="code" href="structDBusHashTable.html#1f974e2cb3038685b3edf493406ad99d">buckets</a>;
<a name="l00174"></a>00174 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *<a class="code" href="structDBusHashTable.html#f71877d64657c34a783caf6b82b016e9">static_buckets</a>[<a class="code" href="group__DBusHashTableInternals.html#g4518324f3c3caacf5694065f4f6071d8">DBUS_SMALL_HASH_TABLE</a>];
<a name="l00178"></a><a class="code" href="structDBusHashTable.html#2dd2b9389d65d30e31e596dd786a9aa7">00178</a> <span class="keywordtype">int</span> <a class="code" href="structDBusHashTable.html#2dd2b9389d65d30e31e596dd786a9aa7">n_buckets</a>;
<a name="l00181"></a><a class="code" href="structDBusHashTable.html#ffbf11a9c3dd72d55b7976891f7b4650">00181</a> <span class="keywordtype">int</span> <a class="code" href="structDBusHashTable.html#ffbf11a9c3dd72d55b7976891f7b4650">n_entries</a>;
<a name="l00184"></a><a class="code" href="structDBusHashTable.html#29c408110c0d189d89b60c6c01cfb0cf">00184</a> <span class="keywordtype">int</span> <a class="code" href="structDBusHashTable.html#29c408110c0d189d89b60c6c01cfb0cf">hi_rebuild_size</a>;
<a name="l00187"></a><a class="code" href="structDBusHashTable.html#ae6ea7cb15d618866854b2b6bd468419">00187</a> <span class="keywordtype">int</span> <a class="code" href="structDBusHashTable.html#ae6ea7cb15d618866854b2b6bd468419">lo_rebuild_size</a>;
<a name="l00190"></a><a class="code" href="structDBusHashTable.html#2e7e7b92bb9633ab95cfaa592b89025c">00190</a> <span class="keywordtype">int</span> <a class="code" href="structDBusHashTable.html#2e7e7b92bb9633ab95cfaa592b89025c">down_shift</a>;
<a name="l00194"></a><a class="code" href="structDBusHashTable.html#ec1230eebce3d256ca9ceebe372647e9">00194</a> <span class="keywordtype">int</span> <a class="code" href="structDBusHashTable.html#ec1230eebce3d256ca9ceebe372647e9">mask</a>;
<a name="l00197"></a><a class="code" href="structDBusHashTable.html#28f326a2947b6be0b0b852db376a1092">00197</a> <a class="code" href="group__DBusHashTable.html#gb0ab9767ffa5b6720a13b3d741630852">DBusHashType</a> <a class="code" href="structDBusHashTable.html#28f326a2947b6be0b0b852db376a1092">key_type</a>;
<a name="l00200"></a><a class="code" href="structDBusHashTable.html#b98bafddf1b1ce1dad01c5595e278e35">00200</a> <a class="code" href="group__DBusHashTableInternals.html#gf7aa30377ff1074657bfef5e834bf931">DBusFindEntryFunction</a> <a class="code" href="structDBusHashTable.html#b98bafddf1b1ce1dad01c5595e278e35">find_function</a>;
<a name="l00202"></a><a class="code" href="structDBusHashTable.html#5f6541574ea8e6bedd80773dce8e52a6">00202</a> <a class="code" href="group__DBusMemory.html#g8792ec2b2b8626ca28022faf51ec415a">DBusFreeFunction</a> <a class="code" href="structDBusHashTable.html#5f6541574ea8e6bedd80773dce8e52a6">free_key_function</a>;
<a name="l00203"></a><a class="code" href="structDBusHashTable.html#fbb42b5326b9c79352b168eace1687ca">00203</a> <a class="code" href="group__DBusMemory.html#g8792ec2b2b8626ca28022faf51ec415a">DBusFreeFunction</a> <a class="code" href="structDBusHashTable.html#fbb42b5326b9c79352b168eace1687ca">free_value_function</a>;
<a name="l00205"></a><a class="code" href="structDBusHashTable.html#d1224e6c3c632afb265b78f8f6e30f97">00205</a> <a class="code" href="structDBusMemPool.html">DBusMemPool</a> *<a class="code" href="structDBusHashTable.html#d1224e6c3c632afb265b78f8f6e30f97">entry_pool</a>;
<a name="l00206"></a>00206 };
<a name="l00207"></a>00207
<a name="l00211"></a><a class="code" href="structDBusRealHashIter.html">00211</a> <span class="keyword">typedef</span> <span class="keyword">struct</span>
<a name="l00212"></a>00212 <span class="keyword"></span>{
<a name="l00213"></a><a class="code" href="structDBusRealHashIter.html#0307c2b8fa9384554ceb3cc965b04633">00213</a> <a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table;
<a name="l00214"></a><a class="code" href="structDBusRealHashIter.html#d36967dc68709d676ad591d7f75dd7fa">00214</a> <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> **bucket;
<a name="l00218"></a><a class="code" href="structDBusRealHashIter.html#438db1cb3a9c6db716f8bf35fe3054c7">00218</a> <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *entry;
<a name="l00219"></a><a class="code" href="structDBusRealHashIter.html#056417c3726f4f98eb94a9d2784a59e0">00219</a> <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *next_entry;
<a name="l00220"></a><a class="code" href="structDBusRealHashIter.html#dbf758933299ee6305c525ea0fe74824">00220</a> <span class="keywordtype">int</span> next_bucket;
<a name="l00221"></a><a class="code" href="structDBusRealHashIter.html#84f2a189ee1eb3e51a8089b798a7797a">00221</a> <span class="keywordtype">int</span> n_entries_on_init;
<a name="l00222"></a>00222 } <a class="code" href="structDBusRealHashIter.html">DBusRealHashIter</a>;
<a name="l00223"></a>00223
<a name="l00224"></a>00224 <span class="keyword">static</span> <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a>* find_direct_function (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table,
<a name="l00225"></a>00225 <span class="keywordtype">void</span> *key,
<a name="l00226"></a>00226 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a> create_if_not_found,
<a name="l00227"></a>00227 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> ***bucket,
<a name="l00228"></a>00228 <a class="code" href="group__DBusHashTable.html#g175dc6ab841ed32bb6acf6e4c0df36a8">DBusPreallocatedHash</a> *preallocated);
<a name="l00229"></a>00229 <span class="keyword">static</span> <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a>* find_string_function (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table,
<a name="l00230"></a>00230 <span class="keywordtype">void</span> *key,
<a name="l00231"></a>00231 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a> create_if_not_found,
<a name="l00232"></a>00232 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> ***bucket,
<a name="l00233"></a>00233 <a class="code" href="group__DBusHashTable.html#g175dc6ab841ed32bb6acf6e4c0df36a8">DBusPreallocatedHash</a> *preallocated);
<a name="l00234"></a>00234 <span class="preprocessor">#ifdef DBUS_BUILD_TESTS</span>
<a name="l00235"></a>00235 <span class="preprocessor"></span><span class="keyword">static</span> <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a>* find_two_strings_function (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table,
<a name="l00236"></a>00236 <span class="keywordtype">void</span> *key,
<a name="l00237"></a>00237 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a> create_if_not_found,
<a name="l00238"></a>00238 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> ***bucket,
<a name="l00239"></a>00239 <a class="code" href="group__DBusHashTable.html#g175dc6ab841ed32bb6acf6e4c0df36a8">DBusPreallocatedHash</a> *preallocated);
<a name="l00240"></a>00240 <span class="preprocessor">#endif</span>
<a name="l00241"></a>00241 <span class="preprocessor"></span><span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> string_hash (<span class="keyword">const</span> <span class="keywordtype">char</span> *str);
<a name="l00242"></a>00242 <span class="preprocessor">#ifdef DBUS_BUILD_TESTS</span>
<a name="l00243"></a>00243 <span class="preprocessor"></span><span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> two_strings_hash (<span class="keyword">const</span> <span class="keywordtype">char</span> *str);
<a name="l00244"></a>00244 <span class="preprocessor">#endif</span>
<a name="l00245"></a>00245 <span class="preprocessor"></span><span class="keyword">static</span> <span class="keywordtype">void</span> rebuild_table (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table);
<a name="l00246"></a>00246 <span class="keyword">static</span> <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a>* alloc_entry (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table);
<a name="l00247"></a>00247 <span class="keyword">static</span> <span class="keywordtype">void</span> remove_entry (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table,
<a name="l00248"></a>00248 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> **bucket,
<a name="l00249"></a>00249 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *entry);
<a name="l00250"></a>00250 <span class="keyword">static</span> <span class="keywordtype">void</span> free_entry (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table,
<a name="l00251"></a>00251 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *entry);
<a name="l00252"></a>00252 <span class="keyword">static</span> <span class="keywordtype">void</span> free_entry_data (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table,
<a name="l00253"></a>00253 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *entry);
<a name="l00254"></a>00254
<a name="l00255"></a>00255
<a name="l00291"></a>00291 <a class="code" href="structDBusHashTable.html">DBusHashTable</a>*
<a name="l00292"></a><a class="code" href="group__DBusHashTable.html#gc8e434348a354b9606d4c50c127a5eb4">00292</a> <a class="code" href="group__DBusHashTable.html#gc8e434348a354b9606d4c50c127a5eb4">_dbus_hash_table_new</a> (<a class="code" href="group__DBusHashTable.html#gb0ab9767ffa5b6720a13b3d741630852">DBusHashType</a> type,
<a name="l00293"></a>00293 <a class="code" href="group__DBusMemory.html#g8792ec2b2b8626ca28022faf51ec415a">DBusFreeFunction</a> key_free_function,
<a name="l00294"></a>00294 <a class="code" href="group__DBusMemory.html#g8792ec2b2b8626ca28022faf51ec415a">DBusFreeFunction</a> value_free_function)
<a name="l00295"></a>00295 {
<a name="l00296"></a>00296 <a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table;
<a name="l00297"></a>00297 <a class="code" href="structDBusMemPool.html">DBusMemPool</a> *entry_pool;
<a name="l00298"></a>00298
<a name="l00299"></a>00299 table = <a class="code" href="group__DBusMemory.html#gba9d823abda7f4cadbaf5177d3b8b793">dbus_new0</a> (<a class="code" href="structDBusHashTable.html">DBusHashTable</a>, 1);
<a name="l00300"></a>00300 <span class="keywordflow">if</span> (table == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l00301"></a>00301 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l00302"></a>00302
<a name="l00303"></a>00303 entry_pool = <a class="code" href="group__DBusMemPool.html#gf1bae02bc5fcb879f77ff2c13ca03ac8">_dbus_mem_pool_new</a> (<span class="keyword">sizeof</span> (<a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a>), <a class="code" href="group__DBusMacros.html#ga8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>);
<a name="l00304"></a>00304 <span class="keywordflow">if</span> (entry_pool == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l00305"></a>00305 {
<a name="l00306"></a>00306 <a class="code" href="group__DBusMemory.html#g488c6b08cc8c1ddf0203243c4b27a13c">dbus_free</a> (table);
<a name="l00307"></a>00307 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l00308"></a>00308 }
<a name="l00309"></a>00309
<a name="l00310"></a>00310 table-><a class="code" href="structDBusHashTable.html#cb2b7bcba65da77f7ecf67da355ff770">refcount</a> = 1;
<a name="l00311"></a>00311 table-><a class="code" href="structDBusHashTable.html#d1224e6c3c632afb265b78f8f6e30f97">entry_pool</a> = entry_pool;
<a name="l00312"></a>00312
<a name="l00313"></a>00313 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (<a class="code" href="group__DBusHashTableInternals.html#g4518324f3c3caacf5694065f4f6071d8">DBUS_SMALL_HASH_TABLE</a> == <a class="code" href="group__DBusInternalsUtils.html#gc153abad46f4eb80999a2b340d29d1f0">_DBUS_N_ELEMENTS</a> (table-><a class="code" href="structDBusHashTable.html#f71877d64657c34a783caf6b82b016e9">static_buckets</a>));
<a name="l00314"></a>00314
<a name="l00315"></a>00315 table-><a class="code" href="structDBusHashTable.html#1f974e2cb3038685b3edf493406ad99d">buckets</a> = table-><a class="code" href="structDBusHashTable.html#f71877d64657c34a783caf6b82b016e9">static_buckets</a>;
<a name="l00316"></a>00316 table-><a class="code" href="structDBusHashTable.html#2dd2b9389d65d30e31e596dd786a9aa7">n_buckets</a> = <a class="code" href="group__DBusHashTableInternals.html#g4518324f3c3caacf5694065f4f6071d8">DBUS_SMALL_HASH_TABLE</a>;
<a name="l00317"></a>00317 table-><a class="code" href="structDBusHashTable.html#ffbf11a9c3dd72d55b7976891f7b4650">n_entries</a> = 0;
<a name="l00318"></a>00318 table-><a class="code" href="structDBusHashTable.html#29c408110c0d189d89b60c6c01cfb0cf">hi_rebuild_size</a> = <a class="code" href="group__DBusHashTableInternals.html#g4518324f3c3caacf5694065f4f6071d8">DBUS_SMALL_HASH_TABLE</a> * <a class="code" href="group__DBusHashTableInternals.html#g8c6d6296d450e37074dbd8c15638b499">REBUILD_MULTIPLIER</a>;
<a name="l00319"></a>00319 table-><a class="code" href="structDBusHashTable.html#ae6ea7cb15d618866854b2b6bd468419">lo_rebuild_size</a> = 0;
<a name="l00320"></a>00320 table-><a class="code" href="structDBusHashTable.html#2e7e7b92bb9633ab95cfaa592b89025c">down_shift</a> = 28;
<a name="l00321"></a>00321 table-><a class="code" href="structDBusHashTable.html#ec1230eebce3d256ca9ceebe372647e9">mask</a> = 3;
<a name="l00322"></a>00322 table-><a class="code" href="structDBusHashTable.html#28f326a2947b6be0b0b852db376a1092">key_type</a> = type;
<a name="l00323"></a>00323
<a name="l00324"></a>00324 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (table-><a class="code" href="structDBusHashTable.html#ec1230eebce3d256ca9ceebe372647e9">mask</a> < table-><a class="code" href="structDBusHashTable.html#2dd2b9389d65d30e31e596dd786a9aa7">n_buckets</a>);
<a name="l00325"></a>00325
<a name="l00326"></a>00326 <span class="keywordflow">switch</span> (table-><a class="code" href="structDBusHashTable.html#28f326a2947b6be0b0b852db376a1092">key_type</a>)
<a name="l00327"></a>00327 {
<a name="l00328"></a>00328 <span class="keywordflow">case</span> <a class="code" href="group__DBusHashTable.html#ggb0ab9767ffa5b6720a13b3d74163085226446bd9fbb15c6c381b35a810207141">DBUS_HASH_INT</a>:
<a name="l00329"></a>00329 <span class="keywordflow">case</span> <a class="code" href="group__DBusHashTable.html#ggb0ab9767ffa5b6720a13b3d74163085238604db762cd0ed315106a95a6b50c4d">DBUS_HASH_POINTER</a>:
<a name="l00330"></a>00330 <span class="keywordflow">case</span> <a class="code" href="group__DBusHashTable.html#ggb0ab9767ffa5b6720a13b3d741630852f9b5230298187cd6953dbcac824b2e4c">DBUS_HASH_ULONG</a>:
<a name="l00331"></a>00331 table-><a class="code" href="structDBusHashTable.html#b98bafddf1b1ce1dad01c5595e278e35">find_function</a> = find_direct_function;
<a name="l00332"></a>00332 <span class="keywordflow">break</span>;
<a name="l00333"></a>00333 <span class="keywordflow">case</span> <a class="code" href="group__DBusHashTable.html#ggb0ab9767ffa5b6720a13b3d741630852481fd0166d28da725b3e97f15192434e">DBUS_HASH_STRING</a>:
<a name="l00334"></a>00334 table-><a class="code" href="structDBusHashTable.html#b98bafddf1b1ce1dad01c5595e278e35">find_function</a> = find_string_function;
<a name="l00335"></a>00335 <span class="keywordflow">break</span>;
<a name="l00336"></a>00336 <span class="keywordflow">case</span> <a class="code" href="group__DBusHashTable.html#ggb0ab9767ffa5b6720a13b3d741630852c750b865c7994a3dd6d1028b7ae76877">DBUS_HASH_TWO_STRINGS</a>:
<a name="l00337"></a>00337 <span class="preprocessor">#ifdef DBUS_BUILD_TESTS</span>
<a name="l00338"></a>00338 <span class="preprocessor"></span> table-><a class="code" href="structDBusHashTable.html#b98bafddf1b1ce1dad01c5595e278e35">find_function</a> = find_two_strings_function;
<a name="l00339"></a>00339 <span class="preprocessor">#endif</span>
<a name="l00340"></a>00340 <span class="preprocessor"></span> <span class="keywordflow">break</span>;
<a name="l00341"></a>00341 <span class="keywordflow">default</span>:
<a name="l00342"></a>00342 <a class="code" href="group__DBusInternalsUtils.html#g0c4961ec784874f1b1f3aeccea8d3da1">_dbus_assert_not_reached</a> (<span class="stringliteral">"Unknown hash table type"</span>);
<a name="l00343"></a>00343 <span class="keywordflow">break</span>;
<a name="l00344"></a>00344 }
<a name="l00345"></a>00345
<a name="l00346"></a>00346 table-><a class="code" href="structDBusHashTable.html#5f6541574ea8e6bedd80773dce8e52a6">free_key_function</a> = key_free_function;
<a name="l00347"></a>00347 table-><a class="code" href="structDBusHashTable.html#fbb42b5326b9c79352b168eace1687ca">free_value_function</a> = value_free_function;
<a name="l00348"></a>00348
<a name="l00349"></a>00349 <span class="keywordflow">return</span> table;
<a name="l00350"></a>00350 }
<a name="l00351"></a>00351
<a name="l00352"></a>00352
<a name="l00359"></a>00359 <a class="code" href="structDBusHashTable.html">DBusHashTable</a> *
<a name="l00360"></a><a class="code" href="group__DBusHashTable.html#g4ad4622378885e5d911c26956e174a45">00360</a> <a class="code" href="group__DBusHashTable.html#g4ad4622378885e5d911c26956e174a45">_dbus_hash_table_ref</a> (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table)
<a name="l00361"></a>00361 {
<a name="l00362"></a>00362 table-><a class="code" href="structDBusHashTable.html#cb2b7bcba65da77f7ecf67da355ff770">refcount</a> += 1;
<a name="l00363"></a>00363
<a name="l00364"></a>00364 <span class="keywordflow">return</span> table;
<a name="l00365"></a>00365 }
<a name="l00366"></a>00366
<a name="l00373"></a>00373 <span class="keywordtype">void</span>
<a name="l00374"></a><a class="code" href="group__DBusHashTable.html#g96b777e00764b44e0f3216fd8478f5a9">00374</a> <a class="code" href="group__DBusHashTable.html#g96b777e00764b44e0f3216fd8478f5a9">_dbus_hash_table_unref</a> (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table)
<a name="l00375"></a>00375 {
<a name="l00376"></a>00376 table-><a class="code" href="structDBusHashTable.html#cb2b7bcba65da77f7ecf67da355ff770">refcount</a> -= 1;
<a name="l00377"></a>00377
<a name="l00378"></a>00378 <span class="keywordflow">if</span> (table-><a class="code" href="structDBusHashTable.html#cb2b7bcba65da77f7ecf67da355ff770">refcount</a> == 0)
<a name="l00379"></a>00379 {
<a name="l00380"></a>00380 <span class="preprocessor">#if 0</span>
<a name="l00381"></a>00381 <span class="preprocessor"></span> <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *entry;
<a name="l00382"></a>00382 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *next;
<a name="l00383"></a>00383 <span class="keywordtype">int</span> i;
<a name="l00384"></a>00384
<a name="l00385"></a>00385 <span class="comment">/* Free the entries in the table. */</span>
<a name="l00386"></a>00386 <span class="keywordflow">for</span> (i = 0; i < table-><a class="code" href="structDBusHashTable.html#2dd2b9389d65d30e31e596dd786a9aa7">n_buckets</a>; i++)
<a name="l00387"></a>00387 {
<a name="l00388"></a>00388 entry = table-><a class="code" href="structDBusHashTable.html#1f974e2cb3038685b3edf493406ad99d">buckets</a>[i];
<a name="l00389"></a>00389 while (entry != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l00390"></a>00390 {
<a name="l00391"></a>00391 next = entry-><a class="code" href="structDBusHashEntry.html#e986e25c0b24237f9848ff43aa1d8501">next</a>;
<a name="l00392"></a>00392
<a name="l00393"></a>00393 free_entry (table, entry);
<a name="l00394"></a>00394
<a name="l00395"></a>00395 entry = next;
<a name="l00396"></a>00396 }
<a name="l00397"></a>00397 }
<a name="l00398"></a>00398 <span class="preprocessor">#else</span>
<a name="l00399"></a>00399 <span class="preprocessor"></span> <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *entry;
<a name="l00400"></a>00400 <span class="keywordtype">int</span> i;
<a name="l00401"></a>00401
<a name="l00402"></a>00402 <span class="comment">/* Free the entries in the table. */</span>
<a name="l00403"></a>00403 <span class="keywordflow">for</span> (i = 0; i < table-><a class="code" href="structDBusHashTable.html#2dd2b9389d65d30e31e596dd786a9aa7">n_buckets</a>; i++)
<a name="l00404"></a>00404 {
<a name="l00405"></a>00405 entry = table-><a class="code" href="structDBusHashTable.html#1f974e2cb3038685b3edf493406ad99d">buckets</a>[i];
<a name="l00406"></a>00406 while (entry != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l00407"></a>00407 {
<a name="l00408"></a>00408 free_entry_data (table, entry);
<a name="l00409"></a>00409
<a name="l00410"></a>00410 entry = entry-><a class="code" href="structDBusHashEntry.html#e986e25c0b24237f9848ff43aa1d8501">next</a>;
<a name="l00411"></a>00411 }
<a name="l00412"></a>00412 }
<a name="l00413"></a>00413 <span class="comment">/* We can do this very quickly with memory pools ;-) */</span>
<a name="l00414"></a>00414 <a class="code" href="group__DBusMemPool.html#g58e4f3def46410d5bb138a2b8f366b1a">_dbus_mem_pool_free</a> (table-><a class="code" href="structDBusHashTable.html#d1224e6c3c632afb265b78f8f6e30f97">entry_pool</a>);
<a name="l00415"></a>00415 <span class="preprocessor">#endif</span>
<a name="l00416"></a>00416 <span class="preprocessor"></span>
<a name="l00417"></a>00417 <span class="comment">/* Free the bucket array, if it was dynamically allocated. */</span>
<a name="l00418"></a>00418 <span class="keywordflow">if</span> (table-><a class="code" href="structDBusHashTable.html#1f974e2cb3038685b3edf493406ad99d">buckets</a> != table-><a class="code" href="structDBusHashTable.html#f71877d64657c34a783caf6b82b016e9">static_buckets</a>)
<a name="l00419"></a>00419 <a class="code" href="group__DBusMemory.html#g488c6b08cc8c1ddf0203243c4b27a13c">dbus_free</a> (table-><a class="code" href="structDBusHashTable.html#1f974e2cb3038685b3edf493406ad99d">buckets</a>);
<a name="l00420"></a>00420
<a name="l00421"></a>00421 <a class="code" href="group__DBusMemory.html#g488c6b08cc8c1ddf0203243c4b27a13c">dbus_free</a> (table);
<a name="l00422"></a>00422 }
<a name="l00423"></a>00423 }
<a name="l00424"></a>00424
<a name="l00430"></a>00430 <span class="keywordtype">void</span>
<a name="l00431"></a><a class="code" href="group__DBusHashTable.html#gd169f3790ca67f8a0adafcdc88ef7188">00431</a> <a class="code" href="group__DBusHashTable.html#gd169f3790ca67f8a0adafcdc88ef7188">_dbus_hash_table_remove_all</a> (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table)
<a name="l00432"></a>00432 {
<a name="l00433"></a>00433 <a class="code" href="structDBusHashIter.html">DBusHashIter</a> iter;
<a name="l00434"></a>00434 <a class="code" href="group__DBusHashTable.html#g1b0e6df8a8617ef0f8f25adfba3acc4c">_dbus_hash_iter_init</a> (table, &iter);
<a name="l00435"></a>00435 <span class="keywordflow">while</span> (<a class="code" href="group__DBusHashTable.html#g723e61fcc91ca673e90ff872c07ea19c">_dbus_hash_iter_next</a> (&iter))
<a name="l00436"></a>00436 {
<a name="l00437"></a>00437 <a class="code" href="group__DBusHashTable.html#g0ef12d773a546f070cff91cbf1e8d16e">_dbus_hash_iter_remove_entry</a>(&iter);
<a name="l00438"></a>00438 }
<a name="l00439"></a>00439 }
<a name="l00440"></a>00440
<a name="l00441"></a>00441 <span class="keyword">static</span> <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a>*
<a name="l00442"></a>00442 alloc_entry (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table)
<a name="l00443"></a>00443 {
<a name="l00444"></a>00444 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *entry;
<a name="l00445"></a>00445
<a name="l00446"></a>00446 entry = <a class="code" href="group__DBusMemPool.html#g0946d54f767b4f55238f5a39c8543df1">_dbus_mem_pool_alloc</a> (table-><a class="code" href="structDBusHashTable.html#d1224e6c3c632afb265b78f8f6e30f97">entry_pool</a>);
<a name="l00447"></a>00447
<a name="l00448"></a>00448 <span class="keywordflow">return</span> entry;
<a name="l00449"></a>00449 }
<a name="l00450"></a>00450
<a name="l00451"></a>00451 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00452"></a>00452 free_entry_data (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table,
<a name="l00453"></a>00453 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *entry)
<a name="l00454"></a>00454 {
<a name="l00455"></a>00455 <span class="keywordflow">if</span> (table-><a class="code" href="structDBusHashTable.html#5f6541574ea8e6bedd80773dce8e52a6">free_key_function</a>)
<a name="l00456"></a>00456 (* table-><a class="code" href="structDBusHashTable.html#5f6541574ea8e6bedd80773dce8e52a6">free_key_function</a>) (entry-><a class="code" href="structDBusHashEntry.html#efd9bbdcbc7d15c906e2c289c8d2e894">key</a>);
<a name="l00457"></a>00457 <span class="keywordflow">if</span> (table-><a class="code" href="structDBusHashTable.html#fbb42b5326b9c79352b168eace1687ca">free_value_function</a>)
<a name="l00458"></a>00458 (* table-><a class="code" href="structDBusHashTable.html#fbb42b5326b9c79352b168eace1687ca">free_value_function</a>) (entry-><a class="code" href="structDBusHashEntry.html#d792e9c81cc3a23859b2c60b3b00af3e">value</a>);
<a name="l00459"></a>00459 }
<a name="l00460"></a>00460
<a name="l00461"></a>00461 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00462"></a>00462 free_entry (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table,
<a name="l00463"></a>00463 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *entry)
<a name="l00464"></a>00464 {
<a name="l00465"></a>00465 free_entry_data (table, entry);
<a name="l00466"></a>00466 <a class="code" href="group__DBusMemPool.html#g4e2feaefee7384ed940059e6c7b0a9d5">_dbus_mem_pool_dealloc</a> (table-><a class="code" href="structDBusHashTable.html#d1224e6c3c632afb265b78f8f6e30f97">entry_pool</a>, entry);
<a name="l00467"></a>00467 }
<a name="l00468"></a>00468
<a name="l00469"></a>00469 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00470"></a>00470 remove_entry (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table,
<a name="l00471"></a>00471 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> **bucket,
<a name="l00472"></a>00472 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *entry)
<a name="l00473"></a>00473 {
<a name="l00474"></a>00474 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (table != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00475"></a>00475 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (bucket != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00476"></a>00476 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (*bucket != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00477"></a>00477 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (entry != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00478"></a>00478
<a name="l00479"></a>00479 <span class="keywordflow">if</span> (*bucket == entry)
<a name="l00480"></a>00480 *bucket = entry-><a class="code" href="structDBusHashEntry.html#e986e25c0b24237f9848ff43aa1d8501">next</a>;
<a name="l00481"></a>00481 <span class="keywordflow">else</span>
<a name="l00482"></a>00482 {
<a name="l00483"></a>00483 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *prev;
<a name="l00484"></a>00484 prev = *bucket;
<a name="l00485"></a>00485
<a name="l00486"></a>00486 <span class="keywordflow">while</span> (prev-><a class="code" href="structDBusHashEntry.html#e986e25c0b24237f9848ff43aa1d8501">next</a> != entry)
<a name="l00487"></a>00487 prev = prev-><a class="code" href="structDBusHashEntry.html#e986e25c0b24237f9848ff43aa1d8501">next</a>;
<a name="l00488"></a>00488
<a name="l00489"></a>00489 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (prev != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00490"></a>00490
<a name="l00491"></a>00491 prev-><a class="code" href="structDBusHashEntry.html#e986e25c0b24237f9848ff43aa1d8501">next</a> = entry-><a class="code" href="structDBusHashEntry.html#e986e25c0b24237f9848ff43aa1d8501">next</a>;
<a name="l00492"></a>00492 }
<a name="l00493"></a>00493
<a name="l00494"></a>00494 table-><a class="code" href="structDBusHashTable.html#ffbf11a9c3dd72d55b7976891f7b4650">n_entries</a> -= 1;
<a name="l00495"></a>00495 free_entry (table, entry);
<a name="l00496"></a>00496 }
<a name="l00497"></a>00497
<a name="l00529"></a>00529 <span class="keywordtype">void</span>
<a name="l00530"></a><a class="code" href="group__DBusHashTable.html#g1b0e6df8a8617ef0f8f25adfba3acc4c">00530</a> <a class="code" href="group__DBusHashTable.html#g1b0e6df8a8617ef0f8f25adfba3acc4c">_dbus_hash_iter_init</a> (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table,
<a name="l00531"></a>00531 <a class="code" href="structDBusHashIter.html">DBusHashIter</a> *iter)
<a name="l00532"></a>00532 {
<a name="l00533"></a>00533 <a class="code" href="structDBusRealHashIter.html">DBusRealHashIter</a> *real;
<a name="l00534"></a>00534
<a name="l00535"></a>00535 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (<span class="keyword">sizeof</span> (<a class="code" href="structDBusHashIter.html">DBusHashIter</a>) == <span class="keyword">sizeof</span> (<a class="code" href="structDBusRealHashIter.html">DBusRealHashIter</a>));
<a name="l00536"></a>00536
<a name="l00537"></a>00537 real = (DBusRealHashIter*) iter;
<a name="l00538"></a>00538
<a name="l00539"></a>00539 real-><a class="code" href="structDBusRealHashIter.html#0307c2b8fa9384554ceb3cc965b04633">table</a> = table;
<a name="l00540"></a>00540 real-><a class="code" href="structDBusRealHashIter.html#d36967dc68709d676ad591d7f75dd7fa">bucket</a> = <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l00541"></a>00541 real-><a class="code" href="structDBusRealHashIter.html#438db1cb3a9c6db716f8bf35fe3054c7">entry</a> = <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l00542"></a>00542 real-><a class="code" href="structDBusRealHashIter.html#056417c3726f4f98eb94a9d2784a59e0">next_entry</a> = <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l00543"></a>00543 real-><a class="code" href="structDBusRealHashIter.html#dbf758933299ee6305c525ea0fe74824">next_bucket</a> = 0;
<a name="l00544"></a>00544 real-><a class="code" href="structDBusRealHashIter.html#84f2a189ee1eb3e51a8089b798a7797a">n_entries_on_init</a> = table-><a class="code" href="structDBusHashTable.html#ffbf11a9c3dd72d55b7976891f7b4650">n_entries</a>;
<a name="l00545"></a>00545 }
<a name="l00546"></a>00546
<a name="l00555"></a>00555 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a>
<a name="l00556"></a><a class="code" href="group__DBusHashTable.html#g723e61fcc91ca673e90ff872c07ea19c">00556</a> <a class="code" href="group__DBusHashTable.html#g723e61fcc91ca673e90ff872c07ea19c">_dbus_hash_iter_next</a> (<a class="code" href="structDBusHashIter.html">DBusHashIter</a> *iter)
<a name="l00557"></a>00557 {
<a name="l00558"></a>00558 <a class="code" href="structDBusRealHashIter.html">DBusRealHashIter</a> *real;
<a name="l00559"></a>00559
<a name="l00560"></a>00560 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (<span class="keyword">sizeof</span> (<a class="code" href="structDBusHashIter.html">DBusHashIter</a>) == <span class="keyword">sizeof</span> (<a class="code" href="structDBusRealHashIter.html">DBusRealHashIter</a>));
<a name="l00561"></a>00561
<a name="l00562"></a>00562 real = (DBusRealHashIter*) iter;
<a name="l00563"></a>00563
<a name="l00564"></a>00564 <span class="comment">/* if this assertion failed someone probably added hash entries</span>
<a name="l00565"></a>00565 <span class="comment"> * during iteration, which is bad.</span>
<a name="l00566"></a>00566 <span class="comment"> */</span>
<a name="l00567"></a>00567 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (real-><a class="code" href="structDBusRealHashIter.html#84f2a189ee1eb3e51a8089b798a7797a">n_entries_on_init</a> >= real-><a class="code" href="structDBusRealHashIter.html#0307c2b8fa9384554ceb3cc965b04633">table</a>-><a class="code" href="structDBusHashTable.html#ffbf11a9c3dd72d55b7976891f7b4650">n_entries</a>);
<a name="l00568"></a>00568
<a name="l00569"></a>00569 <span class="comment">/* Remember that real->entry may have been deleted */</span>
<a name="l00570"></a>00570
<a name="l00571"></a>00571 <span class="keywordflow">while</span> (real-><a class="code" href="structDBusRealHashIter.html#056417c3726f4f98eb94a9d2784a59e0">next_entry</a> == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l00572"></a>00572 {
<a name="l00573"></a>00573 <span class="keywordflow">if</span> (real-><a class="code" href="structDBusRealHashIter.html#dbf758933299ee6305c525ea0fe74824">next_bucket</a> >= real-><a class="code" href="structDBusRealHashIter.html#0307c2b8fa9384554ceb3cc965b04633">table</a>-><a class="code" href="structDBusHashTable.html#2dd2b9389d65d30e31e596dd786a9aa7">n_buckets</a>)
<a name="l00574"></a>00574 {
<a name="l00575"></a>00575 <span class="comment">/* invalidate iter and return false */</span>
<a name="l00576"></a>00576 real-><a class="code" href="structDBusRealHashIter.html#438db1cb3a9c6db716f8bf35fe3054c7">entry</a> = <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l00577"></a>00577 real-><a class="code" href="structDBusRealHashIter.html#0307c2b8fa9384554ceb3cc965b04633">table</a> = <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l00578"></a>00578 real-><a class="code" href="structDBusRealHashIter.html#d36967dc68709d676ad591d7f75dd7fa">bucket</a> = <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l00579"></a>00579 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>;
<a name="l00580"></a>00580 }
<a name="l00581"></a>00581
<a name="l00582"></a>00582 real-><a class="code" href="structDBusRealHashIter.html#d36967dc68709d676ad591d7f75dd7fa">bucket</a> = &(real-><a class="code" href="structDBusRealHashIter.html#0307c2b8fa9384554ceb3cc965b04633">table</a>-><a class="code" href="structDBusHashTable.html#1f974e2cb3038685b3edf493406ad99d">buckets</a>[real-><a class="code" href="structDBusRealHashIter.html#dbf758933299ee6305c525ea0fe74824">next_bucket</a>]);
<a name="l00583"></a>00583 real-><a class="code" href="structDBusRealHashIter.html#056417c3726f4f98eb94a9d2784a59e0">next_entry</a> = *(real-><a class="code" href="structDBusRealHashIter.html#d36967dc68709d676ad591d7f75dd7fa">bucket</a>);
<a name="l00584"></a>00584 real-><a class="code" href="structDBusRealHashIter.html#dbf758933299ee6305c525ea0fe74824">next_bucket</a> += 1;
<a name="l00585"></a>00585 }
<a name="l00586"></a>00586
<a name="l00587"></a>00587 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (real-><a class="code" href="structDBusRealHashIter.html#056417c3726f4f98eb94a9d2784a59e0">next_entry</a> != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00588"></a>00588 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (real-><a class="code" href="structDBusRealHashIter.html#d36967dc68709d676ad591d7f75dd7fa">bucket</a> != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00589"></a>00589
<a name="l00590"></a>00590 real-><a class="code" href="structDBusRealHashIter.html#438db1cb3a9c6db716f8bf35fe3054c7">entry</a> = real-><a class="code" href="structDBusRealHashIter.html#056417c3726f4f98eb94a9d2784a59e0">next_entry</a>;
<a name="l00591"></a>00591 real-><a class="code" href="structDBusRealHashIter.html#056417c3726f4f98eb94a9d2784a59e0">next_entry</a> = real-><a class="code" href="structDBusRealHashIter.html#438db1cb3a9c6db716f8bf35fe3054c7">entry</a>-><a class="code" href="structDBusHashEntry.html#e986e25c0b24237f9848ff43aa1d8501">next</a>;
<a name="l00592"></a>00592
<a name="l00593"></a>00593 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>;
<a name="l00594"></a>00594 }
<a name="l00595"></a>00595
<a name="l00604"></a>00604 <span class="keywordtype">void</span>
<a name="l00605"></a><a class="code" href="group__DBusHashTable.html#g0ef12d773a546f070cff91cbf1e8d16e">00605</a> <a class="code" href="group__DBusHashTable.html#g0ef12d773a546f070cff91cbf1e8d16e">_dbus_hash_iter_remove_entry</a> (<a class="code" href="structDBusHashIter.html">DBusHashIter</a> *iter)
<a name="l00606"></a>00606 {
<a name="l00607"></a>00607 <a class="code" href="structDBusRealHashIter.html">DBusRealHashIter</a> *real;
<a name="l00608"></a>00608
<a name="l00609"></a>00609 real = (<a class="code" href="structDBusRealHashIter.html">DBusRealHashIter</a>*) iter;
<a name="l00610"></a>00610
<a name="l00611"></a>00611 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (real-><a class="code" href="structDBusRealHashIter.html#0307c2b8fa9384554ceb3cc965b04633">table</a> != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00612"></a>00612 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (real-><a class="code" href="structDBusRealHashIter.html#438db1cb3a9c6db716f8bf35fe3054c7">entry</a> != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00613"></a>00613 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (real-><a class="code" href="structDBusRealHashIter.html#d36967dc68709d676ad591d7f75dd7fa">bucket</a> != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00614"></a>00614
<a name="l00615"></a>00615 remove_entry (real-><a class="code" href="structDBusRealHashIter.html#0307c2b8fa9384554ceb3cc965b04633">table</a>, real-><a class="code" href="structDBusRealHashIter.html#d36967dc68709d676ad591d7f75dd7fa">bucket</a>, real-><a class="code" href="structDBusRealHashIter.html#438db1cb3a9c6db716f8bf35fe3054c7">entry</a>);
<a name="l00616"></a>00616
<a name="l00617"></a>00617 real-><a class="code" href="structDBusRealHashIter.html#438db1cb3a9c6db716f8bf35fe3054c7">entry</a> = <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>; <span class="comment">/* make it crash if you try to use this entry */</span>
<a name="l00618"></a>00618 }
<a name="l00619"></a>00619
<a name="l00625"></a>00625 <span class="keywordtype">void</span>*
<a name="l00626"></a><a class="code" href="group__DBusHashTable.html#g34bf277ee37f919bd00516b5ae4e12b5">00626</a> <a class="code" href="group__DBusHashTable.html#g34bf277ee37f919bd00516b5ae4e12b5">_dbus_hash_iter_get_value</a> (<a class="code" href="structDBusHashIter.html">DBusHashIter</a> *iter)
<a name="l00627"></a>00627 {
<a name="l00628"></a>00628 <a class="code" href="structDBusRealHashIter.html">DBusRealHashIter</a> *real;
<a name="l00629"></a>00629
<a name="l00630"></a>00630 real = (<a class="code" href="structDBusRealHashIter.html">DBusRealHashIter</a>*) iter;
<a name="l00631"></a>00631
<a name="l00632"></a>00632 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (real-><a class="code" href="structDBusRealHashIter.html#0307c2b8fa9384554ceb3cc965b04633">table</a> != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00633"></a>00633 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (real-><a class="code" href="structDBusRealHashIter.html#438db1cb3a9c6db716f8bf35fe3054c7">entry</a> != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00634"></a>00634
<a name="l00635"></a>00635 <span class="keywordflow">return</span> real-><a class="code" href="structDBusRealHashIter.html#438db1cb3a9c6db716f8bf35fe3054c7">entry</a>-><a class="code" href="structDBusHashEntry.html#d792e9c81cc3a23859b2c60b3b00af3e">value</a>;
<a name="l00636"></a>00636 }
<a name="l00637"></a>00637
<a name="l00648"></a>00648 <span class="keywordtype">void</span>
<a name="l00649"></a><a class="code" href="group__DBusHashTable.html#g24193343c0948019d4a302fc18bfd5d9">00649</a> <a class="code" href="group__DBusHashTable.html#g24193343c0948019d4a302fc18bfd5d9">_dbus_hash_iter_set_value</a> (<a class="code" href="structDBusHashIter.html">DBusHashIter</a> *iter,
<a name="l00650"></a>00650 <span class="keywordtype">void</span> *value)
<a name="l00651"></a>00651 {
<a name="l00652"></a>00652 <a class="code" href="structDBusRealHashIter.html">DBusRealHashIter</a> *real;
<a name="l00653"></a>00653
<a name="l00654"></a>00654 real = (<a class="code" href="structDBusRealHashIter.html">DBusRealHashIter</a>*) iter;
<a name="l00655"></a>00655
<a name="l00656"></a>00656 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (real-><a class="code" href="structDBusRealHashIter.html#0307c2b8fa9384554ceb3cc965b04633">table</a> != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00657"></a>00657 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (real-><a class="code" href="structDBusRealHashIter.html#438db1cb3a9c6db716f8bf35fe3054c7">entry</a> != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00658"></a>00658
<a name="l00659"></a>00659 <span class="keywordflow">if</span> (real-><a class="code" href="structDBusRealHashIter.html#0307c2b8fa9384554ceb3cc965b04633">table</a>-><a class="code" href="structDBusHashTable.html#fbb42b5326b9c79352b168eace1687ca">free_value_function</a> && value != real-><a class="code" href="structDBusRealHashIter.html#438db1cb3a9c6db716f8bf35fe3054c7">entry</a>-><a class="code" href="structDBusHashEntry.html#d792e9c81cc3a23859b2c60b3b00af3e">value</a>)
<a name="l00660"></a>00660 (* real-><a class="code" href="structDBusRealHashIter.html#0307c2b8fa9384554ceb3cc965b04633">table</a>-><a class="code" href="structDBusHashTable.html#fbb42b5326b9c79352b168eace1687ca">free_value_function</a>) (real-><a class="code" href="structDBusRealHashIter.html#438db1cb3a9c6db716f8bf35fe3054c7">entry</a>-><a class="code" href="structDBusHashEntry.html#d792e9c81cc3a23859b2c60b3b00af3e">value</a>);
<a name="l00661"></a>00661
<a name="l00662"></a>00662 real-><a class="code" href="structDBusRealHashIter.html#438db1cb3a9c6db716f8bf35fe3054c7">entry</a>-><a class="code" href="structDBusHashEntry.html#d792e9c81cc3a23859b2c60b3b00af3e">value</a> = value;
<a name="l00663"></a>00663 }
<a name="l00664"></a>00664
<a name="l00671"></a>00671 <span class="keywordtype">int</span>
<a name="l00672"></a><a class="code" href="group__DBusHashTable.html#g7a1b9fd35f9f7bdd86f9d71a6379053f">00672</a> <a class="code" href="group__DBusHashTable.html#g7a1b9fd35f9f7bdd86f9d71a6379053f">_dbus_hash_iter_get_int_key</a> (<a class="code" href="structDBusHashIter.html">DBusHashIter</a> *iter)
<a name="l00673"></a>00673 {
<a name="l00674"></a>00674 <a class="code" href="structDBusRealHashIter.html">DBusRealHashIter</a> *real;
<a name="l00675"></a>00675
<a name="l00676"></a>00676 real = (<a class="code" href="structDBusRealHashIter.html">DBusRealHashIter</a>*) iter;
<a name="l00677"></a>00677
<a name="l00678"></a>00678 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (real-><a class="code" href="structDBusRealHashIter.html#0307c2b8fa9384554ceb3cc965b04633">table</a> != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00679"></a>00679 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (real-><a class="code" href="structDBusRealHashIter.html#438db1cb3a9c6db716f8bf35fe3054c7">entry</a> != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00680"></a>00680
<a name="l00681"></a>00681 <span class="keywordflow">return</span> <a class="code" href="group__DBusInternalsUtils.html#gbbd3526a2ecd65da80b9f74ac286273d">_DBUS_POINTER_TO_INT</a> (real-><a class="code" href="structDBusRealHashIter.html#438db1cb3a9c6db716f8bf35fe3054c7">entry</a>-><a class="code" href="structDBusHashEntry.html#efd9bbdcbc7d15c906e2c289c8d2e894">key</a>);
<a name="l00682"></a>00682 }
<a name="l00683"></a>00683
<a name="l00690"></a>00690 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span>
<a name="l00691"></a><a class="code" href="group__DBusHashTable.html#g250914a3eab66ad3de0eb2dc11698931">00691</a> <a class="code" href="group__DBusHashTable.html#g250914a3eab66ad3de0eb2dc11698931">_dbus_hash_iter_get_ulong_key</a> (<a class="code" href="structDBusHashIter.html">DBusHashIter</a> *iter)
<a name="l00692"></a>00692 {
<a name="l00693"></a>00693 <a class="code" href="structDBusRealHashIter.html">DBusRealHashIter</a> *real;
<a name="l00694"></a>00694
<a name="l00695"></a>00695 real = (<a class="code" href="structDBusRealHashIter.html">DBusRealHashIter</a>*) iter;
<a name="l00696"></a>00696
<a name="l00697"></a>00697 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (real-><a class="code" href="structDBusRealHashIter.html#0307c2b8fa9384554ceb3cc965b04633">table</a> != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00698"></a>00698 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (real-><a class="code" href="structDBusRealHashIter.html#438db1cb3a9c6db716f8bf35fe3054c7">entry</a> != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00699"></a>00699
<a name="l00700"></a>00700 <span class="keywordflow">return</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span>) real-><a class="code" href="structDBusRealHashIter.html#438db1cb3a9c6db716f8bf35fe3054c7">entry</a>-><a class="code" href="structDBusHashEntry.html#efd9bbdcbc7d15c906e2c289c8d2e894">key</a>;
<a name="l00701"></a>00701 }
<a name="l00702"></a>00702
<a name="l00708"></a>00708 <span class="keyword">const</span> <span class="keywordtype">char</span>*
<a name="l00709"></a><a class="code" href="group__DBusHashTable.html#ga0cff082174b1ab0380902ce4ae43d08">00709</a> <a class="code" href="group__DBusHashTable.html#ga0cff082174b1ab0380902ce4ae43d08">_dbus_hash_iter_get_string_key</a> (<a class="code" href="structDBusHashIter.html">DBusHashIter</a> *iter)
<a name="l00710"></a>00710 {
<a name="l00711"></a>00711 <a class="code" href="structDBusRealHashIter.html">DBusRealHashIter</a> *real;
<a name="l00712"></a>00712
<a name="l00713"></a>00713 real = (<a class="code" href="structDBusRealHashIter.html">DBusRealHashIter</a>*) iter;
<a name="l00714"></a>00714
<a name="l00715"></a>00715 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (real-><a class="code" href="structDBusRealHashIter.html#0307c2b8fa9384554ceb3cc965b04633">table</a> != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00716"></a>00716 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (real-><a class="code" href="structDBusRealHashIter.html#438db1cb3a9c6db716f8bf35fe3054c7">entry</a> != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00717"></a>00717
<a name="l00718"></a>00718 <span class="keywordflow">return</span> real-><a class="code" href="structDBusRealHashIter.html#438db1cb3a9c6db716f8bf35fe3054c7">entry</a>-><a class="code" href="structDBusHashEntry.html#efd9bbdcbc7d15c906e2c289c8d2e894">key</a>;
<a name="l00719"></a>00719 }
<a name="l00720"></a>00720
<a name="l00721"></a>00721 <span class="preprocessor">#ifdef DBUS_BUILD_TESTS</span>
<a name="l00722"></a>00722 <span class="preprocessor"></span>
<a name="l00727"></a>00727 <span class="keyword">const</span> <span class="keywordtype">char</span>*
<a name="l00728"></a>00728 _dbus_hash_iter_get_two_strings_key (<a class="code" href="structDBusHashIter.html">DBusHashIter</a> *iter)
<a name="l00729"></a>00729 {
<a name="l00730"></a>00730 <a class="code" href="structDBusRealHashIter.html">DBusRealHashIter</a> *real;
<a name="l00731"></a>00731
<a name="l00732"></a>00732 real = (<a class="code" href="structDBusRealHashIter.html">DBusRealHashIter</a>*) iter;
<a name="l00733"></a>00733
<a name="l00734"></a>00734 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (real-><a class="code" href="structDBusRealHashIter.html#0307c2b8fa9384554ceb3cc965b04633">table</a> != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00735"></a>00735 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (real-><a class="code" href="structDBusRealHashIter.html#438db1cb3a9c6db716f8bf35fe3054c7">entry</a> != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00736"></a>00736
<a name="l00737"></a>00737 <span class="keywordflow">return</span> real-><a class="code" href="structDBusRealHashIter.html#438db1cb3a9c6db716f8bf35fe3054c7">entry</a>-><a class="code" href="structDBusHashEntry.html#efd9bbdcbc7d15c906e2c289c8d2e894">key</a>;
<a name="l00738"></a>00738 }
<a name="l00739"></a>00739 <span class="preprocessor">#endif </span><span class="comment">/* DBUS_BUILD_TESTS */</span>
<a name="l00740"></a>00740
<a name="l00772"></a>00772 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a>
<a name="l00773"></a><a class="code" href="group__DBusHashTable.html#gb156c35d6dd9ff6e408a835db28323fb">00773</a> <a class="code" href="group__DBusHashTable.html#gb156c35d6dd9ff6e408a835db28323fb">_dbus_hash_iter_lookup</a> (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table,
<a name="l00774"></a>00774 <span class="keywordtype">void</span> *key,
<a name="l00775"></a>00775 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a> create_if_not_found,
<a name="l00776"></a>00776 <a class="code" href="structDBusHashIter.html">DBusHashIter</a> *iter)
<a name="l00777"></a>00777 {
<a name="l00778"></a>00778 <a class="code" href="structDBusRealHashIter.html">DBusRealHashIter</a> *real;
<a name="l00779"></a>00779 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *entry;
<a name="l00780"></a>00780 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> **bucket;
<a name="l00781"></a>00781
<a name="l00782"></a>00782 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (<span class="keyword">sizeof</span> (<a class="code" href="structDBusHashIter.html">DBusHashIter</a>) == <span class="keyword">sizeof</span> (<a class="code" href="structDBusRealHashIter.html">DBusRealHashIter</a>));
<a name="l00783"></a>00783
<a name="l00784"></a>00784 real = (DBusRealHashIter*) iter;
<a name="l00785"></a>00785
<a name="l00786"></a>00786 entry = (* table-><a class="code" href="structDBusHashTable.html#b98bafddf1b1ce1dad01c5595e278e35">find_function</a>) (table, key, create_if_not_found, &bucket, <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00787"></a>00787
<a name="l00788"></a>00788 <span class="keywordflow">if</span> (entry == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l00789"></a>00789 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>;
<a name="l00790"></a>00790
<a name="l00791"></a>00791 real-><a class="code" href="structDBusRealHashIter.html#0307c2b8fa9384554ceb3cc965b04633">table</a> = table;
<a name="l00792"></a>00792 real-><a class="code" href="structDBusRealHashIter.html#d36967dc68709d676ad591d7f75dd7fa">bucket</a> = bucket;
<a name="l00793"></a>00793 real-><a class="code" href="structDBusRealHashIter.html#438db1cb3a9c6db716f8bf35fe3054c7">entry</a> = entry;
<a name="l00794"></a>00794 real-><a class="code" href="structDBusRealHashIter.html#056417c3726f4f98eb94a9d2784a59e0">next_entry</a> = entry-><a class="code" href="structDBusHashEntry.html#e986e25c0b24237f9848ff43aa1d8501">next</a>;
<a name="l00795"></a>00795 real-><a class="code" href="structDBusRealHashIter.html#dbf758933299ee6305c525ea0fe74824">next_bucket</a> = (bucket - table-><a class="code" href="structDBusHashTable.html#1f974e2cb3038685b3edf493406ad99d">buckets</a>) + 1;
<a name="l00796"></a>00796 real-><a class="code" href="structDBusRealHashIter.html#84f2a189ee1eb3e51a8089b798a7797a">n_entries_on_init</a> = table-><a class="code" href="structDBusHashTable.html#ffbf11a9c3dd72d55b7976891f7b4650">n_entries</a>;
<a name="l00797"></a>00797
<a name="l00798"></a>00798 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (&(table-><a class="code" href="structDBusHashTable.html#1f974e2cb3038685b3edf493406ad99d">buckets</a>[real-><a class="code" href="structDBusRealHashIter.html#dbf758933299ee6305c525ea0fe74824">next_bucket</a>-1]) == real-><a class="code" href="structDBusRealHashIter.html#d36967dc68709d676ad591d7f75dd7fa">bucket</a>);
<a name="l00799"></a>00799
<a name="l00800"></a>00800 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>;
<a name="l00801"></a>00801 }
<a name="l00802"></a>00802
<a name="l00803"></a>00803 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00804"></a>00804 add_allocated_entry (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table,
<a name="l00805"></a>00805 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *entry,
<a name="l00806"></a>00806 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> idx,
<a name="l00807"></a>00807 <span class="keywordtype">void</span> *key,
<a name="l00808"></a>00808 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> ***bucket)
<a name="l00809"></a>00809 {
<a name="l00810"></a>00810 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> **b;
<a name="l00811"></a>00811
<a name="l00812"></a>00812 entry-><a class="code" href="structDBusHashEntry.html#efd9bbdcbc7d15c906e2c289c8d2e894">key</a> = key;
<a name="l00813"></a>00813
<a name="l00814"></a>00814 b = &(table-><a class="code" href="structDBusHashTable.html#1f974e2cb3038685b3edf493406ad99d">buckets</a>[idx]);
<a name="l00815"></a>00815 entry-><a class="code" href="structDBusHashEntry.html#e986e25c0b24237f9848ff43aa1d8501">next</a> = *b;
<a name="l00816"></a>00816 *b = entry;
<a name="l00817"></a>00817
<a name="l00818"></a>00818 <span class="keywordflow">if</span> (bucket)
<a name="l00819"></a>00819 *bucket = b;
<a name="l00820"></a>00820
<a name="l00821"></a>00821 table-><a class="code" href="structDBusHashTable.html#ffbf11a9c3dd72d55b7976891f7b4650">n_entries</a> += 1;
<a name="l00822"></a>00822
<a name="l00823"></a>00823 <span class="comment">/* note we ONLY rebuild when ADDING - because you can iterate over a</span>
<a name="l00824"></a>00824 <span class="comment"> * table and remove entries safely.</span>
<a name="l00825"></a>00825 <span class="comment"> */</span>
<a name="l00826"></a>00826 <span class="keywordflow">if</span> (table-><a class="code" href="structDBusHashTable.html#ffbf11a9c3dd72d55b7976891f7b4650">n_entries</a> >= table-><a class="code" href="structDBusHashTable.html#29c408110c0d189d89b60c6c01cfb0cf">hi_rebuild_size</a> ||
<a name="l00827"></a>00827 table-><a class="code" href="structDBusHashTable.html#ffbf11a9c3dd72d55b7976891f7b4650">n_entries</a> < table-><a class="code" href="structDBusHashTable.html#ae6ea7cb15d618866854b2b6bd468419">lo_rebuild_size</a>)
<a name="l00828"></a>00828 rebuild_table (table);
<a name="l00829"></a>00829 }
<a name="l00830"></a>00830
<a name="l00831"></a>00831 <span class="keyword">static</span> <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a>*
<a name="l00832"></a>00832 add_entry (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table,
<a name="l00833"></a>00833 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> idx,
<a name="l00834"></a>00834 <span class="keywordtype">void</span> *key,
<a name="l00835"></a>00835 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> ***bucket,
<a name="l00836"></a>00836 <a class="code" href="group__DBusHashTable.html#g175dc6ab841ed32bb6acf6e4c0df36a8">DBusPreallocatedHash</a> *preallocated)
<a name="l00837"></a>00837 {
<a name="l00838"></a>00838 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *entry;
<a name="l00839"></a>00839
<a name="l00840"></a>00840 <span class="keywordflow">if</span> (preallocated == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l00841"></a>00841 {
<a name="l00842"></a>00842 entry = alloc_entry (table);
<a name="l00843"></a>00843 <span class="keywordflow">if</span> (entry == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l00844"></a>00844 {
<a name="l00845"></a>00845 <span class="keywordflow">if</span> (bucket)
<a name="l00846"></a>00846 *bucket = <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l00847"></a>00847 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l00848"></a>00848 }
<a name="l00849"></a>00849 }
<a name="l00850"></a>00850 <span class="keywordflow">else</span>
<a name="l00851"></a>00851 {
<a name="l00852"></a>00852 entry = (<a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a>*) preallocated;
<a name="l00853"></a>00853 }
<a name="l00854"></a>00854
<a name="l00855"></a>00855 add_allocated_entry (table, entry, idx, key, bucket);
<a name="l00856"></a>00856
<a name="l00857"></a>00857 <span class="keywordflow">return</span> entry;
<a name="l00858"></a>00858 }
<a name="l00859"></a>00859
<a name="l00860"></a>00860 <span class="comment">/* This is g_str_hash from GLib which was</span>
<a name="l00861"></a>00861 <span class="comment"> * extensively discussed/tested/profiled</span>
<a name="l00862"></a>00862 <span class="comment"> */</span>
<a name="l00863"></a>00863 <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>
<a name="l00864"></a>00864 string_hash (<span class="keyword">const</span> <span class="keywordtype">char</span> *str)
<a name="l00865"></a>00865 {
<a name="l00866"></a>00866 <span class="keyword">const</span> <span class="keywordtype">char</span> *p = str;
<a name="l00867"></a>00867 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> h = *p;
<a name="l00868"></a>00868
<a name="l00869"></a>00869 <span class="keywordflow">if</span> (h)
<a name="l00870"></a>00870 <span class="keywordflow">for</span> (p += 1; *p != <span class="charliteral">'\0'</span>; p++)
<a name="l00871"></a>00871 h = (h << 5) - h + *p;
<a name="l00872"></a>00872
<a name="l00873"></a>00873 <span class="keywordflow">return</span> h;
<a name="l00874"></a>00874 }
<a name="l00875"></a>00875
<a name="l00876"></a>00876 <span class="preprocessor">#ifdef DBUS_BUILD_TESTS</span>
<a name="l00877"></a>00877 <span class="preprocessor"></span><span class="comment">/* This hashes a memory block with two nul-terminated strings</span>
<a name="l00878"></a>00878 <span class="comment"> * in it, used in dbus-object-registry.c at the moment.</span>
<a name="l00879"></a>00879 <span class="comment"> */</span>
<a name="l00880"></a>00880 <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>
<a name="l00881"></a>00881 two_strings_hash (<span class="keyword">const</span> <span class="keywordtype">char</span> *str)
<a name="l00882"></a>00882 {
<a name="l00883"></a>00883 <span class="keyword">const</span> <span class="keywordtype">char</span> *p = str;
<a name="l00884"></a>00884 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> h = *p;
<a name="l00885"></a>00885
<a name="l00886"></a>00886 <span class="keywordflow">if</span> (h)
<a name="l00887"></a>00887 <span class="keywordflow">for</span> (p += 1; *p != <span class="charliteral">'\0'</span>; p++)
<a name="l00888"></a>00888 h = (h << 5) - h + *p;
<a name="l00889"></a>00889
<a name="l00890"></a>00890 <span class="keywordflow">for</span> (p += 1; *p != <span class="charliteral">'\0'</span>; p++)
<a name="l00891"></a>00891 h = (h << 5) - h + *p;
<a name="l00892"></a>00892
<a name="l00893"></a>00893 <span class="keywordflow">return</span> h;
<a name="l00894"></a>00894 }
<a name="l00895"></a>00895 <span class="preprocessor">#endif </span><span class="comment">/* DBUS_BUILD_TESTS */</span>
<a name="l00896"></a>00896
<a name="l00898"></a><a class="code" href="group__DBusHashTable.html#g956840f583977db6e1a1481c60cd3d78">00898</a> <span class="keyword">typedef</span> int (* <a class="code" href="group__DBusHashTable.html#g956840f583977db6e1a1481c60cd3d78">KeyCompareFunc</a>) (<span class="keyword">const</span> <span class="keywordtype">void</span> *key_a, <span class="keyword">const</span> <span class="keywordtype">void</span> *key_b);
<a name="l00899"></a>00899
<a name="l00900"></a>00900 <span class="keyword">static</span> <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a>*
<a name="l00901"></a>00901 find_generic_function (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table,
<a name="l00902"></a>00902 <span class="keywordtype">void</span> *key,
<a name="l00903"></a>00903 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> idx,
<a name="l00904"></a>00904 <a class="code" href="group__DBusHashTable.html#g956840f583977db6e1a1481c60cd3d78">KeyCompareFunc</a> compare_func,
<a name="l00905"></a>00905 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a> create_if_not_found,
<a name="l00906"></a>00906 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> ***bucket,
<a name="l00907"></a>00907 <a class="code" href="group__DBusHashTable.html#g175dc6ab841ed32bb6acf6e4c0df36a8">DBusPreallocatedHash</a> *preallocated)
<a name="l00908"></a>00908 {
<a name="l00909"></a>00909 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *entry;
<a name="l00910"></a>00910
<a name="l00911"></a>00911 <span class="keywordflow">if</span> (bucket)
<a name="l00912"></a>00912 *bucket = <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l00913"></a>00913
<a name="l00914"></a>00914 <span class="comment">/* Search all of the entries in this bucket. */</span>
<a name="l00915"></a>00915 entry = table-><a class="code" href="structDBusHashTable.html#1f974e2cb3038685b3edf493406ad99d">buckets</a>[idx];
<a name="l00916"></a>00916 <span class="keywordflow">while</span> (entry != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l00917"></a>00917 {
<a name="l00918"></a>00918 <span class="keywordflow">if</span> ((compare_func == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a> && key == entry-><a class="code" href="structDBusHashEntry.html#efd9bbdcbc7d15c906e2c289c8d2e894">key</a>) ||
<a name="l00919"></a>00919 (compare_func != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a> && (* compare_func) (key, entry-><a class="code" href="structDBusHashEntry.html#efd9bbdcbc7d15c906e2c289c8d2e894">key</a>) == 0))
<a name="l00920"></a>00920 {
<a name="l00921"></a>00921 <span class="keywordflow">if</span> (bucket)
<a name="l00922"></a>00922 *bucket = &(table-><a class="code" href="structDBusHashTable.html#1f974e2cb3038685b3edf493406ad99d">buckets</a>[idx]);
<a name="l00923"></a>00923
<a name="l00924"></a>00924 <span class="keywordflow">if</span> (preallocated)
<a name="l00925"></a>00925 <a class="code" href="group__DBusHashTable.html#g159dfec03d53e6e2ff485fc83aed2552">_dbus_hash_table_free_preallocated_entry</a> (table, preallocated);
<a name="l00926"></a>00926
<a name="l00927"></a>00927 <span class="keywordflow">return</span> entry;
<a name="l00928"></a>00928 }
<a name="l00929"></a>00929
<a name="l00930"></a>00930 entry = entry-><a class="code" href="structDBusHashEntry.html#e986e25c0b24237f9848ff43aa1d8501">next</a>;
<a name="l00931"></a>00931 }
<a name="l00932"></a>00932
<a name="l00933"></a>00933 <span class="keywordflow">if</span> (create_if_not_found)
<a name="l00934"></a>00934 entry = add_entry (table, idx, key, bucket, preallocated);
<a name="l00935"></a>00935 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (preallocated)
<a name="l00936"></a>00936 <a class="code" href="group__DBusHashTable.html#g159dfec03d53e6e2ff485fc83aed2552">_dbus_hash_table_free_preallocated_entry</a> (table, preallocated);
<a name="l00937"></a>00937
<a name="l00938"></a>00938 <span class="keywordflow">return</span> entry;
<a name="l00939"></a>00939 }
<a name="l00940"></a>00940
<a name="l00941"></a>00941 <span class="keyword">static</span> <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a>*
<a name="l00942"></a>00942 find_string_function (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table,
<a name="l00943"></a>00943 <span class="keywordtype">void</span> *key,
<a name="l00944"></a>00944 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a> create_if_not_found,
<a name="l00945"></a>00945 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> ***bucket,
<a name="l00946"></a>00946 <a class="code" href="group__DBusHashTable.html#g175dc6ab841ed32bb6acf6e4c0df36a8">DBusPreallocatedHash</a> *preallocated)
<a name="l00947"></a>00947 {
<a name="l00948"></a>00948 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> idx;
<a name="l00949"></a>00949
<a name="l00950"></a>00950 idx = string_hash (key) & table-><a class="code" href="structDBusHashTable.html#ec1230eebce3d256ca9ceebe372647e9">mask</a>;
<a name="l00951"></a>00951
<a name="l00952"></a>00952 <span class="keywordflow">return</span> find_generic_function (table, key, idx,
<a name="l00953"></a>00953 (<a class="code" href="group__DBusHashTable.html#g956840f583977db6e1a1481c60cd3d78">KeyCompareFunc</a>) strcmp, create_if_not_found, bucket,
<a name="l00954"></a>00954 preallocated);
<a name="l00955"></a>00955 }
<a name="l00956"></a>00956
<a name="l00957"></a>00957 <span class="preprocessor">#ifdef DBUS_BUILD_TESTS</span>
<a name="l00958"></a>00958 <span class="preprocessor"></span><span class="keyword">static</span> <span class="keywordtype">int</span>
<a name="l00959"></a>00959 two_strings_cmp (<span class="keyword">const</span> <span class="keywordtype">char</span> *a,
<a name="l00960"></a>00960 <span class="keyword">const</span> <span class="keywordtype">char</span> *b)
<a name="l00961"></a>00961 {
<a name="l00962"></a>00962 size_t len_a;
<a name="l00963"></a>00963 size_t len_b;
<a name="l00964"></a>00964 <span class="keywordtype">int</span> res;
<a name="l00965"></a>00965
<a name="l00966"></a>00966 res = strcmp (a, b);
<a name="l00967"></a>00967 <span class="keywordflow">if</span> (res != 0)
<a name="l00968"></a>00968 <span class="keywordflow">return</span> res;
<a name="l00969"></a>00969
<a name="l00970"></a>00970 len_a = strlen (a);
<a name="l00971"></a>00971 len_b = strlen (b);
<a name="l00972"></a>00972
<a name="l00973"></a>00973 <span class="keywordflow">return</span> strcmp (a + len_a + 1, b + len_b + 1);
<a name="l00974"></a>00974 }
<a name="l00975"></a>00975 <span class="preprocessor">#endif</span>
<a name="l00976"></a>00976 <span class="preprocessor"></span>
<a name="l00977"></a>00977 <span class="preprocessor">#ifdef DBUS_BUILD_TESTS</span>
<a name="l00978"></a>00978 <span class="preprocessor"></span><span class="keyword">static</span> <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a>*
<a name="l00979"></a>00979 find_two_strings_function (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table,
<a name="l00980"></a>00980 <span class="keywordtype">void</span> *key,
<a name="l00981"></a>00981 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a> create_if_not_found,
<a name="l00982"></a>00982 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> ***bucket,
<a name="l00983"></a>00983 <a class="code" href="group__DBusHashTable.html#g175dc6ab841ed32bb6acf6e4c0df36a8">DBusPreallocatedHash</a> *preallocated)
<a name="l00984"></a>00984 {
<a name="l00985"></a>00985 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> idx;
<a name="l00986"></a>00986
<a name="l00987"></a>00987 idx = two_strings_hash (key) & table-><a class="code" href="structDBusHashTable.html#ec1230eebce3d256ca9ceebe372647e9">mask</a>;
<a name="l00988"></a>00988
<a name="l00989"></a>00989 <span class="keywordflow">return</span> find_generic_function (table, key, idx,
<a name="l00990"></a>00990 (<a class="code" href="group__DBusHashTable.html#g956840f583977db6e1a1481c60cd3d78">KeyCompareFunc</a>) two_strings_cmp, create_if_not_found, bucket,
<a name="l00991"></a>00991 preallocated);
<a name="l00992"></a>00992 }
<a name="l00993"></a>00993 <span class="preprocessor">#endif </span><span class="comment">/* DBUS_BUILD_TESTS */</span>
<a name="l00994"></a>00994
<a name="l00995"></a>00995 <span class="keyword">static</span> <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a>*
<a name="l00996"></a>00996 find_direct_function (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table,
<a name="l00997"></a>00997 <span class="keywordtype">void</span> *key,
<a name="l00998"></a>00998 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a> create_if_not_found,
<a name="l00999"></a>00999 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> ***bucket,
<a name="l01000"></a>01000 <a class="code" href="group__DBusHashTable.html#g175dc6ab841ed32bb6acf6e4c0df36a8">DBusPreallocatedHash</a> *preallocated)
<a name="l01001"></a>01001 {
<a name="l01002"></a>01002 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> idx;
<a name="l01003"></a>01003
<a name="l01004"></a>01004 idx = <a class="code" href="group__DBusHashTableInternals.html#g9dc8fd5a9e25bd2b229366a683ff78f9">RANDOM_INDEX</a> (table, key) & table-><a class="code" href="structDBusHashTable.html#ec1230eebce3d256ca9ceebe372647e9">mask</a>;
<a name="l01005"></a>01005
<a name="l01006"></a>01006
<a name="l01007"></a>01007 <span class="keywordflow">return</span> find_generic_function (table, key, idx,
<a name="l01008"></a>01008 <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>, create_if_not_found, bucket,
<a name="l01009"></a>01009 preallocated);
<a name="l01010"></a>01010 }
<a name="l01011"></a>01011
<a name="l01012"></a>01012 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l01013"></a>01013 rebuild_table (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table)
<a name="l01014"></a>01014 {
<a name="l01015"></a>01015 <span class="keywordtype">int</span> old_size;
<a name="l01016"></a>01016 <span class="keywordtype">int</span> new_buckets;
<a name="l01017"></a>01017 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> **old_buckets;
<a name="l01018"></a>01018 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> **old_chain;
<a name="l01019"></a>01019 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *entry;
<a name="l01020"></a>01020 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a> growing;
<a name="l01021"></a>01021
<a name="l01022"></a>01022 <span class="comment">/*</span>
<a name="l01023"></a>01023 <span class="comment"> * Allocate and initialize the new bucket array, and set up</span>
<a name="l01024"></a>01024 <span class="comment"> * hashing constants for new array size.</span>
<a name="l01025"></a>01025 <span class="comment"> */</span>
<a name="l01026"></a>01026
<a name="l01027"></a>01027 growing = table-><a class="code" href="structDBusHashTable.html#ffbf11a9c3dd72d55b7976891f7b4650">n_entries</a> >= table-><a class="code" href="structDBusHashTable.html#29c408110c0d189d89b60c6c01cfb0cf">hi_rebuild_size</a>;
<a name="l01028"></a>01028
<a name="l01029"></a>01029 old_size = table-><a class="code" href="structDBusHashTable.html#2dd2b9389d65d30e31e596dd786a9aa7">n_buckets</a>;
<a name="l01030"></a>01030 old_buckets = table-><a class="code" href="structDBusHashTable.html#1f974e2cb3038685b3edf493406ad99d">buckets</a>;
<a name="l01031"></a>01031
<a name="l01032"></a>01032 <span class="keywordflow">if</span> (growing)
<a name="l01033"></a>01033 {
<a name="l01034"></a>01034 <span class="comment">/* overflow paranoia */</span>
<a name="l01035"></a>01035 <span class="keywordflow">if</span> (table-><a class="code" href="structDBusHashTable.html#2dd2b9389d65d30e31e596dd786a9aa7">n_buckets</a> < <a class="code" href="group__DBusInternalsUtils.html#g5627db5e165848477e620846f6414db1">_DBUS_INT_MAX</a> / 4 &&
<a name="l01036"></a>01036 table-><a class="code" href="structDBusHashTable.html#2e7e7b92bb9633ab95cfaa592b89025c">down_shift</a> >= 0)
<a name="l01037"></a>01037 new_buckets = table-><a class="code" href="structDBusHashTable.html#2dd2b9389d65d30e31e596dd786a9aa7">n_buckets</a> * 4;
<a name="l01038"></a>01038 <span class="keywordflow">else</span>
<a name="l01039"></a>01039 <span class="keywordflow">return</span>; <span class="comment">/* can't grow anymore */</span>
<a name="l01040"></a>01040 }
<a name="l01041"></a>01041 <span class="keywordflow">else</span>
<a name="l01042"></a>01042 {
<a name="l01043"></a>01043 new_buckets = table-><a class="code" href="structDBusHashTable.html#2dd2b9389d65d30e31e596dd786a9aa7">n_buckets</a> / 4;
<a name="l01044"></a>01044 <span class="keywordflow">if</span> (new_buckets < <a class="code" href="group__DBusHashTableInternals.html#g4518324f3c3caacf5694065f4f6071d8">DBUS_SMALL_HASH_TABLE</a>)
<a name="l01045"></a>01045 <span class="keywordflow">return</span>; <span class="comment">/* don't bother shrinking this far */</span>
<a name="l01046"></a>01046 }
<a name="l01047"></a>01047
<a name="l01048"></a>01048 table-><a class="code" href="structDBusHashTable.html#1f974e2cb3038685b3edf493406ad99d">buckets</a> = <a class="code" href="group__DBusMemory.html#gba9d823abda7f4cadbaf5177d3b8b793">dbus_new0</a> (<a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a>*, new_buckets);
<a name="l01049"></a>01049 <span class="keywordflow">if</span> (table-><a class="code" href="structDBusHashTable.html#1f974e2cb3038685b3edf493406ad99d">buckets</a> == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l01050"></a>01050 {
<a name="l01051"></a>01051 <span class="comment">/* out of memory, yay - just don't reallocate, the table will</span>
<a name="l01052"></a>01052 <span class="comment"> * still work, albeit more slowly.</span>
<a name="l01053"></a>01053 <span class="comment"> */</span>
<a name="l01054"></a>01054 table-><a class="code" href="structDBusHashTable.html#1f974e2cb3038685b3edf493406ad99d">buckets</a> = old_buckets;
<a name="l01055"></a>01055 <span class="keywordflow">return</span>;
<a name="l01056"></a>01056 }
<a name="l01057"></a>01057
<a name="l01058"></a>01058 table-><a class="code" href="structDBusHashTable.html#2dd2b9389d65d30e31e596dd786a9aa7">n_buckets</a> = new_buckets;
<a name="l01059"></a>01059
<a name="l01060"></a>01060 <span class="keywordflow">if</span> (growing)
<a name="l01061"></a>01061 {
<a name="l01062"></a>01062 table-><a class="code" href="structDBusHashTable.html#ae6ea7cb15d618866854b2b6bd468419">lo_rebuild_size</a> = table-><a class="code" href="structDBusHashTable.html#29c408110c0d189d89b60c6c01cfb0cf">hi_rebuild_size</a>;
<a name="l01063"></a>01063 table-><a class="code" href="structDBusHashTable.html#29c408110c0d189d89b60c6c01cfb0cf">hi_rebuild_size</a> *= 4;
<a name="l01064"></a>01064
<a name="l01065"></a>01065 table-><a class="code" href="structDBusHashTable.html#2e7e7b92bb9633ab95cfaa592b89025c">down_shift</a> -= 2; <span class="comment">/* keep 2 more high bits */</span>
<a name="l01066"></a>01066 table-><a class="code" href="structDBusHashTable.html#ec1230eebce3d256ca9ceebe372647e9">mask</a> = (table-><a class="code" href="structDBusHashTable.html#ec1230eebce3d256ca9ceebe372647e9">mask</a> << 2) + 3; <span class="comment">/* keep 2 more high bits */</span>
<a name="l01067"></a>01067 }
<a name="l01068"></a>01068 <span class="keywordflow">else</span>
<a name="l01069"></a>01069 {
<a name="l01070"></a>01070 table-><a class="code" href="structDBusHashTable.html#29c408110c0d189d89b60c6c01cfb0cf">hi_rebuild_size</a> = table-><a class="code" href="structDBusHashTable.html#ae6ea7cb15d618866854b2b6bd468419">lo_rebuild_size</a>;
<a name="l01071"></a>01071 table-><a class="code" href="structDBusHashTable.html#ae6ea7cb15d618866854b2b6bd468419">lo_rebuild_size</a> /= 4;
<a name="l01072"></a>01072
<a name="l01073"></a>01073 table-><a class="code" href="structDBusHashTable.html#2e7e7b92bb9633ab95cfaa592b89025c">down_shift</a> += 2; <span class="comment">/* keep 2 fewer high bits */</span>
<a name="l01074"></a>01074 table-><a class="code" href="structDBusHashTable.html#ec1230eebce3d256ca9ceebe372647e9">mask</a> = table-><a class="code" href="structDBusHashTable.html#ec1230eebce3d256ca9ceebe372647e9">mask</a> >> 2; <span class="comment">/* keep 2 fewer high bits */</span>
<a name="l01075"></a>01075 }
<a name="l01076"></a>01076
<a name="l01077"></a>01077 <span class="preprocessor">#if 0</span>
<a name="l01078"></a>01078 <span class="preprocessor"></span> printf (<span class="stringliteral">"%s table to lo = %d hi = %d downshift = %d mask = 0x%x\n"</span>,
<a name="l01079"></a>01079 growing ? <span class="stringliteral">"GROW"</span> : <span class="stringliteral">"SHRINK"</span>,
<a name="l01080"></a>01080 table-><a class="code" href="structDBusHashTable.html#ae6ea7cb15d618866854b2b6bd468419">lo_rebuild_size</a>,
<a name="l01081"></a>01081 table-><a class="code" href="structDBusHashTable.html#29c408110c0d189d89b60c6c01cfb0cf">hi_rebuild_size</a>,
<a name="l01082"></a>01082 table-><a class="code" href="structDBusHashTable.html#2e7e7b92bb9633ab95cfaa592b89025c">down_shift</a>,
<a name="l01083"></a>01083 table-><a class="code" href="structDBusHashTable.html#ec1230eebce3d256ca9ceebe372647e9">mask</a>);
<a name="l01084"></a>01084 <span class="preprocessor">#endif</span>
<a name="l01085"></a>01085 <span class="preprocessor"></span>
<a name="l01086"></a>01086 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (table-><a class="code" href="structDBusHashTable.html#ae6ea7cb15d618866854b2b6bd468419">lo_rebuild_size</a> >= 0);
<a name="l01087"></a>01087 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (table-><a class="code" href="structDBusHashTable.html#29c408110c0d189d89b60c6c01cfb0cf">hi_rebuild_size</a> > table-><a class="code" href="structDBusHashTable.html#ae6ea7cb15d618866854b2b6bd468419">lo_rebuild_size</a>);
<a name="l01088"></a>01088 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (table-><a class="code" href="structDBusHashTable.html#ec1230eebce3d256ca9ceebe372647e9">mask</a> != 0);
<a name="l01089"></a>01089 <span class="comment">/* the mask is essentially the max index */</span>
<a name="l01090"></a>01090 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (table-><a class="code" href="structDBusHashTable.html#ec1230eebce3d256ca9ceebe372647e9">mask</a> < table-><a class="code" href="structDBusHashTable.html#2dd2b9389d65d30e31e596dd786a9aa7">n_buckets</a>);
<a name="l01091"></a>01091
<a name="l01092"></a>01092 <span class="comment">/*</span>
<a name="l01093"></a>01093 <span class="comment"> * Rehash all of the existing entries into the new bucket array.</span>
<a name="l01094"></a>01094 <span class="comment"> */</span>
<a name="l01095"></a>01095
<a name="l01096"></a>01096 <span class="keywordflow">for</span> (old_chain = old_buckets; old_size > 0; old_size--, old_chain++)
<a name="l01097"></a>01097 {
<a name="l01098"></a>01098 <span class="keywordflow">for</span> (entry = *old_chain; entry != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>; entry = *old_chain)
<a name="l01099"></a>01099 {
<a name="l01100"></a>01100 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> idx;
<a name="l01101"></a>01101 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> **bucket;
<a name="l01102"></a>01102
<a name="l01103"></a>01103 *old_chain = entry-><a class="code" href="structDBusHashEntry.html#e986e25c0b24237f9848ff43aa1d8501">next</a>;
<a name="l01104"></a>01104 <span class="keywordflow">switch</span> (table-><a class="code" href="structDBusHashTable.html#28f326a2947b6be0b0b852db376a1092">key_type</a>)
<a name="l01105"></a>01105 {
<a name="l01106"></a>01106 <span class="keywordflow">case</span> <a class="code" href="group__DBusHashTable.html#ggb0ab9767ffa5b6720a13b3d741630852481fd0166d28da725b3e97f15192434e">DBUS_HASH_STRING</a>:
<a name="l01107"></a>01107 idx = string_hash (entry-><a class="code" href="structDBusHashEntry.html#efd9bbdcbc7d15c906e2c289c8d2e894">key</a>) & table-><a class="code" href="structDBusHashTable.html#ec1230eebce3d256ca9ceebe372647e9">mask</a>;
<a name="l01108"></a>01108 <span class="keywordflow">break</span>;
<a name="l01109"></a>01109 <span class="keywordflow">case</span> <a class="code" href="group__DBusHashTable.html#ggb0ab9767ffa5b6720a13b3d741630852c750b865c7994a3dd6d1028b7ae76877">DBUS_HASH_TWO_STRINGS</a>:
<a name="l01110"></a>01110 #ifdef DBUS_BUILD_TESTS
<a name="l01111"></a>01111 idx = two_strings_hash (entry-><a class="code" href="structDBusHashEntry.html#efd9bbdcbc7d15c906e2c289c8d2e894">key</a>) & table-><a class="code" href="structDBusHashTable.html#ec1230eebce3d256ca9ceebe372647e9">mask</a>;
<a name="l01112"></a>01112 #<span class="keywordflow">else</span>
<a name="l01113"></a>01113 idx = 0;
<a name="l01114"></a>01114 <a class="code" href="group__DBusInternalsUtils.html#g0c4961ec784874f1b1f3aeccea8d3da1">_dbus_assert_not_reached</a> (<span class="stringliteral">"two-strings is not enabled"</span>);
<a name="l01115"></a>01115 <span class="preprocessor">#endif</span>
<a name="l01116"></a>01116 <span class="preprocessor"></span> <span class="keywordflow">break</span>;
<a name="l01117"></a>01117 <span class="keywordflow">case</span> <a class="code" href="group__DBusHashTable.html#ggb0ab9767ffa5b6720a13b3d74163085226446bd9fbb15c6c381b35a810207141">DBUS_HASH_INT</a>:
<a name="l01118"></a>01118 <span class="keywordflow">case</span> <a class="code" href="group__DBusHashTable.html#ggb0ab9767ffa5b6720a13b3d741630852f9b5230298187cd6953dbcac824b2e4c">DBUS_HASH_ULONG</a>:
<a name="l01119"></a>01119 <span class="keywordflow">case</span> <a class="code" href="group__DBusHashTable.html#ggb0ab9767ffa5b6720a13b3d74163085238604db762cd0ed315106a95a6b50c4d">DBUS_HASH_POINTER</a>:
<a name="l01120"></a>01120 idx = <a class="code" href="group__DBusHashTableInternals.html#g9dc8fd5a9e25bd2b229366a683ff78f9">RANDOM_INDEX</a> (table, entry-><a class="code" href="structDBusHashEntry.html#efd9bbdcbc7d15c906e2c289c8d2e894">key</a>);
<a name="l01121"></a>01121 <span class="keywordflow">break</span>;
<a name="l01122"></a>01122 <span class="keywordflow">default</span>:
<a name="l01123"></a>01123 idx = 0;
<a name="l01124"></a>01124 <a class="code" href="group__DBusInternalsUtils.html#g0c4961ec784874f1b1f3aeccea8d3da1">_dbus_assert_not_reached</a> (<span class="stringliteral">"Unknown hash table type"</span>);
<a name="l01125"></a>01125 <span class="keywordflow">break</span>;
<a name="l01126"></a>01126 }
<a name="l01127"></a>01127
<a name="l01128"></a>01128 bucket = &(table-><a class="code" href="structDBusHashTable.html#1f974e2cb3038685b3edf493406ad99d">buckets</a>[idx]);
<a name="l01129"></a>01129 entry-><a class="code" href="structDBusHashEntry.html#e986e25c0b24237f9848ff43aa1d8501">next</a> = *bucket;
<a name="l01130"></a>01130 *bucket = entry;
<a name="l01131"></a>01131 }
<a name="l01132"></a>01132 }
<a name="l01133"></a>01133
<a name="l01134"></a>01134 <span class="comment">/* Free the old bucket array, if it was dynamically allocated. */</span>
<a name="l01135"></a>01135
<a name="l01136"></a>01136 <span class="keywordflow">if</span> (old_buckets != table-><a class="code" href="structDBusHashTable.html#f71877d64657c34a783caf6b82b016e9">static_buckets</a>)
<a name="l01137"></a>01137 <a class="code" href="group__DBusMemory.html#g488c6b08cc8c1ddf0203243c4b27a13c">dbus_free</a> (old_buckets);
<a name="l01138"></a>01138 }
<a name="l01139"></a>01139
<a name="l01149"></a>01149 <span class="keywordtype">void</span>*
<a name="l01150"></a><a class="code" href="group__DBusHashTable.html#gd51eb3fe682721dd4f6a920ca87cb730">01150</a> <a class="code" href="group__DBusHashTable.html#gd51eb3fe682721dd4f6a920ca87cb730">_dbus_hash_table_lookup_string</a> (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table,
<a name="l01151"></a>01151 <span class="keyword">const</span> <span class="keywordtype">char</span> *key)
<a name="l01152"></a>01152 {
<a name="l01153"></a>01153 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *entry;
<a name="l01154"></a>01154
<a name="l01155"></a>01155 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (table-><a class="code" href="structDBusHashTable.html#28f326a2947b6be0b0b852db376a1092">key_type</a> == <a class="code" href="group__DBusHashTable.html#ggb0ab9767ffa5b6720a13b3d741630852481fd0166d28da725b3e97f15192434e">DBUS_HASH_STRING</a>);
<a name="l01156"></a>01156
<a name="l01157"></a>01157 entry = (* table-><a class="code" href="structDBusHashTable.html#b98bafddf1b1ce1dad01c5595e278e35">find_function</a>) (table, (<span class="keywordtype">char</span>*) key, <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>, <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>, <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l01158"></a>01158
<a name="l01159"></a>01159 <span class="keywordflow">if</span> (entry)
<a name="l01160"></a>01160 <span class="keywordflow">return</span> entry-><a class="code" href="structDBusHashEntry.html#d792e9c81cc3a23859b2c60b3b00af3e">value</a>;
<a name="l01161"></a>01161 <span class="keywordflow">else</span>
<a name="l01162"></a>01162 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l01163"></a>01163 }
<a name="l01164"></a>01164
<a name="l01165"></a>01165 <span class="preprocessor">#ifdef DBUS_BUILD_TESTS</span>
<a name="l01166"></a>01166 <span class="preprocessor"></span>
<a name="l01175"></a>01175 <span class="keywordtype">void</span>*
<a name="l01176"></a>01176 _dbus_hash_table_lookup_two_strings (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table,
<a name="l01177"></a>01177 <span class="keyword">const</span> <span class="keywordtype">char</span> *key)
<a name="l01178"></a>01178 {
<a name="l01179"></a>01179 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *entry;
<a name="l01180"></a>01180
<a name="l01181"></a>01181 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (table-><a class="code" href="structDBusHashTable.html#28f326a2947b6be0b0b852db376a1092">key_type</a> == <a class="code" href="group__DBusHashTable.html#ggb0ab9767ffa5b6720a13b3d741630852c750b865c7994a3dd6d1028b7ae76877">DBUS_HASH_TWO_STRINGS</a>);
<a name="l01182"></a>01182
<a name="l01183"></a>01183 entry = (* table-><a class="code" href="structDBusHashTable.html#b98bafddf1b1ce1dad01c5595e278e35">find_function</a>) (table, (<span class="keywordtype">char</span>*) key, <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>, <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>, <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l01184"></a>01184
<a name="l01185"></a>01185 <span class="keywordflow">if</span> (entry)
<a name="l01186"></a>01186 <span class="keywordflow">return</span> entry-><a class="code" href="structDBusHashEntry.html#d792e9c81cc3a23859b2c60b3b00af3e">value</a>;
<a name="l01187"></a>01187 <span class="keywordflow">else</span>
<a name="l01188"></a>01188 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l01189"></a>01189 }
<a name="l01190"></a>01190 <span class="preprocessor">#endif </span><span class="comment">/* DBUS_BUILD_TESTS */</span>
<a name="l01191"></a>01191
<a name="l01201"></a>01201 <span class="keywordtype">void</span>*
<a name="l01202"></a><a class="code" href="group__DBusHashTable.html#g36ff49c4c35599e6fcdadc7f6805c49e">01202</a> <a class="code" href="group__DBusHashTable.html#g36ff49c4c35599e6fcdadc7f6805c49e">_dbus_hash_table_lookup_int</a> (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table,
<a name="l01203"></a>01203 <span class="keywordtype">int</span> key)
<a name="l01204"></a>01204 {
<a name="l01205"></a>01205 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *entry;
<a name="l01206"></a>01206
<a name="l01207"></a>01207 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (table-><a class="code" href="structDBusHashTable.html#28f326a2947b6be0b0b852db376a1092">key_type</a> == <a class="code" href="group__DBusHashTable.html#ggb0ab9767ffa5b6720a13b3d74163085226446bd9fbb15c6c381b35a810207141">DBUS_HASH_INT</a>);
<a name="l01208"></a>01208
<a name="l01209"></a>01209 entry = (* table-><a class="code" href="structDBusHashTable.html#b98bafddf1b1ce1dad01c5595e278e35">find_function</a>) (table, <a class="code" href="group__DBusInternalsUtils.html#g05e902d8504a8a0e0b183fd2e20e329f">_DBUS_INT_TO_POINTER</a> (key), <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>, <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>, <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l01210"></a>01210
<a name="l01211"></a>01211 <span class="keywordflow">if</span> (entry)
<a name="l01212"></a>01212 <span class="keywordflow">return</span> entry-><a class="code" href="structDBusHashEntry.html#d792e9c81cc3a23859b2c60b3b00af3e">value</a>;
<a name="l01213"></a>01213 <span class="keywordflow">else</span>
<a name="l01214"></a>01214 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l01215"></a>01215 }
<a name="l01216"></a>01216
<a name="l01217"></a>01217 <span class="preprocessor">#ifdef DBUS_BUILD_TESTS</span>
<a name="l01218"></a>01218 <span class="preprocessor"></span><span class="comment">/* disabled since it's only used for testing */</span>
<a name="l01228"></a>01228 <span class="keywordtype">void</span>*
<a name="l01229"></a>01229 _dbus_hash_table_lookup_pointer (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table,
<a name="l01230"></a>01230 <span class="keywordtype">void</span> *key)
<a name="l01231"></a>01231 {
<a name="l01232"></a>01232 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *entry;
<a name="l01233"></a>01233
<a name="l01234"></a>01234 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (table-><a class="code" href="structDBusHashTable.html#28f326a2947b6be0b0b852db376a1092">key_type</a> == <a class="code" href="group__DBusHashTable.html#ggb0ab9767ffa5b6720a13b3d74163085238604db762cd0ed315106a95a6b50c4d">DBUS_HASH_POINTER</a>);
<a name="l01235"></a>01235
<a name="l01236"></a>01236 entry = (* table-><a class="code" href="structDBusHashTable.html#b98bafddf1b1ce1dad01c5595e278e35">find_function</a>) (table, key, <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>, <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>, <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l01237"></a>01237
<a name="l01238"></a>01238 <span class="keywordflow">if</span> (entry)
<a name="l01239"></a>01239 <span class="keywordflow">return</span> entry-><a class="code" href="structDBusHashEntry.html#d792e9c81cc3a23859b2c60b3b00af3e">value</a>;
<a name="l01240"></a>01240 <span class="keywordflow">else</span>
<a name="l01241"></a>01241 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l01242"></a>01242 }
<a name="l01243"></a>01243 <span class="preprocessor">#endif </span><span class="comment">/* DBUS_BUILD_TESTS */</span>
<a name="l01244"></a>01244
<a name="l01254"></a>01254 <span class="keywordtype">void</span>*
<a name="l01255"></a><a class="code" href="group__DBusHashTable.html#g5d9caa38b663955ee0c4766f66e4e317">01255</a> <a class="code" href="group__DBusHashTable.html#g5d9caa38b663955ee0c4766f66e4e317">_dbus_hash_table_lookup_ulong</a> (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table,
<a name="l01256"></a>01256 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> key)
<a name="l01257"></a>01257 {
<a name="l01258"></a>01258 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *entry;
<a name="l01259"></a>01259
<a name="l01260"></a>01260 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (table-><a class="code" href="structDBusHashTable.html#28f326a2947b6be0b0b852db376a1092">key_type</a> == <a class="code" href="group__DBusHashTable.html#ggb0ab9767ffa5b6720a13b3d741630852f9b5230298187cd6953dbcac824b2e4c">DBUS_HASH_ULONG</a>);
<a name="l01261"></a>01261
<a name="l01262"></a>01262 entry = (* table-><a class="code" href="structDBusHashTable.html#b98bafddf1b1ce1dad01c5595e278e35">find_function</a>) (table, (<span class="keywordtype">void</span>*) key, <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>, <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>, <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l01263"></a>01263
<a name="l01264"></a>01264 <span class="keywordflow">if</span> (entry)
<a name="l01265"></a>01265 <span class="keywordflow">return</span> entry-><a class="code" href="structDBusHashEntry.html#d792e9c81cc3a23859b2c60b3b00af3e">value</a>;
<a name="l01266"></a>01266 <span class="keywordflow">else</span>
<a name="l01267"></a>01267 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l01268"></a>01268 }
<a name="l01269"></a>01269
<a name="l01278"></a>01278 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a>
<a name="l01279"></a><a class="code" href="group__DBusHashTable.html#g388d50ce1a07bf0790b9f2ecdb08a396">01279</a> <a class="code" href="group__DBusHashTable.html#g388d50ce1a07bf0790b9f2ecdb08a396">_dbus_hash_table_remove_string</a> (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table,
<a name="l01280"></a>01280 <span class="keyword">const</span> <span class="keywordtype">char</span> *key)
<a name="l01281"></a>01281 {
<a name="l01282"></a>01282 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *entry;
<a name="l01283"></a>01283 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> **bucket;
<a name="l01284"></a>01284
<a name="l01285"></a>01285 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (table-><a class="code" href="structDBusHashTable.html#28f326a2947b6be0b0b852db376a1092">key_type</a> == <a class="code" href="group__DBusHashTable.html#ggb0ab9767ffa5b6720a13b3d741630852481fd0166d28da725b3e97f15192434e">DBUS_HASH_STRING</a>);
<a name="l01286"></a>01286
<a name="l01287"></a>01287 entry = (* table-><a class="code" href="structDBusHashTable.html#b98bafddf1b1ce1dad01c5595e278e35">find_function</a>) (table, (<span class="keywordtype">char</span>*) key, <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>, &bucket, <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l01288"></a>01288
<a name="l01289"></a>01289 <span class="keywordflow">if</span> (entry)
<a name="l01290"></a>01290 {
<a name="l01291"></a>01291 remove_entry (table, bucket, entry);
<a name="l01292"></a>01292 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>;
<a name="l01293"></a>01293 }
<a name="l01294"></a>01294 <span class="keywordflow">else</span>
<a name="l01295"></a>01295 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>;
<a name="l01296"></a>01296 }
<a name="l01297"></a>01297
<a name="l01298"></a>01298 <span class="preprocessor">#ifdef DBUS_BUILD_TESTS</span>
<a name="l01299"></a>01299 <span class="preprocessor"></span>
<a name="l01307"></a>01307 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a>
<a name="l01308"></a>01308 _dbus_hash_table_remove_two_strings (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table,
<a name="l01309"></a>01309 <span class="keyword">const</span> <span class="keywordtype">char</span> *key)
<a name="l01310"></a>01310 {
<a name="l01311"></a>01311 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *entry;
<a name="l01312"></a>01312 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> **bucket;
<a name="l01313"></a>01313
<a name="l01314"></a>01314 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (table-><a class="code" href="structDBusHashTable.html#28f326a2947b6be0b0b852db376a1092">key_type</a> == <a class="code" href="group__DBusHashTable.html#ggb0ab9767ffa5b6720a13b3d741630852c750b865c7994a3dd6d1028b7ae76877">DBUS_HASH_TWO_STRINGS</a>);
<a name="l01315"></a>01315
<a name="l01316"></a>01316 entry = (* table-><a class="code" href="structDBusHashTable.html#b98bafddf1b1ce1dad01c5595e278e35">find_function</a>) (table, (<span class="keywordtype">char</span>*) key, <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>, &bucket, <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l01317"></a>01317
<a name="l01318"></a>01318 <span class="keywordflow">if</span> (entry)
<a name="l01319"></a>01319 {
<a name="l01320"></a>01320 remove_entry (table, bucket, entry);
<a name="l01321"></a>01321 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>;
<a name="l01322"></a>01322 }
<a name="l01323"></a>01323 <span class="keywordflow">else</span>
<a name="l01324"></a>01324 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>;
<a name="l01325"></a>01325 }
<a name="l01326"></a>01326 <span class="preprocessor">#endif </span><span class="comment">/* DBUS_BUILD_TESTS */</span>
<a name="l01327"></a>01327
<a name="l01336"></a>01336 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a>
<a name="l01337"></a><a class="code" href="group__DBusHashTable.html#gcdebe75bd692605a69dc73c15e0eefd0">01337</a> <a class="code" href="group__DBusHashTable.html#gcdebe75bd692605a69dc73c15e0eefd0">_dbus_hash_table_remove_int</a> (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table,
<a name="l01338"></a>01338 <span class="keywordtype">int</span> key)
<a name="l01339"></a>01339 {
<a name="l01340"></a>01340 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *entry;
<a name="l01341"></a>01341 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> **bucket;
<a name="l01342"></a>01342
<a name="l01343"></a>01343 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (table-><a class="code" href="structDBusHashTable.html#28f326a2947b6be0b0b852db376a1092">key_type</a> == <a class="code" href="group__DBusHashTable.html#ggb0ab9767ffa5b6720a13b3d74163085226446bd9fbb15c6c381b35a810207141">DBUS_HASH_INT</a>);
<a name="l01344"></a>01344
<a name="l01345"></a>01345 entry = (* table-><a class="code" href="structDBusHashTable.html#b98bafddf1b1ce1dad01c5595e278e35">find_function</a>) (table, <a class="code" href="group__DBusInternalsUtils.html#g05e902d8504a8a0e0b183fd2e20e329f">_DBUS_INT_TO_POINTER</a> (key), <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>, &bucket, <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l01346"></a>01346
<a name="l01347"></a>01347 <span class="keywordflow">if</span> (entry)
<a name="l01348"></a>01348 {
<a name="l01349"></a>01349 remove_entry (table, bucket, entry);
<a name="l01350"></a>01350 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>;
<a name="l01351"></a>01351 }
<a name="l01352"></a>01352 <span class="keywordflow">else</span>
<a name="l01353"></a>01353 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>;
<a name="l01354"></a>01354 }
<a name="l01355"></a>01355
<a name="l01356"></a>01356 <span class="preprocessor">#ifdef DBUS_BUILD_TESTS</span>
<a name="l01357"></a>01357 <span class="preprocessor"></span><span class="comment">/* disabled since it's only used for testing */</span>
<a name="l01366"></a>01366 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a>
<a name="l01367"></a>01367 _dbus_hash_table_remove_pointer (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table,
<a name="l01368"></a>01368 <span class="keywordtype">void</span> *key)
<a name="l01369"></a>01369 {
<a name="l01370"></a>01370 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *entry;
<a name="l01371"></a>01371 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> **bucket;
<a name="l01372"></a>01372
<a name="l01373"></a>01373 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (table-><a class="code" href="structDBusHashTable.html#28f326a2947b6be0b0b852db376a1092">key_type</a> == <a class="code" href="group__DBusHashTable.html#ggb0ab9767ffa5b6720a13b3d74163085238604db762cd0ed315106a95a6b50c4d">DBUS_HASH_POINTER</a>);
<a name="l01374"></a>01374
<a name="l01375"></a>01375 entry = (* table-><a class="code" href="structDBusHashTable.html#b98bafddf1b1ce1dad01c5595e278e35">find_function</a>) (table, key, <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>, &bucket, <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l01376"></a>01376
<a name="l01377"></a>01377 <span class="keywordflow">if</span> (entry)
<a name="l01378"></a>01378 {
<a name="l01379"></a>01379 remove_entry (table, bucket, entry);
<a name="l01380"></a>01380 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>;
<a name="l01381"></a>01381 }
<a name="l01382"></a>01382 <span class="keywordflow">else</span>
<a name="l01383"></a>01383 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>;
<a name="l01384"></a>01384 }
<a name="l01385"></a>01385 <span class="preprocessor">#endif </span><span class="comment">/* DBUS_BUILD_TESTS */</span>
<a name="l01386"></a>01386
<a name="l01395"></a>01395 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a>
<a name="l01396"></a><a class="code" href="group__DBusHashTable.html#g2211f0b52ae08e195186b7d438913b11">01396</a> <a class="code" href="group__DBusHashTable.html#g2211f0b52ae08e195186b7d438913b11">_dbus_hash_table_remove_ulong</a> (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table,
<a name="l01397"></a>01397 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> key)
<a name="l01398"></a>01398 {
<a name="l01399"></a>01399 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *entry;
<a name="l01400"></a>01400 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> **bucket;
<a name="l01401"></a>01401
<a name="l01402"></a>01402 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (table-><a class="code" href="structDBusHashTable.html#28f326a2947b6be0b0b852db376a1092">key_type</a> == <a class="code" href="group__DBusHashTable.html#ggb0ab9767ffa5b6720a13b3d741630852f9b5230298187cd6953dbcac824b2e4c">DBUS_HASH_ULONG</a>);
<a name="l01403"></a>01403
<a name="l01404"></a>01404 entry = (* table-><a class="code" href="structDBusHashTable.html#b98bafddf1b1ce1dad01c5595e278e35">find_function</a>) (table, (<span class="keywordtype">void</span>*) key, <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>, &bucket, <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l01405"></a>01405
<a name="l01406"></a>01406 <span class="keywordflow">if</span> (entry)
<a name="l01407"></a>01407 {
<a name="l01408"></a>01408 remove_entry (table, bucket, entry);
<a name="l01409"></a>01409 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>;
<a name="l01410"></a>01410 }
<a name="l01411"></a>01411 <span class="keywordflow">else</span>
<a name="l01412"></a>01412 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>;
<a name="l01413"></a>01413 }
<a name="l01414"></a>01414
<a name="l01430"></a>01430 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a>
<a name="l01431"></a><a class="code" href="group__DBusHashTable.html#g43e98a91a11952824c544330e19f6c22">01431</a> <a class="code" href="group__DBusHashTable.html#g43e98a91a11952824c544330e19f6c22">_dbus_hash_table_insert_string</a> (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table,
<a name="l01432"></a>01432 <span class="keywordtype">char</span> *key,
<a name="l01433"></a>01433 <span class="keywordtype">void</span> *value)
<a name="l01434"></a>01434 {
<a name="l01435"></a>01435 <a class="code" href="group__DBusHashTable.html#g175dc6ab841ed32bb6acf6e4c0df36a8">DBusPreallocatedHash</a> *preallocated;
<a name="l01436"></a>01436
<a name="l01437"></a>01437 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (table-><a class="code" href="structDBusHashTable.html#28f326a2947b6be0b0b852db376a1092">key_type</a> == <a class="code" href="group__DBusHashTable.html#ggb0ab9767ffa5b6720a13b3d741630852481fd0166d28da725b3e97f15192434e">DBUS_HASH_STRING</a>);
<a name="l01438"></a>01438
<a name="l01439"></a>01439 preallocated = <a class="code" href="group__DBusHashTable.html#g7c2fed5599678e550af10eaa7fd5b1d1">_dbus_hash_table_preallocate_entry</a> (table);
<a name="l01440"></a>01440 <span class="keywordflow">if</span> (preallocated == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l01441"></a>01441 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>;
<a name="l01442"></a>01442
<a name="l01443"></a>01443 <a class="code" href="group__DBusHashTable.html#g770a9b786a9594350165b7224bd173ee">_dbus_hash_table_insert_string_preallocated</a> (table, preallocated,
<a name="l01444"></a>01444 key, value);
<a name="l01445"></a>01445
<a name="l01446"></a>01446 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>;
<a name="l01447"></a>01447 }
<a name="l01448"></a>01448
<a name="l01449"></a>01449 <span class="preprocessor">#ifdef DBUS_BUILD_TESTS</span>
<a name="l01450"></a>01450 <span class="preprocessor"></span>
<a name="l01465"></a>01465 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a>
<a name="l01466"></a>01466 _dbus_hash_table_insert_two_strings (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table,
<a name="l01467"></a>01467 <span class="keywordtype">char</span> *key,
<a name="l01468"></a>01468 <span class="keywordtype">void</span> *value)
<a name="l01469"></a>01469 {
<a name="l01470"></a>01470 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *entry;
<a name="l01471"></a>01471
<a name="l01472"></a>01472 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (table-><a class="code" href="structDBusHashTable.html#28f326a2947b6be0b0b852db376a1092">key_type</a> == <a class="code" href="group__DBusHashTable.html#ggb0ab9767ffa5b6720a13b3d741630852c750b865c7994a3dd6d1028b7ae76877">DBUS_HASH_TWO_STRINGS</a>);
<a name="l01473"></a>01473
<a name="l01474"></a>01474 entry = (* table-><a class="code" href="structDBusHashTable.html#b98bafddf1b1ce1dad01c5595e278e35">find_function</a>) (table, key, <a class="code" href="group__DBusMacros.html#ga8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>, <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>, <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l01475"></a>01475
<a name="l01476"></a>01476 <span class="keywordflow">if</span> (entry == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l01477"></a>01477 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>; <span class="comment">/* no memory */</span>
<a name="l01478"></a>01478
<a name="l01479"></a>01479 <span class="keywordflow">if</span> (table-><a class="code" href="structDBusHashTable.html#5f6541574ea8e6bedd80773dce8e52a6">free_key_function</a> && entry-><a class="code" href="structDBusHashEntry.html#efd9bbdcbc7d15c906e2c289c8d2e894">key</a> != key)
<a name="l01480"></a>01480 (* table-><a class="code" href="structDBusHashTable.html#5f6541574ea8e6bedd80773dce8e52a6">free_key_function</a>) (entry-><a class="code" href="structDBusHashEntry.html#efd9bbdcbc7d15c906e2c289c8d2e894">key</a>);
<a name="l01481"></a>01481
<a name="l01482"></a>01482 <span class="keywordflow">if</span> (table-><a class="code" href="structDBusHashTable.html#fbb42b5326b9c79352b168eace1687ca">free_value_function</a> && entry-><a class="code" href="structDBusHashEntry.html#d792e9c81cc3a23859b2c60b3b00af3e">value</a> != value)
<a name="l01483"></a>01483 (* table-><a class="code" href="structDBusHashTable.html#fbb42b5326b9c79352b168eace1687ca">free_value_function</a>) (entry-><a class="code" href="structDBusHashEntry.html#d792e9c81cc3a23859b2c60b3b00af3e">value</a>);
<a name="l01484"></a>01484
<a name="l01485"></a>01485 entry-><a class="code" href="structDBusHashEntry.html#efd9bbdcbc7d15c906e2c289c8d2e894">key</a> = key;
<a name="l01486"></a>01486 entry-><a class="code" href="structDBusHashEntry.html#d792e9c81cc3a23859b2c60b3b00af3e">value</a> = value;
<a name="l01487"></a>01487
<a name="l01488"></a>01488 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>;
<a name="l01489"></a>01489 }
<a name="l01490"></a>01490 <span class="preprocessor">#endif </span><span class="comment">/* DBUS_BUILD_TESTS */</span>
<a name="l01491"></a>01491
<a name="l01507"></a>01507 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a>
<a name="l01508"></a><a class="code" href="group__DBusHashTable.html#gca20a83f3214db08fa34df2c49c8edd5">01508</a> <a class="code" href="group__DBusHashTable.html#gca20a83f3214db08fa34df2c49c8edd5">_dbus_hash_table_insert_int</a> (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table,
<a name="l01509"></a>01509 <span class="keywordtype">int</span> key,
<a name="l01510"></a>01510 <span class="keywordtype">void</span> *value)
<a name="l01511"></a>01511 {
<a name="l01512"></a>01512 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *entry;
<a name="l01513"></a>01513
<a name="l01514"></a>01514 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (table-><a class="code" href="structDBusHashTable.html#28f326a2947b6be0b0b852db376a1092">key_type</a> == <a class="code" href="group__DBusHashTable.html#ggb0ab9767ffa5b6720a13b3d74163085226446bd9fbb15c6c381b35a810207141">DBUS_HASH_INT</a>);
<a name="l01515"></a>01515
<a name="l01516"></a>01516 entry = (* table-><a class="code" href="structDBusHashTable.html#b98bafddf1b1ce1dad01c5595e278e35">find_function</a>) (table, <a class="code" href="group__DBusInternalsUtils.html#g05e902d8504a8a0e0b183fd2e20e329f">_DBUS_INT_TO_POINTER</a> (key), <a class="code" href="group__DBusMacros.html#ga8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>, <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>, <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l01517"></a>01517
<a name="l01518"></a>01518 <span class="keywordflow">if</span> (entry == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l01519"></a>01519 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>; <span class="comment">/* no memory */</span>
<a name="l01520"></a>01520
<a name="l01521"></a>01521 <span class="keywordflow">if</span> (table-><a class="code" href="structDBusHashTable.html#5f6541574ea8e6bedd80773dce8e52a6">free_key_function</a> && entry-><a class="code" href="structDBusHashEntry.html#efd9bbdcbc7d15c906e2c289c8d2e894">key</a> != <a class="code" href="group__DBusInternalsUtils.html#g05e902d8504a8a0e0b183fd2e20e329f">_DBUS_INT_TO_POINTER</a> (key))
<a name="l01522"></a>01522 (* table-><a class="code" href="structDBusHashTable.html#5f6541574ea8e6bedd80773dce8e52a6">free_key_function</a>) (entry-><a class="code" href="structDBusHashEntry.html#efd9bbdcbc7d15c906e2c289c8d2e894">key</a>);
<a name="l01523"></a>01523
<a name="l01524"></a>01524 <span class="keywordflow">if</span> (table-><a class="code" href="structDBusHashTable.html#fbb42b5326b9c79352b168eace1687ca">free_value_function</a> && entry-><a class="code" href="structDBusHashEntry.html#d792e9c81cc3a23859b2c60b3b00af3e">value</a> != value)
<a name="l01525"></a>01525 (* table-><a class="code" href="structDBusHashTable.html#fbb42b5326b9c79352b168eace1687ca">free_value_function</a>) (entry-><a class="code" href="structDBusHashEntry.html#d792e9c81cc3a23859b2c60b3b00af3e">value</a>);
<a name="l01526"></a>01526
<a name="l01527"></a>01527 entry-><a class="code" href="structDBusHashEntry.html#efd9bbdcbc7d15c906e2c289c8d2e894">key</a> = <a class="code" href="group__DBusInternalsUtils.html#g05e902d8504a8a0e0b183fd2e20e329f">_DBUS_INT_TO_POINTER</a> (key);
<a name="l01528"></a>01528 entry-><a class="code" href="structDBusHashEntry.html#d792e9c81cc3a23859b2c60b3b00af3e">value</a> = value;
<a name="l01529"></a>01529
<a name="l01530"></a>01530 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>;
<a name="l01531"></a>01531 }
<a name="l01532"></a>01532
<a name="l01533"></a>01533 <span class="preprocessor">#ifdef DBUS_BUILD_TESTS</span>
<a name="l01534"></a>01534 <span class="preprocessor"></span><span class="comment">/* disabled since it's only used for testing */</span>
<a name="l01550"></a>01550 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a>
<a name="l01551"></a>01551 _dbus_hash_table_insert_pointer (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table,
<a name="l01552"></a>01552 <span class="keywordtype">void</span> *key,
<a name="l01553"></a>01553 <span class="keywordtype">void</span> *value)
<a name="l01554"></a>01554 {
<a name="l01555"></a>01555 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *entry;
<a name="l01556"></a>01556
<a name="l01557"></a>01557 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (table-><a class="code" href="structDBusHashTable.html#28f326a2947b6be0b0b852db376a1092">key_type</a> == <a class="code" href="group__DBusHashTable.html#ggb0ab9767ffa5b6720a13b3d74163085238604db762cd0ed315106a95a6b50c4d">DBUS_HASH_POINTER</a>);
<a name="l01558"></a>01558
<a name="l01559"></a>01559 entry = (* table-><a class="code" href="structDBusHashTable.html#b98bafddf1b1ce1dad01c5595e278e35">find_function</a>) (table, key, <a class="code" href="group__DBusMacros.html#ga8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>, <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>, <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l01560"></a>01560
<a name="l01561"></a>01561 <span class="keywordflow">if</span> (entry == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l01562"></a>01562 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>; <span class="comment">/* no memory */</span>
<a name="l01563"></a>01563
<a name="l01564"></a>01564 <span class="keywordflow">if</span> (table-><a class="code" href="structDBusHashTable.html#5f6541574ea8e6bedd80773dce8e52a6">free_key_function</a> && entry-><a class="code" href="structDBusHashEntry.html#efd9bbdcbc7d15c906e2c289c8d2e894">key</a> != key)
<a name="l01565"></a>01565 (* table-><a class="code" href="structDBusHashTable.html#5f6541574ea8e6bedd80773dce8e52a6">free_key_function</a>) (entry-><a class="code" href="structDBusHashEntry.html#efd9bbdcbc7d15c906e2c289c8d2e894">key</a>);
<a name="l01566"></a>01566
<a name="l01567"></a>01567 <span class="keywordflow">if</span> (table-><a class="code" href="structDBusHashTable.html#fbb42b5326b9c79352b168eace1687ca">free_value_function</a> && entry-><a class="code" href="structDBusHashEntry.html#d792e9c81cc3a23859b2c60b3b00af3e">value</a> != value)
<a name="l01568"></a>01568 (* table-><a class="code" href="structDBusHashTable.html#fbb42b5326b9c79352b168eace1687ca">free_value_function</a>) (entry-><a class="code" href="structDBusHashEntry.html#d792e9c81cc3a23859b2c60b3b00af3e">value</a>);
<a name="l01569"></a>01569
<a name="l01570"></a>01570 entry-><a class="code" href="structDBusHashEntry.html#efd9bbdcbc7d15c906e2c289c8d2e894">key</a> = key;
<a name="l01571"></a>01571 entry-><a class="code" href="structDBusHashEntry.html#d792e9c81cc3a23859b2c60b3b00af3e">value</a> = value;
<a name="l01572"></a>01572
<a name="l01573"></a>01573 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>;
<a name="l01574"></a>01574 }
<a name="l01575"></a>01575 <span class="preprocessor">#endif </span><span class="comment">/* DBUS_BUILD_TESTS */</span>
<a name="l01576"></a>01576
<a name="l01592"></a>01592 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a>
<a name="l01593"></a><a class="code" href="group__DBusHashTable.html#gf40df7d2c9b05a67ac8c80d9ed88175c">01593</a> <a class="code" href="group__DBusHashTable.html#gf40df7d2c9b05a67ac8c80d9ed88175c">_dbus_hash_table_insert_ulong</a> (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table,
<a name="l01594"></a>01594 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> key,
<a name="l01595"></a>01595 <span class="keywordtype">void</span> *value)
<a name="l01596"></a>01596 {
<a name="l01597"></a>01597 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *entry;
<a name="l01598"></a>01598
<a name="l01599"></a>01599 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (table-><a class="code" href="structDBusHashTable.html#28f326a2947b6be0b0b852db376a1092">key_type</a> == <a class="code" href="group__DBusHashTable.html#ggb0ab9767ffa5b6720a13b3d741630852f9b5230298187cd6953dbcac824b2e4c">DBUS_HASH_ULONG</a>);
<a name="l01600"></a>01600
<a name="l01601"></a>01601 entry = (* table-><a class="code" href="structDBusHashTable.html#b98bafddf1b1ce1dad01c5595e278e35">find_function</a>) (table, (<span class="keywordtype">void</span>*) key, <a class="code" href="group__DBusMacros.html#ga8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>, <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>, <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l01602"></a>01602
<a name="l01603"></a>01603 <span class="keywordflow">if</span> (entry == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l01604"></a>01604 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>; <span class="comment">/* no memory */</span>
<a name="l01605"></a>01605
<a name="l01606"></a>01606 <span class="keywordflow">if</span> (table-><a class="code" href="structDBusHashTable.html#5f6541574ea8e6bedd80773dce8e52a6">free_key_function</a> && entry-><a class="code" href="structDBusHashEntry.html#efd9bbdcbc7d15c906e2c289c8d2e894">key</a> != (<span class="keywordtype">void</span>*) key)
<a name="l01607"></a>01607 (* table-><a class="code" href="structDBusHashTable.html#5f6541574ea8e6bedd80773dce8e52a6">free_key_function</a>) (entry-><a class="code" href="structDBusHashEntry.html#efd9bbdcbc7d15c906e2c289c8d2e894">key</a>);
<a name="l01608"></a>01608
<a name="l01609"></a>01609 <span class="keywordflow">if</span> (table-><a class="code" href="structDBusHashTable.html#fbb42b5326b9c79352b168eace1687ca">free_value_function</a> && entry-><a class="code" href="structDBusHashEntry.html#d792e9c81cc3a23859b2c60b3b00af3e">value</a> != value)
<a name="l01610"></a>01610 (* table-><a class="code" href="structDBusHashTable.html#fbb42b5326b9c79352b168eace1687ca">free_value_function</a>) (entry-><a class="code" href="structDBusHashEntry.html#d792e9c81cc3a23859b2c60b3b00af3e">value</a>);
<a name="l01611"></a>01611
<a name="l01612"></a>01612 entry-><a class="code" href="structDBusHashEntry.html#efd9bbdcbc7d15c906e2c289c8d2e894">key</a> = (<span class="keywordtype">void</span>*) key;
<a name="l01613"></a>01613 entry-><a class="code" href="structDBusHashEntry.html#d792e9c81cc3a23859b2c60b3b00af3e">value</a> = value;
<a name="l01614"></a>01614
<a name="l01615"></a>01615 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>;
<a name="l01616"></a>01616 }
<a name="l01617"></a>01617
<a name="l01625"></a>01625 <a class="code" href="group__DBusHashTable.html#g175dc6ab841ed32bb6acf6e4c0df36a8">DBusPreallocatedHash</a>*
<a name="l01626"></a><a class="code" href="group__DBusHashTable.html#g7c2fed5599678e550af10eaa7fd5b1d1">01626</a> <a class="code" href="group__DBusHashTable.html#g7c2fed5599678e550af10eaa7fd5b1d1">_dbus_hash_table_preallocate_entry</a> (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table)
<a name="l01627"></a>01627 {
<a name="l01628"></a>01628 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *entry;
<a name="l01629"></a>01629
<a name="l01630"></a>01630 entry = alloc_entry (table);
<a name="l01631"></a>01631
<a name="l01632"></a>01632 <span class="keywordflow">return</span> (<a class="code" href="group__DBusHashTable.html#g175dc6ab841ed32bb6acf6e4c0df36a8">DBusPreallocatedHash</a>*) entry;
<a name="l01633"></a>01633 }
<a name="l01634"></a>01634
<a name="l01642"></a>01642 <span class="keywordtype">void</span>
<a name="l01643"></a><a class="code" href="group__DBusHashTable.html#g159dfec03d53e6e2ff485fc83aed2552">01643</a> <a class="code" href="group__DBusHashTable.html#g159dfec03d53e6e2ff485fc83aed2552">_dbus_hash_table_free_preallocated_entry</a> (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table,
<a name="l01644"></a>01644 <a class="code" href="group__DBusHashTable.html#g175dc6ab841ed32bb6acf6e4c0df36a8">DBusPreallocatedHash</a> *preallocated)
<a name="l01645"></a>01645 {
<a name="l01646"></a>01646 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *entry;
<a name="l01647"></a>01647
<a name="l01648"></a>01648 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (preallocated != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l01649"></a>01649
<a name="l01650"></a>01650 entry = (<a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a>*) preallocated;
<a name="l01651"></a>01651
<a name="l01652"></a>01652 <span class="comment">/* Don't use free_entry(), since this entry has no key/data */</span>
<a name="l01653"></a>01653 <a class="code" href="group__DBusMemPool.html#g4e2feaefee7384ed940059e6c7b0a9d5">_dbus_mem_pool_dealloc</a> (table-><a class="code" href="structDBusHashTable.html#d1224e6c3c632afb265b78f8f6e30f97">entry_pool</a>, entry);
<a name="l01654"></a>01654 }
<a name="l01655"></a>01655
<a name="l01669"></a>01669 <span class="keywordtype">void</span>
<a name="l01670"></a><a class="code" href="group__DBusHashTable.html#g770a9b786a9594350165b7224bd173ee">01670</a> <a class="code" href="group__DBusHashTable.html#g770a9b786a9594350165b7224bd173ee">_dbus_hash_table_insert_string_preallocated</a> (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table,
<a name="l01671"></a>01671 <a class="code" href="group__DBusHashTable.html#g175dc6ab841ed32bb6acf6e4c0df36a8">DBusPreallocatedHash</a> *preallocated,
<a name="l01672"></a>01672 <span class="keywordtype">char</span> *key,
<a name="l01673"></a>01673 <span class="keywordtype">void</span> *value)
<a name="l01674"></a>01674 {
<a name="l01675"></a>01675 <a class="code" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a> *entry;
<a name="l01676"></a>01676
<a name="l01677"></a>01677 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (table-><a class="code" href="structDBusHashTable.html#28f326a2947b6be0b0b852db376a1092">key_type</a> == <a class="code" href="group__DBusHashTable.html#ggb0ab9767ffa5b6720a13b3d741630852481fd0166d28da725b3e97f15192434e">DBUS_HASH_STRING</a>);
<a name="l01678"></a>01678 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (preallocated != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l01679"></a>01679
<a name="l01680"></a>01680 entry = (* table-><a class="code" href="structDBusHashTable.html#b98bafddf1b1ce1dad01c5595e278e35">find_function</a>) (table, key, <a class="code" href="group__DBusMacros.html#ga8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>, <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>, preallocated);
<a name="l01681"></a>01681
<a name="l01682"></a>01682 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (entry != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l01683"></a>01683
<a name="l01684"></a>01684 <span class="keywordflow">if</span> (table-><a class="code" href="structDBusHashTable.html#5f6541574ea8e6bedd80773dce8e52a6">free_key_function</a> && entry-><a class="code" href="structDBusHashEntry.html#efd9bbdcbc7d15c906e2c289c8d2e894">key</a> != key)
<a name="l01685"></a>01685 (* table-><a class="code" href="structDBusHashTable.html#5f6541574ea8e6bedd80773dce8e52a6">free_key_function</a>) (entry-><a class="code" href="structDBusHashEntry.html#efd9bbdcbc7d15c906e2c289c8d2e894">key</a>);
<a name="l01686"></a>01686
<a name="l01687"></a>01687 <span class="keywordflow">if</span> (table-><a class="code" href="structDBusHashTable.html#fbb42b5326b9c79352b168eace1687ca">free_value_function</a> && entry-><a class="code" href="structDBusHashEntry.html#d792e9c81cc3a23859b2c60b3b00af3e">value</a> != value)
<a name="l01688"></a>01688 (* table-><a class="code" href="structDBusHashTable.html#fbb42b5326b9c79352b168eace1687ca">free_value_function</a>) (entry-><a class="code" href="structDBusHashEntry.html#d792e9c81cc3a23859b2c60b3b00af3e">value</a>);
<a name="l01689"></a>01689
<a name="l01690"></a>01690 entry-><a class="code" href="structDBusHashEntry.html#efd9bbdcbc7d15c906e2c289c8d2e894">key</a> = key;
<a name="l01691"></a>01691 entry-><a class="code" href="structDBusHashEntry.html#d792e9c81cc3a23859b2c60b3b00af3e">value</a> = value;
<a name="l01692"></a>01692 }
<a name="l01693"></a>01693
<a name="l01700"></a>01700 <span class="keywordtype">int</span>
<a name="l01701"></a><a class="code" href="group__DBusHashTable.html#gd48297fc27442c19a7c4bd4d1ef9ef77">01701</a> <a class="code" href="group__DBusHashTable.html#gd48297fc27442c19a7c4bd4d1ef9ef77">_dbus_hash_table_get_n_entries</a> (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table)
<a name="l01702"></a>01702 {
<a name="l01703"></a>01703 <span class="keywordflow">return</span> table-><a class="code" href="structDBusHashTable.html#ffbf11a9c3dd72d55b7976891f7b4650">n_entries</a>;
<a name="l01704"></a>01704 }
<a name="l01705"></a>01705
<a name="l01708"></a>01708 <span class="preprocessor">#ifdef DBUS_BUILD_TESTS</span>
<a name="l01709"></a>01709 <span class="preprocessor"></span><span class="preprocessor">#include "dbus-test.h"</span>
<a name="l01710"></a>01710 <span class="preprocessor">#include <stdio.h></span>
<a name="l01711"></a>01711
<a name="l01712"></a>01712 <span class="comment">/* If you're wondering why the hash table test takes</span>
<a name="l01713"></a>01713 <span class="comment"> * forever to run, it's because we call this function</span>
<a name="l01714"></a>01714 <span class="comment"> * in inner loops thus making things quadratic.</span>
<a name="l01715"></a>01715 <span class="comment"> */</span>
<a name="l01716"></a>01716 <span class="keyword">static</span> <span class="keywordtype">int</span>
<a name="l01717"></a>01717 count_entries (<a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table)
<a name="l01718"></a>01718 {
<a name="l01719"></a>01719 <a class="code" href="structDBusHashIter.html">DBusHashIter</a> iter;
<a name="l01720"></a>01720 <span class="keywordtype">int</span> count;
<a name="l01721"></a>01721
<a name="l01722"></a>01722 count = 0;
<a name="l01723"></a>01723 <a class="code" href="group__DBusHashTable.html#g1b0e6df8a8617ef0f8f25adfba3acc4c">_dbus_hash_iter_init</a> (table, &iter);
<a name="l01724"></a>01724 <span class="keywordflow">while</span> (<a class="code" href="group__DBusHashTable.html#g723e61fcc91ca673e90ff872c07ea19c">_dbus_hash_iter_next</a> (&iter))
<a name="l01725"></a>01725 ++count;
<a name="l01726"></a>01726
<a name="l01727"></a>01727 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (count == <a class="code" href="group__DBusHashTable.html#gd48297fc27442c19a7c4bd4d1ef9ef77">_dbus_hash_table_get_n_entries</a> (table));
<a name="l01728"></a>01728
<a name="l01729"></a>01729 <span class="keywordflow">return</span> count;
<a name="l01730"></a>01730 }
<a name="l01731"></a>01731
<a name="l01732"></a>01732 <span class="comment">/* Copy the foo\0bar\0 double string thing */</span>
<a name="l01733"></a>01733 <span class="keyword">static</span> <span class="keywordtype">char</span>*
<a name="l01734"></a>01734 _dbus_strdup2 (<span class="keyword">const</span> <span class="keywordtype">char</span> *str)
<a name="l01735"></a>01735 {
<a name="l01736"></a>01736 size_t len;
<a name="l01737"></a>01737 <span class="keywordtype">char</span> *copy;
<a name="l01738"></a>01738
<a name="l01739"></a>01739 <span class="keywordflow">if</span> (str == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l01740"></a>01740 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l01741"></a>01741
<a name="l01742"></a>01742 len = strlen (str);
<a name="l01743"></a>01743 len += strlen ((str + len + 1));
<a name="l01744"></a>01744
<a name="l01745"></a>01745 copy = <a class="code" href="group__DBusMemory.html#g0fff22bd7f055f5581a9898116a744b1">dbus_malloc</a> (len + 2);
<a name="l01746"></a>01746 <span class="keywordflow">if</span> (copy == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l01747"></a>01747 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l01748"></a>01748
<a name="l01749"></a>01749 memcpy (copy, str, len + 2);
<a name="l01750"></a>01750
<a name="l01751"></a>01751 <span class="keywordflow">return</span> copy;
<a name="l01752"></a>01752 }
<a name="l01753"></a>01753
<a name="l01759"></a>01759 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a>
<a name="l01760"></a>01760 _dbus_hash_test (<span class="keywordtype">void</span>)
<a name="l01761"></a>01761 {
<a name="l01762"></a>01762 <span class="keywordtype">int</span> i;
<a name="l01763"></a>01763 <a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table1;
<a name="l01764"></a>01764 <a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table2;
<a name="l01765"></a>01765 <a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table3;
<a name="l01766"></a>01766 <a class="code" href="structDBusHashTable.html">DBusHashTable</a> *table4;
<a name="l01767"></a>01767 <a class="code" href="structDBusHashIter.html">DBusHashIter</a> iter;
<a name="l01768"></a>01768 <span class="preprocessor">#define N_HASH_KEYS 5000</span>
<a name="l01769"></a>01769 <span class="preprocessor"></span> <span class="keywordtype">char</span> **keys;
<a name="l01770"></a>01770 <a class="code" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a> ret = <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>;
<a name="l01771"></a>01771
<a name="l01772"></a>01772 keys = <a class="code" href="group__DBusMemory.html#g54ccb556e7964112a825a7f46c156ca0">dbus_new</a> (<span class="keywordtype">char</span> *, N_HASH_KEYS);
<a name="l01773"></a>01773 <span class="keywordflow">if</span> (keys == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l01774"></a>01774 <a class="code" href="group__DBusInternalsUtils.html#g0c4961ec784874f1b1f3aeccea8d3da1">_dbus_assert_not_reached</a> (<span class="stringliteral">"no memory"</span>);
<a name="l01775"></a>01775
<a name="l01776"></a>01776 <span class="keywordflow">for</span> (i = 0; i < N_HASH_KEYS; i++)
<a name="l01777"></a>01777 {
<a name="l01778"></a>01778 keys[i] = <a class="code" href="group__DBusMemory.html#g0fff22bd7f055f5581a9898116a744b1">dbus_malloc</a> (128);
<a name="l01779"></a>01779
<a name="l01780"></a>01780 <span class="keywordflow">if</span> (keys[i] == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l01781"></a>01781 <a class="code" href="group__DBusInternalsUtils.html#g0c4961ec784874f1b1f3aeccea8d3da1">_dbus_assert_not_reached</a> (<span class="stringliteral">"no memory"</span>);
<a name="l01782"></a>01782 }
<a name="l01783"></a>01783
<a name="l01784"></a>01784 printf (<span class="stringliteral">"Computing test hash keys...\n"</span>);
<a name="l01785"></a>01785 i = 0;
<a name="l01786"></a>01786 <span class="keywordflow">while</span> (i < N_HASH_KEYS)
<a name="l01787"></a>01787 {
<a name="l01788"></a>01788 <span class="keywordtype">int</span> len;
<a name="l01789"></a>01789
<a name="l01790"></a>01790 <span class="comment">/* all the hash keys are TWO_STRINGS, but</span>
<a name="l01791"></a>01791 <span class="comment"> * then we can also use those as regular strings.</span>
<a name="l01792"></a>01792 <span class="comment"> */</span>
<a name="l01793"></a>01793
<a name="l01794"></a>01794 len = sprintf (keys[i], <span class="stringliteral">"Hash key %d"</span>, i);
<a name="l01795"></a>01795 sprintf (keys[i] + len + 1, <span class="stringliteral">"Two string %d"</span>, i);
<a name="l01796"></a>01796 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (*(keys[i] + len) == <span class="charliteral">'\0'</span>);
<a name="l01797"></a>01797 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (*(keys[i] + len + 1) != <span class="charliteral">'\0'</span>);
<a name="l01798"></a>01798 ++i;
<a name="l01799"></a>01799 }
<a name="l01800"></a>01800 printf (<span class="stringliteral">"... done.\n"</span>);
<a name="l01801"></a>01801
<a name="l01802"></a>01802 table1 = <a class="code" href="group__DBusHashTable.html#gc8e434348a354b9606d4c50c127a5eb4">_dbus_hash_table_new</a> (<a class="code" href="group__DBusHashTable.html#ggb0ab9767ffa5b6720a13b3d741630852481fd0166d28da725b3e97f15192434e">DBUS_HASH_STRING</a>,
<a name="l01803"></a>01803 <a class="code" href="group__DBusMemory.html#g488c6b08cc8c1ddf0203243c4b27a13c">dbus_free</a>, <a class="code" href="group__DBusMemory.html#g488c6b08cc8c1ddf0203243c4b27a13c">dbus_free</a>);
<a name="l01804"></a>01804 <span class="keywordflow">if</span> (table1 == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l01805"></a>01805 <span class="keywordflow">goto</span> out;
<a name="l01806"></a>01806
<a name="l01807"></a>01807 table2 = <a class="code" href="group__DBusHashTable.html#gc8e434348a354b9606d4c50c127a5eb4">_dbus_hash_table_new</a> (<a class="code" href="group__DBusHashTable.html#ggb0ab9767ffa5b6720a13b3d74163085226446bd9fbb15c6c381b35a810207141">DBUS_HASH_INT</a>,
<a name="l01808"></a>01808 <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>, <a class="code" href="group__DBusMemory.html#g488c6b08cc8c1ddf0203243c4b27a13c">dbus_free</a>);
<a name="l01809"></a>01809 <span class="keywordflow">if</span> (table2 == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l01810"></a>01810 <span class="keywordflow">goto</span> out;
<a name="l01811"></a>01811
<a name="l01812"></a>01812 table3 = <a class="code" href="group__DBusHashTable.html#gc8e434348a354b9606d4c50c127a5eb4">_dbus_hash_table_new</a> (<a class="code" href="group__DBusHashTable.html#ggb0ab9767ffa5b6720a13b3d741630852f9b5230298187cd6953dbcac824b2e4c">DBUS_HASH_ULONG</a>,
<a name="l01813"></a>01813 <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>, <a class="code" href="group__DBusMemory.html#g488c6b08cc8c1ddf0203243c4b27a13c">dbus_free</a>);
<a name="l01814"></a>01814 <span class="keywordflow">if</span> (table3 == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l01815"></a>01815 <span class="keywordflow">goto</span> out;
<a name="l01816"></a>01816
<a name="l01817"></a>01817 table4 = <a class="code" href="group__DBusHashTable.html#gc8e434348a354b9606d4c50c127a5eb4">_dbus_hash_table_new</a> (<a class="code" href="group__DBusHashTable.html#ggb0ab9767ffa5b6720a13b3d741630852c750b865c7994a3dd6d1028b7ae76877">DBUS_HASH_TWO_STRINGS</a>,
<a name="l01818"></a>01818 <a class="code" href="group__DBusMemory.html#g488c6b08cc8c1ddf0203243c4b27a13c">dbus_free</a>, <a class="code" href="group__DBusMemory.html#g488c6b08cc8c1ddf0203243c4b27a13c">dbus_free</a>);
<a name="l01819"></a>01819 <span class="keywordflow">if</span> (table4 == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l01820"></a>01820 <span class="keywordflow">goto</span> out;
<a name="l01821"></a>01821
<a name="l01822"></a>01822
<a name="l01823"></a>01823 <span class="comment">/* Insert and remove a bunch of stuff, counting the table in between</span>
<a name="l01824"></a>01824 <span class="comment"> * to be sure it's not broken and that iteration works</span>
<a name="l01825"></a>01825 <span class="comment"> */</span>
<a name="l01826"></a>01826 i = 0;
<a name="l01827"></a>01827 <span class="keywordflow">while</span> (i < 3000)
<a name="l01828"></a>01828 {
<a name="l01829"></a>01829 <span class="keywordtype">void</span> *value;
<a name="l01830"></a>01830 <span class="keywordtype">char</span> *key;
<a name="l01831"></a>01831
<a name="l01832"></a>01832 key = <a class="code" href="group__DBusInternalsUtils.html#g9d00d77f6595b9d7ac1baf59d44bf58c">_dbus_strdup</a> (keys[i]);
<a name="l01833"></a>01833 <span class="keywordflow">if</span> (key == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l01834"></a>01834 <span class="keywordflow">goto</span> out;
<a name="l01835"></a>01835 value = <a class="code" href="group__DBusInternalsUtils.html#g9d00d77f6595b9d7ac1baf59d44bf58c">_dbus_strdup</a> (<span class="stringliteral">"Value!"</span>);
<a name="l01836"></a>01836 <span class="keywordflow">if</span> (value == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l01837"></a>01837 <span class="keywordflow">goto</span> out;
<a name="l01838"></a>01838
<a name="l01839"></a>01839 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusHashTable.html#g43e98a91a11952824c544330e19f6c22">_dbus_hash_table_insert_string</a> (table1,
<a name="l01840"></a>01840 key, value))
<a name="l01841"></a>01841 <span class="keywordflow">goto</span> out;
<a name="l01842"></a>01842
<a name="l01843"></a>01843 value = <a class="code" href="group__DBusInternalsUtils.html#g9d00d77f6595b9d7ac1baf59d44bf58c">_dbus_strdup</a> (keys[i]);
<a name="l01844"></a>01844 <span class="keywordflow">if</span> (value == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l01845"></a>01845 <span class="keywordflow">goto</span> out;
<a name="l01846"></a>01846
<a name="l01847"></a>01847 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusHashTable.html#gca20a83f3214db08fa34df2c49c8edd5">_dbus_hash_table_insert_int</a> (table2,
<a name="l01848"></a>01848 i, value))
<a name="l01849"></a>01849 <span class="keywordflow">goto</span> out;
<a name="l01850"></a>01850
<a name="l01851"></a>01851 value = <a class="code" href="group__DBusInternalsUtils.html#g9d00d77f6595b9d7ac1baf59d44bf58c">_dbus_strdup</a> (keys[i]);
<a name="l01852"></a>01852 <span class="keywordflow">if</span> (value == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l01853"></a>01853 <span class="keywordflow">goto</span> out;
<a name="l01854"></a>01854
<a name="l01855"></a>01855 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusHashTable.html#gf40df7d2c9b05a67ac8c80d9ed88175c">_dbus_hash_table_insert_ulong</a> (table3,
<a name="l01856"></a>01856 i, value))
<a name="l01857"></a>01857 <span class="keywordflow">goto</span> out;
<a name="l01858"></a>01858
<a name="l01859"></a>01859 key = _dbus_strdup2 (keys[i]);
<a name="l01860"></a>01860 <span class="keywordflow">if</span> (key == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l01861"></a>01861 <span class="keywordflow">goto</span> out;
<a name="l01862"></a>01862 value = <a class="code" href="group__DBusInternalsUtils.html#g9d00d77f6595b9d7ac1baf59d44bf58c">_dbus_strdup</a> (<span class="stringliteral">"Value!"</span>);
<a name="l01863"></a>01863 <span class="keywordflow">if</span> (value == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l01864"></a>01864 <span class="keywordflow">goto</span> out;
<a name="l01865"></a>01865
<a name="l01866"></a>01866 <span class="keywordflow">if</span> (!_dbus_hash_table_insert_two_strings (table4,
<a name="l01867"></a>01867 key, value))
<a name="l01868"></a>01868 <span class="keywordflow">goto</span> out;
<a name="l01869"></a>01869
<a name="l01870"></a>01870 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (count_entries (table1) == i + 1);
<a name="l01871"></a>01871 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (count_entries (table2) == i + 1);
<a name="l01872"></a>01872 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (count_entries (table3) == i + 1);
<a name="l01873"></a>01873 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (count_entries (table4) == i + 1);
<a name="l01874"></a>01874
<a name="l01875"></a>01875 value = <a class="code" href="group__DBusHashTable.html#gd51eb3fe682721dd4f6a920ca87cb730">_dbus_hash_table_lookup_string</a> (table1, keys[i]);
<a name="l01876"></a>01876 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (value != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l01877"></a>01877 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (strcmp (value, <span class="stringliteral">"Value!"</span>) == 0);
<a name="l01878"></a>01878
<a name="l01879"></a>01879 value = <a class="code" href="group__DBusHashTable.html#g36ff49c4c35599e6fcdadc7f6805c49e">_dbus_hash_table_lookup_int</a> (table2, i);
<a name="l01880"></a>01880 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (value != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l01881"></a>01881 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (strcmp (value, keys[i]) == 0);
<a name="l01882"></a>01882
<a name="l01883"></a>01883 value = <a class="code" href="group__DBusHashTable.html#g5d9caa38b663955ee0c4766f66e4e317">_dbus_hash_table_lookup_ulong</a> (table3, i);
<a name="l01884"></a>01884 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (value != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l01885"></a>01885 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (strcmp (value, keys[i]) == 0);
<a name="l01886"></a>01886
<a name="l01887"></a>01887 value = _dbus_hash_table_lookup_two_strings (table4, keys[i]);
<a name="l01888"></a>01888 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (value != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l01889"></a>01889 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (strcmp (value, <span class="stringliteral">"Value!"</span>) == 0);
<a name="l01890"></a>01890
<a name="l01891"></a>01891 ++i;
<a name="l01892"></a>01892 }
<a name="l01893"></a>01893
<a name="l01894"></a>01894 --i;
<a name="l01895"></a>01895 <span class="keywordflow">while</span> (i >= 0)
<a name="l01896"></a>01896 {
<a name="l01897"></a>01897 <a class="code" href="group__DBusHashTable.html#g388d50ce1a07bf0790b9f2ecdb08a396">_dbus_hash_table_remove_string</a> (table1,
<a name="l01898"></a>01898 keys[i]);
<a name="l01899"></a>01899
<a name="l01900"></a>01900 <a class="code" href="group__DBusHashTable.html#gcdebe75bd692605a69dc73c15e0eefd0">_dbus_hash_table_remove_int</a> (table2, i);
<a name="l01901"></a>01901
<a name="l01902"></a>01902 <a class="code" href="group__DBusHashTable.html#g2211f0b52ae08e195186b7d438913b11">_dbus_hash_table_remove_ulong</a> (table3, i);
<a name="l01903"></a>01903
<a name="l01904"></a>01904 _dbus_hash_table_remove_two_strings (table4,
<a name="l01905"></a>01905 keys[i]);
<a name="l01906"></a>01906
<a name="l01907"></a>01907 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (count_entries (table1) == i);
<a name="l01908"></a>01908 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (count_entries (table2) == i);
<a name="l01909"></a>01909 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (count_entries (table3) == i);
<a name="l01910"></a>01910 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (count_entries (table4) == i);
<a name="l01911"></a>01911
<a name="l01912"></a>01912 --i;
<a name="l01913"></a>01913 }
<a name="l01914"></a>01914
<a name="l01915"></a>01915 <a class="code" href="group__DBusHashTable.html#g4ad4622378885e5d911c26956e174a45">_dbus_hash_table_ref</a> (table1);
<a name="l01916"></a>01916 <a class="code" href="group__DBusHashTable.html#g4ad4622378885e5d911c26956e174a45">_dbus_hash_table_ref</a> (table2);
<a name="l01917"></a>01917 <a class="code" href="group__DBusHashTable.html#g4ad4622378885e5d911c26956e174a45">_dbus_hash_table_ref</a> (table3);
<a name="l01918"></a>01918 <a class="code" href="group__DBusHashTable.html#g4ad4622378885e5d911c26956e174a45">_dbus_hash_table_ref</a> (table4);
<a name="l01919"></a>01919 <a class="code" href="group__DBusHashTable.html#g96b777e00764b44e0f3216fd8478f5a9">_dbus_hash_table_unref</a> (table1);
<a name="l01920"></a>01920 <a class="code" href="group__DBusHashTable.html#g96b777e00764b44e0f3216fd8478f5a9">_dbus_hash_table_unref</a> (table2);
<a name="l01921"></a>01921 <a class="code" href="group__DBusHashTable.html#g96b777e00764b44e0f3216fd8478f5a9">_dbus_hash_table_unref</a> (table3);
<a name="l01922"></a>01922 <a class="code" href="group__DBusHashTable.html#g96b777e00764b44e0f3216fd8478f5a9">_dbus_hash_table_unref</a> (table4);
<a name="l01923"></a>01923 <a class="code" href="group__DBusHashTable.html#g96b777e00764b44e0f3216fd8478f5a9">_dbus_hash_table_unref</a> (table1);
<a name="l01924"></a>01924 <a class="code" href="group__DBusHashTable.html#g96b777e00764b44e0f3216fd8478f5a9">_dbus_hash_table_unref</a> (table2);
<a name="l01925"></a>01925 <a class="code" href="group__DBusHashTable.html#g96b777e00764b44e0f3216fd8478f5a9">_dbus_hash_table_unref</a> (table3);
<a name="l01926"></a>01926 <a class="code" href="group__DBusHashTable.html#g96b777e00764b44e0f3216fd8478f5a9">_dbus_hash_table_unref</a> (table4);
<a name="l01927"></a>01927 table3 = <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l01928"></a>01928
<a name="l01929"></a>01929 <span class="comment">/* Insert a bunch of stuff then check</span>
<a name="l01930"></a>01930 <span class="comment"> * that iteration works correctly (finds the right</span>
<a name="l01931"></a>01931 <span class="comment"> * values, iter_set_value works, etc.)</span>
<a name="l01932"></a>01932 <span class="comment"> */</span>
<a name="l01933"></a>01933 table1 = <a class="code" href="group__DBusHashTable.html#gc8e434348a354b9606d4c50c127a5eb4">_dbus_hash_table_new</a> (<a class="code" href="group__DBusHashTable.html#ggb0ab9767ffa5b6720a13b3d741630852481fd0166d28da725b3e97f15192434e">DBUS_HASH_STRING</a>,
<a name="l01934"></a>01934 <a class="code" href="group__DBusMemory.html#g488c6b08cc8c1ddf0203243c4b27a13c">dbus_free</a>, <a class="code" href="group__DBusMemory.html#g488c6b08cc8c1ddf0203243c4b27a13c">dbus_free</a>);
<a name="l01935"></a>01935 <span class="keywordflow">if</span> (table1 == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l01936"></a>01936 <span class="keywordflow">goto</span> out;
<a name="l01937"></a>01937
<a name="l01938"></a>01938 table2 = <a class="code" href="group__DBusHashTable.html#gc8e434348a354b9606d4c50c127a5eb4">_dbus_hash_table_new</a> (<a class="code" href="group__DBusHashTable.html#ggb0ab9767ffa5b6720a13b3d74163085226446bd9fbb15c6c381b35a810207141">DBUS_HASH_INT</a>,
<a name="l01939"></a>01939 <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>, <a class="code" href="group__DBusMemory.html#g488c6b08cc8c1ddf0203243c4b27a13c">dbus_free</a>);
<a name="l01940"></a>01940 <span class="keywordflow">if</span> (table2 == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l01941"></a>01941 <span class="keywordflow">goto</span> out;
<a name="l01942"></a>01942
<a name="l01943"></a>01943 i = 0;
<a name="l01944"></a>01944 <span class="keywordflow">while</span> (i < 5000)
<a name="l01945"></a>01945 {
<a name="l01946"></a>01946 <span class="keywordtype">char</span> *key;
<a name="l01947"></a>01947 <span class="keywordtype">void</span> *value;
<a name="l01948"></a>01948
<a name="l01949"></a>01949 key = <a class="code" href="group__DBusInternalsUtils.html#g9d00d77f6595b9d7ac1baf59d44bf58c">_dbus_strdup</a> (keys[i]);
<a name="l01950"></a>01950 <span class="keywordflow">if</span> (key == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l01951"></a>01951 <span class="keywordflow">goto</span> out;
<a name="l01952"></a>01952 value = <a class="code" href="group__DBusInternalsUtils.html#g9d00d77f6595b9d7ac1baf59d44bf58c">_dbus_strdup</a> (<span class="stringliteral">"Value!"</span>);
<a name="l01953"></a>01953 <span class="keywordflow">if</span> (value == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l01954"></a>01954 <span class="keywordflow">goto</span> out;
<a name="l01955"></a>01955
<a name="l01956"></a>01956 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusHashTable.html#g43e98a91a11952824c544330e19f6c22">_dbus_hash_table_insert_string</a> (table1,
<a name="l01957"></a>01957 key, value))
<a name="l01958"></a>01958 <span class="keywordflow">goto</span> out;
<a name="l01959"></a>01959
<a name="l01960"></a>01960 value = <a class="code" href="group__DBusInternalsUtils.html#g9d00d77f6595b9d7ac1baf59d44bf58c">_dbus_strdup</a> (keys[i]);
<a name="l01961"></a>01961 <span class="keywordflow">if</span> (value == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l01962"></a>01962 <span class="keywordflow">goto</span> out;
<a name="l01963"></a>01963
<a name="l01964"></a>01964 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusHashTable.html#gca20a83f3214db08fa34df2c49c8edd5">_dbus_hash_table_insert_int</a> (table2,
<a name="l01965"></a>01965 i, value))
<a name="l01966"></a>01966 <span class="keywordflow">goto</span> out;
<a name="l01967"></a>01967
<a name="l01968"></a>01968 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (count_entries (table1) == i + 1);
<a name="l01969"></a>01969 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (count_entries (table2) == i + 1);
<a name="l01970"></a>01970
<a name="l01971"></a>01971 ++i;
<a name="l01972"></a>01972 }
<a name="l01973"></a>01973
<a name="l01974"></a>01974 <a class="code" href="group__DBusHashTable.html#g1b0e6df8a8617ef0f8f25adfba3acc4c">_dbus_hash_iter_init</a> (table1, &iter);
<a name="l01975"></a>01975 <span class="keywordflow">while</span> (<a class="code" href="group__DBusHashTable.html#g723e61fcc91ca673e90ff872c07ea19c">_dbus_hash_iter_next</a> (&iter))
<a name="l01976"></a>01976 {
<a name="l01977"></a>01977 <span class="keyword">const</span> <span class="keywordtype">char</span> *key;
<a name="l01978"></a>01978 <span class="keywordtype">void</span> *value;
<a name="l01979"></a>01979
<a name="l01980"></a>01980 key = <a class="code" href="group__DBusHashTable.html#ga0cff082174b1ab0380902ce4ae43d08">_dbus_hash_iter_get_string_key</a> (&iter);
<a name="l01981"></a>01981 value = <a class="code" href="group__DBusHashTable.html#g34bf277ee37f919bd00516b5ae4e12b5">_dbus_hash_iter_get_value</a> (&iter);
<a name="l01982"></a>01982
<a name="l01983"></a>01983 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (<a class="code" href="group__DBusHashTable.html#gd51eb3fe682721dd4f6a920ca87cb730">_dbus_hash_table_lookup_string</a> (table1, key) == value);
<a name="l01984"></a>01984
<a name="l01985"></a>01985 value = <a class="code" href="group__DBusInternalsUtils.html#g9d00d77f6595b9d7ac1baf59d44bf58c">_dbus_strdup</a> (<span class="stringliteral">"Different value!"</span>);
<a name="l01986"></a>01986 <span class="keywordflow">if</span> (value == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l01987"></a>01987 <span class="keywordflow">goto</span> out;
<a name="l01988"></a>01988
<a name="l01989"></a>01989 <a class="code" href="group__DBusHashTable.html#g24193343c0948019d4a302fc18bfd5d9">_dbus_hash_iter_set_value</a> (&iter, value);
<a name="l01990"></a>01990
<a name="l01991"></a>01991 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (<a class="code" href="group__DBusHashTable.html#gd51eb3fe682721dd4f6a920ca87cb730">_dbus_hash_table_lookup_string</a> (table1, key) == value);
<a name="l01992"></a>01992 }
<a name="l01993"></a>01993
<a name="l01994"></a>01994 <a class="code" href="group__DBusHashTable.html#g1b0e6df8a8617ef0f8f25adfba3acc4c">_dbus_hash_iter_init</a> (table1, &iter);
<a name="l01995"></a>01995 <span class="keywordflow">while</span> (<a class="code" href="group__DBusHashTable.html#g723e61fcc91ca673e90ff872c07ea19c">_dbus_hash_iter_next</a> (&iter))
<a name="l01996"></a>01996 {
<a name="l01997"></a>01997 <a class="code" href="group__DBusHashTable.html#g0ef12d773a546f070cff91cbf1e8d16e">_dbus_hash_iter_remove_entry</a> (&iter);
<a name="l01998"></a>01998 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (count_entries (table1) == i - 1);
<a name="l01999"></a>01999 --i;
<a name="l02000"></a>02000 }
<a name="l02001"></a>02001
<a name="l02002"></a>02002 <a class="code" href="group__DBusHashTable.html#g1b0e6df8a8617ef0f8f25adfba3acc4c">_dbus_hash_iter_init</a> (table2, &iter);
<a name="l02003"></a>02003 <span class="keywordflow">while</span> (<a class="code" href="group__DBusHashTable.html#g723e61fcc91ca673e90ff872c07ea19c">_dbus_hash_iter_next</a> (&iter))
<a name="l02004"></a>02004 {
<a name="l02005"></a>02005 <span class="keywordtype">int</span> key;
<a name="l02006"></a>02006 <span class="keywordtype">void</span> *value;
<a name="l02007"></a>02007
<a name="l02008"></a>02008 key = <a class="code" href="group__DBusHashTable.html#g7a1b9fd35f9f7bdd86f9d71a6379053f">_dbus_hash_iter_get_int_key</a> (&iter);
<a name="l02009"></a>02009 value = <a class="code" href="group__DBusHashTable.html#g34bf277ee37f919bd00516b5ae4e12b5">_dbus_hash_iter_get_value</a> (&iter);
<a name="l02010"></a>02010
<a name="l02011"></a>02011 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (<a class="code" href="group__DBusHashTable.html#g36ff49c4c35599e6fcdadc7f6805c49e">_dbus_hash_table_lookup_int</a> (table2, key) == value);
<a name="l02012"></a>02012
<a name="l02013"></a>02013 value = <a class="code" href="group__DBusInternalsUtils.html#g9d00d77f6595b9d7ac1baf59d44bf58c">_dbus_strdup</a> (<span class="stringliteral">"Different value!"</span>);
<a name="l02014"></a>02014 <span class="keywordflow">if</span> (value == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l02015"></a>02015 <span class="keywordflow">goto</span> out;
<a name="l02016"></a>02016
<a name="l02017"></a>02017 <a class="code" href="group__DBusHashTable.html#g24193343c0948019d4a302fc18bfd5d9">_dbus_hash_iter_set_value</a> (&iter, value);
<a name="l02018"></a>02018
<a name="l02019"></a>02019 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (<a class="code" href="group__DBusHashTable.html#g36ff49c4c35599e6fcdadc7f6805c49e">_dbus_hash_table_lookup_int</a> (table2, key) == value);
<a name="l02020"></a>02020 }
<a name="l02021"></a>02021
<a name="l02022"></a>02022 i = count_entries (table2);
<a name="l02023"></a>02023 <a class="code" href="group__DBusHashTable.html#g1b0e6df8a8617ef0f8f25adfba3acc4c">_dbus_hash_iter_init</a> (table2, &iter);
<a name="l02024"></a>02024 <span class="keywordflow">while</span> (<a class="code" href="group__DBusHashTable.html#g723e61fcc91ca673e90ff872c07ea19c">_dbus_hash_iter_next</a> (&iter))
<a name="l02025"></a>02025 {
<a name="l02026"></a>02026 <a class="code" href="group__DBusHashTable.html#g0ef12d773a546f070cff91cbf1e8d16e">_dbus_hash_iter_remove_entry</a> (&iter);
<a name="l02027"></a>02027 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (count_entries (table2) + 1 == i);
<a name="l02028"></a>02028 --i;
<a name="l02029"></a>02029 }
<a name="l02030"></a>02030
<a name="l02031"></a>02031 <span class="comment">/* add/remove interleaved, to check that we grow/shrink the table</span>
<a name="l02032"></a>02032 <span class="comment"> * appropriately</span>
<a name="l02033"></a>02033 <span class="comment"> */</span>
<a name="l02034"></a>02034 i = 0;
<a name="l02035"></a>02035 <span class="keywordflow">while</span> (i < 1000)
<a name="l02036"></a>02036 {
<a name="l02037"></a>02037 <span class="keywordtype">char</span> *key;
<a name="l02038"></a>02038 <span class="keywordtype">void</span> *value;
<a name="l02039"></a>02039
<a name="l02040"></a>02040 key = <a class="code" href="group__DBusInternalsUtils.html#g9d00d77f6595b9d7ac1baf59d44bf58c">_dbus_strdup</a> (keys[i]);
<a name="l02041"></a>02041 <span class="keywordflow">if</span> (key == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l02042"></a>02042 <span class="keywordflow">goto</span> out;
<a name="l02043"></a>02043
<a name="l02044"></a>02044 value = <a class="code" href="group__DBusInternalsUtils.html#g9d00d77f6595b9d7ac1baf59d44bf58c">_dbus_strdup</a> (<span class="stringliteral">"Value!"</span>);
<a name="l02045"></a>02045 <span class="keywordflow">if</span> (value == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l02046"></a>02046 <span class="keywordflow">goto</span> out;
<a name="l02047"></a>02047
<a name="l02048"></a>02048 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusHashTable.html#g43e98a91a11952824c544330e19f6c22">_dbus_hash_table_insert_string</a> (table1,
<a name="l02049"></a>02049 key, value))
<a name="l02050"></a>02050 <span class="keywordflow">goto</span> out;
<a name="l02051"></a>02051
<a name="l02052"></a>02052 ++i;
<a name="l02053"></a>02053 }
<a name="l02054"></a>02054
<a name="l02055"></a>02055 --i;
<a name="l02056"></a>02056 <span class="keywordflow">while</span> (i >= 0)
<a name="l02057"></a>02057 {
<a name="l02058"></a>02058 <span class="keywordtype">char</span> *key;
<a name="l02059"></a>02059 <span class="keywordtype">void</span> *value;
<a name="l02060"></a>02060
<a name="l02061"></a>02061 key = <a class="code" href="group__DBusInternalsUtils.html#g9d00d77f6595b9d7ac1baf59d44bf58c">_dbus_strdup</a> (keys[i]);
<a name="l02062"></a>02062 <span class="keywordflow">if</span> (key == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l02063"></a>02063 <span class="keywordflow">goto</span> out;
<a name="l02064"></a>02064 value = <a class="code" href="group__DBusInternalsUtils.html#g9d00d77f6595b9d7ac1baf59d44bf58c">_dbus_strdup</a> (<span class="stringliteral">"Value!"</span>);
<a name="l02065"></a>02065 <span class="keywordflow">if</span> (value == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l02066"></a>02066 <span class="keywordflow">goto</span> out;
<a name="l02067"></a>02067
<a name="l02068"></a>02068 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusHashTable.html#g388d50ce1a07bf0790b9f2ecdb08a396">_dbus_hash_table_remove_string</a> (table1, keys[i]))
<a name="l02069"></a>02069 <span class="keywordflow">goto</span> out;
<a name="l02070"></a>02070
<a name="l02071"></a>02071 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusHashTable.html#g43e98a91a11952824c544330e19f6c22">_dbus_hash_table_insert_string</a> (table1,
<a name="l02072"></a>02072 key, value))
<a name="l02073"></a>02073 <span class="keywordflow">goto</span> out;
<a name="l02074"></a>02074
<a name="l02075"></a>02075 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusHashTable.html#g388d50ce1a07bf0790b9f2ecdb08a396">_dbus_hash_table_remove_string</a> (table1, keys[i]))
<a name="l02076"></a>02076 <span class="keywordflow">goto</span> out;
<a name="l02077"></a>02077
<a name="l02078"></a>02078 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (<a class="code" href="group__DBusHashTable.html#gd48297fc27442c19a7c4bd4d1ef9ef77">_dbus_hash_table_get_n_entries</a> (table1) == i);
<a name="l02079"></a>02079
<a name="l02080"></a>02080 --i;
<a name="l02081"></a>02081 }
<a name="l02082"></a>02082
<a name="l02083"></a>02083 <span class="comment">/* nuke these tables */</span>
<a name="l02084"></a>02084 <a class="code" href="group__DBusHashTable.html#g96b777e00764b44e0f3216fd8478f5a9">_dbus_hash_table_unref</a> (table1);
<a name="l02085"></a>02085 <a class="code" href="group__DBusHashTable.html#g96b777e00764b44e0f3216fd8478f5a9">_dbus_hash_table_unref</a> (table2);
<a name="l02086"></a>02086
<a name="l02087"></a>02087
<a name="l02088"></a>02088 <span class="comment">/* Now do a bunch of things again using _dbus_hash_iter_lookup() to</span>
<a name="l02089"></a>02089 <span class="comment"> * be sure that interface works.</span>
<a name="l02090"></a>02090 <span class="comment"> */</span>
<a name="l02091"></a>02091 table1 = <a class="code" href="group__DBusHashTable.html#gc8e434348a354b9606d4c50c127a5eb4">_dbus_hash_table_new</a> (<a class="code" href="group__DBusHashTable.html#ggb0ab9767ffa5b6720a13b3d741630852481fd0166d28da725b3e97f15192434e">DBUS_HASH_STRING</a>,
<a name="l02092"></a>02092 <a class="code" href="group__DBusMemory.html#g488c6b08cc8c1ddf0203243c4b27a13c">dbus_free</a>, <a class="code" href="group__DBusMemory.html#g488c6b08cc8c1ddf0203243c4b27a13c">dbus_free</a>);
<a name="l02093"></a>02093 <span class="keywordflow">if</span> (table1 == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l02094"></a>02094 <span class="keywordflow">goto</span> out;
<a name="l02095"></a>02095
<a name="l02096"></a>02096 table2 = <a class="code" href="group__DBusHashTable.html#gc8e434348a354b9606d4c50c127a5eb4">_dbus_hash_table_new</a> (<a class="code" href="group__DBusHashTable.html#ggb0ab9767ffa5b6720a13b3d74163085226446bd9fbb15c6c381b35a810207141">DBUS_HASH_INT</a>,
<a name="l02097"></a>02097 <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>, <a class="code" href="group__DBusMemory.html#g488c6b08cc8c1ddf0203243c4b27a13c">dbus_free</a>);
<a name="l02098"></a>02098 <span class="keywordflow">if</span> (table2 == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l02099"></a>02099 <span class="keywordflow">goto</span> out;
<a name="l02100"></a>02100
<a name="l02101"></a>02101 i = 0;
<a name="l02102"></a>02102 <span class="keywordflow">while</span> (i < 3000)
<a name="l02103"></a>02103 {
<a name="l02104"></a>02104 <span class="keywordtype">void</span> *value;
<a name="l02105"></a>02105 <span class="keywordtype">char</span> *key;
<a name="l02106"></a>02106
<a name="l02107"></a>02107 key = <a class="code" href="group__DBusInternalsUtils.html#g9d00d77f6595b9d7ac1baf59d44bf58c">_dbus_strdup</a> (keys[i]);
<a name="l02108"></a>02108 <span class="keywordflow">if</span> (key == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l02109"></a>02109 <span class="keywordflow">goto</span> out;
<a name="l02110"></a>02110 value = <a class="code" href="group__DBusInternalsUtils.html#g9d00d77f6595b9d7ac1baf59d44bf58c">_dbus_strdup</a> (<span class="stringliteral">"Value!"</span>);
<a name="l02111"></a>02111 <span class="keywordflow">if</span> (value == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l02112"></a>02112 <span class="keywordflow">goto</span> out;
<a name="l02113"></a>02113
<a name="l02114"></a>02114 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusHashTable.html#gb156c35d6dd9ff6e408a835db28323fb">_dbus_hash_iter_lookup</a> (table1,
<a name="l02115"></a>02115 key, <a class="code" href="group__DBusMacros.html#ga8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>, &iter))
<a name="l02116"></a>02116 <span class="keywordflow">goto</span> out;
<a name="l02117"></a>02117 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (<a class="code" href="group__DBusHashTable.html#g34bf277ee37f919bd00516b5ae4e12b5">_dbus_hash_iter_get_value</a> (&iter) == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l02118"></a>02118 <a class="code" href="group__DBusHashTable.html#g24193343c0948019d4a302fc18bfd5d9">_dbus_hash_iter_set_value</a> (&iter, value);
<a name="l02119"></a>02119
<a name="l02120"></a>02120 value = <a class="code" href="group__DBusInternalsUtils.html#g9d00d77f6595b9d7ac1baf59d44bf58c">_dbus_strdup</a> (keys[i]);
<a name="l02121"></a>02121 <span class="keywordflow">if</span> (value == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l02122"></a>02122 <span class="keywordflow">goto</span> out;
<a name="l02123"></a>02123
<a name="l02124"></a>02124 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusHashTable.html#gb156c35d6dd9ff6e408a835db28323fb">_dbus_hash_iter_lookup</a> (table2,
<a name="l02125"></a>02125 <a class="code" href="group__DBusInternalsUtils.html#g05e902d8504a8a0e0b183fd2e20e329f">_DBUS_INT_TO_POINTER</a> (i), <a class="code" href="group__DBusMacros.html#ga8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>, &iter))
<a name="l02126"></a>02126 <span class="keywordflow">goto</span> out;
<a name="l02127"></a>02127 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (<a class="code" href="group__DBusHashTable.html#g34bf277ee37f919bd00516b5ae4e12b5">_dbus_hash_iter_get_value</a> (&iter) == <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l02128"></a>02128 <a class="code" href="group__DBusHashTable.html#g24193343c0948019d4a302fc18bfd5d9">_dbus_hash_iter_set_value</a> (&iter, value);
<a name="l02129"></a>02129
<a name="l02130"></a>02130 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (count_entries (table1) == i + 1);
<a name="l02131"></a>02131 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (count_entries (table2) == i + 1);
<a name="l02132"></a>02132
<a name="l02133"></a>02133 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusHashTable.html#gb156c35d6dd9ff6e408a835db28323fb">_dbus_hash_iter_lookup</a> (table1, keys[i], <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>, &iter))
<a name="l02134"></a>02134 <span class="keywordflow">goto</span> out;
<a name="l02135"></a>02135
<a name="l02136"></a>02136 value = <a class="code" href="group__DBusHashTable.html#g34bf277ee37f919bd00516b5ae4e12b5">_dbus_hash_iter_get_value</a> (&iter);
<a name="l02137"></a>02137 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (value != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l02138"></a>02138 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (strcmp (value, <span class="stringliteral">"Value!"</span>) == 0);
<a name="l02139"></a>02139
<a name="l02140"></a>02140 <span class="comment">/* Iterate just to be sure it works, though</span>
<a name="l02141"></a>02141 <span class="comment"> * it's a stupid thing to do</span>
<a name="l02142"></a>02142 <span class="comment"> */</span>
<a name="l02143"></a>02143 <span class="keywordflow">while</span> (<a class="code" href="group__DBusHashTable.html#g723e61fcc91ca673e90ff872c07ea19c">_dbus_hash_iter_next</a> (&iter))
<a name="l02144"></a>02144 ;
<a name="l02145"></a>02145
<a name="l02146"></a>02146 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusHashTable.html#gb156c35d6dd9ff6e408a835db28323fb">_dbus_hash_iter_lookup</a> (table2, <a class="code" href="group__DBusInternalsUtils.html#g05e902d8504a8a0e0b183fd2e20e329f">_DBUS_INT_TO_POINTER</a> (i), <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>, &iter))
<a name="l02147"></a>02147 <span class="keywordflow">goto</span> out;
<a name="l02148"></a>02148
<a name="l02149"></a>02149 value = <a class="code" href="group__DBusHashTable.html#g34bf277ee37f919bd00516b5ae4e12b5">_dbus_hash_iter_get_value</a> (&iter);
<a name="l02150"></a>02150 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (value != <a class="code" href="group__DBusMacros.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l02151"></a>02151 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (strcmp (value, keys[i]) == 0);
<a name="l02152"></a>02152
<a name="l02153"></a>02153 <span class="comment">/* Iterate just to be sure it works, though</span>
<a name="l02154"></a>02154 <span class="comment"> * it's a stupid thing to do</span>
<a name="l02155"></a>02155 <span class="comment"> */</span>
<a name="l02156"></a>02156 <span class="keywordflow">while</span> (<a class="code" href="group__DBusHashTable.html#g723e61fcc91ca673e90ff872c07ea19c">_dbus_hash_iter_next</a> (&iter))
<a name="l02157"></a>02157 ;
<a name="l02158"></a>02158
<a name="l02159"></a>02159 ++i;
<a name="l02160"></a>02160 }
<a name="l02161"></a>02161
<a name="l02162"></a>02162 --i;
<a name="l02163"></a>02163 <span class="keywordflow">while</span> (i >= 0)
<a name="l02164"></a>02164 {
<a name="l02165"></a>02165 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusHashTable.html#gb156c35d6dd9ff6e408a835db28323fb">_dbus_hash_iter_lookup</a> (table1, keys[i], <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>, &iter))
<a name="l02166"></a>02166 <a class="code" href="group__DBusInternalsUtils.html#g0c4961ec784874f1b1f3aeccea8d3da1">_dbus_assert_not_reached</a> (<span class="stringliteral">"hash entry should have existed"</span>);
<a name="l02167"></a>02167 <a class="code" href="group__DBusHashTable.html#g0ef12d773a546f070cff91cbf1e8d16e">_dbus_hash_iter_remove_entry</a> (&iter);
<a name="l02168"></a>02168
<a name="l02169"></a>02169 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusHashTable.html#gb156c35d6dd9ff6e408a835db28323fb">_dbus_hash_iter_lookup</a> (table2, <a class="code" href="group__DBusInternalsUtils.html#g05e902d8504a8a0e0b183fd2e20e329f">_DBUS_INT_TO_POINTER</a> (i), <a class="code" href="group__DBusMacros.html#ga93f0eb578d23995850d61f7d61c55c1">FALSE</a>, &iter))
<a name="l02170"></a>02170 <a class="code" href="group__DBusInternalsUtils.html#g0c4961ec784874f1b1f3aeccea8d3da1">_dbus_assert_not_reached</a> (<span class="stringliteral">"hash entry should have existed"</span>);
<a name="l02171"></a>02171 <a class="code" href="group__DBusHashTable.html#g0ef12d773a546f070cff91cbf1e8d16e">_dbus_hash_iter_remove_entry</a> (&iter);
<a name="l02172"></a>02172
<a name="l02173"></a>02173 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (count_entries (table1) == i);
<a name="l02174"></a>02174 <a class="code" href="group__DBusInternalsUtils.html#g129c6c03f011cdc171934d5d386cc797">_dbus_assert</a> (count_entries (table2) == i);
<a name="l02175"></a>02175
<a name="l02176"></a>02176 --i;
<a name="l02177"></a>02177 }
<a name="l02178"></a>02178
<a name="l02179"></a>02179 <a class="code" href="group__DBusHashTable.html#g96b777e00764b44e0f3216fd8478f5a9">_dbus_hash_table_unref</a> (table1);
<a name="l02180"></a>02180 <a class="code" href="group__DBusHashTable.html#g96b777e00764b44e0f3216fd8478f5a9">_dbus_hash_table_unref</a> (table2);
<a name="l02181"></a>02181
<a name="l02182"></a>02182 ret = <a class="code" href="group__DBusMacros.html#ga8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>;
<a name="l02183"></a>02183
<a name="l02184"></a>02184 out:
<a name="l02185"></a>02185 <span class="keywordflow">for</span> (i = 0; i < N_HASH_KEYS; i++)
<a name="l02186"></a>02186 <a class="code" href="group__DBusMemory.html#g488c6b08cc8c1ddf0203243c4b27a13c">dbus_free</a> (keys[i]);
<a name="l02187"></a>02187
<a name="l02188"></a>02188 <a class="code" href="group__DBusMemory.html#g488c6b08cc8c1ddf0203243c4b27a13c">dbus_free</a> (keys);
<a name="l02189"></a>02189
<a name="l02190"></a>02190 <span class="keywordflow">return</span> ret;
<a name="l02191"></a>02191 }
<a name="l02192"></a>02192
<a name="l02193"></a>02193 <span class="preprocessor">#endif </span><span class="comment">/* DBUS_BUILD_TESTS */</span>
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Mon Dec 14 22:26:11 2009 for D-Bus by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.7 </small></address>
</body>
</html>