diff options
author | Anthony G. Basile <blueness@gentoo.org> | 2013-06-05 22:30:19 -0400 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2013-06-05 22:30:19 -0400 |
commit | ac6af1454474115a0105f07c5704e13e40d0ff0e (patch) | |
tree | ed4dcee12c0758a0542dfda09e54a32273c9c832 /src/libudev/hashmap.c | |
parent | b79c75f64b0808e59dd21237361fcefca16e13cb (diff) |
Round 2 of remove unused functions from src/libudev/{hashmap,log,path-util,set,strv,util}
We remove the following functions:
cleanup_pool
uint64_hash_func
hashmap_ensure_allocated
hashmap_clear_free_free
hashmap_replace
hashmap_remove_and_put
hashmap_iterate_skip
hashmap_first
hashmap_first_key
hashmap_last
hashmap_isempty
hashmap_move_one
hashmap_copy
log_metav_object
log_show_color
log_show_location
path_strv_make_absolute_cwd
path_startswith
set_remove
set_move
set_clear
strv_find
strv_contains
strv_merge
strv_split
strv_split_quoted
strv_append
strv_extend
strv_push
strv_split_nulstr
str_compare
dual_timestamp_get
dual_timestamp_from_realtime
timespec_store
timeval_load
timeval_store
parse_boolean
fchmod_umask
parse_env_file
get_process_comm
get_process_id
readlink_and_make_absolute
bus_path_unescape
format_timestamp
acquire_terminal
loop_write
parse_usec
make_stdio
random_ull
lookup_uid
getttyname_malloc
status_printf
replace_env
normalize_env_assignment
wait_for_terminate
freeze
tag_to_udev_node
tty_is_vc_resolve
nulstr_contains
strshorten
hostname_valid_char
display_is_local
get_group_creds
in_gid
dirent_ensure_type
is_locale_utf8
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src/libudev/hashmap.c')
-rw-r--r-- | src/libudev/hashmap.c | 184 |
1 files changed, 0 insertions, 184 deletions
diff --git a/src/libudev/hashmap.c b/src/libudev/hashmap.c index 863312cc6c..6626288cdc 100644 --- a/src/libudev/hashmap.c +++ b/src/libudev/hashmap.c @@ -114,13 +114,6 @@ static void drop_pool(struct pool *p) { } } -__attribute__((destructor)) static void cleanup_pool(void) { - /* Be nice to valgrind */ - - drop_pool(first_hashmap_pool); - drop_pool(first_entry_pool); -} - #endif unsigned string_hash_func(const void *p) { @@ -147,16 +140,6 @@ int trivial_compare_func(const void *a, const void *b) { return a < b ? -1 : (a > b ? 1 : 0); } -unsigned uint64_hash_func(const void *p) { - uint64_t u; - - assert_cc(sizeof(uint64_t) == 2*sizeof(unsigned)); - - u = *(const uint64_t*) p; - - return (unsigned) ((u >> 32) ^ u); -} - Hashmap *hashmap_new(hash_func_t hash_func, compare_func_t compare_func) { bool b; Hashmap *h; @@ -190,18 +173,6 @@ Hashmap *hashmap_new(hash_func_t hash_func, compare_func_t compare_func) { return h; } -int hashmap_ensure_allocated(Hashmap **h, hash_func_t hash_func, compare_func_t compare_func) { - assert(h); - - if (*h) - return 0; - - if (!(*h = hashmap_new(hash_func, compare_func))) - return -ENOMEM; - - return 0; -} - static void link_entry(Hashmap *h, struct hashmap_entry *e, unsigned hash) { assert(h); assert(e); @@ -318,22 +289,6 @@ void hashmap_clear_free(Hashmap *h) { free(p); } -void hashmap_clear_free_free(Hashmap *h) { - if (!h) - return; - - while (h->iterate_list_head) { - void *a, *b; - - a = h->iterate_list_head->value; - b = (void*) h->iterate_list_head->key; - remove_entry(h, h->iterate_list_head); - free(a); - free(b); - } -} - - static struct hashmap_entry *hash_scan(Hashmap *h, unsigned hash, const void *key) { struct hashmap_entry *e; assert(h); @@ -379,23 +334,6 @@ int hashmap_put(Hashmap *h, const void *key, void *value) { return 1; } -int hashmap_replace(Hashmap *h, const void *key, void *value) { - struct hashmap_entry *e; - unsigned hash; - - assert(h); - - hash = h->hash_func(key) % NBUCKETS; - e = hash_scan(h, hash, key); - if (e) { - e->key = key; - e->value = value; - return 0; - } - - return hashmap_put(h, key, value); -} - void* hashmap_get(Hashmap *h, const void *key) { unsigned hash; struct hashmap_entry *e; @@ -444,31 +382,6 @@ void* hashmap_remove(Hashmap *h, const void *key) { return data; } -int hashmap_remove_and_put(Hashmap *h, const void *old_key, const void *new_key, void *value) { - struct hashmap_entry *e; - unsigned old_hash, new_hash; - - if (!h) - return -ENOENT; - - old_hash = h->hash_func(old_key) % NBUCKETS; - if (!(e = hash_scan(h, old_hash, old_key))) - return -ENOENT; - - new_hash = h->hash_func(new_key) % NBUCKETS; - if (hash_scan(h, new_hash, new_key)) - return -EEXIST; - - unlink_entry(h, e, old_hash); - - e->key = new_key; - e->value = value; - - link_entry(h, e, new_hash); - - return 0; -} - void *hashmap_iterate(Hashmap *h, Iterator *i, const void **key) { struct hashmap_entry *e; @@ -539,56 +452,6 @@ at_beginning: return NULL; } -void *hashmap_iterate_skip(Hashmap *h, const void *key, Iterator *i) { - unsigned hash; - struct hashmap_entry *e; - - if (!h) - return NULL; - - hash = h->hash_func(key) % NBUCKETS; - - if (!(e = hash_scan(h, hash, key))) - return NULL; - - *i = (Iterator) e; - - return e->value; -} - -void* hashmap_first(Hashmap *h) { - - if (!h) - return NULL; - - if (!h->iterate_list_head) - return NULL; - - return h->iterate_list_head->value; -} - -void* hashmap_first_key(Hashmap *h) { - - if (!h) - return NULL; - - if (!h->iterate_list_head) - return NULL; - - return (void*) h->iterate_list_head->key; -} - -void* hashmap_last(Hashmap *h) { - - if (!h) - return NULL; - - if (!h->iterate_list_tail) - return NULL; - - return h->iterate_list_tail->value; -} - void* hashmap_steal_first(Hashmap *h) { void *data; @@ -612,14 +475,6 @@ unsigned hashmap_size(Hashmap *h) { return h->n_entries; } -bool hashmap_isempty(Hashmap *h) { - - if (!h) - return true; - - return h->n_entries == 0; -} - int hashmap_merge(Hashmap *h, Hashmap *other) { struct hashmap_entry *e; @@ -667,45 +522,6 @@ void hashmap_move(Hashmap *h, Hashmap *other) { } } -int hashmap_move_one(Hashmap *h, Hashmap *other, const void *key) { - unsigned h_hash, other_hash; - struct hashmap_entry *e; - - if (!other) - return 0; - - assert(h); - - h_hash = h->hash_func(key) % NBUCKETS; - if (hash_scan(h, h_hash, key)) - return -EEXIST; - - other_hash = other->hash_func(key) % NBUCKETS; - if (!(e = hash_scan(other, other_hash, key))) - return -ENOENT; - - unlink_entry(other, e, other_hash); - link_entry(h, e, h_hash); - - return 0; -} - -Hashmap *hashmap_copy(Hashmap *h) { - Hashmap *copy; - - assert(h); - - if (!(copy = hashmap_new(h->hash_func, h->compare_func))) - return NULL; - - if (hashmap_merge(copy, h) < 0) { - hashmap_free(copy); - return NULL; - } - - return copy; -} - char **hashmap_get_strv(Hashmap *h) { char **sv; Iterator it; |