gtpc2m1m | C/C++ Language Support User's Guide |
This function frees the supplied DLL handle and logically deletes the DLL from memory if the handle was the last handle accessing the DLL.
Format
#include <dll.h> int dllfree(dllhandle* dllHandle);
Normal Return
The dllfree function returns the following value when the requested service has been performed.
Error Return
The dllfree function returns one of the following values and sets errno if the return code is not 0:
Programming Considerations
Examples
The following example shows how to use the dllfree function to free the dllHandle, which is in DLL load module DLLB.
#include <stdio.h> #include <dll.h> int DLLA (void); int DLLA() { dllhandle *handle; char *name="DLLB"; int (*fptr1)(int); int *ptr1_var1; int rc=0; handle = dllload(name); /* call to stream DLL */ if (handle == NULL) { printf("failed on call to DLLB DLL\n"); exit(-1); } fptr1 = (int (*)(int)) dllqueryfn(handle,"f1"); /* retrieving f1 function */ if (ftpr1 == NULL) { printf("failed on retrieving f1 function\n"); exit(-2); } ptr1_var1 = dllqueryvar(handle,"var1"); /* retrieving var1 variable */ if (ptr1_var1 == NULL) { printf("failed on retrieving var1 variable\n"); exit(-3); } rc = fptr1(*ptr1_var1); /* execute DLL function f1 */ (*ptr1_var1)++; /* increment value of var1 */ rc = dllfree(handle); /* freeing handle to DLLB DLL */ if (rc != 0) { printf("failed on dllfree call\n"); } return (0); }
Related Information