mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Add experimental shit code that might fix the strict-aliasing issue
This commit is contained in:
parent
253ccc938e
commit
c631738cd6
23
src/main.cpp
23
src/main.cpp
|
@ -22,6 +22,14 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool isBigEndian()
|
||||||
|
{
|
||||||
|
int test = 1;
|
||||||
|
char *p = (char *)&test;
|
||||||
|
|
||||||
|
return p[0] == 0;
|
||||||
|
}
|
||||||
|
|
||||||
void runNativeMessagingHost();
|
void runNativeMessagingHost();
|
||||||
int runGui(int argc, char *argv[]);
|
int runGui(int argc, char *argv[]);
|
||||||
|
|
||||||
|
@ -68,14 +76,12 @@ int runGui(int argc, char *argv[])
|
||||||
// Initialize NetworkManager
|
// Initialize NetworkManager
|
||||||
chatterino::util::NetworkManager::init();
|
chatterino::util::NetworkManager::init();
|
||||||
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
// Initialize application
|
// Initialize application
|
||||||
chatterino::Application app;
|
chatterino::Application app;
|
||||||
|
|
||||||
// Start the application
|
// Start the application
|
||||||
ret = app.run(a);
|
app.run(a);
|
||||||
|
|
||||||
// Application will go out of scope here and deinitialize itself
|
// Application will go out of scope here and deinitialize itself
|
||||||
}
|
}
|
||||||
|
@ -98,6 +104,8 @@ void runNativeMessagingHost()
|
||||||
|
|
||||||
auto &nmm = chatterino::singletons::NativeMessagingManager::getInstance();
|
auto &nmm = chatterino::singletons::NativeMessagingManager::getInstance();
|
||||||
|
|
||||||
|
bool bigEndian = isBigEndian();
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
char size_c[4];
|
char size_c[4];
|
||||||
std::cin.read(size_c, 4);
|
std::cin.read(size_c, 4);
|
||||||
|
@ -106,7 +114,14 @@ void runNativeMessagingHost()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t size = *reinterpret_cast<uint32_t *>(size_c);
|
uint32_t size = 0;
|
||||||
|
if (bigEndian) {
|
||||||
|
size = size_c[3] | static_cast<uint32_t>(size_c[2]) << 8 |
|
||||||
|
static_cast<uint32_t>(size_c[1]) << 16 | static_cast<uint32_t>(size_c[0]) << 24;
|
||||||
|
} else {
|
||||||
|
size = size_c[0] | static_cast<uint32_t>(size_c[1]) << 8 |
|
||||||
|
static_cast<uint32_t>(size_c[2]) << 16 | static_cast<uint32_t>(size_c[3]) << 24;
|
||||||
|
}
|
||||||
|
|
||||||
char *b = (char *)malloc(size + 1);
|
char *b = (char *)malloc(size + 1);
|
||||||
std::cin.read(b, size);
|
std::cin.read(b, size);
|
||||||
|
|
Loading…
Reference in a new issue