GithubHelp home page GithubHelp logo

libintrusive's People

Contributors

graphitemaster avatar pikhq avatar rswinkle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

libintrusive's Issues

Removal from a red-black tree is broken (segmentation fault)

I added only three lines to example.c (see the comments below for the specific additions) which insert a fourth node into the tree and attempt to remove a node from the tree. This results in a segmentation fault at rb.c:169.

void rb() {
    printf(">> RB\n");
    rb_tree_t tree;
    rb_init(&tree, NULL);

    test_rb_t a = { 1 };
    test_rb_t b = { 2 };
    test_rb_t c = { 3 };
    test_rb_t d = { 4 }; /* Addition 1 */

    rb_insert(&tree, &a.node, &test_rb_compare);
    rb_insert(&tree, &b.node, &test_rb_compare);
    rb_insert(&tree, &c.node, &test_rb_compare);
    rb_insert(&tree, &d.node, &test_rb_compare); /* Addition 2 */

    rb_remove(&tree, &a.node); /* Addition 3 */

    // Display them
    rb_node_t *node = rb_head(&tree);
    while (node) {
        rb_node_t *next = rb_next(node);
        rb_node_t *prev = rb_prev(node);
        test_rb_t *c = rb_ref(node, test_rb_t, node);
        test_rb_t *n = next ? rb_ref(next, test_rb_t, node) : NULL;
        test_rb_t *p = prev ? rb_ref(prev, test_rb_t, node) : NULL;
        printf("current: %d, next: %d, prev: %d\n",
                c->number,
                n ? n->number : -1,
                p ? p->number : -1);
        node = next;
    }
}

I know this project is fairly old and unmaintained, but I figured I might as well point this out in case future people attempt to use this as a resource.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.