MCPcopy Create free account
hub / github.com/1a1a11a/libCacheSim / close_reader

Function close_reader

libCacheSim/traceReader/reader.c:549–600  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

547}
548
549int close_reader(reader_t *const reader) {
550 /* close the file in the reader or unmmap the memory in the file
551 then free the memory of reader object
552 Return value: Upon successful completion 0 is returned.
553 Otherwise, EOF is returned and the global variable errno is set to
554 indicate the error. In either case no further
555 access to the stream is possible.*/
556
557 if (reader->trace_type == PLAIN_TXT_TRACE) {
558 fclose(reader->file);
559 free(reader->line_buf);
560 } else if (reader->trace_type == CSV_TRACE) {
561 csv_params_t *csv_params = reader->reader_params;
562 fclose(reader->file);
563 free(reader->line_buf);
564 csv_free(csv_params->csv_parser);
565 free(csv_params->csv_parser);
566 } else if (reader->trace_type == BIN_TRACE) {
567 binary_params_t *params = reader->reader_params;
568 if (params != NULL && params->fmt_str != NULL) {
569 free(params->fmt_str);
570 }
571 if (reader->init_params.binary_fmt_str != NULL) {
572 free(reader->init_params.binary_fmt_str);
573 }
574 }
575
576#ifdef SUPPORT_ZSTD_TRACE
577 if (reader->is_zstd_file) {
578 free_zstd_reader(reader->zstd_reader_p);
579 }
580#endif
581
582 if (!reader->cloned) {
583 if (reader->mapped_file != NULL) {
584 munmap(reader->mapped_file, reader->file_size);
585 }
586 }
587
588 if (reader->reader_params != NULL) {
589 free(reader->reader_params);
590 }
591
592 if (reader->sampler != NULL) {
593 free(reader->sampler);
594 }
595
596 free(reader->trace_path);
597 free(reader);
598
599 return 0;
600}
601
602/**
603 * jump to given position in the trace, such as 0.2, 0.5, 1.0, etc.

Callers 15

mainFunction · 0.85
test_teardownFunction · 0.85
test_reader_more2Function · 0.85
_simulateFunction · 0.85
get_num_of_reqFunction · 0.85
lcs_print_trace_statFunction · 0.85
close_traceFunction · 0.85
free_argFunction · 0.85
free_argFunction · 0.85

Calls 2

csv_freeFunction · 0.85
free_zstd_readerFunction · 0.85