kernel: allow null data_directory

An empty path may be represented with a nullptr. For example,
std::string_view::data() may return nullptr.

Removes the BITCOINKERNEL_ARG_NONNULL attribute for data_directory,
and instead handles such null arguments in the implementation.

Also documents how BITCOINKERNEL_ARG_NONNULL should be used.
This commit is contained in:
stickies-v
2025-11-12 22:27:45 +00:00
parent a3ac59a431
commit 6657bcbdb4
4 changed files with 39 additions and 8 deletions

View File

@@ -937,8 +937,9 @@ public:
class ChainstateManagerOptions : public UniqueHandle<btck_ChainstateManagerOptions, btck_chainstate_manager_options_destroy>
{
public:
ChainstateManagerOptions(const Context& context, const std::string& data_dir, const std::string& blocks_dir)
: UniqueHandle{btck_chainstate_manager_options_create(context.get(), data_dir.c_str(), data_dir.length(), blocks_dir.c_str(), blocks_dir.length())}
ChainstateManagerOptions(const Context& context, std::string_view data_dir, std::string_view blocks_dir)
: UniqueHandle{btck_chainstate_manager_options_create(
context.get(), data_dir.data(), data_dir.length(), blocks_dir.data(), blocks_dir.length())}
{
}