2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation; only version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15 * Place - Suite 330, Boston, MA 02111-1307, USA.
20 #include <lttng-share.h>
22 #include "hashtable.h"
23 #include "../hashtable/rculfhash.h"
24 #include "../hashtable/hash.h"
26 struct cds_lfht
*hashtable_new(unsigned long size
)
29 size
= DEFAULT_HT_SIZE
;
32 return cds_lfht_new(hash_key
, hash_compare_key
, 0x42UL
,
33 CDS_LFHT_AUTO_RESIZE
, size
, NULL
);
36 struct cds_lfht
*hashtable_new_str(unsigned long size
)
39 size
= DEFAULT_HT_SIZE
;
42 return cds_lfht_new(hash_key_str
, hash_compare_key_str
, 0x42UL
,
43 CDS_LFHT_AUTO_RESIZE
, size
, NULL
);
46 struct cds_lfht_node
*hashtable_iter_get_node(struct cds_lfht_iter
*iter
)
53 return cds_lfht_iter_get_node(iter
);
56 struct cds_lfht_node
*hashtable_lookup(struct cds_lfht
*ht
, void *key
,
57 size_t key_len
, struct cds_lfht_iter
*iter
)
60 if (ht
== NULL
|| iter
== NULL
|| key
== NULL
) {
64 cds_lfht_lookup(ht
, key
, key_len
, iter
);
66 return hashtable_iter_get_node(iter
);
69 void hashtable_get_first(struct cds_lfht
*ht
, struct cds_lfht_iter
*iter
)
71 cds_lfht_first(ht
, iter
);
74 void hashtable_get_next(struct cds_lfht
*ht
, struct cds_lfht_iter
*iter
)
76 cds_lfht_next(ht
, iter
);
79 void hashtable_add_unique(struct cds_lfht
*ht
, struct cds_lfht_node
*node
)
81 cds_lfht_add_unique(ht
, node
);
84 void hashtable_node_init(struct cds_lfht_node
*node
, void *key
,
87 cds_lfht_node_init(node
, key
, key_len
);
90 int hashtable_del(struct cds_lfht
*ht
, struct cds_lfht_iter
*iter
)
93 if (ht
== NULL
|| iter
== NULL
) {
97 return cds_lfht_del(ht
, iter
);
100 unsigned long hashtable_get_count(struct cds_lfht
*ht
)
103 unsigned long count
, removed
;
105 cds_lfht_count_nodes(ht
, &ab
, &count
, &removed
, &aa
);
This page took 0.03355 seconds and 6 git commands to generate.