VOID RegFreeMemory( PVOID pMemory ) { LwRtlMemoryFree(pMemory); }
void RegMemoryFree( IN OUT LW_PVOID pMemory ) { return LwRtlMemoryFree(pMemory); }
void RegFreeString( PSTR pszString ) { LwRtlMemoryFree(pszString); }
VOID LwIoFreeMemory( PVOID pMemory ) { LwRtlMemoryFree(pMemory); }
VOID LwIoFreeBuffer( LW_PVOID pMemory ) { LwRtlMemoryFree(pMemory); }
void RegFreeWC16StringArrayWithNullTerminator( PWSTR * ppwStringArray ) { DWORD i = 0; if ( ppwStringArray ) { while (ppwStringArray[i]) { LwRtlMemoryFree(ppwStringArray[i++]); } LwRtlMemoryFree(ppwStringArray); } return; }
static VOID DispatchSignal( siginfo_t* pInfo ) { RING dispatch; PRING pBase = NULL; PRING pRing = NULL; PRING pNext = NULL; PLW_SIGNAL_SUBSCRIPTION pSub = NULL; if (!gSignal.pSubscribers || pInfo->si_signo > gSignal.maxSig || pInfo->si_signo < 0) { return; } RingInit(&dispatch); pBase = &gSignal.pSubscribers[pInfo->si_signo]; for (pRing = pBase->pNext; pRing != pBase; pRing = pRing->pNext) { pSub = LW_STRUCT_FROM_FIELD(pRing, LW_SIGNAL_SUBSCRIPTION, Ring); pSub->ucRefCount++; RingInit(&pSub->DispatchRing); RingEnqueue(&dispatch, &pSub->DispatchRing); } UNLOCK_SIGNAL(); for (pRing = dispatch.pNext; pRing != &dispatch; pRing = pRing->pNext) { pSub = LW_STRUCT_FROM_FIELD(pRing, LW_SIGNAL_SUBSCRIPTION, DispatchRing); NotifyTaskUnixSignal(pSub->pTask, pInfo); } LOCK_SIGNAL(); for (pRing = dispatch.pNext; pRing != &dispatch; pRing = pNext) { pNext = pRing->pNext; pSub = LW_STRUCT_FROM_FIELD(pRing, LW_SIGNAL_SUBSCRIPTION, DispatchRing); if (--pSub->ucRefCount == 0) { RingRemove(&pSub->Ring); LwRtlReleaseTask(&pSub->pTask); LwRtlMemoryFree(pSub); } } }
void RegFreeValueByteArray( PBYTE* ppValues, DWORD dwCount ) { DWORD i; if ( ppValues ) { for(i = 0; i < dwCount; i++) { if (ppValues[i]) { LwRtlMemoryFree(ppValues[i]); } } LwRtlMemoryFree(ppValues); } return; }
void RegFreeWC16StringArray( PWSTR * ppwStringArray, DWORD dwCount ) { DWORD i; if ( ppwStringArray ) { for(i = 0; i < dwCount; i++) { if (ppwStringArray[i]) { LwRtlMemoryFree(ppwStringArray[i]); } } LwRtlMemoryFree(ppwStringArray); } return; }
static VOID LwRtlRBTreeFreeNode( PLWRTL_RB_TREE pRBTree, PLWRTL_RB_TREE_NODE pTreeNode ) { if (pTreeNode->pKey && pRBTree->pfnFreeKey) { pRBTree->pfnFreeKey(pTreeNode->pKey); } if (pTreeNode->pData && pRBTree->pfnFreeData) { pRBTree->pfnFreeData(pTreeNode->pData); } LwRtlMemoryFree(pTreeNode); }
void RegSrvCloseServer( HANDLE hServer ) { PREG_SRV_API_STATE pServerState = (PREG_SRV_API_STATE)hServer; if (pServerState->hEventLog != (HANDLE)NULL) { //RegSrvCloseEventLog(pServerState->hEventLog); } if (pServerState->pToken) { RtlReleaseAccessToken(&pServerState->pToken); } LwRtlMemoryFree(pServerState); }
NTSTATUS RegisterTaskUnixSignal( LW_IN PLW_TASK pTask, LW_IN int Sig, LW_IN LW_BOOLEAN bSubscribe ) { NTSTATUS status = STATUS_SUCCESS; size_t i = 0; PRING pBase = NULL; PRING pRing = NULL; PLW_SIGNAL_SUBSCRIPTION pExisting = NULL; PLW_SIGNAL_SUBSCRIPTION pSub = NULL; struct sigaction action; #ifdef SIGRTMAX int maxSig = SIGRTMAX; #else int maxSig = SIGUSR2; #endif if (Sig == 0) { for (i = 1; i < maxSig + 1; i++) { status = RegisterTaskUnixSignal(pTask, (int) i, bSubscribe); if (status) { return status; } } return STATUS_SUCCESS; } LOCK_SIGNAL(); if (Sig > maxSig || Sig < 0) { status = STATUS_INVALID_PARAMETER; GOTO_ERROR_ON_STATUS(status); } if (!gSignal.pSubscribers) { status = LW_RTL_ALLOCATE_ARRAY_AUTO(&gSignal.pSubscribers, maxSig + 1); GOTO_ERROR_ON_STATUS(status); for (i = 0; i < maxSig + 1; i++) { RingInit(&gSignal.pSubscribers[i]); } gSignal.maxSig = maxSig; } pBase = &gSignal.pSubscribers[Sig]; for (pRing = pBase->pNext; pRing != pBase; pRing = pRing->pNext) { pSub = LW_STRUCT_FROM_FIELD(pRing, LW_SIGNAL_SUBSCRIPTION, Ring); if (pSub->pTask == pTask) { pExisting = pSub; break; } } if (bSubscribe && !pExisting) { if (Sig != SIGINT) { memset(&action, 0, sizeof(action)); /* Make sure there is a dummy handler for the signal so it is actually delivered to the process */ action.sa_handler = DummyHandler; action.sa_flags = 0; if (sigaction(Sig, &action, NULL) < 0) { status = LwErrnoToNtStatus(errno); GOTO_ERROR_ON_STATUS(status); } } status = LW_RTL_ALLOCATE_AUTO(&pSub); GOTO_ERROR_ON_STATUS(status); pSub->pTask = pTask; pSub->ucRefCount = 1; RingInit(&pSub->Ring); RingInit(&pSub->DispatchRing); RingEnqueue(pBase, &pSub->Ring); RetainTask(pTask); } else if (!bSubscribe && pExisting) { RingRemove(&pExisting->Ring); if (--pExisting->ucRefCount == 0) { LwRtlReleaseTask(&pExisting->pTask); LwRtlMemoryFree(pExisting); } } error: UNLOCK_SIGNAL(); return status; }