[Scummvm-cvs-logs] CVS: scummvm/scumm script_v6.cpp,1.101,1.102

Marcus Comstedt marcus_c at users.sourceforge.net
Sun May 4 10:23:37 CEST 2003


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv9093

Modified Files:
	script_v6.cpp 
Log Message:
GCC believes that if we cast a pointer to <type *>, then we are guaranteeing
that the pointer has proper alignment for <type>, and that it can replace the
memcpy() with a direct assignment.  This totally defies the purpose of the
memcpy(), which is there precisely because the memory is unaligned.  Avoid
problems by not making the cast.


Index: script_v6.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v6.cpp,v
retrieving revision 1.101
retrieving revision 1.102
diff -u -d -r1.101 -r1.102
--- script_v6.cpp	30 Apr 2003 13:23:30 -0000	1.101
+++ script_v6.cpp	4 May 2003 17:21:31 -0000	1.102
@@ -425,14 +425,14 @@
 	} else if (_features & GF_AFTER_V8) {
 #if defined(SCUMM_NEED_ALIGNMENT)
 		uint32 tmp = TO_LE_32(value);
-		memcpy(&((uint32 *)ah->data)[base], &tmp, 4);
+		memcpy(&((char *)ah->data)[base*sizeof(uint32)], &tmp, 4);
 #else
 		((uint32 *)ah->data)[base] = TO_LE_32(value);
 #endif
 	} else {
 #if defined(SCUMM_NEED_ALIGNMENT)
 		uint16 tmp = TO_LE_16(value);
-		memcpy(&((uint16 *)ah->data)[base], &tmp, 2);
+		memcpy(&((char *)ah->data)[base*sizeof(uint16)], &tmp, 2);
 #else
 		((uint16 *)ah->data)[base] = TO_LE_16(value);
 #endif





More information about the Scummvm-git-logs mailing list