14 for (
i = 31;
i > (-1);
i--) {
15 if (
v & (0x1U <<
i)) {
16 return (
v & (0x1U <<
i));
24 if (start_id < last_id) {
54 if (!pool || (kick < pool->start_id) || (pool->
start_id == pool->
next_id)) {
57 if (kick == (pool->
next_id - 1)) {
105 storage->
data = data;
137 if (
n > ((storage->
size / 2) + (storage->
size / 4))) {
149 if (
id > storage->
top_id) {
163 if (!storage || !storage->
data || (storage->
size <=
id)) {
172 for (
i = 0;
i < storage->
size && !storage->
data[
i];
i++)
175 return i < storage->
size;
181 if (storage->
size > 0) {
182 for (
i = storage->
size - 1; !storage->
data[
i] &&
i > 0;
i--)
194 if (storage->
size < 1 ||
id >= storage->
size || !storage->
data) {
197 for (
id = *idref + 1;
id < storage->
size && !storage->
data[
id];
id++)
199 if (id < storage->
size) {
209 if (
id == 0 ||
id >= storage->
size || storage->
size < 1 || !storage->
data) {
212 for (
id = *idref - 1;
id > 0 && !storage->
data[
id];
id--)
214 if (storage->
data[
id]) {
222 if (!storage || !storage->
data || (storage->
size <=
id)) {
226 if (
id == storage->
top_id) {
238 storage->
pool = pool;
241 }
else if ((storage->
top_id + 1) < (storage->
size / 4)) {
256 if (!
cb || !storage || !storage->
data) {
264 if (storage->
data[
i]) {
265 return cb(user, storage->
data[
i],
i);
326 storage->
data && (id < storage->data->pool->next_id)) {
327 for (od[0] = 0; od[0] < storage->
ptop; od[0]++) {
337 if (!storage || !
id || !od) {
345 }
else if (storage->
ptop > (storage->
psize * 3 / 4)) {
366 for (od = 0; od < storage->
ptop; od++) {
371 if (od == storage->
ptop) {
373 }
else if (od == (storage->
ptop - 1)) {
377 (storage->
ptop - od - 1) *
sizeof(
ut32));
389 for (od = 0; od < storage->
ptop; od++) {
395 if (od == storage->
ptop) {
412 if (!storage->
ptop) {
415 }
else if ((storage->
ptop + 1) < (storage->
psize / 4)) {
425 n = st->
ptop - od - 1;
432 }
else if ((st->
ptop + 1) < (st->
psize / 4)) {
480 for (
i = storage->
ptop - 1;
i != 0;
i--) {
496 for (
i = 0;
i < storage->
ptop;
i++) {
522 if (!st->
cmp(
in, incoming, user, &cmp_res)) {
531 od[0] = (
ut32)((low + high) / 2);
533 if (!st->
cmp(
in, incoming, user, &cmp_res)) {
555 if (od[0] != storage->
ptop) {
564 if (!storage || !storage->
cmp || !
id || !od) {
567 if (!storage->
ptop) {
573 if (storage->
ptop > (storage->
psize * 3 / 4)) {
580 ut32 od,
id, ptop, *permutation;
582 if (!storage || !storage->
ptop || !storage->
cmp) {
585 if (storage->
ptop == 1) {
595 ptop = storage->
ptop;
597 while (storage->
ptop != ptop) {
598 id = permutation[storage->
ptop];
610 storage->
ptop = ptop;
const lzma_allocator const uint8_t * in
RZ_API void Ht_() free(HtName_(Ht) *ht)
RZ_API const KEY_TYPE bool * found
RZ_API bool rz_id_storage_get_next(RzIDStorage *storage, ut32 *idref)
RZ_API bool rz_id_storage_set(RzIDStorage *storage, void *data, ut32 id)
RZ_API ROIDStorage * rz_oids_new(ut32 start_id, ut32 last_id)
RZ_API RzIDPool * rz_id_pool_new(ut32 start_id, ut32 last_id)
bool oids_od_bfind(ROIDStorage *st, ut32 *od, void *incoming, void *user)
RZ_API void * rz_oids_otake(ROIDStorage *st, ut32 od)
RZ_API bool rz_oids_get_id(ROIDStorage *storage, ut32 od, ut32 *id)
RZ_API bool rz_id_storage_get_prev(RzIDStorage *storage, ut32 *idref)
static bool id_storage_reallocate(RzIDStorage *storage, ut32 size)
RZ_API bool rz_oids_foreach(ROIDStorage *storage, RzIDStorageForeachCb cb, void *user)
RZ_API void * rz_oids_oget(ROIDStorage *storage, ut32 od)
static bool _list(void *user, void *data, ut32 id)
RZ_API bool rz_id_storage_get_lowest(RzIDStorage *storage, ut32 *id)
RZ_API bool rz_oids_to_rear(ROIDStorage *storage, ut32 id)
RZ_API bool rz_id_pool_grab_id(RzIDPool *pool, ut32 *grabber)
static ut32 get_msb(ut32 v)
RZ_API void * rz_id_storage_take(RzIDStorage *storage, ut32 id)
static bool oid_storage_preallocate(ROIDStorage *st, ut32 size)
RZ_API bool rz_oids_insert(ROIDStorage *storage, void *data, ut32 *id, ut32 *od, void *user)
RZ_API bool rz_oids_to_front(ROIDStorage *storage, const ut32 id)
RZ_API void * rz_oids_take(ROIDStorage *storage, ut32 id)
RZ_API RzIDStorage * rz_id_storage_new(ut32 start_id, ut32 last_id)
RZ_API bool rz_oids_sort(ROIDStorage *storage, void *user)
RZ_API RzList * rz_id_storage_list(RzIDStorage *s)
RZ_API void rz_id_storage_free(RzIDStorage *storage)
RZ_API void * rz_oids_last(ROIDStorage *storage)
RZ_API void rz_oids_free(ROIDStorage *storage)
RZ_API bool rz_oids_get_od(ROIDStorage *storage, ut32 id, ut32 *od)
RZ_API bool rz_oids_foreach_prev(ROIDStorage *storage, RzIDStorageForeachCb cb, void *user)
RZ_API void rz_id_pool_free(RzIDPool *pool)
bool oids_od_binsert(ROIDStorage *storage, ut32 id, ut32 *od, void *incoming, void *user)
RZ_API void * rz_oids_get(ROIDStorage *storage, ut32 id)
RZ_API void * rz_id_storage_get(RzIDStorage *storage, ut32 id)
RZ_API void rz_oids_odelete(ROIDStorage *st, ut32 od)
RZ_API bool rz_id_storage_foreach(RzIDStorage *storage, RzIDStorageForeachCb cb, void *user)
RZ_API void rz_id_storage_delete(RzIDStorage *storage, ut32 id)
RZ_API ut32 rz_oids_find(ROIDStorage *storage, void *incoming, void *user)
RZ_API bool rz_oids_add(ROIDStorage *storage, void *data, ut32 *id, ut32 *od)
RZ_API void rz_oids_delete(ROIDStorage *storage, ut32 id)
RZ_API bool rz_id_storage_add(RzIDStorage *storage, void *data, ut32 *id)
RZ_API void * rz_oids_first(ROIDStorage *storage)
RZ_API bool rz_id_storage_get_highest(RzIDStorage *storage, ut32 *id)
RZ_API bool rz_id_pool_kick_id(RzIDPool *pool, ut32 kick)
return memset(p, 0, total)
static void list(RzEgg *egg)
RZ_API RZ_OWN RzList * rz_list_newf(RzListFree f)
Returns a new initialized RzList pointer and sets the free method.
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
void * realloc(void *ptr, size_t size)
#define rz_return_val_if_fail(expr, val)
bool(* RzIDStorageForeachCb)(void *user, void *data, ut32 id)
#define RZ_FREE_CUSTOM(x, y)
RZ_API void rz_vector_pop_front(RzVector *vec, void *into)
RZ_API void * rz_vector_reserve(RzVector *vec, size_t capacity)
RZ_API void * rz_vector_push(RzVector *vec, void *x)
RZ_API void rz_vector_free(RzVector *vec)
RZ_API RzVector * rz_vector_new(size_t elem_size, RzVectorFree free, void *free_user)
static bool rz_vector_empty(const RzVector *vec)