4
4
use crate :: profiles:: collections:: ParallelSet ;
5
5
use crate :: profiles:: datatypes:: { OptionalFunctionId , OptionalMappingId } ;
6
6
use std:: ffi:: c_void;
7
+ use std:: ptr:: null_mut;
7
8
8
9
/// A representation of a location that is an intersection of the Otel and
9
10
/// Pprof representations. Omits some fields to save space because Datadog
10
11
/// doesn't use them in any way. Additionally, Datadog only ever sets one Line,
11
12
/// so it's not a Vec.
12
13
#[ repr( C ) ]
13
- #[ derive( Copy , Clone , Debug , Default , Eq , PartialEq , Hash ) ]
14
+ #[ derive( Copy , Clone , Debug , Eq , PartialEq , Hash ) ]
14
15
pub struct Location {
15
16
pub address : u64 ,
16
17
pub mapping_id : OptionalMappingId ,
17
18
pub line : Line ,
18
19
}
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
+ }
19
29
20
30
// Avoid NonNull<()> in FFI; see PR:
21
31
// https://github.com/mozilla/cbindgen/pull/1098
@@ -24,10 +34,19 @@ pub type LocationId = std::ptr::NonNull<c_void>;
24
34
/// A representation of a line plus function. It omits the column because it's
25
35
/// not used by Datadog.
26
36
#[ repr( C ) ]
27
- #[ derive( Copy , Clone , Debug , Default , Eq , PartialEq , Hash ) ]
37
+ #[ derive( Copy , Clone , Debug , Eq , PartialEq , Hash ) ]
28
38
pub struct Line {
29
39
pub line_number : i64 ,
30
40
pub function_id : OptionalFunctionId ,
31
41
}
32
42
43
+ impl Default for Line {
44
+ fn default ( ) -> Line {
45
+ Line {
46
+ line_number : 0 ,
47
+ function_id : null_mut ( ) ,
48
+ }
49
+ }
50
+ }
51
+
33
52
pub type LocationSet = ParallelSet < Location , 4 > ;
0 commit comments