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 πŸŽ€

go read them, they're all slay, iykyk 🌈


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