10 #define INITIAL_VECTOR_LEN 3
14 #define INITIAL_VECTOR_LEN 4
17 #define NEXT_VECTOR_CAPACITY (vec->capacity < INITIAL_VECTOR_LEN \
18 ? INITIAL_VECTOR_LEN \
19 : vec->capacity <= 12 ? vec->capacity * 2 \
20 : vec->capacity + (vec->capacity >> 1))
22 #define RESIZE_OR_RETURN_NULL(next_capacity) \
24 size_t new_capacity = next_capacity; \
25 void **new_a = realloc(vec->a, vec->elem_size * new_capacity); \
26 if (!new_a && new_capacity) { \
30 vec->capacity = new_capacity; \
53 while (vec->
len > 0) {
84 dst->capacity =
src->capacity;
86 dst->elem_size =
src->elem_size;
88 dst->free_user =
src->free_user;
134 if (index < vec->
len) {
146 if (index < vec->
len) {
157 if (index < vec->
len) {
174 if (index < vec->
len) {
240 #define VEC_INDEX(a, i) (char *)a + elem_size *(i)
246 size_t i = rand() %
len, j = 0;
249 t = (
void *)
malloc(elem_size);
250 pivot = (
void *)
malloc(elem_size);
260 for (
i = 0;
i <
len - 1;
i++) {
293 void *
p = *((
void **)
e);
321 memset(
p, 0,
v->v.elem_size *
v->v.capacity);
347 for (
i = 0;
i < vec->
v.
len;
i++) {
348 if (((
void **)vec->
v.
a)[
i] ==
x) {
349 return &((
void **)vec->
v.
a)[
i];
368 size_t index = el - (
void **)vec->
v.
a;
391 size_t i = rand() %
n, j = 0;
392 void *t, *pivot =
a[
i];
394 for (
i = 0;
i <
n - 1;
i++) {
395 if (
cmp(
a[
i], pivot) < 0) {
static RzILOpEffect * cmp(cs_insn *insn, bool is_thumb)
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void count
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void length
RZ_API void Ht_() free(HtName_(Ht) *ht)
return memset(p, 0, total)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
void * malloc(size_t size)
#define rz_return_if_fail(expr)
#define rz_return_val_if_fail(expr, val)
#define RZ_LOG_ERROR(fmtstr,...)
static void ** rz_pvector_reserve(RzPVector *vec, size_t capacity)
static void * rz_vector_index_ptr(RzVector *vec, size_t index)
void(* RzVectorFree)(void *e, void *user)
void(* RzPVectorFree)(void *e)
int(* RzPVectorComparator)(const void *a, const void *b)
static void * rz_pvector_at(const RzPVector *vec, size_t index)
int(* RzVectorComparator)(const void *a, const void *b)
RZ_API void * rz_vector_assign_at(RzVector *vec, size_t index, void *elem)
RZ_API void rz_vector_pop(RzVector *vec, void *into)
#define NEXT_VECTOR_CAPACITY
RZ_API void rz_pvector_sort(RzPVector *vec, RzPVectorComparator cmp)
static bool vector_clone(RzVector *dst, RzVector *src)
RZ_API void rz_vector_pop_front(RzVector *vec, void *into)
RZ_API void * rz_vector_push_front(RzVector *vec, void *x)
RZ_API void * rz_pvector_pop(RzPVector *vec)
RZ_API void * rz_vector_flush(RzVector *vec)
Turn the vector into a fixed-size array. This will clear the vector and return an array of its origin...
RZ_API void rz_pvector_remove_data(RzPVector *vec, void *x)
RZ_API void rz_pvector_init(RzPVector *vec, RzPVectorFree free)
RZ_API void rz_vector_remove_at(RzVector *vec, size_t index, void *into)
RZ_API void rz_pvector_fini(RzPVector *vec)
static void pvector_free_elem(void *e, void *user)
RZ_API void * rz_vector_reserve(RzVector *vec, size_t capacity)
RZ_API void * rz_vector_push(RzVector *vec, void *x)
RZ_API RzPVector * rz_pvector_new(RzPVectorFree free)
static void quick_sort(void **a, size_t n, RzPVectorComparator cmp)
RZ_API void * rz_pvector_remove_at(RzPVector *vec, size_t index)
RZ_API void * rz_pvector_pop_front(RzPVector *vec)
RZ_API void ** rz_pvector_contains(RzPVector *vec, void *x)
static void vector_free_elems(RzVector *vec)
RZ_API void rz_vector_fini(RzVector *vec)
RZ_API void rz_vector_free(RzVector *vec)
RZ_API void rz_pvector_free(RzPVector *vec)
RZ_API void * rz_vector_insert_range(RzVector *vec, size_t index, void *first, size_t count)
RZ_API RzVector * rz_vector_clone(RzVector *vec)
RZ_API RzVector * rz_vector_new(size_t elem_size, RzVectorFree free, void *free_user)
RZ_API RzPVector * rz_pvector_new_with_len(RzPVectorFree free, size_t length)
RZ_API void rz_vector_clear(RzVector *vec)
RZ_API void rz_vector_assign(RzVector *vec, void *p, void *elem)
RZ_API void rz_vector_init(RzVector *vec, size_t elem_size, RzVectorFree free, void *free_user)
RZ_API void * rz_vector_insert(RzVector *vec, size_t index, void *x)
RZ_API void rz_vector_remove_range(RzVector *vec, size_t index, size_t count, void *into)
#define RESIZE_OR_RETURN_NULL(next_capacity)
RZ_API void rz_pvector_clear(RzPVector *vec)
static void vector_quick_sort(void *a, size_t elem_size, size_t len, RzPVectorComparator cmp, bool reverse)
RZ_API void rz_vector_sort(RzVector *vec, RzVectorComparator cmp, bool reverse)
Sort function for RzVector.
RZ_API void * rz_vector_shrink(RzVector *vec)