Loading...
Searching...
No Matches
vec.h
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright 2016, Olivier MATZ <zer0@droids-corp.org>
*/
#pragma once
#include <stdint.h>
#include <sys/types.h>
typedef void (*ec_vec_elt_free_t)(void *ptr);
typedef void (*ec_vec_elt_copy_t)(void *dst, void *src);
struct ec_vec *ec_vec(size_t elt_size, size_t size, ec_vec_elt_copy_t copy, ec_vec_elt_free_t free);
int ec_vec_add_by_ref(struct ec_vec *vec, void *ptr);
int ec_vec_add_ptr(struct ec_vec *vec, void *elt);
int ec_vec_add_u8(struct ec_vec *vec, uint8_t elt);
int ec_vec_add_u16(struct ec_vec *vec, uint16_t elt);
int ec_vec_add_u32(struct ec_vec *vec, uint32_t elt);
int ec_vec_add_u64(struct ec_vec *vec, uint64_t elt);
int ec_vec_get(void *ptr, const struct ec_vec *vec, size_t idx);
struct ec_vec *ec_vec_dup(const struct ec_vec *vec);
struct ec_vec *ec_vec_ndup(const struct ec_vec *vec, size_t off, size_t len);
void ec_vec_free(struct ec_vec *vec);
__attribute__((pure)) size_t ec_vec_len(const struct ec_vec *vec);
ec_vec_add_by_ref
int ec_vec_add_by_ref(struct ec_vec *vec, void *ptr)
Add reference to a vector.
ec_vec_free
void ec_vec_free(struct ec_vec *vec)
Free a vector and all its contents.
ec_vec_add_u16
int ec_vec_add_u16(struct ec_vec *vec, uint16_t elt)
Add uint16_t value to a vector.
ec_vec_elt_copy_t
void(* ec_vec_elt_copy_t)(void *dst, void *src)
Custom copy callback.
Definition vec.h:32
ec_vec_add_u32
int ec_vec_add_u32(struct ec_vec *vec, uint32_t elt)
Add uint32_t value to a vector.
ec_vec_add_u8
int ec_vec_add_u8(struct ec_vec *vec, uint8_t elt)
Add uint8_t value to a vector.
ec_vec_add_u64
int ec_vec_add_u64(struct ec_vec *vec, uint64_t elt)
Add uint64_t value to a vector.
ec_vec_get
int ec_vec_get(void *ptr, const struct ec_vec *vec, size_t idx)
Get element located at an offset.
ec_vec_elt_free_t
void(* ec_vec_elt_free_t)(void *ptr)
Custom free callback.
Definition vec.h:25
ec_vec_dup
struct ec_vec * ec_vec_dup(const struct ec_vec *vec)
Duplicate a vector.
ec_vec_ndup
struct ec_vec * ec_vec_ndup(const struct ec_vec *vec, size_t off, size_t len)
Duplicate a portion of a vector.
ec_vec
struct ec_vec * ec_vec(size_t elt_size, size_t size, ec_vec_elt_copy_t copy, ec_vec_elt_free_t free)
Create a new vector.
ec_vec_add_ptr
int ec_vec_add_ptr(struct ec_vec *vec, void *elt)
Add opaque element to a vector.