summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Sommerseth <dazo@users.sourceforge.net>2010-12-13 18:23:02 +0100
committerDavid Sommerseth <dazo@users.sourceforge.net>2010-12-13 18:23:02 +0100
commit41e3fbe0fe12ac194c3ba8b60b39d26e826ad141 (patch)
tree1c1afc4c2d5921aee6fbb87eea7ec9f6391838db
parentf4805d70cc4514b2569f8864ac138b5b21409cbc (diff)
downloadeurephia-41e3fbe0fe12ac194c3ba8b60b39d26e826ad141.tar.gz
eurephia-41e3fbe0fe12ac194c3ba8b60b39d26e826ad141.tar.xz
eurephia-41e3fbe0fe12ac194c3ba8b60b39d26e826ad141.zip
Added a new eurephiaVALUES function: eClear_key_value()
This function clears the contents of a eurephiaVALUES key/value record. It will not remove the record from the stack, but only free the key and value pointers and sets them to NULL. Signed-off-by: David Sommerseth <dazo@users.sourceforge.net>
-rw-r--r--common/eurephia_values.c17
-rw-r--r--common/eurephia_values.h1
2 files changed, 16 insertions, 2 deletions
diff --git a/common/eurephia_values.c b/common/eurephia_values.c
index d9f64eb..19fe05d 100644
--- a/common/eurephia_values.c
+++ b/common/eurephia_values.c
@@ -38,6 +38,20 @@
/**
+ * Clears the values of a eurephiaVALUES key/value record.
+ * This function does not remove the record from the stack, but
+ * only frees the key and value pointers and sets them to NULL.
+ *
+ * @param vls Pointer to the eurephiaVALUES record to be cleared
+ */
+void eClear_key_value(eurephiaVALUES *vls) {
+ if( vls != NULL ) {
+ free_nullsafe(NULL, vls->key);
+ free_nullsafe(NULL, vls->val);
+ }
+}
+
+/**
* Internal function. Makes sure a eurephiaVALUES stack is freed up
*
* @param vls Pointer to a eurephiaVALUES stack.
@@ -46,8 +60,7 @@ void do_free_vals(eurephiaVALUES *vls) {
if( vls->next != NULL ) {
do_free_vals(vls->next);
}
- free_nullsafe(NULL, vls->key);
- free_nullsafe(NULL, vls->val);
+ eClear_key_value(vls);
free_nullsafe(NULL, vls);
}
diff --git a/common/eurephia_values.h b/common/eurephia_values.h
index ce91711..a440258 100644
--- a/common/eurephia_values.h
+++ b/common/eurephia_values.h
@@ -41,6 +41,7 @@ eurephiaVALUES *eCreate_value_space(eurephiaCTX *ctx, int evid);
void eAdd_valuestruct(eurephiaCTX *ctx, eurephiaVALUES *vls, eurephiaVALUES *newval);
void eAdd_value(eurephiaCTX *ctx, eurephiaVALUES *vls, const char *key, const char *val);
eurephiaVALUES *eRemove_value(eurephiaCTX *ctx, eurephiaVALUES *vls, unsigned int evgid, unsigned int evid);
+void eClear_key_value(eurephiaVALUES *vls);
/**
* Front-end function for eFree_values_func(). Frees eurephiaVALUES pointer chain and