chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
util: more join() optimizations
[elogind.git]
/
src
/
hashmap.c
diff --git
a/src/hashmap.c
b/src/hashmap.c
index a59b880dffb25bb587f56714cbc03fb75cd2a7ee..ca83e9338552626db3f7d7770a10110cbaacc510 100644
(file)
--- a/
src/hashmap.c
+++ b/
src/hashmap.c
@@
-1,4
+1,4
@@
-/*-*- Mode: C; c-basic-offset: 8 -*-*/
+/*-*- Mode: C; c-basic-offset: 8
; indent-tabs-mode: nil
-*-*/
/***
This file is part of systemd.
/***
This file is part of systemd.
@@
-173,6
+173,15
@@
void hashmap_free(Hashmap*h) {
free(h);
}
free(h);
}
+void hashmap_free_free(Hashmap *h) {
+ void *p;
+
+ while ((p = hashmap_steal_first(h)))
+ free(p);
+
+ hashmap_free(h);
+}
+
void hashmap_clear(Hashmap *h) {
if (!h)
return;
void hashmap_clear(Hashmap *h) {
if (!h)
return;
@@
-467,6
+476,21
@@
void* hashmap_steal_first(Hashmap *h) {
return data;
}
return data;
}
+void* hashmap_steal_first_key(Hashmap *h) {
+ void *key;
+
+ if (!h)
+ return NULL;
+
+ if (!h->iterate_list_head)
+ return NULL;
+
+ key = (void*) h->iterate_list_head->key;
+ remove_entry(h, h->iterate_list_head);
+
+ return key;
+}
+
unsigned hashmap_size(Hashmap *h) {
if (!h)
unsigned hashmap_size(Hashmap *h) {
if (!h)
@@
-568,3
+592,21
@@
Hashmap *hashmap_copy(Hashmap *h) {
return copy;
}
return copy;
}
+
+char **hashmap_get_strv(Hashmap *h) {
+ char **sv;
+ Iterator it;
+ char *item;
+ int n;
+
+ sv = new(char*, h->n_entries+1);
+ if (!sv)
+ return NULL;
+
+ n = 0;
+ HASHMAP_FOREACH(item, h, it)
+ sv[n++] = item;
+ sv[n] = NULL;
+
+ return sv;
+}