Skip to content

Commit 7460b9a

Browse files
committed
fix: Default for Line/Location
1 parent 08fb149 commit 7460b9a

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

datadog-profiling/src/profiles/datatypes/location.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,28 @@
44
use crate::profiles::collections::ParallelSet;
55
use crate::profiles::datatypes::{OptionalFunctionId, OptionalMappingId};
66
use std::ffi::c_void;
7+
use std::ptr::null_mut;
78

89
/// A representation of a location that is an intersection of the Otel and
910
/// Pprof representations. Omits some fields to save space because Datadog
1011
/// doesn't use them in any way. Additionally, Datadog only ever sets one Line,
1112
/// so it's not a Vec.
1213
#[repr(C)]
13-
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, Hash)]
14+
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
1415
pub struct Location {
1516
pub address: u64,
1617
pub mapping_id: OptionalMappingId,
1718
pub line: Line,
1819
}
20+
impl Default for Location {
21+
fn default() -> Location {
22+
Location {
23+
address: 0,
24+
mapping_id: null_mut(),
25+
line: Line::default(),
26+
}
27+
}
28+
}
1929

2030
// Avoid NonNull<()> in FFI; see PR:
2131
// https://github.com/mozilla/cbindgen/pull/1098
@@ -24,10 +34,19 @@ pub type LocationId = std::ptr::NonNull<c_void>;
2434
/// A representation of a line plus function. It omits the column because it's
2535
/// not used by Datadog.
2636
#[repr(C)]
27-
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, Hash)]
37+
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
2838
pub struct Line {
2939
pub line_number: i64,
3040
pub function_id: OptionalFunctionId,
3141
}
3242

43+
impl Default for Line {
44+
fn default() -> Line {
45+
Line {
46+
line_number: 0,
47+
function_id: null_mut(),
48+
}
49+
}
50+
}
51+
3352
pub type LocationSet = ParallelSet<Location, 4>;

0 commit comments

Comments
 (0)