Untitled

 avatar
unknown
c_cpp
a year ago
624 B
12
Indexable
uint64_t wnd_bit_count_apx_new(StateApx* self, uint32_t wnd_size, uint32_t k) {
    assert(wnd_size >= 1);
    assert(k >= 1);

    // TODO: Fill me.
    self->wnd_size = wnd_size;
    self->k = k;
    self->now = 0;

    uint32_t max_buckets = (uint32_t)(k * log2((double)wnd_size / k)) + 1;
    uint64_t memory = ((uint64_t)max_buckets) * sizeof(Bucket*);
    self->group = (Bucket**)malloc(memory);
    for (uint32_t i = 0; i < max_buckets; i++) {
        self->group[i] = NULL;
    }

    // TODO:
    // The function should return the total number of bytes allocated on the heap.
    return memory;
}
Editor is loading...
Leave a Comment