1 /* 2 * Copyright 2017 The Chromium OS Authors. All rights reserved. 3 * Use of this source code is governed by a BSD-style license that can be 4 * found in the LICENSE file. 5 */ 6 7 #ifndef DRV_ARRAY_HELPERS_H 8 #define DRV_ARRAY_HELPERS_H 9 10 #include <stdint.h> 11 12 struct drv_array; 13 14 struct drv_array *drv_array_init(uint32_t item_size); 15 16 /* The data will be copied and appended to the array. */ 17 void *drv_array_append(struct drv_array *array, void *data); 18 19 /* The data at the specified index will be freed -- the array will shrink. */ 20 void drv_array_remove(struct drv_array *array, uint32_t idx); 21 22 void *drv_array_at_idx(struct drv_array *array, uint32_t idx); 23 24 uint32_t drv_array_size(struct drv_array *array); 25 26 /* The array and all associated data will be freed. */ 27 void drv_array_destroy(struct drv_array *array); 28 29 #endif 30