oneTBB
oneTBB copied to clipboard
Allow runtime malloc replacement using LoadLibary
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
- [X] new feature - change that adds functionality
Tests
- [ ] not yet added : but a new test should be to dynamically load the malloc_proxy dll using LoadLibary()
Documentation
- [ Y] needs to be updated
Breaks backward compatibility
- [ ] Yes
- [X ] No
- [ ] Unknown
Notify the following users
List users with @ to send notifications
Other information
This is my very first pull request ever