diff options
| author | Thomas Schmucker <ts@its1.de> | 2021-12-29 10:49:19 +0100 |
|---|---|---|
| committer | Thomas Schmucker <ts@its1.de> | 2021-12-29 10:49:19 +0100 |
| commit | 5e696c74c9649b0e54133d46a3ae92e5ce0632fb (patch) | |
| tree | ef9d4e6bcf9797b74e13ddbf943f424ac1d49664 /list-tail-node.c | |
| parent | a9fecebe13be05c15a5adf5a6fcefacb73d0d035 (diff) | |
| parent | 6ced2a50056acbf7caec404a1edfa3b07fa1ac5d (diff) | |
| download | data-structures-5e696c74c9649b0e54133d46a3ae92e5ce0632fb.tar.gz data-structures-5e696c74c9649b0e54133d46a3ae92e5ce0632fb.tar.bz2 data-structures-5e696c74c9649b0e54133d46a3ae92e5ce0632fb.zip | |
Merge branch 'feat/remove-null-checks'
Diffstat (limited to 'list-tail-node.c')
| -rw-r--r-- | list-tail-node.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/list-tail-node.c b/list-tail-node.c index 4e40912..edfcf31 100644 --- a/list-tail-node.c +++ b/list-tail-node.c | |||
| @@ -33,7 +33,7 @@ create_node(struct list_node *next, T data) | |||
| 33 | { | 33 | { |
| 34 | struct list_node *node = malloc(sizeof *node); | 34 | struct list_node *node = malloc(sizeof *node); |
| 35 | 35 | ||
| 36 | if ( node != NULL ) { | 36 | if ( node ) { |
| 37 | node->next = next; | 37 | node->next = next; |
| 38 | node->data = data; | 38 | node->data = data; |
| 39 | } | 39 | } |
| @@ -47,7 +47,7 @@ list_push_back(struct list *list, T data) | |||
| 47 | { | 47 | { |
| 48 | struct list_node *node = create_node(NULL, data); | 48 | struct list_node *node = create_node(NULL, data); |
| 49 | 49 | ||
| 50 | if ( node != NULL ) { | 50 | if ( node ) { |
| 51 | if ( list->head == NULL ) { | 51 | if ( list->head == NULL ) { |
| 52 | list->head = node; | 52 | list->head = node; |
| 53 | } | 53 | } |
| @@ -68,7 +68,7 @@ list_push_front(struct list *list, T data) | |||
| 68 | { | 68 | { |
| 69 | struct list_node *node = create_node(list->head, data); | 69 | struct list_node *node = create_node(list->head, data); |
| 70 | 70 | ||
| 71 | if ( node != NULL ) { | 71 | if ( node ) { |
| 72 | if ( list->head == NULL ) { // Einfügen in eine leere Liste? | 72 | if ( list->head == NULL ) { // Einfügen in eine leere Liste? |
| 73 | list->tail = node; | 73 | list->tail = node; |
| 74 | } | 74 | } |
| @@ -84,10 +84,10 @@ list_push_front(struct list *list, T data) | |||
| 84 | bool | 84 | bool |
| 85 | list_pop_front(struct list *list, T *data) | 85 | list_pop_front(struct list *list, T *data) |
| 86 | { | 86 | { |
| 87 | if ( list->head != NULL ) { | 87 | if ( list->head ) { |
| 88 | struct list_node *next = list->head->next; | 88 | struct list_node *next = list->head->next; |
| 89 | 89 | ||
| 90 | if ( data != NULL ) { | 90 | if ( data ) { |
| 91 | *data = list->head->data; | 91 | *data = list->head->data; |
| 92 | } | 92 | } |
| 93 | free(list->head); | 93 | free(list->head); |
| @@ -111,7 +111,7 @@ list_insert_next(struct list *list, struct list_node *node, T data) | |||
| 111 | else { | 111 | else { |
| 112 | struct list_node *new_node = create_node(node->next, data); | 112 | struct list_node *new_node = create_node(node->next, data); |
| 113 | 113 | ||
| 114 | if ( new_node != NULL ) { | 114 | if ( new_node ) { |
| 115 | if ( node->next == NULL ) { // Am Ende einfügen | 115 | if ( node->next == NULL ) { // Am Ende einfügen |
| 116 | list->tail = new_node; | 116 | list->tail = new_node; |
| 117 | } | 117 | } |
| @@ -132,7 +132,7 @@ list_delete_next(struct list *list, struct list_node *node, T *data) | |||
| 132 | list_pop_front(list, data); | 132 | list_pop_front(list, data); |
| 133 | } | 133 | } |
| 134 | else { | 134 | else { |
| 135 | if ( node->next != NULL ) { | 135 | if ( node->next ) { |
| 136 | struct list_node *old_node = node->next; | 136 | struct list_node *old_node = node->next; |
| 137 | node->next = node->next->next; | 137 | node->next = node->next->next; |
| 138 | 138 | ||
| @@ -140,7 +140,7 @@ list_delete_next(struct list *list, struct list_node *node, T *data) | |||
| 140 | list->tail = node; | 140 | list->tail = node; |
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | if ( data != NULL ) { | 143 | if ( data ) { |
| 144 | *data = old_node->data; | 144 | *data = old_node->data; |
| 145 | } | 145 | } |
| 146 | free(old_node); | 146 | free(old_node); |
