mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-29 06:33:33 +08:00
GPIO led: Do not allocate memory statically, but only when module loads
This commit is contained in:
@@ -66,7 +66,7 @@ struct gpio_led_s {
|
|||||||
int counter;
|
int counter;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct gpio_led_s gpio_led_data;
|
static struct gpio_led_s *gpio_led_data;
|
||||||
static bool gpio_led_started = false;
|
static bool gpio_led_started = false;
|
||||||
|
|
||||||
__EXPORT int gpio_led_main(int argc, char *argv[]);
|
__EXPORT int gpio_led_main(int argc, char *argv[]);
|
||||||
@@ -170,10 +170,11 @@ int gpio_led_main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&gpio_led_data, 0, sizeof(gpio_led_data));
|
gpio_led_data = malloc(sizeof(struct gpio_led_s));
|
||||||
gpio_led_data.use_io = use_io;
|
memset(gpio_led_data, 0, sizeof(struct gpio_led_s));
|
||||||
gpio_led_data.pin = pin;
|
gpio_led_data->use_io = use_io;
|
||||||
int ret = work_queue(LPWORK, &gpio_led_data.work, gpio_led_start, &gpio_led_data, 0);
|
gpio_led_data->pin = pin;
|
||||||
|
int ret = work_queue(LPWORK, &(gpio_led_data->work), gpio_led_start, gpio_led_data, 0);
|
||||||
|
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
errx(1, "failed to queue work: %d", ret);
|
errx(1, "failed to queue work: %d", ret);
|
||||||
|
|||||||
Reference in New Issue
Block a user