aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/PropSet.h1
-rw-r--r--src/PropSet.cxx27
2 files changed, 28 insertions, 0 deletions
diff --git a/include/PropSet.h b/include/PropSet.h
index 0b4c2f58d..2766b542a 100644
--- a/include/PropSet.h
+++ b/include/PropSet.h
@@ -45,6 +45,7 @@ public:
~PropSet();
void Set(const char *key, const char *val, int lenKey=-1, int lenVal=-1);
void Set(const char *keyVal);
+ void Unset(const char *key, int lenKey=-1);
void SetMultiple(const char *s);
SString Get(const char *key);
SString GetExpanded(const char *key);
diff --git a/src/PropSet.cxx b/src/PropSet.cxx
index bf345145f..6c7145f02 100644
--- a/src/PropSet.cxx
+++ b/src/PropSet.cxx
@@ -383,6 +383,33 @@ void PropSet::Set(const char *keyVal) {
}
}
+void PropSet::Unset(const char *key, int lenKey) {
+ if (!*key) // Empty keys are not supported
+ return;
+ if (lenKey == -1)
+ lenKey = static_cast<int>(strlen(key));
+ unsigned int hash = HashString(key, lenKey);
+ Property *pPrev = NULL;
+ for (Property *p = props[hash % hashRoots]; p; p = p->next) {
+ if ((hash == p->hash) &&
+ ((strlen(p->key) == static_cast<unsigned int>(lenKey)) &&
+ (0 == strncmp(p->key, key, lenKey)))) {
+ if (pPrev)
+ pPrev->next = p->next;
+ else
+ props[hash % hashRoots] = p->next;
+ if (p == enumnext)
+ enumnext = p->next; // Not that anyone should mix enum and Set / Unset.
+ delete [](p->key);
+ delete [](p->val);
+ delete p;
+ return;
+ } else {
+ pPrev = p;
+ }
+ }
+}
+
void PropSet::SetMultiple(const char *s) {
const char *eol = strchr(s, '\n');
while (eol) {