register_destructor

Registers a cleanup function to be used when third-party library unloads.

Library:LibC
Service:Library

Syntax

  #include <library.h> 
   
  int register_destructor (
     int   libid,
     int   (*cleanupFunc)( void *data_area ));
  

Parameters

libid

(IN) Specifies a registered library.

cleanupFunc

(IN) Points to a function to be called whenever one of the clients of the library is terminated by either an UNLOAD command or because the NLM terminated itself by calling exit, abort, NXThreadExit, or so on.

Return Values

If successful, returns 0. Otherwise, returns -1 and sets errno to the following:

Decimal

Name

Description

9

EINVAL

The libid parameter is not valid.

Remarks

This function provides a way to back-register or replace a destructor function after the library has already been registered. It is mostly used by NLM applications exporting DllMain.

See Also