2020-03-05 19:44:09 +00:00
|
|
|
#pragma once
|
|
|
|
|
2021-04-09 15:24:47 +00:00
|
|
|
#include <assert.h>
|
|
|
|
#include <stdlib.h>
|
2018-05-05 19:38:55 +00:00
|
|
|
|
2018-05-28 07:52:44 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2018-05-05 19:38:55 +00:00
|
|
|
typedef struct {
|
|
|
|
unsigned int size;
|
|
|
|
unsigned int capacity;
|
|
|
|
unsigned char* data;
|
|
|
|
unsigned int element_size;
|
|
|
|
} AlignedVector;
|
|
|
|
|
2019-03-13 07:28:23 +00:00
|
|
|
#define ALIGNED_VECTOR_CHUNK_SIZE 256u
|
2018-05-28 06:16:50 +00:00
|
|
|
|
2021-04-20 15:49:00 +00:00
|
|
|
#define AV_NO_INSTRUMENT inline __attribute__((no_instrument_function))
|
|
|
|
#define AV_INLINE_DEBUG AV_NO_INSTRUMENT __attribute__((always_inline))
|
|
|
|
#define AV_FORCE_INLINE static AV_INLINE_DEBUG
|
|
|
|
|
2018-05-26 18:17:42 +00:00
|
|
|
void aligned_vector_init(AlignedVector* vector, unsigned int element_size);
|
2021-04-20 15:08:58 +00:00
|
|
|
void* aligned_vector_reserve(AlignedVector* vector, unsigned int element_count);
|
2018-08-21 08:37:19 +00:00
|
|
|
void* aligned_vector_push_back(AlignedVector* vector, const void* objs, unsigned int count);
|
2018-08-16 16:51:15 +00:00
|
|
|
void* aligned_vector_resize(AlignedVector* vector, const unsigned int element_count);
|
2021-04-20 15:49:00 +00:00
|
|
|
|
|
|
|
AV_FORCE_INLINE void* aligned_vector_at(const AlignedVector* vector, const unsigned int index) {
|
2020-03-05 19:44:09 +00:00
|
|
|
assert(index < vector->size);
|
|
|
|
return &vector->data[index * vector->element_size];
|
|
|
|
}
|
2018-05-26 18:17:42 +00:00
|
|
|
void* aligned_vector_extend(AlignedVector* vector, const unsigned int additional_count);
|
2021-04-20 15:49:00 +00:00
|
|
|
|
|
|
|
AV_FORCE_INLINE void aligned_vector_clear(AlignedVector* vector){
|
2020-03-05 19:44:09 +00:00
|
|
|
vector->size = 0;
|
|
|
|
}
|
2018-05-26 18:17:42 +00:00
|
|
|
void aligned_vector_shrink_to_fit(AlignedVector* vector);
|
|
|
|
void aligned_vector_cleanup(AlignedVector* vector);
|
2020-03-05 19:44:09 +00:00
|
|
|
static inline void* aligned_vector_back(AlignedVector* vector){
|
|
|
|
return aligned_vector_at(vector, vector->size - 1);
|
|
|
|
}
|
2018-05-05 19:38:55 +00:00
|
|
|
|
2018-05-28 07:52:44 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|