Fix sink.ctf.fs: NULL dereference in logging statement
[babeltrace.git] / plugins / ctf / fs-src / data-stream-file.c
1 /*
2 * Copyright 2016-2017 - Philippe Proulx <pproulx@efficios.com>
3 * Copyright 2016 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 * Copyright 2010-2011 - EfficiOS Inc. and Linux Foundation
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24
25 #include <stdlib.h>
26 #include <stdio.h>
27 #include <stdint.h>
28 #include <stdlib.h>
29 #include <stdbool.h>
30 #include <glib.h>
31 #include <inttypes.h>
32 #include <babeltrace/compat/mman-internal.h>
33 #include <babeltrace/endian-internal.h>
34 #include <babeltrace/ctf-ir/stream.h>
35 #include <babeltrace/graph/notification-iterator.h>
36 #include <babeltrace/graph/notification-stream.h>
37 #include <babeltrace/graph/notification-event.h>
38 #include <babeltrace/graph/notification-packet.h>
39 #include <babeltrace/common-internal.h>
40 #include "file.h"
41 #include "metadata.h"
42 #include "../common/notif-iter/notif-iter.h"
43 #include <assert.h>
44 #include "data-stream-file.h"
45 #include <string.h>
46
47 #define BT_LOG_TAG "PLUGIN-CTF-FS-SRC-DS"
48 #include "logging.h"
49
50 static inline
51 size_t remaining_mmap_bytes(struct ctf_fs_ds_file *ds_file)
52 {
53 return ds_file->mmap_valid_len - ds_file->request_offset;
54 }
55
56 static
57 int ds_file_munmap(struct ctf_fs_ds_file *ds_file)
58 {
59 int ret = 0;
60
61 if (!ds_file || !ds_file->mmap_addr) {
62 goto end;
63 }
64
65 if (bt_munmap(ds_file->mmap_addr, ds_file->mmap_len)) {
66 BT_LOGE_ERRNO("Cannot memory-unmap file",
67 ": address=%p, size=%zu, file_path=\"%s\", file=%p",
68 ds_file->mmap_addr, ds_file->mmap_len,
69 ds_file->file->path->str,
70 ds_file->file ? ds_file->file->fp : NULL);
71 ret = -1;
72 goto end;
73 }
74
75 ds_file->mmap_addr = NULL;
76
77 end:
78 return ret;
79 }
80
81 static
82 enum bt_ctf_notif_iter_medium_status ds_file_mmap_next(
83 struct ctf_fs_ds_file *ds_file)
84 {
85 const size_t page_size = bt_common_get_page_size();
86 enum bt_ctf_notif_iter_medium_status ret =
87 BT_CTF_NOTIF_ITER_MEDIUM_STATUS_OK;
88
89 /* Unmap old region */
90 if (ds_file->mmap_addr) {
91 if (ds_file_munmap(ds_file)) {
92 goto error;
93 }
94
95 ds_file->mmap_offset += ds_file->mmap_valid_len;
96 ds_file->request_offset = 0;
97 }
98
99 ds_file->mmap_valid_len = MIN(ds_file->file->size - ds_file->mmap_offset,
100 ds_file->mmap_max_len);
101 if (ds_file->mmap_valid_len == 0) {
102 ret = BT_CTF_NOTIF_ITER_MEDIUM_STATUS_EOF;
103 goto end;
104 }
105 /* Round up to next page, assuming page size being a power of 2. */
106 ds_file->mmap_len = (ds_file->mmap_valid_len + page_size - 1)
107 & ~(page_size - 1);
108 /* Map new region */
109 assert(ds_file->mmap_len);
110 ds_file->mmap_addr = bt_mmap((void *) 0, ds_file->mmap_len,
111 PROT_READ, MAP_PRIVATE, fileno(ds_file->file->fp),
112 ds_file->mmap_offset);
113 if (ds_file->mmap_addr == MAP_FAILED) {
114 BT_LOGE("Cannot memory-map address (size %zu) of file \"%s\" (%p) at offset %jd: %s",
115 ds_file->mmap_len, ds_file->file->path->str,
116 ds_file->file->fp, (intmax_t) ds_file->mmap_offset,
117 strerror(errno));
118 goto error;
119 }
120
121 goto end;
122 error:
123 ds_file_munmap(ds_file);
124 ret = BT_CTF_NOTIF_ITER_MEDIUM_STATUS_ERROR;
125 end:
126 return ret;
127 }
128
129 static
130 enum bt_ctf_notif_iter_medium_status medop_request_bytes(
131 size_t request_sz, uint8_t **buffer_addr,
132 size_t *buffer_sz, void *data)
133 {
134 enum bt_ctf_notif_iter_medium_status status =
135 BT_CTF_NOTIF_ITER_MEDIUM_STATUS_OK;
136 struct ctf_fs_ds_file *ds_file = data;
137
138 if (request_sz == 0) {
139 goto end;
140 }
141
142 /* Check if we have at least one memory-mapped byte left */
143 if (remaining_mmap_bytes(ds_file) == 0) {
144 /* Are we at the end of the file? */
145 if (ds_file->mmap_offset >= ds_file->file->size) {
146 BT_LOGD("Reached end of file \"%s\" (%p)",
147 ds_file->file->path->str, ds_file->file->fp);
148 status = BT_CTF_NOTIF_ITER_MEDIUM_STATUS_EOF;
149 goto end;
150 }
151
152 status = ds_file_mmap_next(ds_file);
153 switch (status) {
154 case BT_CTF_NOTIF_ITER_MEDIUM_STATUS_OK:
155 break;
156 case BT_CTF_NOTIF_ITER_MEDIUM_STATUS_EOF:
157 goto end;
158 default:
159 BT_LOGE("Cannot memory-map next region of file \"%s\" (%p)",
160 ds_file->file->path->str,
161 ds_file->file->fp);
162 goto error;
163 }
164 }
165
166 *buffer_sz = MIN(remaining_mmap_bytes(ds_file), request_sz);
167 *buffer_addr = ((uint8_t *) ds_file->mmap_addr) + ds_file->request_offset;
168 ds_file->request_offset += *buffer_sz;
169 goto end;
170
171 error:
172 status = BT_CTF_NOTIF_ITER_MEDIUM_STATUS_ERROR;
173
174 end:
175 return status;
176 }
177
178 static
179 struct bt_ctf_stream *medop_get_stream(
180 struct bt_ctf_stream_class *stream_class, uint64_t stream_id,
181 void *data)
182 {
183 struct ctf_fs_ds_file *ds_file = data;
184 struct bt_ctf_stream_class *ds_file_stream_class;
185 struct bt_ctf_stream *stream = NULL;
186
187 ds_file_stream_class = bt_ctf_stream_get_class(ds_file->stream);
188 bt_put(ds_file_stream_class);
189
190 if (stream_class != ds_file_stream_class) {
191 /*
192 * Not supported: two packets described by two different
193 * stream classes within the same data stream file.
194 */
195 goto end;
196 }
197
198 stream = ds_file->stream;
199
200 end:
201 return stream;
202 }
203
204 BT_HIDDEN
205 struct bt_ctf_notif_iter_medium_ops ctf_fs_ds_file_medops = {
206 .request_bytes = medop_request_bytes,
207 .get_stream = medop_get_stream,
208 };
209
210 static
211 struct ctf_fs_ds_index *ctf_fs_ds_index_create(size_t length)
212 {
213 struct ctf_fs_ds_index *index = g_new0(struct ctf_fs_ds_index, 1);
214
215 if (!index) {
216 BT_LOGE_STR("Failed to allocate index");
217 goto error;
218 }
219
220 index->entries = g_array_sized_new(FALSE, TRUE,
221 sizeof(struct ctf_fs_ds_index_entry), length);
222 if (!index->entries) {
223 BT_LOGE("Failed to allocate %zu index entries.", length);
224 goto error;
225 }
226 g_array_set_size(index->entries, length);
227 end:
228 return index;
229 error:
230 ctf_fs_ds_index_destroy(index);
231 goto end;
232 }
233
234 static
235 struct bt_ctf_clock_class *get_field_mapped_clock_class(
236 struct bt_ctf_field *field)
237 {
238 struct bt_ctf_field_type *field_type;
239 struct bt_ctf_clock_class *clock_class = NULL;
240
241 field_type = bt_ctf_field_get_type(field);
242 if (!field_type) {
243 goto end;
244 }
245
246 clock_class = bt_ctf_field_type_integer_get_mapped_clock_class(
247 field_type);
248 if (!clock_class) {
249 goto end;
250 }
251 end:
252 bt_put(field_type);
253 return clock_class;
254 }
255
256 static
257 int get_ds_file_packet_bounds_clock_classes(struct ctf_fs_ds_file *ds_file,
258 struct bt_ctf_clock_class **_timestamp_begin_cc,
259 struct bt_ctf_clock_class **_timestamp_end_cc)
260 {
261 int ret;
262 struct bt_ctf_field *timestamp_field = NULL;
263 struct bt_ctf_field *packet_context_field = NULL;
264 struct bt_ctf_clock_class *timestamp_begin_cc = NULL;
265 struct bt_ctf_clock_class *timestamp_end_cc = NULL;
266
267 ret = ctf_fs_ds_file_get_packet_header_context_fields(ds_file,
268 NULL, &packet_context_field);
269 if (ret || !packet_context_field) {
270 BT_LOGD("Cannot retrieve packet context field of stream \'%s\'",
271 ds_file->file->path->str);
272 ret = -1;
273 goto end;
274 }
275
276 timestamp_field = bt_ctf_field_structure_get_field_by_name(
277 packet_context_field, "timestamp_begin");
278 if (!timestamp_field) {
279 BT_LOGD("Cannot retrieve timestamp_begin field in packet context of stream \'%s\'",
280 ds_file->file->path->str);
281 ret = -1;
282 goto end;
283 }
284
285 timestamp_begin_cc = get_field_mapped_clock_class(timestamp_field);
286 if (!timestamp_begin_cc) {
287 BT_LOGD("Cannot retrieve the clock mapped to timestamp_begin of stream \'%s\'",
288 ds_file->file->path->str);
289 }
290 BT_PUT(timestamp_field);
291
292 timestamp_field = bt_ctf_field_structure_get_field_by_name(
293 packet_context_field, "timestamp_end");
294 if (!timestamp_field) {
295 BT_LOGD("Cannot retrieve timestamp_end field in packet context of stream \'%s\'",
296 ds_file->file->path->str);
297 ret = -1;
298 goto end;
299 }
300
301 timestamp_end_cc = get_field_mapped_clock_class(timestamp_field);
302 if (!timestamp_end_cc) {
303 BT_LOGD("Cannot retrieve the clock mapped to timestamp_end in stream \'%s\'",
304 ds_file->file->path->str);
305 }
306
307 if (_timestamp_begin_cc) {
308 *_timestamp_begin_cc = bt_get(timestamp_begin_cc);
309 }
310 if (_timestamp_end_cc) {
311 *_timestamp_end_cc = bt_get(timestamp_end_cc);
312 }
313 end:
314 bt_put(packet_context_field);
315 bt_put(timestamp_field);
316 bt_put(timestamp_begin_cc);
317 bt_put(timestamp_end_cc);
318 return ret;
319 }
320
321 static
322 int convert_cycles_to_ns(struct bt_ctf_clock_class *clock_class,
323 uint64_t cycles, int64_t *ns)
324 {
325 int ret = 0;
326 struct bt_ctf_clock_value *clock_value;
327
328 assert(ns);
329 clock_value = bt_ctf_clock_value_create(clock_class, cycles);
330 if (!clock_value) {
331 ret = -1;
332 goto end;
333 }
334
335 ret = bt_ctf_clock_value_get_value_ns_from_epoch(clock_value, ns);
336 if (ret) {
337 goto end;
338 }
339 end:
340 bt_put(clock_value);
341 return ret;
342 }
343
344 static
345 struct ctf_fs_ds_index *build_index_from_idx_file(
346 struct ctf_fs_ds_file *ds_file)
347 {
348 int ret;
349 gchar *directory = NULL;
350 gchar *basename = NULL;
351 GString *index_basename = NULL;
352 gchar *index_file_path = NULL;
353 GMappedFile *mapped_file = NULL;
354 gsize filesize;
355 const char *mmap_begin = NULL, *file_pos = NULL;
356 const struct ctf_packet_index_file_hdr *header = NULL;
357 struct ctf_fs_ds_index *index = NULL;
358 struct ctf_fs_ds_index_entry *index_entry = NULL;
359 uint64_t total_packets_size = 0;
360 size_t file_index_entry_size;
361 size_t file_entry_count;
362 size_t i;
363 struct bt_ctf_clock_class *timestamp_begin_cc = NULL;
364 struct bt_ctf_clock_class *timestamp_end_cc = NULL;
365
366 BT_LOGD("Building index from .idx file of stream file %s",
367 ds_file->file->path->str);
368
369 ret = get_ds_file_packet_bounds_clock_classes(ds_file,
370 &timestamp_begin_cc, &timestamp_end_cc);
371 if (ret) {
372 BT_LOGD("Cannot get clock classes of \"timestamp_begin\" and \"timestamp_end\" fields");
373 goto error;
374 }
375
376 /* Look for index file in relative path index/name.idx. */
377 basename = g_path_get_basename(ds_file->file->path->str);
378 if (!basename) {
379 BT_LOGE("Cannot get the basename of datastream file %s",
380 ds_file->file->path->str);
381 goto error;
382 }
383
384 directory = g_path_get_dirname(ds_file->file->path->str);
385 if (!directory) {
386 BT_LOGE("Cannot get dirname of datastream file %s",
387 ds_file->file->path->str);
388 goto error;
389 }
390
391 index_basename = g_string_new(basename);
392 if (!index_basename) {
393 BT_LOGE("Cannot allocate index file basename string");
394 goto error;
395 }
396
397 g_string_append(index_basename, ".idx");
398 index_file_path = g_build_filename(directory, "index",
399 index_basename->str, NULL);
400 mapped_file = g_mapped_file_new(index_file_path, FALSE, NULL);
401 if (!mapped_file) {
402 BT_LOGD("Cannot create new mapped file %s",
403 index_file_path);
404 goto error;
405 }
406
407 /*
408 * The g_mapped_file API limits us to 4GB files on 32-bit.
409 * Traces with such large indexes have never been seen in the wild,
410 * but this would need to be adjusted to support them.
411 */
412 filesize = g_mapped_file_get_length(mapped_file);
413 if (filesize < sizeof(*header)) {
414 BT_LOGW("Invalid LTTng trace index file: "
415 "file size (%zu bytes) < header size (%zu bytes)",
416 filesize, sizeof(*header));
417 goto error;
418 }
419
420 mmap_begin = g_mapped_file_get_contents(mapped_file);
421 header = (struct ctf_packet_index_file_hdr *) mmap_begin;
422
423 file_pos = g_mapped_file_get_contents(mapped_file) + sizeof(*header);
424 if (be32toh(header->magic) != CTF_INDEX_MAGIC) {
425 BT_LOGW("Invalid LTTng trace index: \"magic\" field validation failed");
426 goto error;
427 }
428
429 file_index_entry_size = be32toh(header->packet_index_len);
430 file_entry_count = (filesize - sizeof(*header)) / file_index_entry_size;
431 if ((filesize - sizeof(*header)) % file_index_entry_size) {
432 BT_LOGW("Invalid LTTng trace index: the index's size after the header "
433 "(%zu bytes) is not a multiple of the index entry size "
434 "(%zu bytes)", (filesize - sizeof(*header)),
435 sizeof(*header));
436 goto error;
437 }
438
439 index = ctf_fs_ds_index_create(file_entry_count);
440 if (!index) {
441 goto error;
442 }
443
444 index_entry = (struct ctf_fs_ds_index_entry *) &g_array_index(
445 index->entries, struct ctf_fs_ds_index_entry, 0);
446 for (i = 0; i < file_entry_count; i++) {
447 struct ctf_packet_index *file_index =
448 (struct ctf_packet_index *) file_pos;
449 uint64_t packet_size = be64toh(file_index->packet_size);
450
451 if (packet_size % CHAR_BIT) {
452 BT_LOGW("Invalid packet size encountered in LTTng trace index file");
453 goto error;
454 }
455
456 /* Convert size in bits to bytes. */
457 packet_size /= CHAR_BIT;
458 index_entry->packet_size = packet_size;
459
460 index_entry->offset = be64toh(file_index->offset);
461 if (i != 0 && index_entry->offset < (index_entry - 1)->offset) {
462 BT_LOGW("Invalid, non-monotonic, packet offset encountered in LTTng trace index file: "
463 "previous offset=%" PRIu64 ", current offset=%" PRIu64,
464 (index_entry - 1)->offset, index_entry->offset);
465 goto error;
466 }
467
468 index_entry->timestamp_begin = be64toh(file_index->timestamp_begin);
469 index_entry->timestamp_end = be64toh(file_index->timestamp_end);
470 if (index_entry->timestamp_end < index_entry->timestamp_begin) {
471 BT_LOGW("Invalid packet time bounds encountered in LTTng trace index file (begin > end): "
472 "timestamp_begin=%" PRIu64 "timestamp_end=%" PRIu64,
473 index_entry->timestamp_begin,
474 index_entry->timestamp_end);
475 goto error;
476 }
477
478 /* Convert the packet's bound to nanoseconds since Epoch. */
479 ret = convert_cycles_to_ns(timestamp_begin_cc,
480 index_entry->timestamp_begin,
481 &index_entry->timestamp_begin_ns);
482 if (ret) {
483 BT_LOGD("Failed to convert raw timestamp to nanoseconds since Epoch during index parsing");
484 goto error;
485 }
486 ret = convert_cycles_to_ns(timestamp_end_cc,
487 index_entry->timestamp_end,
488 &index_entry->timestamp_end_ns);
489 if (ret) {
490 BT_LOGD("Failed to convert raw timestamp to nanoseconds since Epoch during LTTng trace index parsing");
491 goto error;
492 }
493
494 total_packets_size += packet_size;
495 file_pos += file_index_entry_size;
496 index_entry++;
497 }
498
499 /* Validate that the index addresses the complete stream. */
500 if (ds_file->file->size != total_packets_size) {
501 BT_LOGW("Invalid LTTng trace index file; indexed size != stream file size: "
502 "file_size=%" PRIu64 ", total_packets_size=%" PRIu64,
503 ds_file->file->size, total_packets_size);
504 goto error;
505 }
506 end:
507 g_free(directory);
508 g_free(basename);
509 g_free(index_file_path);
510 if (index_basename) {
511 g_string_free(index_basename, TRUE);
512 }
513 if (mapped_file) {
514 g_mapped_file_unref(mapped_file);
515 }
516 bt_put(timestamp_begin_cc);
517 bt_put(timestamp_end_cc);
518 return index;
519 error:
520 ctf_fs_ds_index_destroy(index);
521 index = NULL;
522 goto end;
523 }
524
525 BT_HIDDEN
526 struct ctf_fs_ds_file *ctf_fs_ds_file_create(
527 struct ctf_fs_trace *ctf_fs_trace,
528 struct bt_ctf_notif_iter *notif_iter,
529 struct bt_ctf_stream *stream, const char *path)
530 {
531 int ret;
532 const size_t page_size = bt_common_get_page_size();
533 struct ctf_fs_ds_file *ds_file = g_new0(struct ctf_fs_ds_file, 1);
534
535 if (!ds_file) {
536 goto error;
537 }
538
539 ds_file->file = ctf_fs_file_create();
540 if (!ds_file->file) {
541 goto error;
542 }
543
544 ds_file->stream = bt_get(stream);
545 ds_file->cc_prio_map = bt_get(ctf_fs_trace->cc_prio_map);
546 g_string_assign(ds_file->file->path, path);
547 ret = ctf_fs_file_open(ds_file->file, "rb");
548 if (ret) {
549 goto error;
550 }
551
552 ds_file->notif_iter = notif_iter;
553 bt_ctf_notif_iter_set_medops_data(ds_file->notif_iter, ds_file);
554 if (!ds_file->notif_iter) {
555 goto error;
556 }
557
558 ds_file->mmap_max_len = page_size * 2048;
559
560 goto end;
561
562 error:
563 /* Do not touch "borrowed" file. */
564 ctf_fs_ds_file_destroy(ds_file);
565 ds_file = NULL;
566
567 end:
568 return ds_file;
569 }
570
571 BT_HIDDEN
572 struct ctf_fs_ds_index *ctf_fs_ds_file_build_index(
573 struct ctf_fs_ds_file *ds_file)
574 {
575 return build_index_from_idx_file(ds_file);
576 }
577
578 BT_HIDDEN
579 void ctf_fs_ds_file_destroy(struct ctf_fs_ds_file *ds_file)
580 {
581 if (!ds_file) {
582 return;
583 }
584
585 bt_put(ds_file->cc_prio_map);
586 bt_put(ds_file->stream);
587 (void) ds_file_munmap(ds_file);
588
589 if (ds_file->file) {
590 ctf_fs_file_destroy(ds_file->file);
591 }
592
593 g_free(ds_file);
594 }
595
596 BT_HIDDEN
597 struct bt_notification_iterator_next_return ctf_fs_ds_file_next(
598 struct ctf_fs_ds_file *ds_file)
599 {
600 enum bt_ctf_notif_iter_status notif_iter_status;
601 struct bt_notification_iterator_next_return ret = {
602 .status = BT_NOTIFICATION_ITERATOR_STATUS_ERROR,
603 .notification = NULL,
604 };
605
606 notif_iter_status = bt_ctf_notif_iter_get_next_notification(
607 ds_file->notif_iter, ds_file->cc_prio_map, &ret.notification);
608
609 switch (notif_iter_status) {
610 case BT_CTF_NOTIF_ITER_STATUS_EOF:
611 ret.status = BT_NOTIFICATION_ITERATOR_STATUS_END;
612 break;
613 case BT_CTF_NOTIF_ITER_STATUS_OK:
614 ret.status = BT_NOTIFICATION_ITERATOR_STATUS_OK;
615 break;
616 case BT_CTF_NOTIF_ITER_STATUS_AGAIN:
617 /*
618 * Should not make it this far as this is
619 * medium-specific; there is nothing for the user to do
620 * and it should have been handled upstream.
621 */
622 abort();
623 case BT_CTF_NOTIF_ITER_STATUS_INVAL:
624 case BT_CTF_NOTIF_ITER_STATUS_ERROR:
625 default:
626 ret.status = BT_NOTIFICATION_ITERATOR_STATUS_ERROR;
627 break;
628 }
629
630 return ret;
631 }
632
633 BT_HIDDEN
634 int ctf_fs_ds_file_get_packet_header_context_fields(
635 struct ctf_fs_ds_file *ds_file,
636 struct bt_ctf_field **packet_header_field,
637 struct bt_ctf_field **packet_context_field)
638 {
639 enum bt_ctf_notif_iter_status notif_iter_status;
640 int ret = 0;
641
642 assert(ds_file);
643 notif_iter_status = bt_ctf_notif_iter_get_packet_header_context_fields(
644 ds_file->notif_iter, packet_header_field, packet_context_field);
645 switch (notif_iter_status) {
646 case BT_CTF_NOTIF_ITER_STATUS_EOF:
647 case BT_CTF_NOTIF_ITER_STATUS_OK:
648 break;
649 case BT_CTF_NOTIF_ITER_STATUS_AGAIN:
650 abort();
651 case BT_CTF_NOTIF_ITER_STATUS_INVAL:
652 case BT_CTF_NOTIF_ITER_STATUS_ERROR:
653 default:
654 goto error;
655 break;
656 }
657
658 goto end;
659
660 error:
661 ret = -1;
662
663 if (packet_header_field) {
664 bt_put(*packet_header_field);
665 }
666
667 if (packet_context_field) {
668 bt_put(*packet_context_field);
669 }
670
671 end:
672 return ret;
673 }
674
675 BT_HIDDEN
676 void ctf_fs_ds_index_destroy(struct ctf_fs_ds_index *index)
677 {
678 if (!index) {
679 return;
680 }
681
682 if (index->entries) {
683 g_array_free(index->entries, TRUE);
684 }
685 g_free(index);
686 }
This page took 0.052699 seconds and 4 git commands to generate.