diff options
author | bapt <bapt@FreeBSD.org> | 2014-07-19 23:44:57 +0000 |
---|---|---|
committer | bapt <bapt@FreeBSD.org> | 2014-07-19 23:44:57 +0000 |
commit | 6f718e3669e9ecc1b1ca407a465d6ee20571a2b8 (patch) | |
tree | ba71cc26671c93ed9809f7cadb07734c0bddb4c7 /contrib/libucl/src/ucl_hash.c | |
parent | 6095428430d025abcf6983536297f168bf62b45b (diff) | |
download | FreeBSD-src-6f718e3669e9ecc1b1ca407a465d6ee20571a2b8.zip FreeBSD-src-6f718e3669e9ecc1b1ca407a465d6ee20571a2b8.tar.gz |
MFC: r263648, r264789, r266636
This brings:
- schema validation
- xpath-like interface for ucl objects
Adapt pkg(7) to the new libucl API
Diffstat (limited to 'contrib/libucl/src/ucl_hash.c')
-rw-r--r-- | contrib/libucl/src/ucl_hash.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/contrib/libucl/src/ucl_hash.c b/contrib/libucl/src/ucl_hash.c index a3711de..c2e80cb 100644 --- a/contrib/libucl/src/ucl_hash.c +++ b/contrib/libucl/src/ucl_hash.c @@ -21,6 +21,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "ucl_internal.h" #include "ucl_hash.h" #include "utlist.h" @@ -39,11 +40,15 @@ ucl_hash_create (void) void ucl_hash_destroy (ucl_hash_t* hashlin, ucl_hash_free_func *func) { ucl_hash_node_t *elt, *tmp; + const ucl_object_t *cur, *otmp; HASH_ITER (hh, hashlin->buckets, elt, tmp) { HASH_DELETE (hh, hashlin->buckets, elt); if (func) { - func (elt->data); + DL_FOREACH_SAFE (elt->data, cur, otmp) { + /* Need to deconst here */ + func (__DECONST (ucl_object_t *, cur)); + } } UCL_FREE (sizeof (ucl_hash_node_t), elt); } @@ -51,7 +56,8 @@ void ucl_hash_destroy (ucl_hash_t* hashlin, ucl_hash_free_func *func) } void -ucl_hash_insert (ucl_hash_t* hashlin, ucl_object_t *obj, const char *key, unsigned keylen) +ucl_hash_insert (ucl_hash_t* hashlin, const ucl_object_t *obj, + const char *key, unsigned keylen) { ucl_hash_node_t *node; @@ -60,7 +66,7 @@ ucl_hash_insert (ucl_hash_t* hashlin, ucl_object_t *obj, const char *key, unsign HASH_ADD_KEYPTR (hh, hashlin->buckets, key, keylen, node); } -void* +const void* ucl_hash_iterate (ucl_hash_t *hashlin, ucl_hash_iter_t *iter) { ucl_hash_node_t *elt = *iter; @@ -91,7 +97,7 @@ ucl_hash_iter_has_next (ucl_hash_iter_t iter) } -ucl_object_t* +const ucl_object_t* ucl_hash_search (ucl_hash_t* hashlin, const char *key, unsigned keylen) { ucl_hash_node_t *found; @@ -108,7 +114,7 @@ ucl_hash_search (ucl_hash_t* hashlin, const char *key, unsigned keylen) } void -ucl_hash_delete (ucl_hash_t* hashlin, ucl_object_t *obj) +ucl_hash_delete (ucl_hash_t* hashlin, const ucl_object_t *obj) { ucl_hash_node_t *found; |