Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2007-07-23 16:42:24 +0200
committerArthur de Jong <arthur@arthurdejong.org>2007-07-23 16:42:24 +0200
commit14514d2217f770a3a3baefacaa59acf75ad351dd (patch)
tree459b8f46d3ca80e8fd5a68523358e418b66f89f7 /common
parentc1bd1e7559b5f40e6dbeedcb7608ac10a7989818 (diff)
add support for removing entries from a DICT by setting the value to NULL (this does not free any memory)
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-ldapd@313 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'common')
-rw-r--r--common/dict.c10
-rw-r--r--common/dict.h2
2 files changed, 7 insertions, 5 deletions
diff --git a/common/dict.c b/common/dict.c
index 5178a6f..1b7e787 100644
--- a/common/dict.c
+++ b/common/dict.c
@@ -91,11 +91,13 @@ DICT *dict_new(void)
int dict_put(DICT *dict,const char *key,void *value)
{
struct dict_entry *entry;
- /* ignore setting of value to NULL */
- if (value==NULL)
- return 0; /* probably do dict_del(dict,key) */
entry=dict_entry_find(dict,key);
- if (entry==NULL)
+ if ((entry==NULL)&&(value==NULL))
+ {
+ /* the key didn't exist, no point in creating one */
+ return 0;
+ }
+ else if (entry==NULL)
{
/* create new entry and insert it in the list */
entry=dict_entry_new(key);
diff --git a/common/dict.h b/common/dict.h
index 104c5a7..c91c901 100644
--- a/common/dict.h
+++ b/common/dict.h
@@ -51,7 +51,7 @@ void *dict_get(DICT *dict,const char *key)
/* Delete a key-value association from the dictionary.
All key comparisons are case insensitive. */
-/*void dict_del(LEGACYDICT *dict,const char *key);*/
+/*void dict_del(DICT *dict,const char *key);*/
/* Remove the dictionary from memory. All allocated storage
for the dictionary and the keys is freed. */