Notifications : Fix copy when the messages is spread across multiple os_mbuf.
This commit is contained in:
parent
cabf1168d4
commit
07b6812f61
5 changed files with 28 additions and 23 deletions
|
|
@ -7,17 +7,10 @@ using namespace Pinetime::Controllers;
|
|||
constexpr uint8_t NotificationManager::MessageSize;
|
||||
|
||||
|
||||
void NotificationManager::Push(Pinetime::Controllers::NotificationManager::Categories category,
|
||||
const char *message, uint8_t currentMessageSize) {
|
||||
// TODO handle edge cases on read/write index
|
||||
auto checkedSize = std::min(currentMessageSize, MessageSize);
|
||||
auto& notif = notifications[writeIndex];
|
||||
std::memcpy(notif.message.data(), message, checkedSize);
|
||||
notif.message[checkedSize] = '\0';
|
||||
notif.category = category;
|
||||
void NotificationManager::Push(NotificationManager::Notification &¬if) {
|
||||
notif.id = GetNextId();
|
||||
notif.valid = true;
|
||||
|
||||
notifications[writeIndex] = std::move(notif);
|
||||
writeIndex = (writeIndex + 1 < TotalNbNotifications) ? writeIndex + 1 : 0;
|
||||
if(!empty)
|
||||
readIndex = (readIndex + 1 < TotalNbNotifications) ? readIndex + 1 : 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue