Standards / Extensions | C or C++ | Dependencies |
---|---|---|
C Library | both |
#include <dll.h>
int dllfree(dllhandle *dllHandle);
Frees the supplied dynamic link library (DLL). It also deletes the DLL from memory if the handle was the last handle accessing the DLL.
⁄* CELEBDL4
The following example shows how to use dllfree() to free the
dllhandle for the DLL stream.
*⁄
#include <stdio.h>
#include <dll.h>
#include <stdlib.h>
int main() {
dllhandle *handle;
char *name="stream";
int (*fptr1)(int);
int (*fptr)(int);
int *ptr_var1;
int *ptr_var;
int rc=0;
handle = dllload(name); ⁄* call to stream DLL *⁄
if (handle == NULL) {
perror("failed on call to stream DLL");
exit(-1);
}
fptr1 = (int (*)(int)) dllqueryfn(handle,"f1");
⁄* retrieving f1 function *⁄
if (fptr == NULL) {
perror("failed on retrieving f1 function");
exit(-2);
}
ptr_var = dllqueryvar(handle,"var1");
⁄* retrieving var1 variable *⁄
if (ptr_var1 == NULL) {
perror("failed on retrieving var1 variable");
exit(-3);
}
rc = fptr(*ptr_var1); ⁄* execute DLL function f1 *⁄
*ptr_var++; ⁄* increment value of var1 *⁄
rc = dllfree(handle); ⁄* freeing handle to stream DLL *⁄
if (rc != 0) {
perror("failed on dllfree call");
}
return (0);
}