From 41e3fbe0fe12ac194c3ba8b60b39d26e826ad141 Mon Sep 17 00:00:00 2001 From: David Sommerseth Date: Mon, 13 Dec 2010 18:23:02 +0100 Subject: 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 --- common/eurephia_values.c | 17 +++++++++++++++-- common/eurephia_values.h | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'common') 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 @@ -37,6 +37,20 @@ #include +/** + * 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 * @@ -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 -- cgit