1 /* Copyright (C) 2002 Christopher Clark <firstname.lastname@cl.cam.ac.uk> */
4 #include "hashtable_private.h"
5 #include "hashtable_utility.h"
10 /*****************************************************************************/
13 * function to change the value associated with a key, where there already
14 * exists a value bound to the key in the hashtable.
15 * Source due to Holger Schemel.
19 hashtable_change(struct hashtable
*h
, void *k
, void *v
)
22 unsigned int hashvalue
, index
;
23 hashvalue
= hash(h
,k
);
24 index
= indexFor(h
->tablelength
,hashvalue
);
28 /* Check hash value to short circuit heavier comparison */
29 if ((hashvalue
== e
->h
) && (h
->eqfn(k
, e
->k
)))
41 * Copyright (c) 2002, Christopher Clark
42 * All rights reserved.
44 * Redistribution and use in source and binary forms, with or without
45 * modification, are permitted provided that the following conditions
48 * * Redistributions of source code must retain the above copyright
49 * notice, this list of conditions and the following disclaimer.
51 * * Redistributions in binary form must reproduce the above copyright
52 * notice, this list of conditions and the following disclaimer in the
53 * documentation and/or other materials provided with the distribution.
55 * * Neither the name of the original author; nor the names of any contributors
56 * may be used to endorse or promote products derived from this software
57 * without specific prior written permission.
60 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
61 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
62 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
63 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
64 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
65 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
66 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
67 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
68 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
69 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
70 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.