+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+
+
+void InitLineInfo (void)
+/* Initialize the line infos */
+{
+ /* Allocate 8 slots */
+ AllocatedSlots = 8;
+ CurLineInfo = xmalloc (AllocatedSlots * sizeof (LineInfoSlot));
+
+ /* Initalize the predefined slots */
+ UsedSlots = 2;
+ CurLineInfo[LI_SLOT_ASM].Type = LI_TYPE_ASM;
+ CurLineInfo[LI_SLOT_ASM].Info = 0;
+ CurLineInfo[LI_SLOT_EXT].Type = LI_TYPE_EXT;
+ CurLineInfo[LI_SLOT_EXT].Info = 0;
+}
+
+
+
+unsigned AllocLineInfoSlot (unsigned Type)
+/* Allocate a line info slot of the given type and return the slot index */
+{
+ /* Grow the array if necessary */
+ if (UsedSlots >= AllocatedSlots) {
+ LineInfoSlot* NewLineInfo;
+ AllocatedSlots *= 2;
+ NewLineInfo = xmalloc (AllocatedSlots * sizeof (LineInfoSlot));
+ memcpy (NewLineInfo, CurLineInfo, UsedSlots * sizeof (LineInfoSlot));
+ xfree (CurLineInfo);
+ CurLineInfo = NewLineInfo;
+ }
+
+ /* Array is now big enough, add the new data */
+ CurLineInfo[UsedSlots].Type = Type;
+ CurLineInfo[UsedSlots].Info = 0;
+
+ /* Increment the count and return the index of the new slot */
+ return UsedSlots++;
+}
+
+
+
+void FreeLineInfoSlot (unsigned Slot)
+/* Free the line info in the given slot. Note: Alloc/Free must be used in
+ * FIFO order.
+ */
+{
+ /* Check the parameter */
+ PRECONDITION (Slot == UsedSlots - 1);
+
+ /* Free the last entry */
+ FreeLineInfo (CurLineInfo[Slot].Info);
+ --UsedSlots;
+}
+
+
+
+void GenLineInfo (unsigned Slot, unsigned File, unsigned long Line, unsigned Col)
+/* Generate a new line info in the given slot */
+{
+ /* Get a pointer to the slot */
+ LineInfoSlot* S = CurLineInfo + Slot;
+
+ /* Check if we already have data */
+ if (S->Info) {
+ /* Generate new data only if it is different from the existing. */
+ if (S->Info->Pos.Col == Col &&
+ S->Info->Pos.Line == Line &&
+ S->Info->Pos.Name == File) {
+ /* Already there */
+ return;
+ }
+
+ /* We have data, but it's not identical. If it is in use, copy it to
+ * line info collection, otherwise delete it.
+ */
+ FreeLineInfo (S->Info);
+
+ }
+
+ /* Allocate new data */
+ S->Info = NewLineInfo (S->Type, File, Line, Col);
+}
+
+
+
+void ClearLineInfo (unsigned Slot)
+/* Clear the line info in the given slot */
+{
+ /* Get a pointer to the slot */
+ LineInfoSlot* S = CurLineInfo + Slot;
+
+ /* Free the struct and zero the pointer */
+ FreeLineInfo (S->Info);
+ S->Info = 0;
+}
+
+
+
+LineInfo* GetLineInfo (unsigned Slot)
+/* Get the line info from the given slot */