Skip to content

Commit 557263c

Browse files
committed
fix
1 parent f31cfbf commit 557263c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+154
-147
lines changed

include/fast_io_core_impl/bitops/rtz.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,4 @@ inline constexpr ::fast_io::bitops::rtz_result<T> rtz(T n) noexcept
202202
return ::fast_io::bitops::details::rtz_impl<false>(n);
203203
}
204204

205-
} // namespace fast_io::bitops
205+
} // namespace fast_io::bitops

include/fast_io_core_impl/codecvt/general.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ template <encoding_scheme src_encoding = encoding_scheme::execution_charset,
518518
inline constexpr dest_char_type *general_code_cvt_full(src_char_type const *src_first, src_char_type const *src_last,
519519
dest_char_type *__restrict dst) noexcept
520520
{
521+
// No need to consider dst_last
521522
if constexpr (src_encoding == encoding_scheme::execution_charset)
522523
{
523524
constexpr auto src_scheme = get_execution_charset_encoding_scheme<src_char_type>(src_encoding);

include/fast_io_core_impl/dynamic_output_buffer.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class basic_generic_dynamic_output_buffer
1919

2020
inline constexpr ~basic_generic_dynamic_output_buffer()
2121
{
22-
if (begin_ptr && begin_ptr != buffer)
22+
if (begin_ptr != buffer)
2323
{
2424
using typed_allocator = typed_generic_allocator_adapter<allocator_type, char_type>;
2525
if constexpr (typed_allocator::has_deallocate)
@@ -30,7 +30,6 @@ class basic_generic_dynamic_output_buffer
3030
{
3131
typed_allocator::deallocate_n(begin_ptr, buffer_size);
3232
}
33-
begin_ptr = nullptr;
3433
}
3534
}
3635
};

include/fast_io_crypto/platforms/nt_bcrypt.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,11 @@ class nt_bcrypt_hash_file
3939
{
4040
::fast_io::details::deallocate_with_secure_clear<false>(digest_buffer, bcrypt_size);
4141
}
42-
digest_buffer = nullptr;
43-
if (this->hashHandle)
42+
if (this->hashHandle) [[likely]]
4443
{
4544
::fast_io::win32::BCryptDestroyHash(this->hashHandle);
4645
}
47-
if (this->phAlgorithm)
46+
if (this->phAlgorithm) [[likely]]
4847
{
4948
::fast_io::win32::BCryptCloseAlgorithmProvider(this->phAlgorithm, 0u);
5049
}
@@ -82,7 +81,7 @@ struct bcrypt_algo_guard
8281
inline bcrypt_algo_guard &operator=(bcrypt_algo_guard const &) = delete;
8382
inline ~bcrypt_algo_guard()
8483
{
85-
if (this->phalgo)
84+
if (this->phalgo) [[likely]]
8685
{
8786
::fast_io::win32::BCryptCloseAlgorithmProvider(this->phalgo, 0u);
8887
}

include/fast_io_driver/mangling.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ struct cxa_demangle
8989
~cxa_demangle()
9090
{
9191
free(buffer);
92+
buffer = nullptr;
93+
length = static_cast<::std::size_t>(0u);
9294
}
9395
};
9496

include/fast_io_freestanding_impl/io_buffer/io_buffer.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@ class basic_io_buffer
123123
inline constexpr ~basic_io_buffer()
124124
{
125125
::fast_io::details::destroy_basic_io_buffer(*this);
126-
input_buffer = {};
127-
output_buffer = {};
128126
}
129127
};
130128

include/fast_io_freestanding_impl/scanners/line_scanner.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ struct basic_line_scanner_buffer
3939
{
4040
::fast_io::details::deallocate_iobuf_space<false, char_type>(
4141
this->begin_ptr, static_cast<::std::size_t>(this->end_ptr - this->begin_ptr));
42-
43-
this->begin_ptr = nullptr;
44-
this->curr_ptr = nullptr;
45-
this->end_ptr = nullptr;
4642
}
4743
};
4844
buffer_type buffer;

include/fast_io_hosted/async_coro.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ class async_io_coroutine
6565
});
6666
if constexpr (write)
6767
{
68-
async_read_callback(scheduler, stream, first, last, overlapped, offset);
68+
async_write_callback(scheduler, stream, first, last, overlapped, offset);
6969
}
7070
else
7171
{
72-
async_write_callback(scheduler, stream, first, last, overlapped, offset);
72+
async_read_callback(scheduler, stream, first, last, overlapped, offset);
7373
}
7474
}
7575
};
@@ -108,11 +108,11 @@ class async_scatter_io_coroutine
108108
});
109109
if constexpr (write)
110110
{
111-
async_scatter_read_callback(scheduler, stream, scatters, overlapped, offset);
111+
async_scatter_write_callback(scheduler, stream, scatters, overlapped, offset);
112112
}
113113
else
114114
{
115-
async_scatter_write_callback(scheduler, stream, scatters, overlapped, offset);
115+
async_scatter_read_callback(scheduler, stream, scatters, overlapped, offset);
116116
}
117117
}
118118
};

include/fast_io_hosted/auto_indent.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ namespace fast_io
44
{
55

66
template <::std::ranges::contiguous_range rg,
7-
typename containe = ::fast_io::containers::vector<::std::size_t, ::fast_io::native_thread_local_allocator>>
7+
typename container = ::fast_io::containers::vector<::std::size_t, ::fast_io::native_thread_local_allocator>>
88
requires ::std::integral<::std::ranges::range_value_t<rg>>
99
inline constexpr auto auto_indent(rg &&r)
1010
{
1111
if constexpr (::std::is_array_v<::std::remove_cvref_t<rg>>)
1212
{
13-
return ::fast_io::details::calculate_auto_width_result<containe>(
13+
return ::fast_io::details::calculate_auto_width_result<container>(
1414
::std::ranges::data(r), ::std::ranges::data(r) + (::std::ranges::size(r) - 1));
1515
}
1616
else
1717
{
18-
return ::fast_io::details::calculate_auto_width_result<containe>(
18+
return ::fast_io::details::calculate_auto_width_result<container>(
1919
::std::ranges::data(r), ::std::ranges::data(r) + ::std::ranges::size(r));
2020
}
2121
}

include/fast_io_hosted/dbg/nt_dbg.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ inline constexpr ::std::size_t calculate_nt_dbg_fmt_string_size() noexcept
3434
{
3535
if constexpr (iswide)
3636
{
37-
static_assert((SIZE_MAX - 1 / 3) > n);
37+
static_assert(((SIZE_MAX - 1) / 3) > n);
3838
return 3 * n + 1; //%wZ
3939
}
4040
else
4141
{
42-
static_assert((SIZE_MAX - 1 / 2) > n);
42+
static_assert(((SIZE_MAX - 1) / 2) > n);
4343
return 2 * n + 1; //%Z
4444
}
4545
}
@@ -94,9 +94,13 @@ inline void nt_fmt_dbg_forward([[maybe_unused]] nt_dbg_carrier carr, char8_t con
9494
--arg;
9595
void const *arg_n_ptr{arg->base};
9696
::std::size_t arg_n_len{arg->len};
97+
/// @todo In the Windows NT debugging implementation, string lengths are silently truncated and UINT_LEAST16_MAX does not issue any error indications or warnings to the caller, which may result in incomplete debugging output.
9798
if (UINT_LEAST16_MAX < arg_n_len)
9899
{
100+
::fast_io::fast_terminate();
101+
#if 0
99102
arg_n_len = UINT_LEAST16_MAX;
103+
#endif
100104
}
101105
::std::uint_least16_t const u16argnlen{static_cast<::std::uint_least16_t>(arg_n_len)};
102106
::fast_io::win32::nt::ansi_string astr{u16argnlen, u16argnlen,
@@ -112,9 +116,13 @@ template <bool iswide>
112116
inline void nt_dbg_write_impl([[maybe_unused]] nt_dbg_carrier carr, char const *first, char const *last) noexcept
113117
{
114118
::std::size_t arg_n_len{static_cast<::std::size_t>(last - first)};
119+
/// @todo In the Windows NT debugging implementation, string lengths are silently truncated and UINT_LEAST16_MAX does not issue any error indications or warnings to the caller, which may result in incomplete debugging output.
115120
if (UINT_LEAST16_MAX < arg_n_len)
116121
{
122+
::fast_io::fast_terminate();
123+
#if 0
117124
arg_n_len = UINT_LEAST16_MAX;
125+
#endif
118126
}
119127
::std::uint_least16_t const u16argnlen{static_cast<::std::uint_least16_t>(arg_n_len)};
120128
::fast_io::win32::nt::ansi_string astr{u16argnlen, u16argnlen, const_cast<char *>(first)};

0 commit comments

Comments
 (0)