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

malloc free #17

Open
jamesbankkkk opened this issue Dec 23, 2016 · 4 comments
Open

malloc free #17

jamesbankkkk opened this issue Dec 23, 2016 · 4 comments

Comments

@jamesbankkkk
Copy link

for the iterator, when malloc a ptr to iterator, we should use (list_iterator_t **ptr)to destroy, because
void
list_iterator_destroy(list_iterator_t *self) {
LIST_FREE(self);
self = NULL;
}

this is not save, because the
if (val == node->val) {
list_iterator_destroy(it);
return node;
}
it still ptr the memory of free

we should use list_iterator_destory(&it);

@stephenmathieson
Copy link
Member

PR welcome! =)

@jamesbankkkk
Copy link
Author

every good

@jamesbankkkk
Copy link
Author

my colleague said that is the end of code, so can do

@jamesbankkkk
Copy link
Author

why in another place, at the list_iterator_destroy(..){LIST_FREE(self); self = null;} why you use null,

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