HRESULT StdMemAllocator_create(LPUNKNOWN lpUnkOuter, LPVOID * ppv) { StdMemAllocator * pMemAlloc; HRESULT hr; *ppv = NULL; if (lpUnkOuter) return CLASS_E_NOAGGREGATION; if (!(pMemAlloc = CoTaskMemAlloc(sizeof(*pMemAlloc)))) return E_OUTOFMEMORY; InitializeCriticalSection(&pMemAlloc->csState); pMemAlloc->csState.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": StdMemAllocator.csState"); pMemAlloc->pMemory = NULL; if (SUCCEEDED(hr = BaseMemAllocator_Init(StdMemAllocator_Alloc, StdMemAllocator_Free, NULL, NULL, NULL, StdMemAllocator_Destroy, &pMemAlloc->csState, &pMemAlloc->base))) *ppv = pMemAlloc; else CoTaskMemFree(pMemAlloc); return hr; }
HRESULT StdMemAllocator_create(LPUNKNOWN lpUnkOuter, LPVOID * ppv) { StdMemAllocator * pMemAlloc; HRESULT hr; *ppv = NULL; if (lpUnkOuter) return CLASS_E_NOAGGREGATION; if (!(pMemAlloc = CoTaskMemAlloc(sizeof(*pMemAlloc)))) return E_OUTOFMEMORY; pMemAlloc->pMemory = NULL; if (SUCCEEDED(hr = BaseMemAllocator_Init(StdMemAllocator_Alloc, StdMemAllocator_Free, &pMemAlloc->base))) *ppv = (LPVOID)pMemAlloc; else CoTaskMemFree(pMemAlloc); return hr; }