1 // SPDX-License-Identifier: GPL-2.0
3 #include <linux/log2.h>
4 #include <linux/slab.h>
7 int __bch2_darray_resize(darray_char *d, size_t element_size, size_t new_size, gfp_t gfp)
9 if (new_size > d->size) {
10 new_size = roundup_pow_of_two(new_size);
12 void *data = kvmalloc_array(new_size, element_size, gfp);
16 memcpy(data, d->data, d->size * element_size);
17 if (d->data != d->preallocated)