Remove dynamic memory allocation (malloc/calloc/free)
- Add static memory pool implementation (se050_mem_pool.c/h) - Replace all malloc/calloc with pool allocations - Replace all free with pool deallocations - Remove strdup usage (use fixed-size buffer instead) - Update I2C HAL to use fixed-size dev_path array - All 24 tests pass with static memory only Suitable for embedded environments (u-boot, ESP32) without heap.
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
#define SE050_I2C_HAL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Status codes */
|
||||
typedef enum {
|
||||
@@ -24,10 +26,12 @@ typedef enum {
|
||||
} se050_status_t;
|
||||
|
||||
/* I2C HAL structure */
|
||||
#define SE050_I2C_DEV_PATH_MAX 64
|
||||
|
||||
typedef struct {
|
||||
void *handle; /**< I2C file descriptor */
|
||||
uint8_t slave_addr; /**< I2C slave address */
|
||||
const char *dev_path; /**< I2C device path */
|
||||
char dev_path[SE050_I2C_DEV_PATH_MAX]; /**< I2C device path */
|
||||
int wakeup_pin; /**< Wakeup GPIO pin (-1 if unused) */
|
||||
} se050_i2c_hal_t;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user