-
Notifications
You must be signed in to change notification settings - Fork 744
Open
Description
I preface that I'm quite new to C so this may be completely off. However, in:
Lines 256 to 275 in 5b0555f
| if (set->equal_func(data, rover->data) != 0) { | |
| /* This data is already in the set */ | |
| return 0; | |
| } | |
| rover = rover->next; | |
| } | |
| /* Not in the set. We must add a new entry. */ | |
| /* Make a new entry for this data */ | |
| newentry = (SetEntry *) malloc(sizeof(SetEntry)); | |
| if (newentry == NULL) { | |
| return 0; | |
| } |
the 0 return value is used both for an operation that does not change the state of a set (because the value already exists), which may or may not be an issue, and a memory error, which is more likely to be an issue, and of a different type.
Shall the former not use a kind of custom error code, and the latter an ENOMEM according to https://www.gnu.org/software/libc/manual/html_node/Error-Codes.html ?
Thanks.
Metadata
Metadata
Assignees
Labels
No labels