data_structures

data structures in C
Log | Files | Refs | Feed

commit 94b5cb5b11c6f64fdf3aa30619d2ea7ef746f2ab
parent f623fe3e6d8a6e2ad15193e65a177f145e74ee1b
Author: Jenny Doe <tng@soykaf.me>
Date:   Fri, 22 Mar 2019 00:33:39 +0100

fixed: silently fails on max size

Diffstat:
Mclist.c | 2+-
Mclist.h | 2+-
Mdlist.c | 2+-
Mdlist.h | 2+-
Mlist.c | 2+-
Mlist.h | 2+-
6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/clist.c b/clist.c @@ -37,7 +37,7 @@ clist_ins_next(cList * list, cListElmt * left, void *data) { /* silently fail */ if (list->size == UINT_MAX - 1) { - return (1); + return (0); } cListElmt *new_element = malloc(sizeof(cListElmt)); diff --git a/clist.h b/clist.h @@ -23,7 +23,7 @@ void clist_init(cList *, void (*) (void *)); /* can fail */ void clist_destroy(cList *); -/* returns 0 on success, 1 when malloc fail */ +/* returns 0 on success or max size, 1 when malloc fail */ int clist_ins_next(cList *, cListElmt *, void *); /* returns 0 on success, 1 if list's size is 0 */ diff --git a/dlist.c b/dlist.c @@ -38,7 +38,7 @@ dlist_ins_next(dList * list, dListElmt * left, void *data) { /* silently fail */ if (list->size == UINT_MAX - 1) { - return (1); + return (0); } dListElmt *new_element = malloc(sizeof(dListElmt)); diff --git a/dlist.h b/dlist.h @@ -25,7 +25,7 @@ void dlist_init(dList *, void (*) (void *)); /* can fail */ void dlist_destroy(dList *); -/* returns 0 on success, 1 when malloc fail */ +/* returns 0 on success or max size, 1 when malloc fail */ int dlist_ins_next(dList *, dListElmt *, void *); int dlist_ins_prev(dList *, dListElmt *, void *); diff --git a/list.c b/list.c @@ -38,7 +38,7 @@ list_ins_next(List * list, ListElmt * left, void *data) { /* silently fail */ if (list->size == UINT_MAX - 1) { - return (1); + return (0); } ListElmt *new_element = malloc(sizeof(ListElmt)); diff --git a/list.h b/list.h @@ -24,7 +24,7 @@ void list_init(List *, void (*) (void *)); /* can fail */ void list_destroy(List *); -/* returns 0 on success, 1 when malloc fail */ +/* returns 0 on success or max size, 1 when malloc fail */ int list_ins_next(List *, ListElmt *, void *); /* returns 0 on success, 1 if list's size is 0 */