Allow runtime malloc replacement using LoadLibary #828
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When a .dll is loaded using the LoadLibary() then the "reserved" parameter is NULL in the DllMain() function. This makes it impossible to dynamicly load the malloc_proxy dynamically at runtime because the "reserved" parameter is checked to be not null. So I removed the (I think needles) condition on that variable so that the doMallocReplacement() will be called on a LoadLibary(). This allows programmers to create applications that can "optionally" use the tbb_malloc replacement without having to re-link the application.
Description
We are creating an application that will allow end-users to choose what malloc acceleration technique the application should use. But in order to accomidate the runtime option we need to be able to instantiate / call the tbb-malloc proxy replacement at runtime using LoadLibary() and not at Link time. As documented by Microsoft ( https://docs.microsoft.com/en-us/windows/win32/dlls/dllmain ) the DllMain function is called when a dll is "linked" to the application a bit different then when the .dll is loaded using the LoadLibary(). the last parameter ( named reserved ) will be NULL when using the LoadLibary() at runtime. The fix is easy , don't check this reserved parameter to be different then NULL.
Fixes # - issue number(s) if exists
Fixes the previously inability to dynamically setup the malloc_proxy using LoadLibary()
Add a respective label(s) to PR if you have permissions
Tests
Documentation
Breaks backward compatibility
Notify the following users
List users with
@
to send notificationsOther information
This is my very first pull request ever