From 91d08d9950b844e4ac02c0214c7bfe3a54d3bee1 Mon Sep 17 00:00:00 2001 From: Jeremy Leibs Date: Mon, 27 Nov 2023 19:18:21 +0100 Subject: [PATCH] Fix c++ spawn failure by handling empty string properly --- crates/rerun_c/src/lib.rs | 10 +++++++--- rerun_cpp/src/rerun/spawn_options.hpp | 6 ++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/crates/rerun_c/src/lib.rs b/crates/rerun_c/src/lib.rs index 54f6a4dca226..413076a902fb 100644 --- a/crates/rerun_c/src/lib.rs +++ b/crates/rerun_c/src/lib.rs @@ -42,6 +42,10 @@ impl CStringView { pub fn is_null(&self) -> bool { self.string.is_null() } + + pub fn is_empty(&self) -> bool { + self.length == 0 + } } pub type CRecordingStream = u32; @@ -71,15 +75,15 @@ impl CSpawnOptions { spawn_opts.port = self.port; } - if !self.memory_limit.is_null() { + if !self.memory_limit.is_empty() { spawn_opts.memory_limit = self.memory_limit.as_str("memory_limit")?.to_owned(); } - if !self.executable_name.is_null() { + if !self.executable_name.is_empty() { spawn_opts.executable_name = self.executable_name.as_str("executable_name")?.to_owned(); } - if !self.executable_path.is_null() { + if !self.executable_path.is_empty() { spawn_opts.executable_path = Some(self.executable_path.as_str("executable_path")?.to_owned()); } diff --git a/rerun_cpp/src/rerun/spawn_options.hpp b/rerun_cpp/src/rerun/spawn_options.hpp index 5ce95f3b16b5..c861aaca2767 100644 --- a/rerun_cpp/src/rerun/spawn_options.hpp +++ b/rerun_cpp/src/rerun/spawn_options.hpp @@ -23,17 +23,19 @@ namespace rerun { /// When this limit is reached, Rerun will drop the oldest data. /// Example: `16GB` or `50%` (of system total). /// - /// Defaults to `75%` if null. + /// Defaults to `75%` if unset. std::string_view memory_limit = "75%"; /// Specifies the name of the Rerun executable. /// /// You can omit the `.exe` suffix on Windows. + /// + /// Defaults to `rerun` if unset. std::string_view executable_name = "rerun"; /// Enforce a specific executable to use instead of searching though PATH /// for `SpawnOptions::executable_name`. - std::string_view executable_path = ""; + std::string_view executable_path; /// Convert to the corresponding rerun_c struct for internal use. ///