87 if (in_end_chunk->
to > newto) {
88 newto = in_end_chunk->
to;
101 if (in_end_chunk && in_end_chunk !=
c) {
107 if (in_end_index && in_start_index < in_end_index - 1) {
109 for (
size_t i = in_start_index + 1;
i <= in_end_index - 1;
i++) {
165 bool must_extend =
false;
168 if (newsize <= c->
to) {
177 must_extend = newsize &&
c->to < newsize - 1;
180 must_extend = !!newsize;
230 ut64 next_off = empty_to + 1;
233 if (
c->from <= empty_to) {
234 next_off =
RZ_MIN(
c->to + 1, next_off);
235 empty_to =
c->from - 1;
236 memcpy(
buf + empty_to - priv->
offset + 1,
c->data, next_off - empty_to - 1);
241 if (empty_to >= priv->
offset) {
353 return to_i > from_i;
static st64 sparse_write(SparsePriv *priv, ut64 addr, const ut8 *data, ut64 len)
RZ_API bool rz_buf_sparse_populated_in(RzBuffer *b, ut64 from, ut64 to)
static bool sparse_limits(SparsePriv *priv, ut64 *max)
static ut64 buf_sparse_size(RzBuffer *b)
static bool buf_sparse_init(RzBuffer *b, const void *user)
RZ_API void rz_buf_sparse_set_write_mode(RzBuffer *b, RzBufferSparseWriteMode mode)
Only for sparse RzBuffers.
static st64 buf_sparse_write(RzBuffer *b, const ut8 *buf, ut64 len)
static size_t chunk_index_in(SparsePriv *priv, ut64 addr)
struct buf_sparse_priv SparsePriv
static int chunk_cmp(ut64 addr, void *a)
static bool buf_sparse_fini(RzBuffer *b)
static bool buf_sparse_resize(RzBuffer *b, ut64 newsize)
static st64 buf_sparse_seek(RzBuffer *b, st64 addr, int whence)
RZ_API const RzBufferSparseChunk * rz_buf_sparse_get_chunks(RzBuffer *b, RZ_NONNULL size_t *count)
Only for sparse RzBuffers, get all sparse data chunks currently populated.
static void chunk_fini(void *a, void *user)
struct sparse_init_config_t SparseInitConfig
static const RzBufferMethods buffer_sparse_methods
static st64 buf_sparse_read(RzBuffer *b, ut8 *buf, ut64 len)
static struct buf_sparse_priv * get_priv_sparse(RzBuffer *b)
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
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 * realloc(void *ptr, size_t size)
assert(limit<=UINT32_MAX/2)
#define rz_warn_if_reached()
#define rz_warn_if_fail(expr)
#define rz_return_if_fail(expr)
#define rz_return_val_if_fail(expr, val)
RZ_API st64 rz_buf_write_at(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL const ut8 *buf, ut64 len)
Write len bytes of the buffer at the specified address.
RZ_API RzBuffer * rz_buf_ref(RzBuffer *b)
Increment the reference count of the buffer.
RZ_API st64 rz_buf_read_at(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL RZ_OUT ut8 *buf, ut64 len)
Read len bytes of the buffer at the specified address.
@ RZ_BUF_SPARSE_WRITE_MODE_SPARSE
all writes are performed in the sparse overlay
@ RZ_BUF_SPARSE_WRITE_MODE_THROUGH
all writes are performed in the underlying base buffer
RZ_API void rz_buf_free(RzBuffer *b)
Free all internal data hold by the buffer and the buffer.
RZ_API ut64 rz_buf_size(RZ_NONNULL RzBuffer *b)
Return the size of the buffer.
#define RZ_NUM_CMP(a, b)
Typical comparison (1/0/-1) for two numbers of arbitrary types, including unsigned.
#define rz_vector_lower_bound(vec, x, i, cmp)
static void * rz_vector_index_ptr(RzVector *vec, size_t index)
#define rz_vector_upper_bound(vec, x, i, cmp)
RZ_API void rz_vector_fini(RzVector *vec)
static size_t rz_vector_len(const RzVector *vec)
RZ_API void rz_vector_init(RzVector *vec, size_t elem_size, RzVectorFree free, void *free_user)
static bool rz_vector_empty(const RzVector *vec)
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)
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr from
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr socklen_t static fromlen const void const struct sockaddr to
RzVector chunks
of RzBufferSparseChunk, non-overlapping, ordered by from addr
RzBufferSparseWriteMode write_mode
RzBuffer * base
If not NULL, unpopulated bytes are taken from this, else Oxff.
ut8 * data
size == to - from + 1
ut64 to
inclusive, there can't be chunks with size == 0
RzBufferSparseWriteMode write_mode
ut64(WINAPI *w32_GetEnabledXStateFeatures)()