Skip to content

Commit

Permalink
Change ICorProfilerMethodEnum to use the COMPtr (#6334)
Browse files Browse the repository at this point in the history
## Summary of changes

This PR changes the way we handle `ICorProfilerMethodEnum` to use the
`COMPtr` to release it when it's out of scope.

## Reason for change

Match the rejitprofiler test in the dotnet runtime repo:
https://github.com/dotnet/runtime/blob/98049e56a415d9bcf2d002fba71f399ba08cf39c/src/tests/profiler/native/rejitprofiler/rejitprofiler.cpp#L280-L281

and instead of manually calling `Release` use the `COMPtrHolder` to
automatically release it.
  • Loading branch information
tonyredondo authored Nov 22, 2024
1 parent fb950f7 commit 31bf06f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions tracer/src/Datadog.Tracer.Native/rejit_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ bool RejitHandlerModuleMethod::RequestRejitForInlinersInModule(ModuleID moduleId
{
// Now we enumerate all methods that inline the current methodDef
BOOL incompleteData = false;
ICorProfilerMethodEnum* methodEnum;
ComPtr<ICorProfilerMethodEnum> methodEnum;

HRESULT hr = pInfo->EnumNgenModuleMethodsInliningThisMethod(moduleId, currentModuleId, currentMethodDef,
&incompleteData, &methodEnum);
&incompleteData, methodEnum.GetAddressOf());
std::ostringstream hexValue;
hexValue << std::hex << hr;
if (SUCCEEDED(hr))
Expand All @@ -82,8 +82,7 @@ bool RejitHandlerModuleMethod::RequestRejitForInlinersInModule(ModuleID moduleId
methods.push_back(method.methodId);
total++;
}
methodEnum->Release();
methodEnum = nullptr;

if (total > 0)
{
handler->EnqueueForRejit(modules, methods);
Expand Down

0 comments on commit 31bf06f

Please sign in to comment.