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

after list_remove item is still available #22

Open
ApaDoctor opened this issue Oct 28, 2018 · 1 comment
Open

after list_remove item is still available #22

ApaDoctor opened this issue Oct 28, 2018 · 1 comment

Comments

@ApaDoctor
Copy link

ApaDoctor commented Oct 28, 2018

#include <stdlib.h>
#include "list.h"


int main(){
  list_t *gc = list_new();
  list_node_t *node =  list_append(gc, list_node_new("foo"));
  list_node_t *node_2 =  list_append(gc, list_node_new("bar"));
  printf("node: %s, node_2: %s\n", (char*)node->val, (char*)node_2->val);
  list_remove(gc, node);
  printf("length: %d\n", gc->len);
  printf("node: %s, node_2: %s\n", (char*)node->val, (char*)node_2->val);
  
  return 0;
}

Output:

node: foo, node_2: bar
length: 1
node: foo, node_2: bar

Is this a bug, or it's some compiler caching?

@xuniuer
Copy link

xuniuer commented Nov 2, 2019

Is there a function called list_append in the implementation? I cannot see it. In test.c, list_rpush/list_lpush are used.

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