Changeset 2193905 for lib/data-struct/linked_list.c
- Timestamp:
- 11/29/18 10:12:59 (2 years ago)
- Branches:
- develop
- Children:
- fdf23b8
- Parents:
- d74ca03
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/data-struct/linked_list.c
r88b9798 r2193905 26 26 #include "linked_list.h" 27 27 28 #include <assert.h>29 28 #include <stddef.h> 30 29 #include <stdlib.h> … … 72 71 /* Create the new node */ 73 72 new = (libtrace_list_node_t *)malloc(sizeof(libtrace_list_node_t)); 74 /*assert(new != NULL);*/75 73 if (!new) { 76 74 fprintf(stderr, "Unable to allocate memory for node in libtrace_list_push_front()\n"); … … 78 76 } 79 77 new->data = malloc(l->element_size); 80 /*assert(new->data != NULL);*/81 78 if (!new->data) { 82 79 fprintf(stderr, "Unable to allocate memory for node data in libtrace_list_push_front()\n"); … … 87 84 88 85 if (l->head == NULL) { 89 /*assert(l->tail == NULL && l->size == 0);*/ 90 if (l->tail != NULL && l->size != 0) { 86 if (l->tail != NULL || l->size != 0) { 91 87 fprintf(stderr, "Error cannot have a NULL head with a non NULL tail and a size of non 0 in libtrace_list_push_front()\n"); 92 88 return; … … 111 107 /* Create the new node */ 112 108 new = (libtrace_list_node_t *)malloc(sizeof(libtrace_list_node_t)); 113 /*assert(new != NULL);*/114 109 if (!new) { 115 110 fprintf(stderr, "Unable to allocate memory for node in libtrace_list_push_back()\n"); … … 117 112 } 118 113 new->data = malloc(l->element_size); 119 /*assert(new->data != NULL);*/120 114 if (!new->data) { 121 115 fprintf(stderr, "Unable to allocate memory for node data in libtrace_list_push_back()\n"); … … 126 120 127 121 if (l->tail == NULL) { 128 /*assert(l->head == NULL && l->size == 0);*/ 129 if (l->head != NULL && l->size != 0) { 122 if (l->head != NULL || l->size != 0) { 130 123 fprintf(stderr, "Error cannot have a NULL tail with a non NULL head and a size of non 0 in libtrace_list_push_back()\n"); 131 124 return; … … 219 212 while (index--) { 220 213 ret = ret->next; 221 /*assert(ret != NULL);*/222 214 if (!ret) { 223 215 fprintf(stderr, "Error encountered NULL index in libtrace_list_get_index()\n");
Note: See TracChangeset
for help on using the changeset viewer.