// SPDX-License-Identifier: BSD-3-Clause OR Apache-2.0 /* * hal_platform.c * * Description: contains the POSIX implementation of the hardware * abstraction layer interface for platform-specific functionality * */ #include "platform/hal_io.h" #include "platform/hal_platform.h" #include #include #include #include static char **restart_args; // Should be compatible with the main() function signature. // cppcheck-suppress constParameter void hal_platform_init(int argc, char *argv[]) { hal_io_init(); restart_args = malloc(sizeof(char *) * argc); if (restart_args) { // Copy all commandline args to the restart argument buffer for (int i = 1; i < argc; i++) restart_args[i - 1] = strdup(argv[i]); // NULL-terminate the array restart_args[argc - 1] = NULL; } else { LOG_ERROR("Error: Cannot allocate memory for restart buffer"); } } void hal_platform_teardown(void) { free(restart_args); }