c-algorithms icon indicating copy to clipboard operation
c-algorithms copied to clipboard

Cannot distinguish between no-op insert and memory error

Open scossu opened this issue 5 years ago • 0 comments

I preface that I'm quite new to C so this may be completely off. However, in:

https://github.com/fragglet/c-algorithms/blob/5b0555f4aa832a9d4c8662316994faa80f52ae93/src/set.c#L256-L275

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.

scossu avatar Oct 31 '18 03:10 scossu