M

Mammoth

Member

Last active 2 weeks ago

  1. 2 weeks ago
    Sat Mar 4 14:36:20 2017
    M Mammoth posted in How to use the cleanup functions.

    Thank for the answer, somehow forgot how the whole thing worked! :)

  2. 3 weeks ago
    Sun Feb 26 22:58:57 2017
    M Mammoth started the conversation How to use the cleanup functions.

    Hello,

    i am using lfds711 queue bss but i have troubles freeing the allocated data.

    As i understood it, i need to call the lfds711_queue_bss_cleanup with a callback that will call free for each elements i allocated, however i keep getting segfault by doing that.

    Here is the simple implementation of my callbacks:

    void q_element_cleanup_callback(struct lfds711_queue_bss_state *qbsss, void *key, void *value) {
        free(value);
    }

    Initialization:

        struct lfds711_queue_bss_element *synth_commands_queue_element =
            aligned_alloc(fas_commands_queue_size, sizeof(struct lfds711_queue_bss_element) * fas_commands_queue_size);
        lfds711_queue_bss_init_valid_on_current_logical_core(&synth_commands_queue_state, synth_commands_queue_element, fas_commands_queue_size, NULL);

    Allocation:

    // usd->synth is allocated with a generic malloc just before this
    lfds711_queue_bss_enqueue(&synth_commands_queue_state, NULL, (void *)usd->synth);

    Maybe i misundertood how you can free the data, i am also using a freelist for the ringbuffer and calling lfds711_freelist_cleanup work fine so i just don't know why doing this just crash?

    Thank you for this great library btw.

  3. Sun Feb 26 13:19:21 2017
    M Mammoth joined the forum.