#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
-#include <stdbool.h>
#include <glib.h>
#include <inttypes.h>
#include "compat/mman.h"
static inline
size_t remaining_mmap_bytes(struct ctf_fs_ds_file *ds_file)
{
- BT_ASSERT(ds_file->mmap_len >= ds_file->request_offset);
+ BT_ASSERT_DBG(ds_file->mmap_len >= ds_file->request_offset);
return ds_file->mmap_len - ds_file->request_offset;
}
map_requested_offset:
offset_in_mapping = offset %
- bt_common_get_page_size(ds_file->log_level);
+ bt_mmap_get_offset_align_size(ds_file->log_level);
ds_file->mmap_offset = offset - offset_in_mapping;
ds_file->request_offset = offset_in_mapping;
total_packets_size += packet_size;
file_pos += file_index_entry_size;
- g_ptr_array_add(index->entries, index_entry);
prev_index_entry = index_entry;
+
+ /* Give ownership of `index_entry` to `index->entries`. */
+ g_ptr_array_add(index->entries, index_entry);
+ index_entry = NULL;
}
/* Validate that the index addresses the complete stream. */
goto error;
}
- do {
+ while (true) {
off_t current_packet_size_bytes;
struct ctf_fs_ds_index_entry *index_entry;
struct bt_msg_iter_packet_properties props;
"next-packet-offset=%jd",
(intmax_t) (current_packet_offset_bytes - current_packet_size_bytes),
(intmax_t) current_packet_offset_bytes);
-
- } while (iter_status == BT_MSG_ITER_STATUS_OK);
-
- if (iter_status != BT_MSG_ITER_STATUS_OK) {
- goto error;
}
end:
bt_logging_level log_level)
{
int ret;
- const size_t page_size = bt_common_get_page_size(log_level);
+ const size_t offset_align = bt_mmap_get_offset_align_size(log_level);
struct ctf_fs_ds_file *ds_file = g_new0(struct ctf_fs_ds_file, 1);
if (!ds_file) {
goto error;
}
- ds_file->mmap_max_len = page_size * 2048;
+ ds_file->mmap_max_len = offset_align * 2048;
goto end;