Make much more usage of dynamic strings (StrBufs) instead of char* and

friends. Since names and other strings are now StrBufs in many places, code
for output had to be changed.
Added support for string literals to StrBuf.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3825 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz
2008-03-31 20:54:45 +00:00
parent 6a7e844500
commit 9174f65e54
78 changed files with 1228 additions and 864 deletions

View File

@@ -6,8 +6,8 @@
/* */
/* */
/* */
/* (C) 1998-2003 Ullrich von Bassewitz */
/* R<EFBFBD>merstrasse 52 */
/* (C) 1998-2008 Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
@@ -283,34 +283,23 @@ unsigned ReadStr (FILE* F)
*/
{
unsigned Id;
char* B;
char Buf[256];
StrBuf Buf = STATIC_STRBUF_INITIALIZER;
/* Read the length */
unsigned Len = ReadVar (F);
/* If the string is short enough, use our buffer on the stack, otherwise
* allocate space on the heap.
*/
if (Len < sizeof (Buf)) {
B = Buf;
} else {
B = xmalloc (Len + 1);
}
/* Expand the string buffer memory */
SB_Realloc (&Buf, Len);
/* Read the string */
ReadData (F, B, Len);
/* Terminate the string */
B[Len] = '\0';
ReadData (F, SB_GetBuf (&Buf), Len);
Buf.Len = Len;
/* Insert it into the string pool and remember the id */
Id = GetStringId (B);
Id = GetStrBufId (&Buf);
/* If we had allocated memory before, free it now */
if (B != Buf) {
xfree (B);
}
/* Free the memory buffer */
SB_Done (&Buf);
/* Return the string id */
return Id;