Andrew Talbot : dmloader: Assign to structs instead of using memcpy.

Alexandre Julliard julliard at winehq.org
Mon Feb 25 06:51:38 CST 2008


Module: wine
Branch: master
Commit: 4cd6ef739d4699f4ccfa53c3256af5c46f06193b
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=4cd6ef739d4699f4ccfa53c3256af5c46f06193b

Author: Andrew Talbot <andrew.talbot at talbotville.com>
Date:   Sat Feb 23 16:58:32 2008 +0000

dmloader: Assign to structs instead of using memcpy.

---

 dlls/dmloader/container.c |   18 +++++++++---------
 dlls/dmloader/loader.c    |   32 ++++++++++++++++----------------
 2 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/dlls/dmloader/container.c b/dlls/dmloader/container.c
index d4fc4d9..98fbf51 100644
--- a/dlls/dmloader/container.c
+++ b/dlls/dmloader/container.c
@@ -120,7 +120,7 @@ static HRESULT WINAPI IDirectMusicContainerImpl_IDirectMusicContainer_EnumObject
 						result = DMUS_S_STRING_TRUNCATED;
 				}
 				if (pDesc)
-					memcpy (pDesc, &pContainedObject->Desc, sizeof(DMUS_OBJECTDESC));
+					*pDesc = pContainedObject->Desc;
 				return result;
 			}
 			dwCount++;
@@ -171,10 +171,10 @@ static HRESULT WINAPI IDirectMusicContainerImpl_IDirectMusicObject_GetDescriptor
 		ERR(": pDesc bad write pointer\n");
 		return E_POINTER;
 	}
-	
+
 	DM_STRUCT_INIT(pDesc);
-	memcpy (pDesc, &This->Desc, sizeof(DMUS_OBJECTDESC));
-	
+	*pDesc = This->Desc;
+
 	return S_OK;
 }
 
@@ -199,7 +199,7 @@ static HRESULT WINAPI IDirectMusicContainerImpl_IDirectMusicObject_SetDescriptor
 	}
 
 	if (pDesc->dwValidData & DMUS_OBJ_OBJECT) {
-		memcpy (&This->Desc.guidObject, &pDesc->guidObject, sizeof(GUID));
+		This->Desc.guidObject = pDesc->guidObject;
 		dwNewFlags |= DMUS_OBJ_OBJECT;
 	}
 	if (pDesc->dwValidData & DMUS_OBJ_NAME) {
@@ -276,7 +276,7 @@ static HRESULT WINAPI IDirectMusicContainerImpl_IDirectMusicObject_ParseDescript
 				TRACE_(dmfile)(": container form\n");
 				/* set guidClass */
 				pDesc->dwValidData |= DMUS_OBJ_CLASS;
-				memcpy (&pDesc->guidClass, &CLSID_DirectMusicContainer, sizeof(CLSID));				
+				pDesc->guidClass = CLSID_DirectMusicContainer;
 				do {
 					IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
 					StreamCount += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
@@ -490,7 +490,7 @@ static HRESULT WINAPI IDirectMusicContainerImpl_IPersistStream_Load (LPPERSISTST
 			switch (Chunk.fccID) {
 				case DMUS_FOURCC_CONTAINER_FORM: {
 					TRACE_(dmfile)(": container form\n");
-					memcpy (&This->Desc.guidClass, &CLSID_DirectMusicContainer, sizeof(CLSID));
+					This->Desc.guidClass = CLSID_DirectMusicContainer;
 					This->Desc.dwValidData |= DMUS_OBJ_CLASS;
 					do {
 						IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
@@ -618,7 +618,7 @@ static HRESULT WINAPI IDirectMusicContainerImpl_IPersistStream_Load (LPPERSISTST
 																		TRACE_(dmdump)(": contained object header: \n%s\n", debugstr_DMUS_IO_CONTAINED_OBJECT_HEADER(&tmpObjectHeader));
 																		/* copy guidClass */
 																		pNewEntry->Desc.dwValidData |= DMUS_OBJ_CLASS;
-																		memcpy (&pNewEntry->Desc.guidClass, &tmpObjectHeader.guidClassID, sizeof(GUID));
+																		pNewEntry->Desc.guidClass = tmpObjectHeader.guidClassID;
 																		/* store flags */
 																		pNewEntry->dwFlags = tmpObjectHeader.dwFlags;
 																		break;
@@ -648,7 +648,7 @@ static HRESULT WINAPI IDirectMusicContainerImpl_IPersistStream_Load (LPPERSISTST
 																							if (!IsEqualCLSID (&pNewEntry->Desc.guidClass, &tmpReferenceHeader.guidClassID)) ERR(": object header declares different CLSID than reference header?\n");
 																							/* it shouldn't be necessary to copy guidClass, since it was set in contained object header already...
 																							   yet if they happen to be different, I'd rather stick to this one */
-																							memcpy (&pNewEntry->Desc.guidClass, &tmpReferenceHeader.guidClassID, sizeof(GUID));
+																							pNewEntry->Desc.guidClass = tmpReferenceHeader.guidClassID;
 																							pNewEntry->Desc.dwValidData |= tmpReferenceHeader.dwValidData;
 																							break;																	
 																						}
diff --git a/dlls/dmloader/loader.c b/dlls/dmloader/loader.c
index b920d9c..8f1f2c2 100644
--- a/dlls/dmloader/loader.c
+++ b/dlls/dmloader/loader.c
@@ -492,7 +492,7 @@ static HRESULT WINAPI IDirectMusicLoaderImpl_IDirectMusicLoader_ScanDirectory (L
 		DMUS_OBJECTDESC Desc;
 		DM_STRUCT_INIT(&Desc);
 		Desc.dwValidData = DMUS_OBJ_CLASS | DMUS_OBJ_FILENAME | DMUS_OBJ_FULLPATH | DMUS_OBJ_DATE;
-		memcpy (&Desc.guidClass, rguidClass, sizeof(GUID));
+		Desc.guidClass = *rguidClass;
 		strcpyW (Desc.wszFileName, FileData.cFileName);
 		FileTimeToLocalFileTime (&FileData.ftCreationTime, &Desc.ftDate);
 		IDirectMusicLoader8_SetObject (iface, &Desc);
@@ -690,15 +690,15 @@ static HRESULT WINAPI IDirectMusicLoaderImpl_IDirectMusicLoader_EnumObject (LPDI
 	LPWINE_LOADER_ENTRY pObjectEntry;
 	ICOM_THIS_MULTI(IDirectMusicLoaderImpl, LoaderVtbl, iface);
 	TRACE("(%p, %s, %d, %p)\n", This, debugstr_dmguid(rguidClass), dwIndex, pDesc);
-	
+
 	DM_STRUCT_INIT(pDesc);
-	
+
 	LIST_FOR_EACH (pEntry, This->pObjects) {
 		pObjectEntry = LIST_ENTRY (pEntry, WINE_LOADER_ENTRY, entry);
-			
+
 		if (IsEqualGUID (rguidClass, &GUID_DirectMusicAllTypes) || IsEqualGUID (rguidClass, &pObjectEntry->Desc.guidClass)) {
 			if (dwCount == dwIndex) {
-				memcpy (pDesc, &pObjectEntry->Desc, sizeof(DMUS_OBJECTDESC));
+				*pDesc = pObjectEntry->Desc;
 				/* we aren't supposed to reveal this info */
 				pDesc->dwValidData &= ~(DMUS_OBJ_MEMORY | DMUS_OBJ_STREAM);
 				pDesc->pbMemData = NULL;
@@ -744,12 +744,12 @@ static HRESULT WINAPI IDirectMusicLoaderImpl_IDirectMusicLoader_LoadObjectFromFi
 	ICOM_THIS_MULTI(IDirectMusicLoaderImpl, LoaderVtbl, iface);
 	DMUS_OBJECTDESC ObjDesc;
 	WCHAR wszLoaderSearchPath[MAX_PATH];
-	
+
 	TRACE("(%p, %s, %s, %s, %p): wrapping to IDirectMusicLoaderImpl_GetObject\n", This, debugstr_dmguid(rguidClassID), debugstr_dmguid(iidInterfaceID), debugstr_w(pwzFilePath), ppObject);
-	
+
 	DM_STRUCT_INIT(&ObjDesc);	
 	ObjDesc.dwValidData = DMUS_OBJ_FILENAME | DMUS_OBJ_FULLPATH | DMUS_OBJ_CLASS; /* I believe I've read somewhere in MSDN that this function requires either full path or relative path */
-	memcpy (&ObjDesc.guidClass, rguidClassID, sizeof(CLSID));
+	ObjDesc.guidClass = *rguidClassID;
 	/* OK, MSDN says that search order is the following:
 	    - current directory (DONE)
 	    - windows search path (FIXME: how do I get that?)
@@ -817,8 +817,8 @@ HRESULT WINAPI DMUSIC_CreateDirectMusicLoaderImpl (LPCGUID lpcGUID, LPVOID *ppob
 	/* set default DLS collection (via SetObject... so that loading via DMUS_OBJ_OBJECT is possible) */
 	DM_STRUCT_INIT(&Desc);
 	Desc.dwValidData = DMUS_OBJ_CLASS | DMUS_OBJ_FILENAME | DMUS_OBJ_FULLPATH | DMUS_OBJ_OBJECT;
-	memcpy (&Desc.guidClass, &CLSID_DirectMusicCollection, sizeof(CLSID));
-	memcpy (&Desc.guidObject, &GUID_DefaultGMCollection, sizeof(GUID));
+	Desc.guidClass = CLSID_DirectMusicCollection;
+	Desc.guidObject = GUID_DefaultGMCollection;
 	DMUSIC_GetDefaultGMPath (Desc.wszFileName);
 	IDirectMusicLoader_SetObject ((LPDIRECTMUSICLOADER8)obj, &Desc);
 	/* and now the workaroundTM for "invalid" default DLS; basically, 
@@ -939,10 +939,10 @@ HRESULT WINAPI DMUSIC_InitLoaderSettings (LPDIRECTMUSICLOADER8 iface) {
 
 	TRACE(": (%p)\n", This);
 	GetCurrentDirectoryW (MAX_PATH, wszCurrent);
-	
+
 	for (i = 0; i < sizeof(classes)/sizeof(REFCLSID); i++) {
 		LPWINE_LOADER_OPTION pNewSetting = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(WINE_LOADER_OPTION));
-		memcpy (&pNewSetting->guidClass, classes[i], sizeof(CLSID));
+		pNewSetting->guidClass = *classes[i];
 		strcpyW (pNewSetting->wszSearchPath, wszCurrent);
 		pNewSetting->bCache = TRUE;
 		list_add_tail (This->pClassSettings, &pNewSetting->entry);
@@ -954,10 +954,10 @@ HRESULT WINAPI DMUSIC_InitLoaderSettings (LPDIRECTMUSICLOADER8 iface) {
 HRESULT WINAPI DMUSIC_CopyDescriptor (LPDMUS_OBJECTDESC pDst, LPDMUS_OBJECTDESC pSrc) {
 	TRACE(": copy \n%s", debugstr_DMUS_OBJECTDESC(pSrc));
 	/* copy field by field */
-	if (pSrc->dwValidData & DMUS_OBJ_CLASS) memcpy (&pDst->guidClass, &pSrc->guidClass, sizeof(CLSID));
-	if (pSrc->dwValidData & DMUS_OBJ_OBJECT) memcpy (&pDst->guidObject, &pSrc->guidObject, sizeof(GUID));
-	if (pSrc->dwValidData & DMUS_OBJ_DATE) memcpy (&pDst->ftDate, &pSrc->ftDate, sizeof(FILETIME));
-	if (pSrc->dwValidData & DMUS_OBJ_VERSION) memcpy (&pDst->vVersion, &pSrc->vVersion, sizeof(DMUS_VERSION));
+	if (pSrc->dwValidData & DMUS_OBJ_CLASS) pDst->guidClass = pSrc->guidClass;
+	if (pSrc->dwValidData & DMUS_OBJ_OBJECT) pDst->guidObject = pSrc->guidObject;
+	if (pSrc->dwValidData & DMUS_OBJ_DATE) pDst->ftDate = pSrc->ftDate;
+	if (pSrc->dwValidData & DMUS_OBJ_VERSION) pDst->vVersion = pSrc->vVersion;
 	if (pSrc->dwValidData & DMUS_OBJ_NAME) strcpyW (pDst->wszName, pSrc->wszName);
 	if (pSrc->dwValidData & DMUS_OBJ_CATEGORY) strcpyW (pDst->wszCategory, pSrc->wszCategory);
 	if (pSrc->dwValidData & DMUS_OBJ_FILENAME) strcpyW (pDst->wszFileName, pSrc->wszFileName);




More information about the wine-cvs mailing list