]> git.sur5r.net Git - cc65/blobdiff - src/common/gentype.c
Merge remote-tracking branch 'upstream/master' into a5200
[cc65] / src / common / gentype.c
index dd108252850b6a31255fee80a3db4bc5592788ba..019569084db7d6b1c666998648b2376a3c008f5e 100644 (file)
@@ -34,6 +34,7 @@
 
 
 /* common */
+#include "check.h"
 #include "gentype.h"
 #include "strbuf.h"
 
@@ -53,7 +54,7 @@ void GT_AddArray (StrBuf* Type, unsigned ArraySize)
     unsigned SizeBytes;
 
     /* Remember the current position */
-    char* A = SB_GetBuf (Type) + SB_GetLen (Type);
+    unsigned Pos = SB_GetLen (Type);
 
     /* Add a dummy array token */
     SB_AppendChar (Type, GT_TYPE_ARRAY);
@@ -67,14 +68,16 @@ void GT_AddArray (StrBuf* Type, unsigned ArraySize)
     } while (ArraySize);
 
     /* Write the correct array token */
-    *A = GT_ARRAY (SizeBytes);
+    SB_GetBuf (Type)[Pos] = GT_ARRAY (SizeBytes);
 }
 
 
 
-unsigned GT_GetArraySize (StrBuf* Type)
-/* Retrieve the size of an array stored in Type at the current index position.
- * The index position will get moved past the array size.
+unsigned GT_GetElementCount (StrBuf* Type)
+/* Retrieve the element count of an array stored in Type at the current index
+ * position. Note: Index must point to the array token itself, since the size
+ * of the element count is encoded there. The index position will get moved
+ * past the array.
  */
 {
     /* Get the number of bytes for the element count */
@@ -120,9 +123,3 @@ const char* GT_AsString (const StrBuf* Type, StrBuf* String)
     /* Return the contents of String */
     return SB_GetConstBuf (String);
 }
-
-
-
-
-
-