diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-06-21 14:59:11 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-06-21 14:59:11 -0700 |
| commit | 815926bb8a8c206ce64be33de5c24be6ddcbe6f7 (patch) | |
| tree | adddb553af838b0297191b2741a21d4959e2cd5b /src/nng.h | |
| parent | 763b8deee1fd38566b85d4745a83adae245d9b26 (diff) | |
| download | nng-815926bb8a8c206ce64be33de5c24be6ddcbe6f7.tar.gz nng-815926bb8a8c206ce64be33de5c24be6ddcbe6f7.tar.bz2 nng-815926bb8a8c206ce64be33de5c24be6ddcbe6f7.zip | |
Expose a library finalizer suitable for atexit().
Diffstat (limited to 'src/nng.h')
| -rw-r--r-- | src/nng.h | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -55,6 +55,16 @@ typedef struct nng_stat nng_stat; // mode. NNG_DECL int nng_open(nng_socket *, uint16_t proto); +// nng_fini is used to terminate the library, freeing certain global resources. +// Its a good idea to call this with atexit() or during application shutdown. +// For most cases, this call is optional, but failure to do so may cause +// memory checkers like valgrind to incorrectly flag memory leaks. Note that +// this particular API is NOT THREADSAFE, and MUST NOT BE CALLED WHILE ANY +// OTHER APIS ARE IN USE. (It is safe however to call other functions such +// as nng_open *after* this function returns, provided that the functions do +// not run concurrently!) +NNG_DECL void nng_fini(void); + // nng_close closes the socket, terminating all activity and // closing any underlying connections and releasing any associated // resources. Memory associated with the socket is freed, so it is an |
