Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions sdk/Windows/SMXGif.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,11 @@ class DataStream
void ReadBytes(string &s, int count)
{
s.clear();
while(count--)
s.reserve(count); // Reserve memory to avoid multiple allocations
for (int i = 0; i < count; ++i)
{
s.push_back(ReadByte());
}
}

void skip(int bytes)
Expand Down Expand Up @@ -142,9 +145,9 @@ class LWZStream
while(1)
{
uint8_t blocksize = stream.ReadByte();
stream.skip(blocksize);
if(bytes_remaining == 0)
if (blocksize == 0)
break;
stream.skip(blocksize);
}
}

Expand Down Expand Up @@ -211,6 +214,8 @@ string LWZDecoder::DecodeImage()
next_free_slot = clear + 2;
prev_code1 = -1;
prev_code2 = -1;
dictionary.clear();
dictionary.resize(1 << GIFBITS);
continue;
}

Expand Down
10 changes: 6 additions & 4 deletions sdk/Windows/SMXPanelAnimationUpload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "Helpers.h"
#include <string>
#include <vector>
#include <array>
using namespace std;
using namespace SMX;

Expand All @@ -23,12 +24,12 @@ using namespace SMX;
namespace
{
// Panel names for error messages.
static const char *panel_names[] = {
static const std::array<const char*, 9> panel_names = {
"up-left", "up", "up-right",
"left", "center", "right",
"down-left", "down", "down-right",
};
}
} // namespace

// These structs are the protocol we use to send offline graphics to the pad.
// This isn't related to realtime lighting.
Expand Down Expand Up @@ -89,8 +90,9 @@ namespace PanelLightGraphic

uint16_t offset = 0;
uint8_t size = 0;
uint8_t data[240];
std::array<uint8_t, 240> data = { 0 }; // Initialize the array with zeros
};

#pragma pack(pop)

#pragma pack(push, 1)
Expand Down Expand Up @@ -316,7 +318,7 @@ namespace ProtocolHelpers

int bytes_left = size - offset;
packet.size = min(sizeof(PanelLightGraphic::upload_packet::data), bytes_left);
memcpy(packet.data, buf, packet.size);
memcpy(packet.data.data(), buf, packet.size); // Use data() to get the pointer
packets.push_back(packet);

offset += packet.size;
Expand Down