Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

list_remove should check node to NULL #25

Open
LuisCRSousa opened this issue Mar 23, 2020 · 3 comments
Open

list_remove should check node to NULL #25

LuisCRSousa opened this issue Mar 23, 2020 · 3 comments

Comments

@LuisCRSousa
Copy link

Because if I use list_remove(list, list_find(list, item)) it will break because list_find could return NULL

@stephenmathieson
Copy link
Member

stephenmathieson commented Mar 24, 2020

Currently we expect you to check the return value of list_find:

list_node_t *thing = list_find(list, "value");
if (thing != NULL) {
  list_remove(list, thing);
}

I think this is a reasonable thing to do. What is the use case for not checking the return value yourself?

@LuisCRSousa
Copy link
Author

A lib should be bullet proof and check for this kind of edge cases that's all.
I just wanted to do it in one line of code, there's no need to repeat the same code over and over again.

Thanks :)

@stephenmathieson
Copy link
Member

Feel free to open a PR :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants