Search code examples
c++cmallocdlopen

Should i do malloc() before using dlopen()?


Below shown is the code snippet i am using. Should I allocate space using malloc before doing dlopen?

void* pvHandle = NULL;

/* Dynamically loading library */
pvHandle = dlopen ("libame.so", RTLD_LAZY | RTLD_GLOBAL);       
if (!pvHandle)
    {
        pszError = dlerror();
        cout << "Error : " << pszError;
    }

Please help me clear this doubt. Thanks in Advance.


Solution

  • No, dlopen returns an opaque handle to the library, you do not need to allocate any memory yourself.