From ac82a58332c371c0338871b1776af2f8a45db5aa Mon Sep 17 00:00:00 2001 From: avolkov Date: Wed, 22 Nov 2006 17:21:36 +0000 Subject: [PATCH] Copy strings instead of merely storing ptrs to them git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2517 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/src/sc2code/libs/resource/alist.c | 10 +++++----- sc2/src/sc2code/libs/resource/alist.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sc2/src/sc2code/libs/resource/alist.c b/sc2/src/sc2code/libs/resource/alist.c index 0614a52ca..42ac9a4e3 100644 --- a/sc2/src/sc2code/libs/resource/alist.c +++ b/sc2/src/sc2code/libs/resource/alist.c @@ -24,12 +24,12 @@ #include "alist.h" alist_entry * -AlistEntry_New (const char *key, const char *value) +AlistEntry_New (alist *m, const char *key, const char *value) { alist_entry *e; e = malloc (sizeof(alist_entry)); - e->key = key; - e->value = value; + e->key = StringBank_AddOrFindString(m->bank, key); + e->value = StringBank_AddOrFindString(m->bank, value); e->next = NULL; return e; } @@ -84,11 +84,11 @@ Alist_PutString (alist *m, const char *key, const char *value) { alist_entry *e = Alist_GetEntry (m, key); if (e == NULL) { - e = AlistEntry_New(key, value); + e = AlistEntry_New(m, key, value); e->next = m->first; m->first = e; } else { - e->value = value; + e->value = StringBank_AddOrFindString(m->bank, value); } } diff --git a/sc2/src/sc2code/libs/resource/alist.h b/sc2/src/sc2code/libs/resource/alist.h index 9e3ee8758..729b6e855 100644 --- a/sc2/src/sc2code/libs/resource/alist.h +++ b/sc2/src/sc2code/libs/resource/alist.h @@ -37,7 +37,7 @@ typedef struct _alist_map { /* ***** alist_entry operations ***** */ /* Constructor and destructor */ -alist_entry *AlistEntry_New (const char *key, const char *value); +alist_entry *AlistEntry_New (alist *m, const char *key, const char *value); void AlistEntry_Free (alist_entry *e); /* ***** alist operations ***** */