Skip to content

Commit 71d54e6

Browse files
committed
Remove some magic, and rtimulib wrapper frees in the right order.
1 parent 5e812f2 commit 71d54e6

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/rtimulib_wrapper.cc

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
struct WrapperContext {
66
RTIMUSettings* p_settings;
77
RTIMU* p_imu;
8-
uint32_t magic;
98
};
109

1110
struct Vector3D {
@@ -37,13 +36,11 @@ extern "C" {
3736
void rtimulib_wrapper_destroy(WrapperContext* p_context);
3837
void rtimulib_set_sensors(WrapperContext* p_context, int gyro, int accel, int compass);
3938
int rtimulib_wrapper_imu_read(WrapperContext* p_context);
40-
int rtimulib_wrapper_get_imu_fusion_pose(WrapperContext* p_context, Vector3D* p_output);
39+
int rtimulib_wrapper_get_imu_data(WrapperContext* p_context, AllData* p_output);
4140
}
4241

4342
WrapperContext* rtimulib_wrapper_create(void) {
4443
WrapperContext* p_context = new WrapperContext;
45-
p_context->magic = 0xDEADBEEF;
46-
printf("Magic at create is %08x\n", p_context->magic);
4744
// TODO: Should be ~/.config/sense_hat/RTIMULib
4845
p_context->p_settings = new RTIMUSettings("RTIMULib");
4946
p_context->p_imu = RTIMU::createIMU(p_context->p_settings);
@@ -54,9 +51,9 @@ WrapperContext* rtimulib_wrapper_create(void) {
5451
}
5552

5653
void rtimulib_wrapper_destroy(WrapperContext* p_context) {
57-
printf("Magic at destroy is %08x\n", p_context->magic);
58-
delete p_context->p_settings;
54+
// The settings object must outlive the IMU object
5955
delete p_context->p_imu;
56+
delete p_context->p_settings;
6057
delete p_context;
6158
}
6259

0 commit comments

Comments
 (0)