/
githubmirror
/
nvme-cli
Обзор
Документация
Войти
/
githubmirror
/
nvme-cli
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
shared/array-util.c
35 строк
710 B
Martin Belanger
shared: rename everything to the shr_ namespace
28 июл 2026, 10:55
28 июл 2026, 10:55
8876cbc
Код
Авторство
О чём код?
// SPDX-License-Identifier: LGPL-2.1-or-later /* * This file is part of nvme-cli. * Copyright (c) 2026 Dell Technologies Inc. or its subsidiaries. * * Authors: Martin Belanger <martin.belanger@dell.com> */ #include <errno.h> #include <stdlib.h> #include "array-util.h" int shr_ptrarray_append(struct shr_ptrarray *a, void *item) { if (a->len == a->cap) { size_t newcap = a->cap ? a->cap * 2 : 8; void **newitems = realloc(a->items, newcap * sizeof(*newitems)); if (!newitems) return -ENOMEM; a->items = newitems; a->cap = newcap; } a->items[a->len++] = item; return 0; } void shr_ptrarray_free(struct shr_ptrarray *a) { free(a->items); a->items = NULL; a->len = 0; a->cap = 0; }