-void nmem_critical_enter (void)
-{
- NMEM_ENTER;
-}
-
-void nmem_critical_leave (void)
-{
- NMEM_LEAVE;
-}
-
-void nmem_init (void)
-{
- if (!log_level_initialized)
- {
- log_level=yaz_log_module_level("nmem");
- log_level_initialized=1;
- }
-
- if (++nmem_init_flag == 1)
- {
-#ifdef WIN32
- InitializeCriticalSection(&critical_section);
-#elif YAZ_GNU_THREADS
- yaz_log (log_level, "pth_init"); /* ??? */
- pth_init ();
-#endif
- nmem_active_no = 0;
- freelist = NULL;
- cfreelist = NULL;
- }
-}
-
-void nmem_exit (void)
-{
- if (--nmem_init_flag == 0)
- {
- oid_exit();
- while (freelist)
- {
- struct nmem_block *fl = freelist;
- freelist = freelist->next;
- xfree (fl->buf);
- xfree (fl);
- }
- while (cfreelist)
- {
- struct nmem_control *cfl = cfreelist;
- cfreelist = cfreelist->next;
- xfree (cfl);
- }
-#ifdef WIN32
- DeleteCriticalSection(&critical_section);
-#endif
- }
-}
-
-
-#ifdef WIN32
-BOOL WINAPI DllMain (HINSTANCE hinstDLL,
- DWORD reason,
- LPVOID reserved)
-{
- switch (reason)
- {
- case DLL_PROCESS_ATTACH:
- nmem_init ();
- break;
- case DLL_PROCESS_DETACH:
- nmem_exit ();
- }
- return TRUE;
-}
-#endif
-