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
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 ***** */
|
||||
|
||||
Reference in New Issue
Block a user