Ignore:
Timestamp:
11/29/18 10:12:59 (2 years ago)
Author:
Jacob Van Walraven <jcv9@…>
Branches:
develop
Children:
fdf23b8
Parents:
d74ca03
Message:

Apply changes required for pull request #81

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/data-struct/linked_list.c

    r88b9798 r2193905  
    2626#include "linked_list.h"
    2727
    28 #include <assert.h>
    2928#include <stddef.h>
    3029#include <stdlib.h>
     
    7271        /* Create the new node */
    7372        new = (libtrace_list_node_t *)malloc(sizeof(libtrace_list_node_t));
    74         /*assert(new != NULL);*/
    7573        if (!new) {
    7674                fprintf(stderr, "Unable to allocate memory for node in libtrace_list_push_front()\n");
     
    7876        }
    7977        new->data = malloc(l->element_size);
    80         /*assert(new->data != NULL);*/
    8178        if (!new->data) {
    8279                fprintf(stderr, "Unable to allocate memory for node data in libtrace_list_push_front()\n");
     
    8784
    8885        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) {
    9187                        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");
    9288                        return;
     
    111107        /* Create the new node */
    112108        new = (libtrace_list_node_t *)malloc(sizeof(libtrace_list_node_t));
    113         /*assert(new != NULL);*/
    114109        if (!new) {
    115110                fprintf(stderr, "Unable to allocate memory for node in libtrace_list_push_back()\n");
     
    117112        }
    118113        new->data = malloc(l->element_size);
    119         /*assert(new->data != NULL);*/
    120114        if (!new->data) {
    121115                fprintf(stderr, "Unable to allocate memory for node data in libtrace_list_push_back()\n");
     
    126120
    127121        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) {
    130123                        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");
    131124                        return;
     
    219212        while (index--) {
    220213                ret = ret->next;
    221                 /*assert(ret != NULL);*/
    222214                if (!ret) {
    223215                        fprintf(stderr, "Error encountered NULL index in libtrace_list_get_index()\n");
Note: See TracChangeset for help on using the changeset viewer.