WIP: Fixes for linux builds.

This commit is contained in:
Chad Attermann committed 2025-08-24 21:33:51 -06:00
1 parent ec31f11eaa
commit e9cd61f375
4 files changed
+27 -5

No files matched your search

+1 -1
View File
@@ -569,7 +569,7 @@ void testIndex() {
assert(bytes[1] == 'e');
assert(bytes[2] == 'l');
assert(bytes[3] == 'l');
assert(bytes[4] == '0');
assert(bytes[4] == 'o');
}
void testBytes() {
+1 -3
View File
@@ -9,9 +9,7 @@
; https://docs.platformio.org/page/projectconf.html
[platformio]
;default_envs = native
;include_dir = ../../src
;src_dir = ../../src
default_envs = native
include_dir = .
src_dir = .
+23 -1
View File
@@ -8,10 +8,31 @@
#include <stddef.h>
#include <string.h>
#include <stdlib.h>
#include <vector>
#include <string>
#include <memory>
// Finds the start of the first occurrence of the substring needle of length needlelen in the memory area haystack of length haystacklen.
inline void* memmem(const void* haystack, size_t haystack_len, const void* needle, size_t needle_len) {
const unsigned char* h = (const unsigned char*)haystack;
const unsigned char* n = (const unsigned char*)needle;
if (needle_len == 0)
return (void*)h;
if (haystack_len < needle_len)
return nullptr;
for (size_t i = 0; i <= haystack_len - needle_len; i++) {
if (h[i] == n[0] && memcmp(&h[i], n, needle_len) == 0) {
return (void*)&h[i];
}
}
return nullptr;
}
namespace RNS {
#define COW
@@ -316,7 +337,8 @@ MEM("Creating from data-move...");
if (!_data || _data->data() == nullptr || (size_t)pos >= _data->size()) {
return -1;
}
const char* ptr = strnstr((const char*)(_data->data() + pos), str, (_data->size() - pos));
//const char* ptr = strnstr((const char*)(_data->data() + pos), str, (_data->size() - pos));
void* ptr = memmem((const void*)(_data->data() + pos), (_data->size() - pos), (const void*)str, strlen(str));
if (ptr == nullptr) {
return -1;
}
+2
View File
@@ -4,6 +4,8 @@
#include <Arduino.h>
#endif
#include <stdarg.h>
#include <string>
#define LOG(msg, level) (RNS::log(msg, level))