Now deletes memory returned from the transferable

This commit is contained in:
rods%netscape.com 1999-07-20 21:02:02 +00:00
Родитель ebb98de6ad
Коммит a236c8a98b
2 изменённых файлов: 8 добавлений и 1 удалений

Просмотреть файл

@ -631,12 +631,16 @@ NS_IMETHODIMP nsClipboard::ForceDataToClipboard()
PRUint32 dataLen; PRUint32 dataLen;
// Get the data as a bunch-o-bytes from the clipboard // Get the data as a bunch-o-bytes from the clipboard
// this call hands back new memory with the contents copied into it
mTransferable->GetTransferData(df, &data, &dataLen); mTransferable->GetTransferData(df, &data, &dataLen);
// now place it on the Clipboard // now place it on the Clipboard
if (nsnull != data) { if (nsnull != data) {
PlaceDataOnClipboard(format, (char *)data, dataLen); PlaceDataOnClipboard(format, (char *)data, dataLen);
} }
// Now, delete the memory that was created by the transferable
delete [] data;
} }
} }
delete dfList; delete dfList;

Просмотреть файл

@ -329,7 +329,7 @@ HRESULT nsDataObj::GetText(nsString * aDF, FORMATETC& aFE, STGMEDIUM& aSTG)
char * data; char * data;
PRUint32 len; PRUint32 len;
// NOTE: Transferable keeps ownership of the memory // NOTE: Transferable creates new memory, that needs to be deleted
mTransferable->GetTransferData(aDF, (void **)&data, &len); mTransferable->GetTransferData(aDF, (void **)&data, &len);
if (0 == len) { if (0 == len) {
return ResultFromScode(E_FAIL); return ResultFromScode(E_FAIL);
@ -387,6 +387,9 @@ HRESULT nsDataObj::GetText(nsString * aDF, FORMATETC& aFE, STGMEDIUM& aSTG)
aSTG.hGlobal = hGlobalMemory; aSTG.hGlobal = hGlobalMemory;
// Now, delete the memory that was created by the transferable
delete [] data;
return ResultFromScode(S_OK); return ResultFromScode(S_OK);
} }