diff --git a/include/neocomm.h b/include/neocomm.h index 7dee73d..b2cca1d 100644 --- a/include/neocomm.h +++ b/include/neocomm.h @@ -30,3 +30,8 @@ * else 0 is returned. */ int NeoComm_init(unsigned int max_nodes); + +/** + * @brief Disconnect all currently active connections and shutdown all modules. + */ +void NeoComm_shutdown(); diff --git a/include/nodes.h b/include/nodes.h index e0e5d3c..fddf90e 100644 --- a/include/nodes.h +++ b/include/nodes.h @@ -27,6 +27,9 @@ struct address { unsigned short port; ///< Port of address. }; +/** + * @brief Structure used for NeoComm nodes. + */ struct node { /// The address of the node. struct address address; @@ -50,7 +53,10 @@ struct node { */ int NeoComm_init_nodes(unsigned int max_nodes); -void NeoComm_deinit_nodes(); +/** + * @brief Deinitialize all the nodes. + */ +void NeoComm_shutdown_nodes(); /** * @brief Enlarge the list. diff --git a/src/neocomm.c b/src/neocomm.c index 5246742..ba2b368 100644 --- a/src/neocomm.c +++ b/src/neocomm.c @@ -24,3 +24,7 @@ int NeoComm_init(unsigned int max_nodes) { return 0; return 1; } + +void NeoComm_shutdown() { + NeoComm_shutdown_nodes(); +} diff --git a/src/nodes.c b/src/nodes.c index 54c47cd..54eecae 100644 --- a/src/nodes.c +++ b/src/nodes.c @@ -40,7 +40,9 @@ int NeoComm_init_nodes(unsigned int max_nodes) { return 1; } -void NeoComm_deinit_nodes() { +void NeoComm_shutdown_nodes() { + if(!node_list) + return; free(node_list); node_max = 0; node_count = 0;