summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorDavid Sommerseth <dazo@users.sourceforge.net>2008-11-30 21:24:46 +0100
committerDavid Sommerseth <dazo@users.sourceforge.net>2008-11-30 21:24:46 +0100
commitf415e9a4709b35a0d9662a2877f597af6a36796f (patch)
treeae06ca49ec509337b4cab2c4fbcee7ed38e6fd06 /common
parentd3dddc4b73351fe24abd6059b8fe38ebf97ae3e8 (diff)
downloadeurephia-f415e9a4709b35a0d9662a2877f597af6a36796f.tar.gz
eurephia-f415e9a4709b35a0d9662a2877f597af6a36796f.tar.xz
eurephia-f415e9a4709b35a0d9662a2877f597af6a36796f.zip
Splittet eAdd_value(...) up and put parts of it into eAdd_valuestruct(...) to add a eurephiaVALUES struct to an existing chain
Diffstat (limited to 'common')
-rw-r--r--common/eurephia_values.c31
-rw-r--r--common/eurephia_values.h1
2 files changed, 22 insertions, 10 deletions
diff --git a/common/eurephia_values.c b/common/eurephia_values.c
index 06dc6b4..fad9eb6 100644
--- a/common/eurephia_values.c
+++ b/common/eurephia_values.c
@@ -71,10 +71,27 @@ eurephiaVALUES *eCreate_value_space(eurephiaCTX *ctx, int evgid)
}
+void eAdd_valuestruct(eurephiaCTX *ctx, eurephiaVALUES *vls, eurephiaVALUES *newval) {
+ eurephiaVALUES *ptr = NULL;
+ int vid = 0;
+
+ DEBUG(ctx, 31, "Function call: eAdd_valuestruct(ctx, vls(%i), '%s', '%s')",
+ (vls != NULL ? vls->evid : -1), newval->key, newval->val);
+
+ // Add values to the value chain, loop to the end and append it
+ ptr = vls;
+ while( ptr->next != NULL ) {
+ vid = ptr->evid;
+ ptr = ptr->next;
+ }
+ newval->evid = vid+1; // Increase the value counter
+ newval->evid = ptr->evid;
+ ptr->next = newval;
+}
+
void eAdd_value(eurephiaCTX *ctx, eurephiaVALUES *vls, const char *key, const char *val)
{
- eurephiaVALUES *ptr = NULL, *ptr2 = NULL;
- int vid = 0;
+ eurephiaVALUES *ptr = NULL;
DEBUG(ctx, 31, "Function call: eAdd_value(ctx, vls(%i), '%s', '%s')",
(vls != NULL ? vls->evid : -1), key, val);
@@ -89,14 +106,8 @@ void eAdd_value(eurephiaCTX *ctx, eurephiaVALUES *vls, const char *key, const ch
ptr->val = strdup_nullsafe(val);
ptr->evgid = vls->evgid;
- // Add values to the value chain, loop to the end and append it
- ptr2 = vls;
- while( ptr2->next != NULL ) {
- vid = ptr2->evid;
- ptr2 = ptr2->next;
- }
- ptr->evid = vid+1; // Increase the value counter
- ptr2->next = ptr;
+ // Add value struct to the chain
+ eAdd_valuestruct(ctx, vls, ptr);
}
diff --git a/common/eurephia_values.h b/common/eurephia_values.h
index 420da80..04d16de 100644
--- a/common/eurephia_values.h
+++ b/common/eurephia_values.h
@@ -28,6 +28,7 @@ char *eGet_value(eurephiaVALUES *vls, const char *key);
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);
#define eFree_values(c, v) { eFree_values_func(c, v); v = NULL; }