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:
km
2026-03-29 19:07:57 +09:00
parent 479fcd37c1
commit 11bcc5e0c3
11 changed files with 447 additions and 79 deletions
+3 -6
View File
@@ -136,7 +136,8 @@ se050_status_t se050_i2c_init(se050_i2c_hal_t *hal, const char *dev_path, uint8_
hal->handle = handle;
hal->slave_addr = slave_addr;
hal->dev_path = strdup(dev_path);
strncpy(hal->dev_path, dev_path, SE050_I2C_DEV_PATH_MAX - 1);
hal->dev_path[SE050_I2C_DEV_PATH_MAX - 1] = '\0';
return SE050_OK;
}
@@ -152,11 +153,7 @@ void se050_i2c_close(se050_i2c_hal_t *hal)
hal->handle = NULL;
}
if (hal->dev_path) {
free((void *)hal->dev_path);
hal->dev_path = NULL;
}
hal->dev_path[0] = '\0';
hal->slave_addr = 0;
}