Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| SHA1 Hash: | 7240dfdba152b1e6acdd7191a313b013a4801db5 |
|---|---|
| Date: | 2008-11-04 19:46:57 |
| User: | stephan |
| Comment: | removed whhash_sh_xxx() API. |
Tags And Properties
- branch=trunk inherited from [a870fea998]
- sym-trunk inherited from [a870fea998]
Changes
Changes to src/whhash.c
| Old (803862366eb1b033) | New (093eb3ad84431bd0) | |||
|---|---|---|---|---|
| 1 | /* Copyright (C) 2004 Christopher Clark <firstname.lastname@cl.cam.ac.uk> */ | 1 | /* Copyright (C) 2004 Christopher Clark <firstname.lastname@cl.cam.ac.uk> */ | |
| 2 | /* Copyright (C) 2008 Stephan Beal (http://wanderinghorse.net/home/stephan/) */ | 2 | /* Copyright (C) 2008 Stephan Beal (http://wanderinghorse.net/home/stephan/) */ | |
| 3 | 3 | |||
| 4 | #include "whhash.h" | 4 | #include "whhash.h" | |
| 5 | #include <stdlib.h> | 5 | #include <stdlib.h> | |
| 814 hidden lines | ||||
| 820 | parent = e; | 820 | parent = e; | |
| 821 | e = e->next; | 821 | e = e->next; | |
| 822 | } | 822 | } | |
| 823 | return 0; | 823 | return 0; | |
| 824 | } | 824 | } | |
| 825 | < | |||
| 826 | whhash_table * whhash_sh_create() | < | ||
| 827 | { | < | ||
| 828 | whhash_table * h = whhash_create(16, | < | ||
| 829 | whhash_hash_cstring_djb2m, | < | ||
| 830 | whhash_cmp_cstring ); | < | ||
| 831 | h->flags |= whhash_flags.SH_API; | < | ||
| 832 | return h; | < | ||
| 833 | } | < | ||
| 834 | /** | < | ||
| 835 | WHHASH_SH ensures that whhash_table H is compatible with | < | ||
| 836 | whhash_sh_create()'s table. If it's not then return RV is called. | < | ||
| 837 | */ | < | ||
| 838 | #define WHHASH_SH(H,RV) if( !h || !(h->flags & whhash_flags.SH_API) ) return RV; | < | ||
| 839 | < | |||
| 840 | int whhash_sh_insert(whhash_table * h, char const * key, void * val) | < | ||
| 841 | { | < | ||
| 842 | WHHASH_SH(h,0); | < | ||
| 843 | // FIXME: we need to copy this string and see free() to the dtor! | < | ||
| 844 | return whhash_insert(h,(char *) key, val); | < | ||
| 845 | /** | < | ||
| 846 | i don't like that (char*) cast at all :( | < | ||
| 847 | */ | < | ||
| 848 | } | < | ||
| 849 | < | |||
| 850 | void * whhash_sh_search(whhash_table * h, char const * key) | < | ||
| 851 | { | < | ||
| 852 | WHHASH_SH(h,0); | < | ||
| 853 | return whhash_search( h, key ); | < | ||
| 854 | } | < | ||
| 855 | void * whhash_sh_take(whhash_table * h, char const * key) | < | ||
| 856 | { | < | ||
| 857 | WHHASH_SH(h,0); | < | ||
| 858 | return whhash_take( h, (char *)key ); | < | ||
| 859 | } | < | ||
| 860 | int whhash_sh_remove(whhash_table * h, char const * key) | < | ||
| 861 | { | < | ||
| 862 | WHHASH_SH(h,0); | < | ||
| 863 | return whhash_remove( h, (char *)key ); | < | ||
| 864 | } | < | ||
| 865 | < | |||
| 866 | #undef WHHASH_SH | < | ||
| 867 | 825 | |||
| 868 | #ifdef __cplusplus | 826 | #ifdef __cplusplus | |
| 869 | } /* extern "C" */ | 827 | } /* extern "C" */ | |
| 870 | #endif | 828 | #endif | |
| 871 | 829 | |||
| 28 hidden lines | ||||
| 900 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | 858 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
| 901 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 859 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
| 902 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 860 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
| 903 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 861 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 904 | */ | 862 | */ | |
Changes to src/whhash.h
| Old (11a780b3eb4023be) | New (b966a1a75384615d) | |||
|---|---|---|---|---|
| 1 | /* Copyright (C) 2002 Christopher Clark <firstname.lastname@cl.cam.ac.uk> */ | 1 | /* Copyright (C) 2002 Christopher Clark <firstname.lastname@cl.cam.ac.uk> */ | |
| 2 | /* Copyright (C) 2008 Stephan Beal (http://wanderinghorse.net/home/stephan/) */ | 2 | /* Copyright (C) 2008 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 | #ifndef WANDERINGHORSE_NET_WHHASH_H_INCLUDED | 4 | #ifndef WANDERINGHORSE_NET_WHHASH_H_INCLUDED | |
| 5 | #define WANDERINGHORSE_NET_WHHASH_H_INCLUDED | 5 | #define WANDERINGHORSE_NET_WHHASH_H_INCLUDED | |
| 595 hidden lines | ||||
| 601 | /** | 601 | /** | |
| 602 | Returns the current statistics for h, or an object | 602 | Returns the current statistics for h, or an object | |
| 603 | with all 0 values if (!h). | 603 | with all 0 values if (!h). | |
| 604 | */ | 604 | */ | |
| 605 | whhash_stats whhash_get_stats( whhash_table const * h ); | 605 | whhash_stats whhash_get_stats( whhash_table const * h ); | |
| 606 | < | |||
| 607 | /** | < | ||
| 608 | Creates a new hashtable which is specialized for use with | < | ||
| 609 | (char const *) keys. It is not intended to own the keys, | < | ||
| 610 | and due to constness rules results are undefined if you | < | ||
| 611 | set a destructor for the keys. | < | ||
| 612 | < | |||
| 613 | The other functions in this API named whhash_sh_something() | < | ||
| 614 | are intended only to be used with hashes created by this function, | < | ||
| 615 | and in fact check their hashtable argument to see if it was created | < | ||
| 616 | by this function. If a hashtable created using whhash_create() is | < | ||
| 617 | passed to them, they will return an error result (e.g. a null pointer | < | ||
| 618 | or a false value). | < | ||
| 619 | */ | < | ||
| 620 | whhash_table * whhash_sh_create(); | < | ||
| 621 | < | |||
| 622 | /** | < | ||
| 623 | Functionally identical to whhash_insert(), but only works with hashtables | < | ||
| 624 | created by whhash_sh_create(). | < | ||
| 625 | */ | < | ||
| 626 | int whhash_sh_insert(whhash_table *h, char const * key, void * val); | < | ||
| 627 | < | |||
| 628 | /** | < | ||
| 629 | Functionally identical to whhash_search(), but only works with hashtables | < | ||
| 630 | created by whhash_sh_create(). | < | ||
| 631 | */ | < | ||
| 632 | void * whhash_sh_search(whhash_table *h, char const * key); | < | ||
| 633 | < | |||
| 634 | /** | < | ||
| 635 | Functionally identical to whhash_take(), but only works with hashtables | < | ||
| 636 | created by whhash_sh_create(). | < | ||
| 637 | */ | < | ||
| 638 | void * whhash_sh_take(whhash_table *h, char const * key); | < | ||
| 639 | < | |||
| 640 | /** | < | ||
| 641 | Functionally identical to whhash_remove(), but only works with hashtables | < | ||
| 642 | created by whhash_sh_create(). | < | ||
| 643 | */ | < | ||
| 644 | int whhash_sh_remove(whhash_table *h, char const * key); | < | ||
| 645 | 606 | |||
| 646 | #ifdef __cplusplus | 607 | #ifdef __cplusplus | |
| 647 | } /* extern "C" */ | 608 | } /* extern "C" */ | |
| 648 | #endif | 609 | #endif | |
| 649 | #endif /* WANDERINGHORSE_NET_WHHASH_H_INCLUDED */ | 610 | #endif /* WANDERINGHORSE_NET_WHHASH_H_INCLUDED */ | |
| 28 hidden lines | ||||
| 678 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | 639 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
| 679 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 640 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
| 680 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 641 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
| 681 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 642 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 682 | */ | 643 | */ | |