New shutdown function.

This commit is contained in:
Nicolás A. Ortega 2017-07-02 17:13:59 +02:00
parent a393cb8b4e
commit 0db8eb82e9
No known key found for this signature in database
GPG Key ID: 3D786FB3123FF1DD
4 changed files with 19 additions and 2 deletions

View File

@ -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();

View File

@ -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.

View File

@ -24,3 +24,7 @@ int NeoComm_init(unsigned int max_nodes) {
return 0;
return 1;
}
void NeoComm_shutdown() {
NeoComm_shutdown_nodes();
}

View File

@ -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;