Skip to content

Commit

Permalink
Add seg_erased
Browse files Browse the repository at this point in the history
  • Loading branch information
anchitj committed Jun 4, 2024
1 parent 7c01770 commit 4071f8b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/rdbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,7 @@ size_t rd_buf_erase(rd_buf_t *rbuf, size_t absof, size_t size) {
segremains);

seg->seg_of -= toerase;
seg->seg_erased += toerase;
rbuf->rbuf_len -= toerase;

of += toerase;
Expand Down Expand Up @@ -712,6 +713,7 @@ int rd_buf_write_seek(rd_buf_t *rbuf, size_t absof) {
rd_segment_t *this = next;
next = TAILQ_PREV(this, rd_segment_head, seg_link);
rd_buf_destroy_segment(rbuf, this);
rbuf->rbuf_erased -= seg->seg_erased;
}

/* Update relative write offset */
Expand Down
2 changes: 2 additions & 0 deletions src/rdbuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ typedef struct rd_segment_s {
* beginning in the grand rd_buf_t */
void (*seg_free)(void *p); /**< Optional free function for seg_p */
int seg_flags; /**< Segment flags */
size_t seg_erased; /** Total number of bytes erased from
* this segment. */
#define RD_SEGMENT_F_RDONLY 0x1 /**< Read-only segment */
#define RD_SEGMENT_F_FREE \
0x2 /**< Free segment on destroy, \
Expand Down

0 comments on commit 4071f8b

Please sign in to comment.