From 6254e18b3f0391f27b6f8b09b2a5a96bdb328890 Mon Sep 17 00:00:00 2001 From: Vibhor Gaur Date: Thu, 8 Jan 2015 18:11:35 +0530 Subject: [PATCH] Fixing memory leak issues in test files Change-Id: I1aeeab6fc7e02c7d75c1f7671f9f77afbd42954f --- test/src/accelerometer.c | 4 ++++ test/src/gravity.c | 2 ++ test/src/gyro.c | 4 ++++ test/src/light.c | 4 ++++ test/src/linear_acceleration.c | 2 ++ test/src/orientation.c | 2 ++ test/src/pressure.c | 4 ++++ test/src/proxi.c | 4 ++++ test/src/temperature.c | 4 ++++ 9 files changed, 30 insertions(+) diff --git a/test/src/accelerometer.c b/test/src/accelerometer.c index fe61f37..cef4971 100644 --- a/test/src/accelerometer.c +++ b/test/src/accelerometer.c @@ -73,6 +73,7 @@ int main(int argc,char **argv) if (result < 0) { printf("Can't start accelerometer SENSOR\n"); printf("Error\n\n\n\n"); + free(event_condition); return -1; } @@ -89,6 +90,7 @@ int main(int argc,char **argv) if (result < 0) { printf("Can't disconnect Accelerometer sensor\n"); printf("Error\n\n\n\n"); + free(event_condition); return -1; } } @@ -112,6 +114,7 @@ int main(int argc,char **argv) printf("Error\n\n\n\n"); sf_unregister_event(handle, event); sf_disconnect(handle); + free(event_condition); return -1; } @@ -125,6 +128,7 @@ int main(int argc,char **argv) if (stop_handle < 0) { printf("Error\n\n"); return -1; + free(event_condition); } sf_disconnect(handle); diff --git a/test/src/gravity.c b/test/src/gravity.c index a055013..d3cba2d 100755 --- a/test/src/gravity.c +++ b/test/src/gravity.c @@ -86,6 +86,7 @@ int main(int argc,char **argv) printf("Error\n\n\n\n"); sf_unregister_event(handle, event); sf_disconnect(handle); + free(event_condition); return -1; } @@ -97,6 +98,7 @@ int main(int argc,char **argv) if (stop_handle < 0) { printf("Error\n\n"); + free(event_condition); return -1; } diff --git a/test/src/gyro.c b/test/src/gyro.c index 915971b..a3332f7 100644 --- a/test/src/gyro.c +++ b/test/src/gyro.c @@ -75,6 +75,7 @@ int main(int argc,char **argv) if (result < 0) { printf("Can't start gyroscope SENSOR\n"); printf("Error\n\n\n\n"); + free(event_condition); return -1; } @@ -91,6 +92,7 @@ int main(int argc,char **argv) if (result < 0) { printf("Can't disconnect gyroscope sensor\n"); printf("Error\n\n\n\n"); + free(event_condition); return -1; } } @@ -114,6 +116,7 @@ int main(int argc,char **argv) printf("Error\n\n\n\n"); sf_unregister_event(handle, event); sf_disconnect(handle); + free(event_condition); return -1; } @@ -126,6 +129,7 @@ int main(int argc,char **argv) if (stop_handle < 0) { printf("Error\n\n"); + free(event_condition); return -1; } diff --git a/test/src/light.c b/test/src/light.c index e2b6e69..ba99732 100644 --- a/test/src/light.c +++ b/test/src/light.c @@ -75,6 +75,7 @@ int main(int argc,char **argv) if (result < 0) { printf("Can't start light SENSOR\n"); printf("Error\n\n\n\n"); + free(event_condition); return -1; } @@ -90,6 +91,7 @@ int main(int argc,char **argv) if (result < 0) { printf("Can't disconnect light sensor\n"); printf("Error\n\n\n\n"); + free(event_condition); return -1; } } @@ -113,6 +115,7 @@ int main(int argc,char **argv) printf("Error\n\n\n\n"); sf_unregister_event(handle, event); sf_disconnect(handle); + free(event_condition); return -1; } @@ -125,6 +128,7 @@ int main(int argc,char **argv) if (stop_handle < 0) { printf("Error\n\n"); + free(event_condition); return -1; } diff --git a/test/src/linear_acceleration.c b/test/src/linear_acceleration.c index e45f4cc..f992a68 100755 --- a/test/src/linear_acceleration.c +++ b/test/src/linear_acceleration.c @@ -86,6 +86,7 @@ int main(int argc,char **argv) printf("Error\n\n\n\n"); sf_unregister_event(handle, event); sf_disconnect(handle); + free(event_condition); return -1; } @@ -98,6 +99,7 @@ int main(int argc,char **argv) if (stop_handle < 0) { printf("Error\n\n"); + free(event_condition); return -1; } diff --git a/test/src/orientation.c b/test/src/orientation.c index 1886ad1..57bc82b 100755 --- a/test/src/orientation.c +++ b/test/src/orientation.c @@ -86,6 +86,7 @@ int main(int argc,char **argv) printf("Error\n\n\n\n"); sf_unregister_event(handle, event); sf_disconnect(handle); + free(event_condition); return -1; } @@ -97,6 +98,7 @@ int main(int argc,char **argv) if (stop_handle < 0) { printf("Error\n\n"); + free(event_condition); return -1; } sf_disconnect(handle); diff --git a/test/src/pressure.c b/test/src/pressure.c index 12f5734..7621160 100644 --- a/test/src/pressure.c +++ b/test/src/pressure.c @@ -75,6 +75,7 @@ int main(int argc,char **argv) if (result < 0) { printf("Can't start pressure SENSOR\n"); printf("Error\n\n\n\n"); + free(event_condition); return -1; } @@ -91,6 +92,7 @@ int main(int argc,char **argv) if (result < 0) { printf("Can't disconnect pressure sensor\n"); printf("Error\n\n\n\n"); + free(event_condition); return -1; } } @@ -114,6 +116,7 @@ int main(int argc,char **argv) printf("Error\n\n\n\n"); sf_unregister_event(handle, event); sf_disconnect(handle); + free(event_condition); return -1; } @@ -126,6 +129,7 @@ int main(int argc,char **argv) if (stop_handle < 0) { printf("Error\n\n"); + free(event_condition); return -1; } diff --git a/test/src/proxi.c b/test/src/proxi.c index 4d3092d..23da057 100644 --- a/test/src/proxi.c +++ b/test/src/proxi.c @@ -90,6 +90,7 @@ int main(int argc,char **argv) if (result < 0) { printf("Can't start proximity SENSOR\n"); printf("Error\n\n\n\n"); + free(event_condition); return -1; } @@ -106,6 +107,7 @@ int main(int argc,char **argv) if (result < 0) { printf("Can't disconnect proximity sensor\n"); printf("Error\n\n\n\n"); + free(event_condition); return -1; } } @@ -144,6 +146,7 @@ int main(int argc,char **argv) printf("Error\n\n\n\n"); sf_unregister_event(handle, event); sf_disconnect(handle); + free(event_condition); return -1; } @@ -156,6 +159,7 @@ int main(int argc,char **argv) if (stop_handle < 0) { printf("Error\n\n"); + free(event_condition); return -1; } diff --git a/test/src/temperature.c b/test/src/temperature.c index 3f852c8..01e6e81 100644 --- a/test/src/temperature.c +++ b/test/src/temperature.c @@ -74,6 +74,7 @@ int main(int argc,char **argv) if (result < 0) { printf("Can't start temperature SENSOR\n"); printf("Error\n\n\n\n"); + free(event_condition); return -1; } @@ -90,6 +91,7 @@ int main(int argc,char **argv) if (result < 0) { printf("Can't disconnect temperature sensor\n"); printf("Error\n\n\n\n"); + free(event_condition); return -1; } } @@ -113,6 +115,7 @@ int main(int argc,char **argv) printf("Error\n\n\n\n"); sf_unregister_event(handle, event); sf_disconnect(handle); + free(event_condition); return -1; } @@ -125,6 +128,7 @@ int main(int argc,char **argv) if (stop_handle < 0) { printf("Error\n\n"); + free(event_condition); return -1; } -- 2.7.4