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

Simple Stack #18

Open
Maxmawt opened this issue Mar 13, 2018 · 0 comments
Open

Simple Stack #18

Maxmawt opened this issue Mar 13, 2018 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@Maxmawt
Copy link
Collaborator

Maxmawt commented Mar 13, 2018

Pour le push, si le deuxième malloc fails, les tests ne vérifient pas que noeud initialisé au préalable est libéré, ce qui peut créer de grosses memory leak.
ex:

if(!head) return 1;
struct node* new = (struct node*) malloc(sizeof(struct node));
if(!new) return 1;
new->name = (char*) malloc(sizeof(strlen(value)+1));
if(!new->name){
    //free(new);
    return 1;
}
strcpy(new->name,value);
new->next = *head;
*head = new;
return 0;

Et ce code passe tous les tests

@Maxmawt Maxmawt added the enhancement New feature or request label Mar 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants