[Scummvm-cvs-logs] scummvm master -> 9c01c385124e80cce56504b57d5fc17b863ee601

fingolfin max at quendi.de
Wed May 18 14:09:28 CEST 2011


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
9c01c38512 TINSEL: Document pDispList OBJECT linked list 'trick'


Commit: 9c01c385124e80cce56504b57d5fc17b863ee601
    https://github.com/scummvm/scummvm/commit/9c01c385124e80cce56504b57d5fc17b863ee601
Author: Max Horn (max at quendi.de)
Date: 2011-05-18T05:06:56-07:00

Commit Message:
TINSEL: Document pDispList OBJECT linked list 'trick'

Changed paths:
    engines/tinsel/background.cpp



diff --git a/engines/tinsel/background.cpp b/engines/tinsel/background.cpp
index 4f0623d..79a8d4a 100644
--- a/engines/tinsel/background.cpp
+++ b/engines/tinsel/background.cpp
@@ -162,6 +162,21 @@ OBJECT *GetPlayfieldList(int which) {
 	pPlayfield = pCurBgnd->fieldArray + which;
 
 	// return the display list pointer for this playfield
+	//
+	// HACK: We pretend that pPlayfield is an OBJECT here, by explicitly
+	// casting a pointer to it (resp. to its first member) to an OBJECT
+	// pointer.
+	// Of course it isn't, but its first member is pDispList, an OBJECT
+	// pointer, just like the first member of an OBJECT is pNext, also
+	// an OBJECT pointer. This (classic) trick allows us to use
+	// pPlayfield as a fake anchor element for the linked list of
+	// objects pDispList points to, which in turn simplifies some list
+	// manipulation code. Alas, this is prone to confuse aliasing
+	// analysis in compilers, and also silly developers like myself ;).
+	// So at the very least, I figured we should document this trick
+	// here explicitly.
+	// Personally, I would prefer if we got rid of this trick, e.g. by
+	// introducing an explicit anchor element.
 	return (OBJECT *)&pPlayfield->pDispList;
 }
 






More information about the Scummvm-git-logs mailing list