mirror of
https://github.com/meshtastic/firmware.git
synced 2025-10-28 07:13:25 +00:00
build error fixes
This commit is contained in:
parent
c8f3cbb0f9
commit
71353874a1
@ -14,14 +14,21 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Global message text pool and state
|
// Global message text pool and state
|
||||||
static char g_messagePool[MESSAGE_TEXT_POOL_SIZE];
|
static char *g_messagePool = nullptr;
|
||||||
static size_t g_poolWritePos = 0;
|
static size_t g_poolWritePos = 0;
|
||||||
|
|
||||||
// Reset pool (called on boot or clear)
|
// Reset pool (called on boot or clear)
|
||||||
static inline void resetMessagePool()
|
static inline void resetMessagePool()
|
||||||
{
|
{
|
||||||
|
if (!g_messagePool) {
|
||||||
|
g_messagePool = static_cast<char *>(malloc(MESSAGE_TEXT_POOL_SIZE));
|
||||||
|
if (!g_messagePool) {
|
||||||
|
LOG_ERROR("MessageStore: Failed to allocate %d bytes for message pool", MESSAGE_TEXT_POOL_SIZE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
g_poolWritePos = 0;
|
g_poolWritePos = 0;
|
||||||
memset(g_messagePool, 0, sizeof(g_messagePool));
|
memset(g_messagePool, 0, MESSAGE_TEXT_POOL_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate text in pool and return offset
|
// Allocate text in pool and return offset
|
||||||
@ -46,7 +53,7 @@ static inline uint16_t storeTextInPool(const char *src, size_t len)
|
|||||||
// Retrieve a const pointer to message text by offset
|
// Retrieve a const pointer to message text by offset
|
||||||
static inline const char *getTextFromPool(uint16_t offset)
|
static inline const char *getTextFromPool(uint16_t offset)
|
||||||
{
|
{
|
||||||
if (offset >= MESSAGE_TEXT_POOL_SIZE)
|
if (!g_messagePool || offset >= MESSAGE_TEXT_POOL_SIZE)
|
||||||
return "";
|
return "";
|
||||||
return &g_messagePool[offset];
|
return &g_messagePool[offset];
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user