• Home
  • Raw
  • Download

Lines Matching refs:bb

59 struct backed_block* backed_block_iter_next(struct backed_block* bb) {  in backed_block_iter_next()  argument
60 return bb->next; in backed_block_iter_next()
63 unsigned int backed_block_len(struct backed_block* bb) { in backed_block_len() argument
64 return bb->len; in backed_block_len()
67 unsigned int backed_block_block(struct backed_block* bb) { in backed_block_block() argument
68 return bb->block; in backed_block_block()
71 void* backed_block_data(struct backed_block* bb) { in backed_block_data() argument
72 assert(bb->type == BACKED_BLOCK_DATA); in backed_block_data()
73 return bb->data.data; in backed_block_data()
76 const char* backed_block_filename(struct backed_block* bb) { in backed_block_filename() argument
77 assert(bb->type == BACKED_BLOCK_FILE); in backed_block_filename()
78 return bb->file.filename; in backed_block_filename()
81 int backed_block_fd(struct backed_block* bb) { in backed_block_fd() argument
82 assert(bb->type == BACKED_BLOCK_FD); in backed_block_fd()
83 return bb->fd.fd; in backed_block_fd()
86 int64_t backed_block_file_offset(struct backed_block* bb) { in backed_block_file_offset() argument
87 assert(bb->type == BACKED_BLOCK_FILE || bb->type == BACKED_BLOCK_FD); in backed_block_file_offset()
88 if (bb->type == BACKED_BLOCK_FILE) { in backed_block_file_offset()
89 return bb->file.offset; in backed_block_file_offset()
91 return bb->fd.offset; in backed_block_file_offset()
95 uint32_t backed_block_fill_val(struct backed_block* bb) { in backed_block_fill_val() argument
96 assert(bb->type == BACKED_BLOCK_FILL); in backed_block_fill_val()
97 return bb->fill.val; in backed_block_fill_val()
100 enum backed_block_type backed_block_type(struct backed_block* bb) { in backed_block_type() argument
101 return bb->type; in backed_block_type()
104 void backed_block_destroy(struct backed_block* bb) { in backed_block_destroy() argument
105 if (bb->type == BACKED_BLOCK_FILE) { in backed_block_destroy()
106 free(bb->file.filename); in backed_block_destroy()
109 free(bb); in backed_block_destroy()
121 struct backed_block* bb = bbl->data_blocks; in backed_block_list_destroy() local
122 while (bb) { in backed_block_list_destroy()
123 struct backed_block* next = bb->next; in backed_block_list_destroy()
124 backed_block_destroy(bb); in backed_block_list_destroy()
125 bb = next; in backed_block_list_destroy()
134 struct backed_block* bb; in backed_block_list_move() local
154 for (bb = from->data_blocks; bb; bb = bb->next) { in backed_block_list_move()
155 if (bb->next == start) { in backed_block_list_move()
156 bb->next = end->next; in backed_block_list_move()
166 for (bb = to->data_blocks; bb; bb = bb->next) { in backed_block_list_move()
167 if (!bb->next || bb->next->block > start->block) { in backed_block_list_move()
168 end->next = bb->next; in backed_block_list_move()
169 bb->next = start; in backed_block_list_move()
231 struct backed_block* bb; in queue_bb() local
248 bb = bbl->last_used; in queue_bb()
250 bb = bbl->data_blocks; in queue_bb()
253 for (; bb->next && bb->next->block < new_bb->block; bb = bb->next) in queue_bb()
256 if (bb->next == nullptr) { in queue_bb()
257 bb->next = new_bb; in queue_bb()
259 new_bb->next = bb->next; in queue_bb()
260 bb->next = new_bb; in queue_bb()
264 if (!merge_bb(bbl, bb, new_bb)) { in queue_bb()
266 bbl->last_used = bb; in queue_bb()
275 struct backed_block* bb = reinterpret_cast<backed_block*>(calloc(1, sizeof(struct backed_block))); in backed_block_add_fill() local
276 if (bb == nullptr) { in backed_block_add_fill()
280 bb->block = block; in backed_block_add_fill()
281 bb->len = len; in backed_block_add_fill()
282 bb->type = BACKED_BLOCK_FILL; in backed_block_add_fill()
283 bb->fill.val = fill_val; in backed_block_add_fill()
284 bb->next = nullptr; in backed_block_add_fill()
286 return queue_bb(bbl, bb); in backed_block_add_fill()
292 struct backed_block* bb = reinterpret_cast<backed_block*>(calloc(1, sizeof(struct backed_block))); in backed_block_add_data() local
293 if (bb == nullptr) { in backed_block_add_data()
297 bb->block = block; in backed_block_add_data()
298 bb->len = len; in backed_block_add_data()
299 bb->type = BACKED_BLOCK_DATA; in backed_block_add_data()
300 bb->data.data = data; in backed_block_add_data()
301 bb->next = nullptr; in backed_block_add_data()
303 return queue_bb(bbl, bb); in backed_block_add_data()
309 struct backed_block* bb = reinterpret_cast<backed_block*>(calloc(1, sizeof(struct backed_block))); in backed_block_add_file() local
310 if (bb == nullptr) { in backed_block_add_file()
314 bb->block = block; in backed_block_add_file()
315 bb->len = len; in backed_block_add_file()
316 bb->type = BACKED_BLOCK_FILE; in backed_block_add_file()
317 bb->file.filename = strdup(filename); in backed_block_add_file()
318 bb->file.offset = offset; in backed_block_add_file()
319 bb->next = nullptr; in backed_block_add_file()
321 return queue_bb(bbl, bb); in backed_block_add_file()
327 struct backed_block* bb = reinterpret_cast<backed_block*>(calloc(1, sizeof(struct backed_block))); in backed_block_add_fd() local
328 if (bb == nullptr) { in backed_block_add_fd()
332 bb->block = block; in backed_block_add_fd()
333 bb->len = len; in backed_block_add_fd()
334 bb->type = BACKED_BLOCK_FD; in backed_block_add_fd()
335 bb->fd.fd = fd; in backed_block_add_fd()
336 bb->fd.offset = offset; in backed_block_add_fd()
337 bb->next = nullptr; in backed_block_add_fd()
339 return queue_bb(bbl, bb); in backed_block_add_fd()
342 int backed_block_split(struct backed_block_list* bbl, struct backed_block* bb, in backed_block_split() argument
348 if (bb->len <= max_len) { in backed_block_split()
357 *new_bb = *bb; in backed_block_split()
359 new_bb->len = bb->len - max_len; in backed_block_split()
360 new_bb->block = bb->block + max_len / bbl->block_size; in backed_block_split()
361 new_bb->next = bb->next; in backed_block_split()
362 bb->next = new_bb; in backed_block_split()
363 bb->len = max_len; in backed_block_split()
365 switch (bb->type) { in backed_block_split()
367 new_bb->data.data = (char*)bb->data.data + max_len; in backed_block_split()