diff options
author | Greg <gmp@wow.st> | 2016-12-27 12:23:51 -0500 |
---|---|---|
committer | Greg <gmp@wow.st> | 2016-12-27 12:23:51 -0500 |
commit | fdb1aae3a98d94da90b2ee36bd5ae4423e3b213b (patch) | |
tree | 16973c4b6b975cd6849845afb5133102c78cd690 /src/hashmap.c | |
parent | 540069551da7a9c56874e568c449cfa3d72e4af4 (diff) |
Move lookup_variable into hashmap.c / hashmap.h
Diffstat (limited to 'src/hashmap.c')
-rw-r--r-- | src/hashmap.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/hashmap.c b/src/hashmap.c index b99f838..7793d08 100644 --- a/src/hashmap.c +++ b/src/hashmap.c @@ -493,3 +493,24 @@ ssize_t hashmap_remove (hashmap_t map, const char *key) /* The key was not found, so return 0 */ return deleted; } + +/* + * Look up the value for a variable. + */ +char *lookup_variable (hashmap_t map, const char *varname) +{ + hashmap_iter result_iter; + char *key; + char *data; + + result_iter = hashmap_find (map, varname); + + if (hashmap_is_end (map, result_iter)) + return (NULL); + + if (hashmap_return_entry (map, result_iter, + &key, (void **) &data) < 0) + return (NULL); + + return (data); +} |