From 77110021abb683e4d7471a204817fd2b80522970 Mon Sep 17 00:00:00 2001 From: uz Date: Sun, 21 Aug 2011 13:21:11 +0000 Subject: [PATCH] Implementation of StringPool has changed. git-svn-id: svn://svn.cc65.org/cc65/trunk@5242 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/ca65/main.c | 3 +++ src/ca65/spool.c | 14 +++++++++++--- src/ca65/spool.h | 21 ++++++++++++--------- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/ca65/main.c b/src/ca65/main.c index 7364891bc..8dc77a38d 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -863,6 +863,9 @@ int main (int argc, char* argv []) /* Initialize the cmdline module */ InitCmdLine (&argc, &argv, "ca65"); + /* Initialize the string pool */ + InitStrPool (); + /* Initialize the include search paths */ InitIncludePaths (); diff --git a/src/ca65/spool.c b/src/ca65/spool.c index 7d5bd98ea..0b77ef615 100644 --- a/src/ca65/spool.c +++ b/src/ca65/spool.c @@ -45,7 +45,7 @@ -StringPool StrPool = STATIC_STRINGPOOL_INITIALIZER; +StringPool* StrPool = 0; @@ -61,7 +61,7 @@ void WriteStrPool (void) unsigned I; /* Get the number of strings in the string pool */ - unsigned Count = SP_GetCount (&StrPool); + unsigned Count = SP_GetCount (StrPool); /* Tell the object file module that we're about to start the string pool */ ObjStartStrPool (); @@ -71,7 +71,7 @@ void WriteStrPool (void) /* Write the strings in id order */ for (I = 0; I < Count; ++I) { - ObjWriteBuf (SP_Get (&StrPool, I)); + ObjWriteBuf (SP_Get (StrPool, I)); } /* Done writing the string pool */ @@ -80,3 +80,11 @@ void WriteStrPool (void) +void InitStrPool (void) +/* Initialize the string pool */ +{ + StrPool = NewStringPool (1103); +} + + + diff --git a/src/ca65/spool.h b/src/ca65/spool.h index 517320e0d..050e63abb 100644 --- a/src/ca65/spool.h +++ b/src/ca65/spool.h @@ -49,7 +49,7 @@ -extern StringPool StrPool; +extern StringPool* StrPool; @@ -63,45 +63,48 @@ extern StringPool StrPool; INLINE unsigned GetStrBufId (const StrBuf* S) /* Return the id of the given string buffer */ { - return SP_Add (&StrPool, S); + return SP_Add (StrPool, S); } #else -# define GetStrBufId(S) SP_Add (&StrPool, (S)) +# define GetStrBufId(S) SP_Add (StrPool, (S)) #endif #if defined(HAVE_INLINE) INLINE unsigned GetStringId (const char* S) /* Return the id of the given string */ { - return SP_AddStr (&StrPool, S); + return SP_AddStr (StrPool, S); } #else -# define GetStringId(S) SP_AddStr (&StrPool, (S)) +# define GetStringId(S) SP_AddStr (StrPool, (S)) #endif #if defined(HAVE_INLINE) INLINE const StrBuf* GetStrBuf (unsigned Index) /* Convert a string index into a string */ { - return SP_Get (&StrPool, Index); + return SP_Get (StrPool, Index); } #else -# define GetStrBuf(Index) SP_Get (&StrPool, (Index)) +# define GetStrBuf(Index) SP_Get (StrPool, (Index)) #endif #if defined(HAVE_INLINE) INLINE const char* GetString (unsigned Index) /* Convert a string index into a string */ { - return SB_GetConstBuf (SP_Get (&StrPool, Index)); + return SB_GetConstBuf (SP_Get (StrPool, Index)); } #else -# define GetString(Index) SB_GetConstBuf (SP_Get (&StrPool, (Index))) +# define GetString(Index) SB_GetConstBuf (SP_Get (StrPool, (Index))) #endif void WriteStrPool (void); /* Write the string pool to the object file */ +void InitStrPool (void); +/* Initialize the string pool */ + /* End of spool.h */ -- 2.39.5