Changeset 100204 in vbox for trunk/src/VBox/GuestHost/SharedClipboard/clipboard-common.cpp
- Timestamp:
- Jun 19, 2023 9:11:37 AM (18 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/SharedClipboard/clipboard-common.cpp
r99974 r100204 63 63 * @returns VBox status code. 64 64 * @param uID Payload ID to set for this payload. Useful for consequtive payloads. 65 * @param pvData Data block to associate to this payload. 66 * @param cbData Size (in bytes) of data block to associate. 65 * @param pvData Data to associate to this payload. 66 * The payload owns the data then. 67 * @param cbData Size (in bytes) of data to associate. 68 * @param ppPayload Where to store the allocated event payload on success. 69 */ 70 int ShClPayloadInit(uint32_t uID, void *pvData, uint32_t cbData, 71 PSHCLEVENTPAYLOAD *ppPayload) 72 { 73 AssertPtrReturn(pvData, VERR_INVALID_POINTER); 74 AssertReturn(cbData > 0, VERR_INVALID_PARAMETER); 75 76 PSHCLEVENTPAYLOAD pPayload = (PSHCLEVENTPAYLOAD)RTMemAlloc(sizeof(SHCLEVENTPAYLOAD)); 77 if (pPayload) 78 { 79 pPayload->pvData = pvData; 80 pPayload->cbData = cbData; 81 pPayload->uID = uID; 82 83 *ppPayload = pPayload; 84 return VINF_SUCCESS; 85 } 86 87 return VERR_NO_MEMORY; 88 } 89 90 /** 91 * Allocates a new event payload. 92 * 93 * @returns VBox status code. 94 * @param uID Payload ID to set for this payload. Useful for consequtive payloads. 95 * @param pvData Data block to allocate (duplicate) to this payload. 96 * @param cbData Size (in bytes) of data block to allocate. 67 97 * @param ppPayload Where to store the allocated event payload on success. 68 98 */ … … 73 103 AssertReturn(cbData > 0, VERR_INVALID_PARAMETER); 74 104 75 PSHCLEVENTPAYLOAD pPayload = (PSHCLEVENTPAYLOAD)RTMemAlloc(sizeof(SHCLEVENTPAYLOAD)); 76 if (pPayload) 77 { 78 pPayload->pvData = RTMemDup(pvData, cbData); 79 if (pPayload->pvData) 80 { 81 pPayload->cbData = cbData; 82 pPayload->uID = uID; 83 84 *ppPayload = pPayload; 85 return VINF_SUCCESS; 86 } 87 88 RTMemFree(pPayload); 89 } 105 void *pvDataDup = RTMemDup(pvData, cbData); 106 if (pvDataDup) 107 return ShClPayloadInit(uID, pvDataDup, cbData, ppPayload); 108 90 109 return VERR_NO_MEMORY; 91 110 } … … 418 437 * Detaches a payload from an event, internal version. 419 438 * 420 * @returns Pointer to the detached payload. Can be NULL if the payloadhas no payload.439 * @returns Pointer to the detached payload. Can be NULL if the event has no payload. 421 440 * @param pEvent Event to detach payload for. 422 441 */ … … 480 499 481 500 /** 482 * Releases an event by decreasing its reference count.501 * Releases event by decreasing its reference count. Will be destroys once the reference count reaches 0. 483 502 * 484 503 * @returns New reference count, or UINT32_MAX if failed.
Note:
See TracChangeset
for help on using the changeset viewer.