QBARRAY.H(3)
π QBARRAY.H(3) π
okay bestie, welcome to libqb Programmer's Manual β this is the qbarray.h page and it's genuinely such a serve, let me tell you everything π«Ά
β¨ NAME β¨
qbarray.h β this is a dynamic array (it can grow, but without moving memory) π
πΈ SYNOPSIS πΈ
#include <qb/qbarray.h>
π¦ DESCRIPTION π¦
okay so here's the whole vibe in code first, because honestly it's giving main character energy:
arr = qb_array_create_2(64, sizeof(struct my_struct), 256);
...
res = qb_array_index(arr, idx, (void**)&my_ptr);
if (res < 0) {
return res;
}
// use my_ptr, now even if there is a grow, this pointer will be valid.
bestie, look at that comment at the bottom π that's the WHOLE point. my_ptr stays valid even if the array grows. no cap. it's iconic behavior and we're obsessed.
Currently, this dynamic array abstract data type can accommodate only 2^QB_ARRAY_MAX_INDEX_BITS elements, and with standard zero-based indexing, this gives a valid index range [0, QB_ARRAY_MAX_ELEMENTS), where the notation denotes that the beginning of the interval is included and the end is excluded. periodt. π
In other words (fr fr, listen up π₯): client space shall avoid a pitfall of relying solely on the type of the max_elements parameter to qb_array_create and/or of the idx parameter to qb_array_index β and yes, these types conflict, anyway π so likeβ¦ don't do that. the vibe check will not pass.
β οΈ not me warning you twice: that interval is half-open, bestie. QB_ARRAY_MAX_ELEMENTS itself is NOT a valid index. do not go there. π
π SEE ALSO π
qb_array_elems_per_bin_get(3)qb_array_new_bin_cb_set(3)qb_array_create(3)qb_array_grow(3)qb_array_num_bins_get(3)qb_array_index(3)qb_array_create_2(3)qb_array_free(3)
go read them, they're all slay, iykyk π
π COPYRIGHT π
Copyright (C) 2010-2020 Red Hat, Inc.
and that's the whole page, bestie!! πΈ this was libqb's qbarray.h(3), and the version stamp on this lil masterpiece is dated 2025-09-16 β so if you're reading this in the future, hi, love you, the facts are still the facts π stay hydrated, keep your pointers valid, and don't index past the end, mwah π«Άβ¨
π¦ where this page comes from
- fedora 44: libqb-devel 2.0.9-2.fc44 Β· LGPL-2.1-or-later
- fedora 44: libqb-devel 2.0.9-2.fc44 Β· LGPL-2.1-or-later
- ubuntu resolute: libqb-dev 2.0.9-1ubuntu1 Β· LGPL-2.1-or-later
- ubuntu stonking: libqb-dev 2.0.9-1ubuntu1 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms