Rizin
unix-like reverse engineering framework and cli tools
rz_skyline.h
Go to the documentation of this file.
1 #ifndef RZ_SKYLINE_H
2 #define RZ_SKYLINE_H
3 
4 #include "rz_vector.h"
5 #include "rz_util/rz_itv.h"
6 
7 typedef struct rz_skyline_item_t {
9  void *user;
11 
12 typedef struct rz_skyline_t {
15 
16 RZ_API bool rz_skyline_add(RzSkyline *skyline, RzInterval itv, void *user);
18 
19 static inline void rz_skyline_init(RzSkyline *skyline) {
20  rz_return_if_fail(skyline);
21  rz_vector_init(&skyline->v, sizeof(RzSkylineItem), NULL, NULL);
22 }
23 
24 static inline void rz_skyline_fini(RzSkyline *skyline) {
25  rz_return_if_fail(skyline);
26  rz_vector_fini(&skyline->v);
27 }
28 
29 static inline void rz_skyline_clear(RzSkyline *skyline) {
30  rz_return_if_fail(skyline);
31  rz_vector_clear(&skyline->v);
32 }
33 
34 static inline const RzSkylineItem *rz_skyline_get_item(RzSkyline *skyline, ut64 addr) {
35  rz_return_val_if_fail(skyline, NULL);
36  return rz_skyline_get_item_intersect(skyline, addr, 1);
37 }
38 
39 static inline void *rz_skyline_get(RzSkyline *skyline, ut64 addr) {
40  rz_return_val_if_fail(skyline, NULL);
41  const RzSkylineItem *item = rz_skyline_get_item(skyline, addr);
42  return item ? item->user : NULL;
43 }
44 
45 static inline void *rz_skyline_get_intersect(RzSkyline *skyline, ut64 addr, ut64 len) {
46  rz_return_val_if_fail(skyline, NULL);
47  const RzSkylineItem *item = rz_skyline_get_item_intersect(skyline, addr, len);
48  return item ? item->user : NULL;
49 }
50 
51 static inline bool rz_skyline_contains(RzSkyline *skyline, ut64 addr) {
52  rz_return_val_if_fail(skyline, false);
53  return (bool)rz_skyline_get_item(skyline, addr);
54 }
55 
56 #endif
size_t len
Definition: 6502dis.c:15
#define RZ_API
#define NULL
Definition: cris-opc.c:27
#define rz_return_if_fail(expr)
Definition: rz_assert.h:100
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
static void * rz_skyline_get_intersect(RzSkyline *skyline, ut64 addr, ut64 len)
Definition: rz_skyline.h:45
static void * rz_skyline_get(RzSkyline *skyline, ut64 addr)
Definition: rz_skyline.h:39
static bool rz_skyline_contains(RzSkyline *skyline, ut64 addr)
Definition: rz_skyline.h:51
RZ_API const RzSkylineItem * rz_skyline_get_item_intersect(RzSkyline *skyline, ut64 addr, ut64 len)
Definition: skyline.c:60
static void rz_skyline_init(RzSkyline *skyline)
Definition: rz_skyline.h:19
static const RzSkylineItem * rz_skyline_get_item(RzSkyline *skyline, ut64 addr)
Definition: rz_skyline.h:34
static void rz_skyline_fini(RzSkyline *skyline)
Definition: rz_skyline.h:24
static void rz_skyline_clear(RzSkyline *skyline)
Definition: rz_skyline.h:29
struct rz_skyline_t RzSkyline
RZ_API bool rz_skyline_add(RzSkyline *skyline, RzInterval itv, void *user)
Definition: skyline.c:12
struct rz_skyline_item_t RzSkylineItem
RZ_API void rz_vector_fini(RzVector *vec)
Definition: vector.c:61
RZ_API void rz_vector_clear(RzVector *vec)
Definition: vector.c:68
RZ_API void rz_vector_init(RzVector *vec, size_t elem_size, RzVectorFree free, void *free_user)
Definition: vector.c:33
RzInterval itv
Definition: rz_skyline.h:8
RzVector v
Definition: rz_skyline.h:13
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static int addr
Definition: z80asm.c:58