Rizin
unix-like reverse engineering framework and cli tools
rz_idpool.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2017-2018 condret <condr3t@protonmail.com>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #ifndef RZ_ID_STORAGE_H
5 #define RZ_ID_STORAGE_H
6 
7 #include <rz_vector.h>
8 #include <rz_types.h>
9 #include <rz_list.h>
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 typedef struct rz_id_pool_t {
21 
22 RZ_API RzIDPool *rz_id_pool_new(ut32 start_id, ut32 last_id);
23 RZ_API bool rz_id_pool_grab_id(RzIDPool *pool, ut32 *grabber);
24 RZ_API bool rz_id_pool_kick_id(RzIDPool *pool, ut32 kick);
25 RZ_API void rz_id_pool_free(RzIDPool *pool);
26 
27 typedef struct rz_id_storage_t {
29  void **data;
33 
34 typedef bool (*RzIDStorageForeachCb)(void *user, void *data, ut32 id);
35 typedef bool (*ROIDStorageCompareCb)(void *in, void *incoming, void *user, int *cmp_res);
36 
37 RZ_API RzIDStorage *rz_id_storage_new(ut32 start_id, ut32 last_id);
38 RZ_API bool rz_id_storage_set(RzIDStorage *storage, void *data, ut32 id);
39 RZ_API bool rz_id_storage_add(RzIDStorage *storage, void *data, ut32 *id);
40 RZ_API void *rz_id_storage_get(RzIDStorage *storage, ut32 id);
41 RZ_API bool rz_id_storage_get_next(RzIDStorage *storage, ut32 *id);
42 RZ_API bool rz_id_storage_get_prev(RzIDStorage *storage, ut32 *id);
43 RZ_API void rz_id_storage_delete(RzIDStorage *storage, ut32 id);
44 RZ_API void *rz_id_storage_take(RzIDStorage *storage, ut32 id);
50 
51 typedef struct rz_ordered_id_storage_t {
58 
59 RZ_API ROIDStorage *rz_oids_new(ut32 start_id, ut32 last_id);
60 RZ_API void *rz_oids_get(ROIDStorage *storage, ut32 id);
61 RZ_API void *rz_oids_oget(ROIDStorage *storage, ut32 od);
62 RZ_API bool rz_oids_get_id(ROIDStorage *storage, ut32 od, ut32 *id);
63 RZ_API bool rz_oids_get_od(ROIDStorage *storage, ut32 id, ut32 *od);
64 RZ_API bool rz_oids_to_front(ROIDStorage *storage, const ut32 id);
65 RZ_API bool rz_oids_to_rear(ROIDStorage *storage, const ut32 id);
66 RZ_API void rz_oids_delete(ROIDStorage *storage, ut32 id);
68 RZ_API void rz_oids_free(ROIDStorage *storage);
69 RZ_API bool rz_oids_add(ROIDStorage *storage, void *data, ut32 *id, ut32 *od);
70 RZ_API void *rz_oids_take(ROIDStorage *storage, ut32 id);
71 RZ_API void *rz_oids_otake(ROIDStorage *st, ut32 od);
72 RZ_API bool rz_oids_foreach(ROIDStorage *storage, RzIDStorageForeachCb cb, void *user);
74 RZ_API bool rz_oids_insert(ROIDStorage *storage, void *data, ut32 *id, ut32 *od, void *user);
75 RZ_API bool rz_oids_sort(ROIDStorage *storage, void *user);
76 RZ_API ut32 rz_oids_find(ROIDStorage *storage, void *incoming, void *user);
77 RZ_API void *rz_oids_last(ROIDStorage *storage);
78 RZ_API void *rz_oids_first(ROIDStorage *storage);
79 
80 #ifdef __cplusplus
81 }
82 #endif
83 
84 #endif
const lzma_allocator const uint8_t * in
Definition: block.h:527
#define RZ_API
uint32_t ut32
int id
Definition: op.c:540
static RzSocket * s
Definition: rtr.c:28
RZ_API bool rz_id_storage_set(RzIDStorage *storage, void *data, ut32 id)
Definition: idpool.c:131
RZ_API ROIDStorage * rz_oids_new(ut32 start_id, ut32 last_id)
Definition: idpool.c:289
RZ_API RzIDPool * rz_id_pool_new(ut32 start_id, ut32 last_id)
Definition: idpool.c:22
RZ_API bool rz_id_storage_get_prev(RzIDStorage *storage, ut32 *id)
Definition: idpool.c:206
bool(* RzIDStorageForeachCb)(void *user, void *data, ut32 id)
Definition: rz_idpool.h:34
RZ_API void * rz_oids_otake(ROIDStorage *st, ut32 od)
Definition: idpool.c:444
RZ_API bool rz_oids_get_id(ROIDStorage *storage, ut32 od, ut32 *id)
Definition: idpool.c:316
RZ_API bool rz_oids_foreach(ROIDStorage *storage, RzIDStorageForeachCb cb, void *user)
Definition: idpool.c:474
struct rz_id_storage_t RzIDStorage
RZ_API void * rz_oids_oget(ROIDStorage *storage, ut32 od)
Definition: idpool.c:308
RZ_API bool rz_id_storage_get_lowest(RzIDStorage *storage, ut32 *id)
Definition: idpool.c:169
struct rz_id_pool_t RzIDPool
RZ_API bool rz_id_pool_grab_id(RzIDPool *pool, ut32 *grabber)
Definition: idpool.c:34
RZ_API void * rz_id_storage_take(RzIDStorage *storage, ut32 id)
Definition: idpool.c:248
RZ_API bool rz_oids_insert(ROIDStorage *storage, void *data, ut32 *id, ut32 *od, void *user)
Definition: idpool.c:563
RZ_API bool rz_oids_to_front(ROIDStorage *storage, const ut32 id)
Definition: idpool.c:361
RZ_API bool rz_oids_to_rear(ROIDStorage *storage, const ut32 id)
Definition: idpool.c:382
RZ_API void * rz_oids_take(ROIDStorage *storage, ut32 id)
Definition: idpool.c:437
RZ_API RzIDStorage * rz_id_storage_new(ut32 start_id, ut32 last_id)
Definition: idpool.c:80
RZ_API bool rz_oids_sort(ROIDStorage *storage, void *user)
Definition: idpool.c:579
RZ_API RzList * rz_id_storage_list(RzIDStorage *s)
Definition: idpool.c:283
RZ_API void rz_id_storage_free(RzIDStorage *storage)
Definition: idpool.c:270
RZ_API void * rz_oids_last(ROIDStorage *storage)
Definition: idpool.c:459
RZ_API void rz_oids_free(ROIDStorage *storage)
Definition: idpool.c:450
RZ_API bool rz_id_storage_get_next(RzIDStorage *storage, ut32 *id)
Definition: idpool.c:191
RZ_API bool rz_oids_get_od(ROIDStorage *storage, ut32 id, ut32 *od)
Definition: idpool.c:324
RZ_API bool rz_oids_foreach_prev(ROIDStorage *storage, RzIDStorageForeachCb cb, void *user)
Definition: idpool.c:490
RZ_API void rz_id_pool_free(RzIDPool *pool)
Definition: idpool.c:72
RZ_API void * rz_oids_get(ROIDStorage *storage, ut32 id)
Definition: idpool.c:301
RZ_API void * rz_id_storage_get(RzIDStorage *storage, ut32 id)
Definition: idpool.c:162
RZ_API void rz_oids_odelete(ROIDStorage *st, ut32 od)
Definition: idpool.c:420
bool(* ROIDStorageCompareCb)(void *in, void *incoming, void *user, int *cmp_res)
Definition: rz_idpool.h:35
RZ_API bool rz_id_storage_foreach(RzIDStorage *storage, RzIDStorageForeachCb cb, void *user)
Definition: idpool.c:254
RZ_API void rz_id_storage_delete(RzIDStorage *storage, ut32 id)
Definition: idpool.c:221
RZ_API ut32 rz_oids_find(ROIDStorage *storage, void *incoming, void *user)
Definition: idpool.c:614
RZ_API bool rz_oids_add(ROIDStorage *storage, void *data, ut32 *id, ut32 *od)
Definition: idpool.c:336
RZ_API void rz_oids_delete(ROIDStorage *storage, ut32 id)
Definition: idpool.c:406
RZ_API bool rz_id_storage_add(RzIDStorage *storage, void *data, ut32 *id)
Definition: idpool.c:155
RZ_API void * rz_oids_first(ROIDStorage *storage)
Definition: idpool.c:467
RZ_API bool rz_id_storage_get_highest(RzIDStorage *storage, ut32 *id)
Definition: idpool.c:178
RZ_API bool rz_id_pool_kick_id(RzIDPool *pool, ut32 kick)
Definition: idpool.c:53
struct rz_ordered_id_storage_t ROIDStorage
ut32 start_id
Definition: rz_idpool.h:16
ut32 next_id
Definition: rz_idpool.h:18
ut32 last_id
Definition: rz_idpool.h:17
RzVector * freed_ids
Definition: rz_idpool.h:19
void ** data
Definition: rz_idpool.h:29
RzIDPool * pool
Definition: rz_idpool.h:28
ROIDStorageCompareCb cmp
Definition: rz_idpool.h:56
RzIDStorage * data
Definition: rz_idpool.h:55
#define bool
Definition: sysdefs.h:146
static const char * cb[]
Definition: z80_tab.h:176