mirror of
https://github.com/cc65/cc65.git
synced 2025-01-26 02:30:17 +00:00
Implementation of StringPool has changed.
git-svn-id: svn://svn.cc65.org/cc65/trunk@5240 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
e1a861f0a5
commit
bf889a1928
@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 2003 Ullrich von Bassewitz */
|
/* (C) 2003-2011, Ullrich von Bassewitz */
|
||||||
/* Römerstrasse 52 */
|
/* Roemerstrasse 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@ -44,7 +44,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
StringPool StrPool = STATIC_STRINGPOOL_INITIALIZER;
|
StringPool* StrPool = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -57,10 +57,13 @@ StringPool StrPool = STATIC_STRINGPOOL_INITIALIZER;
|
|||||||
void InitStrPool (void)
|
void InitStrPool (void)
|
||||||
/* Initialize the string pool */
|
/* Initialize the string pool */
|
||||||
{
|
{
|
||||||
|
/* Allocate a string pool */
|
||||||
|
StrPool = NewStringPool (1103);
|
||||||
|
|
||||||
/* We insert a first string here, which will have id zero. This means
|
/* We insert a first string here, which will have id zero. This means
|
||||||
* that we can treat index zero later as invalid.
|
* that we can treat index zero later as invalid.
|
||||||
*/
|
*/
|
||||||
SP_AddStr (&StrPool, "<invalid message #0>");
|
SP_AddStr (StrPool, "<invalid message #0>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 2003-2008 Ullrich von Bassewitz */
|
/* (C) 2003-2011, Ullrich von Bassewitz */
|
||||||
/* Roemerstrasse 52 */
|
/* Roemerstrasse 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@ -53,7 +53,7 @@
|
|||||||
#define INVALID_STRING_ID 0U
|
#define INVALID_STRING_ID 0U
|
||||||
|
|
||||||
/* The string pool we're using */
|
/* The string pool we're using */
|
||||||
extern StringPool StrPool;
|
extern StringPool* StrPool;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -67,40 +67,40 @@ extern StringPool StrPool;
|
|||||||
INLINE unsigned GetStrBufId (const StrBuf* S)
|
INLINE unsigned GetStrBufId (const StrBuf* S)
|
||||||
/* Return the id of the given string buffer */
|
/* Return the id of the given string buffer */
|
||||||
{
|
{
|
||||||
return SP_Add (&StrPool, S);
|
return SP_Add (StrPool, S);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
# define GetStrBufId(S) SP_Add (&StrPool, (S))
|
# define GetStrBufId(S) SP_Add (StrPool, (S))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_INLINE)
|
#if defined(HAVE_INLINE)
|
||||||
INLINE unsigned GetStringId (const char* S)
|
INLINE unsigned GetStringId (const char* S)
|
||||||
/* Return the id of the given string */
|
/* Return the id of the given string */
|
||||||
{
|
{
|
||||||
return SP_AddStr (&StrPool, S);
|
return SP_AddStr (StrPool, S);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
# define GetStringId(S) SP_AddStr (&StrPool, (S))
|
# define GetStringId(S) SP_AddStr (StrPool, (S))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_INLINE)
|
#if defined(HAVE_INLINE)
|
||||||
INLINE const StrBuf* GetStrBuf (unsigned Index)
|
INLINE const StrBuf* GetStrBuf (unsigned Index)
|
||||||
/* Convert a string index into a string */
|
/* Convert a string index into a string */
|
||||||
{
|
{
|
||||||
return SP_Get (&StrPool, Index);
|
return SP_Get (StrPool, Index);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
# define GetStrBuf(Index) SP_Get (&StrPool, (Index))
|
# define GetStrBuf(Index) SP_Get (StrPool, (Index))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_INLINE)
|
#if defined(HAVE_INLINE)
|
||||||
INLINE const char* GetString (unsigned Index)
|
INLINE const char* GetString (unsigned Index)
|
||||||
/* Convert a string index into a string */
|
/* Convert a string index into a string */
|
||||||
{
|
{
|
||||||
return SB_GetConstBuf (SP_Get (&StrPool, Index));
|
return SB_GetConstBuf (SP_Get (StrPool, Index));
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
# define GetString(Index) SB_GetConstBuf (SP_Get (&StrPool, (Index)))
|
# define GetString(Index) SB_GetConstBuf (SP_Get (StrPool, (Index)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void InitStrPool (void);
|
void InitStrPool (void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user