CK_RV PKCS11_Objects_OpenSSL::DestroyObject(Cryptoki_Session_Context* pSessionCtx, CK_OBJECT_HANDLE hObject) { OBJECT_DATA* pData = GetObjectFromHandle(pSessionCtx, hObject); if(pData == NULL) return CKR_OBJECT_HANDLE_INVALID; if(--pData->RefCount <= 0) { if(pData->Type == KeyType) { PKCS11_Keys_OpenSSL::DeleteKey(pSessionCtx, (KEY_DATA *)pData->Data); } else if(pData->Type == CertificateType) { CERT_DATA* pCert = (CERT_DATA*)pData->Data; X509_free(pCert->cert); } return FreeObject(pSessionCtx, hObject) == NULL ? CKR_OBJECT_HANDLE_INVALID : CKR_OK; } return CKR_OK; }
_Use_decl_annotations_ int WINAPI WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR commandLine, int commandShow) { UMSpinLock spinLock; UMCriticalSection cs; CRITICAL_SECTION cs2; LARGE_INTEGER freq, start, stop, osCS, myCS; HANDLE threads[64]; UMSpinLockInitialize(&spinLock); UMCriticalSectionInitialize(&cs, _countof(threads)); InitializeCriticalSection(&cs2); for (uint32_t i = 0; i < _countof(threads); ++i) { threads[i] = CreateThread(NULL, 0, ThreadProcSpinLock, &spinLock, 0, NULL); assert(threads[i] != NULL); } WaitForMultipleObjects(_countof(threads), threads, TRUE, INFINITE); uint32_t value = buffer[0]; for (uint32_t i = 0; i < _countof(buffer); ++i) { if (buffer[i] != value) { OutputDebugString(L"\n\nERROR ERROR\n"); assert(false); } } QueryPerformanceFrequency(&freq); QueryPerformanceCounter(&start); for (uint32_t i = 0; i < _countof(threads); ++i) { CloseHandle(threads[i]); threads[i] = CreateThread(NULL, 0, ThreadProcCS, &cs, 0, NULL); assert(threads[i] != NULL); } WaitForMultipleObjects(_countof(threads), threads, TRUE, INFINITE); QueryPerformanceCounter(&stop); myCS.QuadPart = stop.QuadPart - start.QuadPart; value = buffer[0]; for (uint32_t i = 0; i < _countof(buffer); ++i) { if (buffer[i] != value) { OutputDebugString(L"\n\nERROR ERROR\n"); assert(false); } } QueryPerformanceCounter(&start); for (uint32_t i = 0; i < _countof(threads); ++i) { CloseHandle(threads[i]); threads[i] = CreateThread(NULL, 0, ThreadProcOSCS, &cs2, 0, NULL); assert(threads[i] != NULL); } WaitForMultipleObjects(_countof(threads), threads, TRUE, INFINITE); QueryPerformanceCounter(&stop); osCS.QuadPart = stop.QuadPart - start.QuadPart; value = buffer[0]; for (uint32_t i = 0; i < _countof(buffer); ++i) { if (buffer[i] != value) { OutputDebugString(L"\n\nERROR ERROR\n"); assert(false); } } for (uint32_t i = 0; i < _countof(threads); ++i) { CloseHandle(threads[i]); } UMCriticalSectionDestroy(&cs); typedef struct { uint32_t X; float F; } Foo; Foo f; Foo* g; Handle h; char buffer[] = "Hello, World"; wchar_t buffer2[100]; char buffer3[100]; GameObject go1; GameObject go2; AabbNode* root = NULL; go1.Signature = SIGNATURE; go2.Signature = SIGNATURE; AabbNodeStartup(GetGameObjectBounds); go1.Node = AabbNodeInsert(&root, go1.Mins, go1.Maxs, &go1); go2.Node = AabbNodeInsert(&root, go2.Mins, go2.Maxs, &go2); // AabbNodeRemove(&root, root); AabbNodeRemove(&root, go1.Node); AabbNodeRemove(&root, go2.Node); UNREFERENCED_PARAMETER(instance); UNREFERENCED_PARAMETER(prevInstance); UNREFERENCED_PARAMETER(commandLine); UNREFERENCED_PARAMETER(commandShow); f.X = 3; f.F = -234.8f; if (!HandleTableStartup()) { return -1; } h = AllocHandle(&f, 1); if (h == InvalidHandle) { return -2; } g = (Foo*)GetObjectFromHandle(h); if (g == 0) { return -3; } FreeHandle(h); HandleTableShutdown(); if (!ConvertCharToWChar(buffer, buffer2, 100)) { return -3; } if (!ConvertWCharToChar(buffer2, buffer3, 100)) { return -4; } return 0; }