OsclMemPoolResizableAllocator::MemPoolBlockInfo* OsclMemPoolResizableAllocator::findfreeblock(uint32 aBlockAlignedSize)
{
    OSCL_ASSERT(aBlockAlignedSize > 0);
    OSCL_ASSERT(aBlockAlignedSize == oscl_mem_aligned_size(aBlockAlignedSize));

    // Go through each mempool buffer and return the first free block that
    // is bigger than the specified size

    if (aBlockAlignedSize == 0)
    {
        // Request should be non-zero
        OSCL_LEAVE(OsclErrArgument);
        // OSCL_UNUSED_RETURN(NULL);    This statement was removed to avoid compiler warning for Unreachable Code
    }

    for (uint32 i = 0; i < iMemPoolBufferList.size(); ++i)
    {
        MemPoolBufferInfo* bufferinfo = iMemPoolBufferList[i];
        MemPoolBlockInfo* blockinfo = bufferinfo->iNextFreeBlock;
        while (blockinfo != NULL)
        {
            if ((blockinfo->iBlockSize/* - iBlockInfoAlignedSize*/) >= aBlockAlignedSize)
            {
                // This free block fits the request
                return blockinfo;
            }

            // Go to the next free block
            blockinfo = blockinfo->iNextFreeBlock;
        }
    }

    return NULL;
}
OSCL_EXPORT_REF bool OsclMemPoolResizableAllocator::trim(OsclAny* aPtr, uint32 aBytesToFree)
{
    // Amount to free has to be aligned
    uint32 alignedbytestofree = oscl_mem_aligned_size(aBytesToFree);
    if (alignedbytestofree > aBytesToFree)
    {
        // Not aligned so decrease amount to free by one alignment size
        alignedbytestofree -= 8;
    }
    OSCL_ASSERT(alignedbytestofree <= aBytesToFree);

    // Check that the returned pointer is from the memory pool
    if (validateblock(aPtr) == false)
    {
        OSCL_LEAVE(OsclErrArgument);
        // OSCL_UNUSED_RETURN(false);   This statement was removed to avoid compiler warning for Unreachable Code
    }

    // Retrieve the block info header and validate the info
    uint8* byteptr = (uint8*)aPtr;
    MemPoolBlockInfo* resizeblock = (MemPoolBlockInfo*)(byteptr - iBlockInfoAlignedSize);
    OSCL_ASSERT(resizeblock != NULL);
    OSCL_ASSERT(resizeblock->iBlockPreFence == OSCLMEMPOOLRESIZABLEALLOCATOR_PREFENCE_PATTERN);
    OSCL_ASSERT(resizeblock->iBlockPostFence == OSCLMEMPOOLRESIZABLEALLOCATOR_POSTFENCE_PATTERN);

    if ((resizeblock->iBlockSize - iBlockInfoAlignedSize) < alignedbytestofree)
    {
        // The bytes to free in the resize is bigger than the original buffer size
        OSCL_LEAVE(OsclErrArgument);
        // OSCL_UNUSED_RETURN(false);   This statement was removed to avoid compiler warning for Unreachable Code
    }

    if (alignedbytestofree < (iBlockInfoAlignedSize + OSCLMEMPOOLRESIZABLEALLOCATOR_MIN_BUFFERSIZE))
    {
        // The resizing cannot be done since the amount to free doesn't have
        // enough space to put in a block info header plus the minimum buffer for the new free block
        // So don't do anything and return
        return false;
    }

    // Create and fill in a block info header for the memory being freed back to memory pool
    MemPoolBlockInfo* freeblock = (MemPoolBlockInfo*)((uint8*)resizeblock + resizeblock->iBlockSize - alignedbytestofree);
    freeblock->iBlockPreFence = OSCLMEMPOOLRESIZABLEALLOCATOR_PREFENCE_PATTERN;
    freeblock->iNextFreeBlock = NULL;
    freeblock->iPrevFreeBlock = NULL;
    freeblock->iBlockSize = alignedbytestofree;
    freeblock->iBlockBuffer = (uint8*)freeblock + iBlockInfoAlignedSize;
    freeblock->iParentBuffer = resizeblock->iParentBuffer;
    freeblock->iBlockPostFence = OSCLMEMPOOLRESIZABLEALLOCATOR_POSTFENCE_PATTERN;

    // Return the free block to the memory pool buffer
    deallocateblock(*freeblock);

    // Adjust the block info for the block being resized
    resizeblock->iBlockSize -= alignedbytestofree;
    return true;
}
OsclMemPoolResizableAllocator::MemPoolBufferInfo* OsclMemPoolResizableAllocator::addnewmempoolbuffer(uint32 aBufferAlignedSize)
{
    OSCL_ASSERT(aBufferAlignedSize > 0);
    OSCL_ASSERT(aBufferAlignedSize == oscl_mem_aligned_size(aBufferAlignedSize));

    // Allocate memory for one buffer
    uint8* newbuffer = NULL;
    if (iMemPoolBufferAllocator)
    {
        // Use the outside allocator
        newbuffer = (uint8*)iMemPoolBufferAllocator->ALLOCATE(aBufferAlignedSize);
    }
    else
    {
        // Allocate directly from heap
        newbuffer = (uint8*)OSCL_MALLOC(aBufferAlignedSize);
    }

    if (newbuffer == NULL)
    {
        OSCL_LEAVE(OsclErrNoMemory);
        // OSCL_UNUSED_RETURN(NULL);    This statement was removed to avoid compiler warning for Unreachable Code
    }

#if OSCL_MEM_FILL_WITH_PATTERN
    oscl_memset(newbuffer, 0x55, aBufferAlignedSize);
#endif

    // Fill in the buffer info header
    MemPoolBufferInfo* newbufferinfo = (MemPoolBufferInfo*)newbuffer;
    newbufferinfo->iBufferPreFence = OSCLMEMPOOLRESIZABLEALLOCATOR_PREFENCE_PATTERN;
    newbufferinfo->iStartAddr = (OsclAny*)(newbuffer + iBufferInfoAlignedSize);
    newbufferinfo->iEndAddr = (OsclAny*)(newbuffer + aBufferAlignedSize - 1);
    newbufferinfo->iBufferSize = aBufferAlignedSize;
    newbufferinfo->iNumOutstanding = 0;
    newbufferinfo->iNextFreeBlock = (MemPoolBlockInfo*)(newbufferinfo->iStartAddr);
    newbufferinfo->iAllocatedSz = 0;
    newbufferinfo->iBufferPostFence = OSCLMEMPOOLRESIZABLEALLOCATOR_POSTFENCE_PATTERN;

    // Put in one free block in the new buffer
    MemPoolBlockInfo* freeblockinfo = (MemPoolBlockInfo*)(newbufferinfo->iStartAddr);
    freeblockinfo->iBlockPreFence = OSCLMEMPOOLRESIZABLEALLOCATOR_PREFENCE_PATTERN;
    freeblockinfo->iNextFreeBlock = NULL;
    freeblockinfo->iPrevFreeBlock = NULL;
    freeblockinfo->iBlockSize = aBufferAlignedSize - iBufferInfoAlignedSize;
    freeblockinfo->iBlockBuffer = (uint8*)freeblockinfo + iBlockInfoAlignedSize;
    freeblockinfo->iParentBuffer = newbufferinfo;
    freeblockinfo->iBlockPostFence = OSCLMEMPOOLRESIZABLEALLOCATOR_POSTFENCE_PATTERN;

    // Add the new buffer to the list
    iMemPoolBufferList.push_front(newbufferinfo);

    return newbufferinfo;
}
OsclTrapStack::~OsclTrapStack()
{
    //there should not be leftover items at this point
    OSCL_ASSERT(!iTop);
    OSCL_ASSERT(!TrapTop());

    //pop all items off the stack so memory gets freed.
    while (iTop)
        Pop();
    while (TrapTop())
        PopTrap();
}
OsclAny* OsclMemPoolResizableAllocator::allocateblock(MemPoolBlockInfo& aBlockPtr, uint32 aNumAlignedBytes)
{
    OSCL_ASSERT(aNumAlignedBytes > 0);
    OSCL_ASSERT(aNumAlignedBytes == oscl_mem_aligned_size(aNumAlignedBytes));

    if (aNumAlignedBytes == 0)
    {
        OSCL_LEAVE(OsclErrArgument);
        // OSCL_UNUSED_RETURN(NULL);    This statement was removed to avoid compiler warning for Unreachable Code
    }

    // Remove the free block from the double linked list
    if (aBlockPtr.iPrevFreeBlock == NULL && aBlockPtr.iNextFreeBlock != NULL)
    {
        // Removing from the beginning of the free list
        aBlockPtr.iNextFreeBlock->iPrevFreeBlock = NULL;
        aBlockPtr.iParentBuffer->iNextFreeBlock = aBlockPtr.iNextFreeBlock;
    }
    else if (aBlockPtr.iPrevFreeBlock != NULL && aBlockPtr.iNextFreeBlock == NULL)
    {
        // Removing from the end of the free list
        aBlockPtr.iPrevFreeBlock->iNextFreeBlock = NULL;
    }
    else if (aBlockPtr.iPrevFreeBlock == NULL && aBlockPtr.iNextFreeBlock == NULL)
    {
        // Free list becomes empty so update the parent buffer's link
        aBlockPtr.iParentBuffer->iNextFreeBlock = NULL;
    }
    else
    {
        // Removing from middle of the free list
        aBlockPtr.iPrevFreeBlock->iNextFreeBlock = aBlockPtr.iNextFreeBlock;
        aBlockPtr.iNextFreeBlock->iPrevFreeBlock = aBlockPtr.iPrevFreeBlock;
    }

    aBlockPtr.iNextFreeBlock = NULL;
    aBlockPtr.iPrevFreeBlock = NULL;

    aBlockPtr.iParentBuffer->iAllocatedSz += aBlockPtr.iBlockSize;

    // Resize the block if too large
    uint32 extraspace = aBlockPtr.iBlockSize - iBlockInfoAlignedSize - aNumAlignedBytes;
    if (extraspace > (iBlockInfoAlignedSize + OSCLMEMPOOLRESIZABLEALLOCATOR_MIN_BUFFERSIZE))
    {
        trim(aBlockPtr.iBlockBuffer, extraspace);
    }

#if OSCL_MEM_FILL_WITH_PATTERN
    oscl_memset(aBlockPtr.iBlockBuffer, 0x55, (aBlockPtr.iBlockSize - iBlockInfoAlignedSize));
#endif
    return aBlockPtr.iBlockBuffer;
}
OSCL_EXPORT_REF void OsclTLSRegistry::registerInstance(OsclAny* ptr, uint32 ID, int32 &aError)
{
    OSCL_ASSERT(ID < OSCL_TLS_MAX_SLOTS);

    aError = 0;
    TOsclTlsKey *pkey = NULL;

#if (OSCL_TLS_IS_KEYED)
    if (!iTlsKey)
    {
        aError = EPVErrorBaseNotInstalled;//No table!
        return ;
    }
    pkey = iTlsKey->iOsclTlsKey;
#endif

    registry_pointer_type registry = OSCL_STATIC_CAST(registry_pointer_type , TLSStorageOps::get_registry(pkey));
    if (!OSCL_TLS_REGISTRY_VALID(registry))
    {
        aError = EPVErrorBaseNotInstalled;//no registry!
        return;
    }

    registry[ID] = ptr;

}
OSCL_EXPORT_REF bool PvmfPortBaseImpl::isIncomingFull()
//derived class can override this to redefine "queue full" condition.
{
    if (iIncomingQueue.iThreshold == 0)
    {
        //should never happen
        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
                        (0, "0x%x PvmfPortBaseImpl::isIncomingFull: Zero Threshold", this));
        OSCL_ASSERT(false);
        return true;
    }
    if (iIncomingQueue.iQ.size() == iIncomingQueue.iCapacity)
    {
        return true;
    }
    if (iIncomingQueue.iBusy == true)
    {
        //this implies that we were at capacity previously
        //wait for occupancy to fall below threshold before
        //treating the queue as "not-full"
        if (iIncomingQueue.iQ.size() >= iIncomingQueue.iThreshold)
        {
            return true;
        }
    }
    //this means that we are below capacity and are approaching
    //capacity, or that we have fallen below threshold. in either
    //case treat queue as "not-full"
    return false;
}
OSCL_EXPORT_REF OsclAny* OsclTLSRegistry::getInstance(uint32 ID, int32 &aError)
{
    OSCL_ASSERT(ID < OSCL_TLS_MAX_SLOTS);

    aError = 0;

    TOsclTlsKey* pkey = NULL;

    sLock.Lock();
#if (OSCL_TLS_IS_KEYED)
    if (!iTlsKey)
    {
        aError = EPVErrorBaseNotInstalled;//No table!
        sLock.Unlock();
        return NULL;
    }
    pkey = iTlsKey->iOsclTlsKey;
#endif

    registry_pointer_type registry = OSCL_STATIC_CAST(registry_pointer_type , TLSStorageOps::get_registry(pkey));
    if (!OSCL_TLS_REGISTRY_VALID(registry))
    {
        aError = EPVErrorBaseNotInstalled;//No registry!
        sLock.Unlock();
        return NULL;
    }
    registry_type id = registry[ID];
    sLock.Unlock();

    return id;
}
OSCL_EXPORT_REF OsclSemaphore::~OsclSemaphore()
{
    //make sure it was closed

    OSCL_ASSERT(!bCreated);

}
OSCL_EXPORT_REF PVMFStatus
PVMFSMFSPBaseNode::CheckCPMCommandCompleteStatus(PVMFCommandId aID,
        PVMFStatus aStatus)
{
    PVMFStatus status = aStatus;
    if (aID == iCPMGetLicenseInterfaceCmdId)
    {
        if (aStatus == PVMFErrNotSupported)
        {
            /* License Interface is Optional */
            status = PVMFSuccess;
        }
    }

    if ((status != PVMFSuccess))
    {
        OSCL_ASSERT(aID != iCPMResetCmdId);
        if (iCurrErrHandlingCommand.size() > 0)
        {
            if (PVMF_SMFSP_NODE_RESET_DUE_TO_ERROR == iCurrErrHandlingCommand.front().iCmd)
            {

                //skip to next step, cpm cleanup steps are not coupled so moving to next step even if
                //some of inbetween step fails may not be harmful
                status = PVMFSuccess;
            }
        }
    }

    return status;
}
OSCL_EXPORT_REF void ThreadSafeMemPoolFixedChunkAllocator::destroymempool()
{
    // If ref count reaches 0 then destroy this object
    if (iRefCount <= 0)
    {
#if OSCL_MEM_CHECK_ALL_MEMPOOL_CHUNKS_ARE_RETURNED
        // Assert if all of the chunks were not returned
        OSCL_ASSERT(iFreeMemChunkList.size() == iNumChunk);
#endif

        iFreeMemChunkList.clear();

        if (iMemPool)
        {
            if (iMemPoolAllocator)
            {
                iMemPoolAllocator->deallocate(iMemPool);
            }
            else
            {
                OSCL_FREE(iMemPool);
            }

            iMemPool = NULL;
        }
    }
}
int32 OsclFileCache::Open(uint32 mode, uint32 size)
//Called to open the cache for a newly opened file.
//The NativeOpen was just called prior to this and was successful.
{
    //should not be called with zero-size cache.
    OSCL_ASSERT(size > 0);

    //Save the mode
    _mode = mode;

    //open logger object only if logging is enabled on this
    //file
    if (iContainer.iLogger)
        iLogger = PVLogger::GetLoggerObject("OsclFileCache");
    else
        iLogger = NULL;

    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
                    (0, "OsclFileCache(0x%x)::Open mode %d size %d", this, mode, size));

    // Create the movable cache.
    // Re-allocate it if the size has changed.
    if (_movableCache.pBuffer
            && size != _movableCache.capacity)
    {
        OSCL_FREE(_movableCache.pBuffer);
        _movableCache.pBuffer = NULL;
    }
    if (!_movableCache.pBuffer
            && size > 0)
    {
        _movableCache.pBuffer = (uint8*)OSCL_MALLOC(size);
    }
    if (!_movableCache.pBuffer)
    {
        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
                        (0, "OsclFileCache(0x%x)::Open ERROR no memory %d", this));
        return (-1);//error
    }
    _movableCache.capacity = _movableCache.usableSize = size;
    _movableCache.filePosition = 0;
    _movableCache.updateStart = _movableCache.updateEnd = 0;
    _movableCache.currentPos = _movableCache.endPos = 0;

    //Position the cache at zero.
    SetCachePosition(0);

    //get initial file size & native position
    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
                    (0, "OsclFileCache(0x%x)::Open CallingNativeSize", this));
    _fileSize = iContainer.CallNativeSize();
    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
                    (0, "OsclFileCache(0x%x)::Open CallingNativeTell", this));
    _nativePosition = iContainer.CallNativeTell();

    return 0;
}
Пример #13
0
/**
 * Locks the Mutex
 *
 * @param It wont take any parameters
 *
 * @return Returns the Error whether it is success or failure
 *incase of failure it will return what is the specific error
 */
OSCL_EXPORT_REF void OsclMutex::Lock()
{
    //verify the mutex is created.
    OSCL_ASSERT(bCreated);


    pthread_mutex_lock(&ObjMutex);

}
OSCL_EXPORT_REF OsclAny* TLSStorageOps::get_registry(TOsclTlsKey* key)
{
#if (OSCL_TLS_IS_KEYED)
    OSCL_ASSERT(key);
    return OSCL_TLS_GET_FUNC(*key);
#else
    OSCL_UNUSED_ARG(key);
    return OSCL_TLS_GET_FUNC();
#endif
}
Пример #15
0
inline void OsclTrapStack::PopTrap()
//pop the trap mark stack.
{
    OSCL_ASSERT(TrapTop());//ETrapPopUnderflow

    //call destructor on the item in-place
    TrapTop()->~OsclTrapStackItem();

    popTrapIndex();
}
Пример #16
0
void OsclTrapStack::Leaving()
//a leave is happening, so cleanup all items on the stack
//for the current trap level.
{
    //check for a leave outside any trap.
    OSCL_ASSERT(TrapTop());//ETrapLevelUnderflow

    while (iTop && iTop->iTAny != TrapTop()->iTAny)
        PopDealloc();
}
OsclAsyncFile::OsclAsyncFile(OsclNativeFile& aFile, int32 aCacheSize, PVLogger* aLogger)
        : OsclActiveObject(OsclActiveObject::EPriorityHighest, "OsclAsyncFile"),
        iNativeFile(aFile),
        iNativeFileDuplicate(NULL),
        iTotalCacheSize(aCacheSize),
        iStartAsyncRead(false),
        iReadPtrDummyLen(0),
        iReadPtr(0, iReadPtrDummyLen, 0)
{
    iLogger = aLogger;

    iHasNativeAsyncRead = iNativeFile.HasAsyncRead();

    // Init thread state tracking variable(s)
    if (iHasNativeAsyncRead)
    {
        /* For native async read set the thread state to active
         * since this is logically equivalent to the read thread
         * already running for the non-native implementation.  Some
         * of the shared logic in this class uses this state variable
         * so it needs to be set properly for the native async case also.
         */
        iAsyncReadThreadState = EAsyncReadActive;
    }
    else
    {
        /* otherwise there is not native async read support so this
         * class will need to launch a reader thread.  Initialize the
         * state to EAsyncReadNotActive to record the fact that the thread
         * has not been launched yet.
         */
        iAsyncReadThreadState = EAsyncReadNotActive;
    }
    iAsyncReadThreadExitFlag = false;



    //this is the number of buffers we allocate internally for the linked buffer
    //list.  There is also one extra buffer of this size-- the 'iDataBuffer'.
    iKCacheBufferCount = 4;

    //'min bytes read ahead' is how much data we will try to keep available
    //from the async reads.  It must be <= iKCacheBufferCount * iTotalCacheSize;
    iKMinBytesReadAhead = (3 * iTotalCacheSize);
    OSCL_ASSERT(iKMinBytesReadAhead <= (int32)(iKCacheBufferCount*iTotalCacheSize));

    //this is the size of each read request to the native file system.
    //it must be <= the individual buffer size, so we use 8k as the default,
    //but then limit it to the input buffer size.
    iKAsyncReadBufferSize = 8 * 1024 ;
    if ((uint32)iKAsyncReadBufferSize > iTotalCacheSize)
        iKAsyncReadBufferSize = iTotalCacheSize;

}
Пример #18
0
void OsclDNSIBase::CancelFxn(TPVDNSFxn aFxn)
{
    switch (aFxn)
    {
        case EPVDNSGetHostByName:
            CancelGetHostByName();
            break;
        default:
            OSCL_ASSERT(false);
            break;
    }
}
Пример #19
0
void OsclTrapStack::PushL(OsclTrapItem anItem)
{
    //Note: on Symbian you get a panic for doing
    //a push outside any TRAP statement, so generate an
    //error here also.
    OSCL_ASSERT(TrapTop());//ETrapPushAtLevelZero

    OsclAny* ptr = iAlloc->ALLOCATE(sizeof(OsclTrapStackItem));
    OsclError::LeaveIfNull(ptr);
    OsclTrapStackItem *item = new(ptr) OsclTrapStackItem(anItem);
    Push(item);
}
OSCL_EXPORT_REF
PVMIExternalDownloadSimulator::~PVMIExternalDownloadSimulator()
{
    if (iExtensionRefCount != 0)
    {
        OSCL_ASSERT(false);
    }
    Reset();
    if (IsAdded())
    {
        RemoveFromScheduler();
    }
};
void OsclSocketServI::LoopbackSocket::Write()
//Write to the loopback socket
{
    if (!iEnable)
        return;

    char tmpBuf[2] = {0, 0};
    int nbytes, err;
    bool wouldblock, ok;
    OsclSendTo(iSocket, tmpBuf, 1, iAddr, ok, err, nbytes, wouldblock);

    //if send failed, the select call will hang forever, so just go ahead and abort now.
    OSCL_ASSERT(ok);
}
/* ======================================================================== */
PVWavParserReturnCode PV_Wav_Parser::ReadData(uint8* buff, uint32 size, uint32& bytesread)
{
    OSCL_ASSERT(ipWAVFile != NULL);

    // read data
    if ((bytesread = ipWAVFile->Read(buff, 1, size)) == 0)
    {
        if (ipWAVFile->EndOfFile())
            return PVWAVPARSER_END_OF_FILE;
        else
            return PVWAVPARSER_READ_ERROR;
    }
    return PVWAVPARSER_OK;
}
PVMFStatus PvmfJBJitterBufferDurationTimer::Start()
{
    PVMF_JBNODE_LOGINFO((0, "PvmfJBJitterBufferDurationTimer::Start"));
    if (iJitterBufferDurationInMS > 0)
    {
        RunIfNotReady(iJitterBufferDurationInMS*1000);
        uint32 startTime = 0;

        // setup timer
        iRunClock.Stop();
        bool result = iRunClock.SetStartTime32(startTime, OSCLCLOCK_USEC);
        OSCL_ASSERT(result);
        result = iRunClock.Start();
        OSCL_ASSERT(result);

        iStarted = true;
        return PVMFSuccess;
    }
    else
    {
        return PVMFFailure;
    }
}
Пример #24
0
OSCL_EXPORT_REF void OsclErrorTrapImp::UnTrap()
{
    //clear the global leave code
    iLeave = 0;

    bool notempty = iTrapStack->UnTrap();
    OSCL_UNUSED_ARG(notempty);

#if defined(PVERROR_IMP_JUMPS)
    iJumpData->PopMark();
#endif

    OSCL_ASSERT(!notempty);//ETrapLevelNotEmpty
}
void OsclSocketRequestAO::CleanupParam(bool aDeallocate)
{
    //cleanup the socket request parameters-- can't use
    //virtual destructor because an allocator was used and
    //destructor is called explicitly.
    if (iParam)
    {
        switch (iContainer.iSocketFxn)
        {
            case EPVSocketRecvFrom:
                ((RecvFromParam*)iParam)->~RecvFromParam();
                break;
            case EPVSocketRecv:
                ((RecvParam*)iParam)->~RecvParam();
                break;
            case EPVSocketSendTo:
                ((SendToParam*)iParam)->~SendToParam();
                break;
            case EPVSocketSend:
                ((SendParam*)iParam)->~SendParam();
                break;
            case EPVSocketAccept:
                ((AcceptParam*)iParam)->~AcceptParam();
                break;
            case EPVSocketConnect:
                ((ConnectParam*)iParam)->~ConnectParam();
                break;
            case EPVSocketShutdown:
                ((ShutdownParam*)iParam)->~ShutdownParam();
                break;
            case EPVSocketBind:
                ((BindParam*)iParam)->~BindParam();
                break;
            case EPVSocketListen:
                ((ListenParam*)iParam)->~ListenParam();
                break;
            default:
                OSCL_ASSERT(false);
                break;
        }
        //free memory if needed.
        if (aDeallocate)
        {
            Alloc().deallocate(iParam);
            iParam = NULL;
            iParamSize = 0;
        }
    }
}
OSCL_EXPORT_REF void OsclSingletonRegistry::registerInstance(OsclAny* ptr, uint32 ID, int32 &aError)
{
    OSCL_ASSERT(ID < OSCL_SINGLETON_ID_LAST);

    aError = 0;
    if (!iSingletonTable)
    {
        aError = EPVErrorBaseNotInstalled;//no table!
        return;
    }

    iSingletonTable->iSingletonLocks[ID].Lock();
    iSingletonTable->iSingletons[ID] = ptr;
    iSingletonTable->iSingletonLocks[ID].Unlock();
}
Пример #27
0
inline bool OsclTrapStack::UnTrap()
//leave the current trap by popping the trap stack.
{
    //check for untrap without corresponding trap.
    OSCL_ASSERT(TrapTop());//ETrapLevelUnderflow

    //make sure all cleanup items in this level have
    //been popped.
    bool notempty = (iTop
                     && iTop->iTAny != TrapTop()->iTAny);

    PopTrap();

    return notempty;
}
void OsclMemPoolResizableAllocator::destroyallmempoolbuffers()
{
    while (iMemPoolBufferList.empty() == false)
    {
        MemPoolBufferInfo* bufferinfo = iMemPoolBufferList[0];
        // Check the buffer
        OSCL_ASSERT(bufferinfo != NULL);
        OSCL_ASSERT(bufferinfo->iBufferPreFence == OSCLMEMPOOLRESIZABLEALLOCATOR_PREFENCE_PATTERN);
        OSCL_ASSERT(bufferinfo->iBufferPostFence == OSCLMEMPOOLRESIZABLEALLOCATOR_POSTFENCE_PATTERN);
        OSCL_ASSERT(bufferinfo->iNumOutstanding == 0);

        // Free the memory
        if (iMemPoolBufferAllocator)
        {
            iMemPoolBufferAllocator->deallocate((OsclAny*)bufferinfo);
        }
        else
        {
            OSCL_FREE((OsclAny*)bufferinfo);
        }

        iMemPoolBufferList.erase(iMemPoolBufferList.begin());
    }
}
PVMFStatus PvmfJBJitterBufferDurationTimer::Stop()
{
    PVMF_JBNODE_LOGINFO((0, "PvmfJBJitterBufferDurationTimer::Stop"));
    Cancel();

    if (iStarted)
    {
        bool result = iRunClock.Stop();
        OSCL_UNUSED_ARG(result);
        OSCL_ASSERT(result);
    }

    iStarted = false;
    iJitterBufferDurationInMS = 0;
    return PVMFSuccess;
}
int OsclSocketIBase::GetShutdown(TPVSocketShutdown aOsclVal)
//map socket API value to platform-specific value.
{
    switch (aOsclVal)
    {
        case EPVSocketRecvShutdown:
            return OSCL_SD_RECEIVE;
        case EPVSocketSendShutdown:
            return OSCL_SD_SEND;
        case EPVSocketBothShutdown:
            return OSCL_SD_BOTH;
        default:
            OSCL_ASSERT(0);
    }
    return 0;
}