This builds on the work in PR #70, refactoring cubeb_log_internal_buf_fmt() slightly to accommodate for a variable length list of formatting arguments. The format!() call (which heap allocates a new String) cubeb_log!() uses when invoked with a format string can now be handled by passing the format string and argument list to cubeb_log_internal_buf_fmt() to be formatted via std::fmt::write() into the temporary stack buffer already used by the non-formatting log code path.
I changed the signature of cubeb_async_log() and cubeb_async_log_reset_threads() because a void return in C is () in Rust. It looks like c_void is intended for use with unsized pointers (and that odd C-vs-C++ behaviour with (void) vs () parameters that cubeb_async_log_reset_threads() also demonstrated). The new signature also happens to match the type inside the g_cubeb_log_callback when unwrapped, giving a consistent signature for cubeb_log_internal_buf_fmt() to accept.
Also added MaybeUninit in an attempt to reduce the overhead of cubeb_log!() slightly by avoiding memset()ing 1024 bytes of temporary stack space to 0 on every log call.
This builds on the work in PR #70, refactoring
cubeb_log_internal_buf_fmt()
slightly to accommodate for a variable length list of formatting arguments. Theformat!()
call (which heap allocates a newString
)cubeb_log!()
uses when invoked with a format string can now be handled by passing the format string and argument list tocubeb_log_internal_buf_fmt()
to be formatted viastd::fmt::write()
into the temporary stack buffer already used by the non-formatting log code path.I changed the signature of
cubeb_async_log()
andcubeb_async_log_reset_threads()
because avoid
return in C is()
in Rust. It looks likec_void
is intended for use with unsized pointers (and that odd C-vs-C++ behaviour with(void)
vs()
parameters that cubeb_async_log_reset_threads() also demonstrated). The new signature also happens to match the type inside theg_cubeb_log_callback
when unwrapped, giving a consistent signature forcubeb_log_internal_buf_fmt()
to accept.Also added
MaybeUninit
in an attempt to reduce the overhead ofcubeb_log!()
slightly by avoidingmemset()
ing 1024 bytes of temporary stack space to 0 on every log call.