Skip to content

Commit

Permalink
Fix c++ spawn failure by handling empty string properly
Browse files Browse the repository at this point in the history
  • Loading branch information
jleibs committed Nov 27, 2023
1 parent 5174435 commit 1e0afa4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 7 additions & 3 deletions crates/rerun_c/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}
Expand Down
6 changes: 4 additions & 2 deletions rerun_cpp/src/rerun/spawn_options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down

0 comments on commit 1e0afa4

Please sign in to comment.