Lines Matching refs:bb

60 struct backed_block *backed_block_iter_next(struct backed_block *bb)
62 return bb->next;
65 unsigned int backed_block_len(struct backed_block *bb)
67 return bb->len;
70 unsigned int backed_block_block(struct backed_block *bb)
72 return bb->block;
75 void *backed_block_data(struct backed_block *bb)
77 assert(bb->type == BACKED_BLOCK_DATA);
78 return bb->data.data;
81 const char *backed_block_filename(struct backed_block *bb)
83 assert(bb->type == BACKED_BLOCK_FILE);
84 return bb->file.filename;
87 int backed_block_fd(struct backed_block *bb)
89 assert(bb->type == BACKED_BLOCK_FD);
90 return bb->fd.fd;
93 int64_t backed_block_file_offset(struct backed_block *bb)
95 assert(bb->type == BACKED_BLOCK_FILE || bb->type == BACKED_BLOCK_FD);
96 if (bb->type == BACKED_BLOCK_FILE) {
97 return bb->file.offset;
98 } else { /* bb->type == BACKED_BLOCK_FD */
99 return bb->fd.offset;
103 uint32_t backed_block_fill_val(struct backed_block *bb)
105 assert(bb->type == BACKED_BLOCK_FILL);
106 return bb->fill.val;
109 enum backed_block_type backed_block_type(struct backed_block *bb)
111 return bb->type;
114 void backed_block_destroy(struct backed_block *bb)
116 if (bb->type == BACKED_BLOCK_FILE) {
117 free(bb->file.filename);
120 free(bb);
133 struct backed_block *bb = bbl->data_blocks;
134 while (bb) {
135 struct backed_block *next = bb->next;
136 backed_block_destroy(bb);
137 bb = next;
148 struct backed_block *bb;
168 for (bb = from->data_blocks; bb; bb = bb->next) {
169 if (bb->next == start) {
170 bb->next = end->next;
180 for (bb = to->data_blocks; bb; bb = bb->next) {
181 if (!bb->next || bb->next->block > start->block) {
182 end->next = bb->next;
183 bb->next = start;
249 struct backed_block *bb;
263 pointer to the last bb that was added, and start searching from
266 bb = bbl->last_used;
268 bb = bbl->data_blocks;
271 for (; bb->next && bb->next->block < new_bb->block; bb = bb->next)
274 if (bb->next == NULL) {
275 bb->next = new_bb;
277 new_bb->next = bb->next;
278 bb->next = new_bb;
282 merge_bb(bbl, bb, new_bb);
291 struct backed_block *bb = calloc(1, sizeof(struct backed_block));
292 if (bb == NULL) {
296 bb->block = block;
297 bb->len = len;
298 bb->type = BACKED_BLOCK_FILL;
299 bb->fill.val = fill_val;
300 bb->next = NULL;
302 return queue_bb(bbl, bb);
309 struct backed_block *bb = calloc(1, sizeof(struct backed_block));
310 if (bb == NULL) {
314 bb->block = block;
315 bb->len = len;
316 bb->type = BACKED_BLOCK_DATA;
317 bb->data.data = data;
318 bb->next = NULL;
320 return queue_bb(bbl, bb);
327 struct backed_block *bb = calloc(1, sizeof(struct backed_block));
328 if (bb == NULL) {
332 bb->block = block;
333 bb->len = len;
334 bb->type = BACKED_BLOCK_FILE;
335 bb->file.filename = strdup(filename);
336 bb->file.offset = offset;
337 bb->next = NULL;
339 return queue_bb(bbl, bb);
346 struct backed_block *bb = calloc(1, sizeof(struct backed_block));
347 if (bb == NULL) {
351 bb->block = block;
352 bb->len = len;
353 bb->type = BACKED_BLOCK_FD;
354 bb->fd.fd = fd;
355 bb->fd.offset = offset;
356 bb->next = NULL;
358 return queue_bb(bbl, bb);
361 int backed_block_split(struct backed_block_list *bbl, struct backed_block *bb,
368 if (bb->len <= max_len) {
373 if (bb == NULL) {
377 *new_bb = *bb;
379 new_bb->len = bb->len - max_len;
380 new_bb->block = bb->block + max_len / bbl->block_size;
381 new_bb->next = bb->next;
382 bb->next = new_bb;
383 bb->len = max_len;
385 switch (bb->type) {
387 new_bb->data.data = (char *)bb->data.data + max_len;