Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
ptahmose committed Oct 18, 2024
1 parent 4628fad commit de5ad99
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions OctaveMex/octavelibczi.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,11 @@ static void Initialize()
pfn_OnInitialize = (void(*)())GetProcAddress(hModule, "OnInitialize");
pfn_OnShutdown = (void(*)())GetProcAddress(hModule, "OnShutdown");
pfn_mexFunction = (void(*)(int, Parameter[], int, const Parameter[], struct IAppExtensionFunctions*))GetProcAddress(hModule, "mexFunction");
if (pfn_OnInitialize == NULL || pfn_OnShutdown == NULL || pfn_mexFunction == NULL)
{
FreeLibrary(hModule);
mexErrMsgIdAndTxt("MATLAB:mexlibCZI:getProcAddressFailed", "Failed to get the address of the function.");
}
#else
static const char DllName[] = "libmexlibczi.so";

Expand Down Expand Up @@ -376,12 +381,12 @@ static void Initialize()
pfn_OnInitialize = (void(*)())dlsym(hModule, "OnInitialize");
pfn_OnShutdown = (void(*)())dlsym(hModule, "OnShutdown");
pfn_mexFunction = (void(*)(int, Parameter[], int, const Parameter[], struct IAppExtensionFunctions*))dlsym(hModule, "mexFunction");
#endif
if (pfn_OnInitialize == NULL || pfn_OnShutdown == NULL || pfn_mexFunction == NULL)
{
FreeLibrary(hModule);
dlclose(hModule);
mexErrMsgIdAndTxt("MATLAB:mexlibCZI:getProcAddressFailed", "Failed to get the address of the function.");
}
#endif

pfn_OnInitialize();
mexAtExit(pfn_OnShutdown);
Expand Down

0 comments on commit de5ad99

Please sign in to comment.