/* Copyright (c) 2001-2009 by SoftIntegration, Inc. All Rights Reserved */
#include<dlfcn.h>
#include "class1_ch.h"

Class1::~Class1() {
  void *fptr;
  fptr = dlsym(g_sample_dlhandle, "Class1_dClass1_chdl");
  if(fptr == NULL)  {
     printf("Error: %s(): dlsym(): %s\n", __class_func__, dlerror());
     return;
  }

  /* call the chdl function in DLL by address */
  dlrunfun(fptr, NULL, NULL, this);
  g_sample_dlcount--; // to decrease count of instance

  if(g_sample_dlcount <= 0 && g_sample_dlhandle != NULL) {
    if(dlclose(g_sample_dlhandle)!=0)
       printf("Error: %s(): dlclose(): %s\n", __class_func__, dlerror());
  }
}
