HRESULT STDMETHODCALLTYPE ClassFactory::CreateInstance()

in src/profiler/src/ClassFactory.cpp [46:71]


HRESULT STDMETHODCALLTYPE ClassFactory::CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObject)
{
    if (pUnkOuter != nullptr)
    {
        *ppvObject = nullptr;
        return CLASS_E_NOAGGREGATION;
    }

    CorProfiler* profiler = new CorProfiler();
    if (profiler == nullptr)
    {
        return E_FAIL;
    }

    assert(riid == __uuidof(ICorProfilerCallback8) ||
           riid == __uuidof(ICorProfilerCallback7) ||
           riid == __uuidof(ICorProfilerCallback6) ||
           riid == __uuidof(ICorProfilerCallback5) ||
           riid == __uuidof(ICorProfilerCallback4) ||
           riid == __uuidof(ICorProfilerCallback3) ||
           riid == __uuidof(ICorProfilerCallback2) ||
           riid == __uuidof(ICorProfilerCallback) ||
           riid == IID_IUnknown);

    return profiler->QueryInterface(riid, ppvObject);
}