]> git.meshlink.io Git - meshlink/blobdiff - src/submesh.c
Add assert() calls to the library.
[meshlink] / src / submesh.c
index 7d4a326ed733cd9bf551e4f3bf0ea041c34e8934..6780b8a095e12867f3e8ed7f3606ce53d903ada6 100644 (file)
 #include "protocol.h"
 
 void init_submeshes(meshlink_handle_t *mesh) {
+       assert(!mesh->submeshes);
        mesh->submeshes = list_alloc((list_action_t)free_submesh);
 }
 
 void exit_submeshes(meshlink_handle_t *mesh) {
-       list_delete_list(mesh->submeshes);
+       if(mesh->submeshes) {
+               list_delete_list(mesh->submeshes);
+       }
+
        mesh->submeshes = NULL;
 }
 
@@ -58,6 +62,7 @@ void free_submesh(submesh_t *s) {
 
 static submesh_t *submesh_new(meshlink_handle_t *mesh, const char *submesh) {
        submesh_t *s = NULL;
+       assert(submesh);
 
        s = new_submesh();
        s->name = xstrdup(submesh);
@@ -67,6 +72,7 @@ static submesh_t *submesh_new(meshlink_handle_t *mesh, const char *submesh) {
 }
 
 submesh_t *create_submesh(meshlink_handle_t *mesh, const char *submesh) {
+       assert(submesh);
        submesh_t *s = NULL;
 
        if(0 == strcmp(submesh, CORE_MESH)) {
@@ -96,6 +102,7 @@ submesh_t *create_submesh(meshlink_handle_t *mesh, const char *submesh) {
 }
 
 submesh_t *lookup_or_create_submesh(meshlink_handle_t *mesh, const char *submesh) {
+       assert(submesh);
        submesh_t *s = NULL;
 
        if(0 == strcmp(submesh, CORE_MESH)) {
@@ -133,6 +140,8 @@ void submesh_del(meshlink_handle_t *mesh, submesh_t *s) {
 }
 
 submesh_t *lookup_submesh(struct meshlink_handle *mesh, const char *submesh_name) {
+       assert(submesh_name);
+
        submesh_t *submesh = NULL;
 
        if(!mesh->submeshes) {
@@ -155,4 +164,4 @@ bool submesh_allows_node(const submesh_t *submesh, const node_t *node) {
        } else {
                return false;
        }
-}
\ No newline at end of file
+}