From 4cb464db834a83f9805e39da4ff1af2b66f6bb1c Mon Sep 17 00:00:00 2001
From: Andrew Tridgell <andrew@tridgell.net>
Date: Tue, 6 Jan 2015 15:15:20 +1100
Subject: [PATCH] Plane: reduce the frame size of setup_failsafe_mixing()

---
 ArduPlane/px4_mixer.pde | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/ArduPlane/px4_mixer.pde b/ArduPlane/px4_mixer.pde
index d5c5f3a27..486335184 100644
--- a/ArduPlane/px4_mixer.pde
+++ b/ArduPlane/px4_mixer.pde
@@ -193,6 +193,8 @@ static bool setup_failsafe_mixing(void)
     const char *mixer_filename = "/fs/microsd/APM/MIXER.MIX";
     const char *custom_mixer_filename = "/fs/microsd/APM/CUSTOM.MIX";
     bool ret = false;
+    char *buf = NULL;
+    const uint16_t buf_size = 2048;
 
     if (!create_mixer_file(mixer_filename)) {
         return false;
@@ -215,8 +217,11 @@ static bool setup_failsafe_mixing(void)
         return false;
     }
 
-    char buf[2048];
-    if (load_mixer_file(filename, &buf[0], sizeof(buf)) != 0) {
+    buf = (char *)malloc(buf_size);
+    if (buf == NULL) {
+        goto failed;
+    }
+    if (load_mixer_file(filename, &buf[0], buf_size) != 0) {
         hal.console->printf("Unable to load %s\n", filename);
         goto failed;
     }
@@ -303,6 +308,9 @@ static bool setup_failsafe_mixing(void)
     ret = true;
 
 failed:
+    if (buf != NULL) {
+        free(buf);
+    }
     if (px4io_fd != -1) {
         close(px4io_fd);
     }
-- 
GitLab