---
name: "qbarray.h"
section: "3"
platform: "linux"
package: "libqb"
version: "2.0.10-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/qbarray.h"
---

# qbarray.h(3)

This is a dynamic array (it can grow, but without moving memory).

## NAME

qbarray.h - This is a dynamic array (it can grow, but without moving memory).

## SYNOPSIS

```
#include <qb/qbarray.h>
```

## DESCRIPTION

```
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.
```

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 the beginning of the interval is included and the end is excluded. In other words, client space shall avoid a pitfall of relying solely on the type of **max\_elements** parameter to *qb\_array\_create* and/or of **idx** parameter to *qb\_array\_index* (these types conflict, anyway).

## SEE ALSO

[*qb\_array\_elems\_per\_bin\_get*(3)](/qb_array_elems_per_bin_get/3.md), [*qb\_array\_new\_bin\_cb\_set*(3)](/qb_array_new_bin_cb_set/3.md), [*qb\_array\_create*(3)](/qb_array_create/3.md), [*qb\_array\_grow*(3)](/qb_array_grow/3.md), [*qb\_array\_num\_bins\_get*(3)](/qb_array_num_bins_get/3.md), [*qb\_array\_index*(3)](/qb_array_index/3.md), [*qb\_array\_create\_2*(3)](/qb_array_create_2/3.md), [*qb\_array\_free*(3)](/qb_array_free/3.md)

## COPYRIGHT

Copyright (C) 2010-2020 Red Hat, Inc.
