VirtualBox

Changeset 85986 in vbox for trunk/src


Ignore:
Timestamp:
Sep 1, 2020 5:55:05 PM (4 years ago)
Author:
vboxsync
Message:

Shared Clipboard: Resolved @todos wrt detaching payloads. bugref:9437

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/GuestHost/SharedClipboard/clipboard-common.cpp

    r85985 r85986  
    282282 * Detaches a payload from an event, internal version.
    283283 *
     284 * @returns Pointer to the detached payload. Can be NULL if the payload has no payload.
    284285 * @param   pEvent              Event to detach payload for.
    285286 */
    286 static void shclEventPayloadDetachInternal(PSHCLEVENT pEvent)
    287 {
    288     /** @todo r=bird: This should return pPayload.  It should also not need
    289      *        assert the validity of pEvent in non-strict builds, given that this
    290      *        is an static + internal function, that's a complete waste of time. */
    291     AssertPtrReturnVoid(pEvent);
     287static PSHCLEVENTPAYLOAD shclEventPayloadDetachInternal(PSHCLEVENT pEvent)
     288{
     289#ifdef VBOX_STRICT
     290    AssertPtrReturn(pEvent, NULL);
     291#endif
     292
     293    PSHCLEVENTPAYLOAD pPayload = pEvent->pPayload;
    292294
    293295    pEvent->pPayload = NULL;
     296
     297    return pPayload;
    294298}
    295299
     
    358362            if (ppPayload)
    359363            {
    360                 *ppPayload = pEvent->pPayload;
    361 
    362364                /* Make sure to detach payload here, as the caller now owns the data. */
    363                 shclEventPayloadDetachInternal(pEvent);
     365                *ppPayload = shclEventPayloadDetachInternal(pEvent);
    364366            }
    365367        }
     
    447449    LogFlowFuncLeaveRC(rc);
    448450    return rc;
    449 }
    450 
    451 /**
    452  * Detaches a payload from an event.
    453  *
    454  * @returns VBox status code.
    455  * @param   pSource             Event source of event to detach payload for.
    456  * @param   uID                 Event ID to detach payload for.
    457  */
    458 void ShClEventPayloadDetach(PSHCLEVENTSOURCE pSource, SHCLEVENTID uID)
    459 {
    460     /** @todo r=bird: This API is not needed, it either is a no-op as it
    461      *        replicates work done by ShClEventWait or it leaks the payload as
    462      *        ShClEventWait is the only way to get it as far as I can tell. */
    463 
    464     AssertPtrReturnVoid(pSource);
    465 
    466     LogFlowFunc(("uSource=%RU16, uEvent=%RU32\n", pSource->uID, uID));
    467 
    468     PSHCLEVENT pEvent = shclEventGet(pSource, uID);
    469     if (pEvent)
    470     {
    471         shclEventPayloadDetachInternal(pEvent);
    472     }
    473 #ifdef DEBUG_andy
    474     else
    475         AssertMsgFailed(("uSource=%RU16, uEvent=%RU32\n", pSource->uID, uID));
    476 #endif
    477451}
    478452
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette