Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| SHA1 Hash: | 19ed2cdde24b3cdbf70015a2416b7d91ddb1fb1b |
|---|---|
| Date: | 2009-11-12 18:07:47 |
| User: | stephan |
| Comment: | pulled in latest copy from c11n tree |
Tags And Properties
- branch=trunk inherited from [a870fea998]
- sym-trunk inherited from [a870fea998]
Changes
Changes to src/whhash.c
| Old (619c682594cf8a73) | New (d2951f58e30f45cd) | |||
|---|---|---|---|---|
| 1 | /* Copyright (C) 2004 Christopher Clark <firstname.lastname@cl.cam.ac.uk> */ | | | 1 | /* Copyright (C) 2002, 2004 Christopher Clark <firstname.lastname@cl.cam.ac.uk> */ |
| 2 | /* Copyright (C) 2008 Stephan Beal (http://wanderinghorse.net/home/stephan/) */ | | | 2 | /* Copyright (C) 2008, 2009 Stephan Beal (http://wanderinghorse.net/home/stephan/) */ |
| 3 | /** | | | 3 | /* |
| 4 | License: as of 2009, this code is Public Domain in jurisdictions which | | | 4 | On 17 June 2009, i (Stephan Beal) got permission from the original author |
| 5 | recognize Public Domain, and New BSD in all other jurisdictions. | | | 5 | (Christopher Clark) to dual-license this code under the following terms: |
| 6 | */ | | | 6 | |
| 7 | #include "whhash.h" | | | 7 | - If the code is used in a jurisdiction where Public Domain |
| | | 8 | property is regonized, then this code may be considered to be | ||
| | | 9 | in the Public Domain. Its author expressly disclaims copyright | ||
| | | 10 | in jurisdictions where such a disclaimer is allowed. | ||
| | | 11 | |||
| | | 12 | - If the code is used in a jurisdiction which does not recognize | ||
| | | 13 | Public Domain, the code must be used in terms with the MIT license, | ||
| | | 14 | as described clearly and concisely at: | ||
| | | 15 | |||
| | | 16 | http://en.wikipedia.org/wiki/MIT_License | ||
| | | 17 | |||
| | | 18 | and reproduced in full below. | ||
| | | 19 | |||
| | | 20 | - If the code is used in a jurisdiction which recognizes Public | ||
| | | 21 | Domain, the user may use the code without limits, as for Public | ||
| | | 22 | Domain property, or may instead opt to use the code under the terms | ||
| | | 23 | of the MIT license. | ||
| | | 24 | |||
| | | 25 | The MIT licensing terms follow: | ||
| | | 26 | ======================================================================== | ||
| | | 27 | Copyright (C) 2002, 2004 Christopher Clark <firstname.lastname@cl.cam.ac.uk> | ||
| | | 28 | Copyright (c) 2008, 2009 Stephan Beal (http://wanderinghorse.net/home/stephan/) | ||
| | | 29 | |||
| | | 30 | Permission is hereby granted, free of charge, to any person | ||
| | | 31 | obtaining a copy of this software and associated documentation | ||
| | | 32 | files (the "Software"), to deal in the Software without | ||
| | | 33 | restriction, including without limitation the rights to use, copy, | ||
| | | 34 | modify, merge, publish, distribute, sublicense, and/or sell copies | ||
| | | 35 | of the Software, and to permit persons to whom the Software is | ||
| | | 36 | furnished to do so, subject to the following conditions: | ||
| | | 37 | |||
| | | 38 | The above copyright notice and this permission notice shall be | ||
| | | 39 | included in all copies or substantial portions of the Software. | ||
| | | 40 | |||
| | | 41 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| | | 42 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| | | 43 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
| | | 44 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
| | | 45 | BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
| | | 46 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
| | | 47 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| | | 48 | SOFTWARE. | ||
| | | 49 | ======================================================================== | ||
| | | 50 | |||
| | | 51 | #include "s11n.net/c11n/detail/whhash.h" | ||
| 8 | #include <stdlib.h> | 52 | #include <stdlib.h> | |
| 9 | //#include <stdio.h> | 53 | //#include <stdio.h> | |
| 10 | #include <string.h> | 54 | #include <string.h> | |
| 11 | 55 | |||
| 12 | #ifdef __cplusplus | 56 | #ifdef __cplusplus | |
| 848 hidden lines | ||||
| 861 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | 905 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
| 862 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 906 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
| 863 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 907 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
| 864 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 908 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 865 | */ | 909 | */ | |
Changes to src/whhash.h
| Old (35cfd2b0d7267ec4) | New (df620ac9754d7a10) | |||
|---|---|---|---|---|
| 1 | /* Copyright (C) 2002 Christopher Clark <firstname.lastname@cl.cam.ac.uk> */ | | | 1 | /* Copyright (C) 2002, 2004 Christopher Clark <firstname.lastname@cl.cam.ac.uk> */ |
| 2 | /* Copyright (C) 2008 Stephan Beal (http://wanderinghorse.net/home/stephan/) */ | | | 2 | /* Copyright (C) 2008, 2009 Stephan Beal (http://wanderinghorse.net/home/stephan/) */ |
| 3 | /* Code originally taken from: http://www.cl.cam.ac.uk/~cwc22/hashtable/ */ | 3 | /* Code originally taken from: http://www.cl.cam.ac.uk/~cwc22/hashtable/ */ | |
| 4 | /** | | | 4 | /* |
| 5 | In 2009 Stephan Beal got permission from Christopher Clark to | | | 5 | On 17 June 2009, i (Stephan Beal) got permission from the original author |
| 6 | re-license this code as Public Domain. Thus this code is now | | | 6 | (Christopher Clark) to dual-license this code under the following terms: |
| 7 | Public Domain in jurisdictions which recognize Public Domain, and | | | 7 | |
| 8 | the New BSD License in all other jurisdictions. | | | 8 | - If the code is used in a jurisdiction where Public Domain |
| | | 9 | property is regonized, then this code may be considered to be | ||
| | | 10 | in the Public Domain. Its author expressly disclaims copyright | ||
| | | 11 | in jurisdictions where such a disclaimer is allowed. | ||
| | | 12 | |||
| | | 13 | - If the code is used in a jurisdiction which does not recognize | ||
| | | 14 | Public Domain, the code must be used in terms with the MIT license, | ||
| | | 15 | as described clearly and concisely at: | ||
| | | 16 | |||
| | | 17 | http://en.wikipedia.org/wiki/MIT_License | ||
| | | 18 | |||
| | | 19 | and reproduced in full below. | ||
| | | 20 | |||
| | | 21 | - If the code is used in a jurisdiction which recognizes Public | ||
| | | 22 | Domain, the user may use the code without limits, as for Public | ||
| | | 23 | Domain property, or may instead opt to use the code under the terms | ||
| | | 24 | of the MIT license. | ||
| | | 25 | |||
| | | 26 | The MIT licensing terms follow: | ||
| | | 27 | ======================================================================== | ||
| | | 28 | Copyright (C) 2002, 2004 Christopher Clark <firstname.lastname@cl.cam.ac.uk> | ||
| | | 29 | Copyright (c) 2008, 2009 Stephan Beal (http://wanderinghorse.net/home/stephan/) | ||
| | | 30 | |||
| | | 31 | Permission is hereby granted, free of charge, to any person | ||
| | | 32 | obtaining a copy of this software and associated documentation | ||
| | | 33 | files (the "Software"), to deal in the Software without | ||
| | | 34 | restriction, including without limitation the rights to use, copy, | ||
| | | 35 | modify, merge, publish, distribute, sublicense, and/or sell copies | ||
| | | 36 | of the Software, and to permit persons to whom the Software is | ||
| | | 37 | furnished to do so, subject to the following conditions: | ||
| | | 38 | |||
| | | 39 | The above copyright notice and this permission notice shall be | ||
| | | 40 | included in all copies or substantial portions of the Software. | ||
| | | 41 | |||
| | | 42 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| | | 43 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| | | 44 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
| | | 45 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
| | | 46 | BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
| | | 47 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
| | | 48 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| | | 49 | SOFTWARE. | ||
| | | 50 | ======================================================================== | ||
| | | 51 | (END LICENSE TEXT) | ||
| | | 52 | |||
| | | 53 | The MIT license is compatible with both the GPL and commercial | ||
| | | 54 | software, affording one all of the rights of Public Domain with the | ||
| | | 55 | minor nuisance of being required to keep the above copyright notice | ||
| | | 56 | and license text in the source code. Note also that by accepting the | ||
| | | 57 | Public Domain "license" you can re-license your copy using whatever | ||
| | | 58 | license you like. | ||
| 9 | */ | 59 | */ | |
| 10 | #ifndef WANDERINGHORSE_NET_WHHASH_H_INCLUDED | 60 | #ifndef WANDERINGHORSE_NET_WHHASH_H_INCLUDED | |
| 11 | #define WANDERINGHORSE_NET_WHHASH_H_INCLUDED | 61 | #define WANDERINGHORSE_NET_WHHASH_H_INCLUDED | |
| 12 | #include <stddef.h> /* size_t */ | 62 | #include <stddef.h> /* size_t */ | |
| 13 | #ifdef __cplusplus | 63 | #ifdef __cplusplus | |
| 5 hidden lines | ||||
| 19 | The functions and types named whhash* are part of the | 69 | The functions and types named whhash* are part of the | |
| 20 | WanderingHorse.net hashtable library. It is a hashtable | 70 | WanderingHorse.net hashtable library. It is a hashtable | |
| 21 | implementation based on code by Christopher Clark, | 71 | implementation based on code by Christopher Clark, | |
| 22 | adopted, extended, and changed somewhat by yours truly. | 72 | adopted, extended, and changed somewhat by yours truly. | |
| 23 | 73 | |||
| 24 | License: Public Domain in jurisdictions which allow it, otherwise | | | 74 | License: Dual: Public Domain in jurisdictions which allow it, |
| 25 | New BSD License. | | | 75 | or optionally the MIT license. |
| 26 | 76 | |||
| 27 | Maintainer: Stephan Beal (http://wanderinghorse.net/home/stephan) | 77 | Maintainer: Stephan Beal (http://wanderinghorse.net/home/stephan) | |
| 28 | 78 | |||
| 29 | The hashtables described here map (void*) to (void*) by using a | 79 | The hashtables described here map (void*) to (void*) by using a | |
| 30 | client-supplied hash algorithm on the key pointers. The hashtable | 80 | client-supplied hash algorithm on the key pointers. The hashtable | |
| 31 | can optionally take over ownership of its keys or values, via | 81 | can optionally take over ownership of its keys or values, via | |
| 32 | whhash_set_key_dtor() and whhash_set_val_dtor(). The ownership | | | 82 | whhash_set_key_dtor() and whhash_set_key_dtor(). The ownership |
| 33 | management option makes this type useful as a simple garbage | 83 | management option makes this type useful as a simple garbage | |
| 34 | collector. | 84 | collector. | |
| 35 | 85 | |||
| 36 | @section whhash_sec_example Example | 86 | @section whhash_sec_example Example | |
| 37 | 87 | |||
| 111 hidden lines | ||||
| 149 | store items which are shared across threads in a hashtable unless | 199 | store items which are shared across threads in a hashtable unless | |
| 150 | you know that lifetime and ownership issues can be mitigated. If, | 200 | you know that lifetime and ownership issues can be mitigated. If, | |
| 151 | e.g., a hashtable does not own its entries, one needs to make sure | 201 | e.g., a hashtable does not own its entries, one needs to make sure | |
| 152 | that if the entry is deleted from somewhere else, that it's | 202 | that if the entry is deleted from somewhere else, that it's | |
| 153 | removed from the hashtable (or ensure that that entry cannot be | 203 | removed from the hashtable (or ensure that that entry cannot be | |
| 154 | referenced again, otherwise you'll get a dangling pointer back). | | | 204 | references again, otherwise you'll get a dangling pointer back). |
| 155 | 205 | |||
| 156 | 206 | |||
| 157 | @section whhash_sec_links Other resources | 207 | @section whhash_sec_links Other resources | |
| 158 | 208 | |||
| 159 | Some other resources: | 209 | Some other resources: | |
| 141 hidden lines | ||||
| 301 | 351 | |||
| 302 | /** | 352 | /** | |
| 303 | whhash_search() searches for the given key and returns the | 353 | whhash_search() searches for the given key and returns the | |
| 304 | associated value (if found) or 0 (if not found). Ownership of the | 354 | associated value (if found) or 0 (if not found). Ownership of the | |
| 305 | returned value is unchanged. | 355 | returned value is unchanged. | |
| 306 | < | |||
| 307 | Maintainer's note: the h parameter should be const, but its not | < | ||
| 308 | for internal reasons. | < | ||
| 309 | */ | 356 | */ | |
| 310 | void * | 357 | void * | |
| 311 | whhash_search(whhash_table *h, void const * k); | 358 | whhash_search(whhash_table *h, void const * k); | |
| 312 | 359 | |||
| 313 | /** | 360 | /** | |
| 100 hidden lines | ||||
| 414 | int whhash_cmp_long( void const * k1, void const * k2 ); | 461 | int whhash_cmp_long( void const * k1, void const * k2 ); | |
| 415 | 462 | |||
| 416 | /** | 463 | /** | |
| 417 | An int/long hashing function for use with whhash_create(). It | 464 | An int/long hashing function for use with whhash_create(). It | |
| 418 | requires that n point to a long integer, and it simply returns the | 465 | requires that n point to a long integer, and it simply returns the | |
| 419 | value of *n, or whhash_hash_val_err on error (n is NULL). | | | 466 | value of n, or whhash_hash_val_err on error (n is NULL). |
| 420 | */ | 467 | */ | |
| 421 | whhash_val_t whhash_hash_long( void const * n ); | 468 | whhash_val_t whhash_hash_long( void const * n ); | |
| 422 | 469 | |||
| 423 | /** | 470 | /** | |
| 424 | This is a hash routine for generic void pointers. To avoid clustering | 471 | This is a hash routine for generic void pointers. To avoid clustering | |
| 224 hidden lines | ||||
| 649 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | 696 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
| 650 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 697 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
| 651 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 698 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
| 652 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 699 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 653 | */ | 700 | */ | |