VirtualBox

Changeset 101996 in vbox


Ignore:
Timestamp:
Nov 8, 2023 5:57:26 PM (13 months ago)
Author:
vboxsync
Message:

libs/xpcom/ipc: More conversion to IPRT infrastructure, bugref:10545

Location:
trunk/src/libs/xpcom18a4/ipc/ipcd
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/ipc/ipcd/daemon/src/ipcd.cpp

    r101933 r101996  
    3636 * ***** END LICENSE BLOCK ***** */
    3737
    38 #include "prlog.h"
    3938#include "prio.h"
    4039
     
    4746#include "ipcd.h"
    4847
     48#include <iprt/assert.h>
     49
    4950//-----------------------------------------------------------------------------
    5051
     
    6566IPC_DispatchMsg(ipcClient *client, const ipcMessage *msg)
    6667{
    67     PR_ASSERT(client);
    68     PR_ASSERT(msg);
     68    Assert(client);
     69    Assert(msg);
    6970
    7071    // remember if client is expecting SYNC_REPLY.  we'll add that flag to the
    7172    // next message sent to the client.
    7273    if (msg->TestFlag(IPC_MSG_FLAG_SYNC_QUERY)) {
    73         PR_ASSERT(client->GetExpectsSyncReply() == PR_FALSE);
     74        Assert(client->GetExpectsSyncReply() == PR_FALSE);
    7475        // XXX shouldn't we remember the TargetID as well, and only set the
    7576        //     SYNC_REPLY flag on the next message sent to the same TargetID?
     
    8889IPC_SendMsg(ipcClient *client, ipcMessage *msg)
    8990{
    90     PR_ASSERT(msg);
     91    Assert(msg);
    9192
    9293    if (client == NULL) {
     
    172173IPC_EnumClients(ipcClientEnumFunc func, void *closure)
    173174{
    174     PR_ASSERT(func);
     175    Assert(func);
    175176    for (int i = 0; i < ipcClientCount; ++i) {
    176177        if (func(closure, &ipcClients[i], ipcClients[i].ID()) == PR_FALSE)
     
    182183IPC_GetClientID(ipcClient *client)
    183184{
    184     PR_ASSERT(client);
     185    Assert(client);
    185186    return client->ID();
    186187}
     
    189190IPC_ClientHasName(ipcClient *client, const char *name)
    190191{
    191     PR_ASSERT(client);
    192     PR_ASSERT(name);
     192    Assert(client);
     193    Assert(name);
    193194    return client->HasName(name);
    194195}
     
    197198IPC_ClientHasTarget(ipcClient *client, const nsID &target)
    198199{
    199     PR_ASSERT(client);
     200    Assert(client);
    200201    return client->HasTarget(target);
    201202}
     
    204205IPC_EnumClientNames(ipcClient *client, ipcClientNameEnumFunc func, void *closure)
    205206{
    206     PR_ASSERT(client);
    207     PR_ASSERT(func);
     207    Assert(client);
     208    Assert(func);
    208209    const ipcStringNode *node = client->Names();
    209210    while (node) {
     
    217218IPC_EnumClientTargets(ipcClient *client, ipcClientTargetEnumFunc func, void *closure)
    218219{
    219     PR_ASSERT(client);
    220     PR_ASSERT(func);
     220    Assert(client);
     221    Assert(func);
    221222    const ipcIDNode *node = client->Targets();
    222223    while (node) {
  • trunk/src/libs/xpcom18a4/ipc/ipcd/extensions/lock/src/ipcLockProtocol.cpp

    r1 r101996  
    3838#include <stdlib.h>
    3939#include <string.h>
    40 #include "prlog.h"
    4140#include "ipcLockProtocol.h"
     41
     42#include <iprt/assert.h>
    4243
    4344//-----------------------------------------------------------------------------
     
    8182IPC_UnflattenLockMsg(const PRUint8 *buf, PRUint32 bufLen, ipcLockMsg *msg)
    8283{
    83     PR_ASSERT(bufLen > 2); // malformed buffer otherwise
     84    Assert(bufLen > 2); // malformed buffer otherwise
    8485    msg->opcode = get_opcode(buf);
    8586    msg->flags = get_flags(buf);
  • trunk/src/libs/xpcom18a4/ipc/ipcd/extensions/transmngr/common/tmUtils.h

    r1 r101996  
    4242#include "nsError.h"
    4343#include "nsID.h"
    44 #include "prlog.h"
    4544#include <stdio.h>
     45
     46#include <iprt/assert.h>
    4647
    4748// UUID used to identify the Transaction Module in both daemon and client
  • trunk/src/libs/xpcom18a4/ipc/ipcd/extensions/transmngr/common/tmVector.cpp

    r31259 r101996  
    3838#include <stdlib.h>
    3939#include "tmVector.h"
    40 #ifdef VBOX_USE_IPRT_IN_XPCOM
    41 # include <iprt/mem.h>
    42 #endif
     40
     41#include <iprt/mem.h>
    4342
    4443////////////////////////////////////////////////////////////////////////////
     
    4948tmVector::~tmVector() {
    5049  if (mElements)
    51 #ifdef VBOX_USE_IPRT_IN_XPCOM
    5250    RTMemFree((void*)mElements);
    53 #else
    54     free((void*)mElements);
    55 #endif
    5651}
    5752
     
    6257tmVector::Init() {
    6358
    64 #ifdef VBOX_USE_IPRT_IN_XPCOM
    6559  mElements = (void**) RTMemAllocZ (mCapacity * sizeof(void*));
    66 #else
    67   mElements = (void**) calloc (mCapacity, sizeof(void*));
    68 #endif
    6960  if (!mElements)
    7061    return NS_ERROR_OUT_OF_MEMORY;
     
    7768PRInt32
    7869tmVector::Append(void *aElement){
    79   PR_ASSERT(aElement);
     70  Assert(aElement);
    8071
    8172  // make sure there is room
     
    9485void
    9586tmVector::Remove(void *aElement) {
    96   PR_ASSERT(aElement);
     87  Assert(aElement);
    9788
    9889  for (PRUint32 index = 0; index < mNext; index++) {
     
    111102void
    112103tmVector::RemoveAt(PRUint32 aIndex) {
    113   PR_ASSERT(aIndex < mNext);
     104  Assert(aIndex < mNext);
    114105
    115106  // remove the element if it isn't already nsnull
     
    148139
    149140  PRUint32 newcap = mCapacity + GROWTH_INC;
    150 #ifdef VBOX_USE_IPRT_IN_XPCOM
    151141  mElements = (void**) RTMemRealloc(mElements, (newcap * sizeof(void*)));
    152 #else
    153   mElements = (void**) realloc(mElements, (newcap * sizeof(void*)));
    154 #endif
    155142  if (mElements) {
    156143    mCapacity = newcap;
     
    167154  PRUint32 newcap = mCapacity - GROWTH_INC;
    168155  if (mNext < newcap) {
    169 #ifdef VBOX_USE_IPRT_IN_XPCOM
    170156    mElements = (void**) RTMemRealloc(mElements, newcap * sizeof(void*));
    171 #else
    172     mElements = (void**) realloc(mElements, newcap * sizeof(void*));
    173 #endif
    174157    if (!mElements)
    175158      return NS_ERROR_OUT_OF_MEMORY;
  • trunk/src/libs/xpcom18a4/ipc/ipcd/extensions/transmngr/common/tmVector.h

    r1 r101996  
    118118    */
    119119  void* operator[](PRUint32 index) {
    120     PR_ASSERT(index < mNext);
     120    Assert(index < mNext);
    121121    return mElements[index];
    122122  }
  • trunk/src/libs/xpcom18a4/ipc/ipcd/shared/src/ipcMessage.cpp

    r31259 r101996  
    3838#include <stdlib.h>
    3939#include <string.h>
    40 #include "prlog.h"
    4140#include "ipcMessage.h"
    42 #ifdef VBOX_USE_IPRT_IN_XPCOM
    43 # include <iprt/mem.h>
    44 #endif
     41
     42#include <iprt/assert.h>
     43#include <iprt/mem.h>
     44
    4545
    4646ipcMessage::~ipcMessage()
    4747{
    4848    if (mMsgHdr)
    49 #ifdef VBOX_USE_IPRT_IN_XPCOM
    5049        RTMemFree(mMsgHdr);
    51 #else
    52         free(mMsgHdr);
    53 #endif
    5450}
    5551
     
    5854{
    5955    if (mMsgHdr) {
    60 #ifdef VBOX_USE_IPRT_IN_XPCOM
    6156        RTMemFree(mMsgHdr);
    62 #else
    63         free(mMsgHdr);
    64 #endif
    6557        mMsgHdr = NULL;
    6658    }
     
    7971    // copy buf if non-null
    8072    if (mMsgHdr) {
    81 #ifdef VBOX_USE_IPRT_IN_XPCOM
    8273        clone->mMsgHdr = (ipcMessageHeader *) RTMemDup(mMsgHdr, mMsgHdr->mLen);
    83 #else
    84         clone->mMsgHdr = (ipcMessageHeader *) malloc(mMsgHdr->mLen);
    85         memcpy(clone->mMsgHdr, mMsgHdr, mMsgHdr->mLen);
    86 #endif
    8774    }
    8875    else
     
    9986{
    10087    if (mMsgHdr)
    101 #ifdef VBOX_USE_IPRT_IN_XPCOM
    10288        RTMemFree(mMsgHdr);
    103 #else
    104         free(mMsgHdr);
    105 #endif
     89
    10690    mMsgComplete = PR_FALSE;
    10791
    10892    // allocate message data
    10993    PRUint32 msgLen = IPC_MSG_HEADER_SIZE + dataLen;
    110 #ifdef VBOX_USE_IPRT_IN_XPCOM
    11194    mMsgHdr = (ipcMessageHeader *) RTMemAlloc(msgLen);
    112 #else
    113     mMsgHdr = (ipcMessageHeader *) malloc(msgLen);
    114 #endif
    11595    if (!mMsgHdr) {
    11696        mMsgHdr = NULL;
     
    134114ipcMessage::SetData(PRUint32 offset, const char *data, PRUint32 dataLen)
    135115{
    136     PR_ASSERT(mMsgHdr != NULL);
     116    Assert(mMsgHdr != NULL);
    137117
    138118    if (offset + dataLen > DataLen())
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