Small Tweak

This commit is contained in:
TheBrokenRail 2025-02-15 15:22:03 -05:00
parent 0a0c3cebb3
commit f40a7c3545
2 changed files with 10 additions and 7 deletions

View File

@ -23,12 +23,12 @@ struct copy_array {
if (arr == nullptr) { if (arr == nullptr) {
length = 0; length = 0;
} }
this->size = length * sizeof(T); size = length * sizeof(T);
this->data = arr; data = arr;
} }
explicit copy_array(const char *str) { explicit copy_array(const char *str) {
this->size = str != nullptr ? (strlen(str) + 1) : 0; size = str != nullptr ? (strlen(str) + 1) : 0;
this->data = str; data = str;
} }
uint32_t size; uint32_t size;
const void *data; const void *data;

View File

@ -18,11 +18,13 @@ __attribute__((visibility("internal"))) void _add_handler(unsigned char id, hand
// Arguments // Arguments
struct TrampolineArguments { struct TrampolineArguments {
// Constructor
explicit TrampolineArguments(const unsigned char *args) { explicit TrampolineArguments(const unsigned char *args) {
this->raw_args = args; raw_args = args;
this->position = 0; position = 0;
} }
// Read Next Value
template <typename T> template <typename T>
T next() { T next() {
block_pointer(T); block_pointer(T);
@ -30,6 +32,7 @@ struct TrampolineArguments {
raw_args += sizeof(T); raw_args += sizeof(T);
return ret; return ret;
} }
// Read Next Array
template <typename T> template <typename T>
const T *next_arr(uint32_t *length = nullptr) { const T *next_arr(uint32_t *length = nullptr) {
block_pointer(T); block_pointer(T);
@ -37,7 +40,7 @@ struct TrampolineArguments {
if (length != nullptr) { if (length != nullptr) {
*length = size / sizeof(T); *length = size / sizeof(T);
} }
static bool just_read_pointer = getenv(MCPI_USE_PIPE_TRAMPOLINE_ENV) == nullptr; static bool just_read_pointer = !is_trampoline_pipe_based();
if (size == 0) { if (size == 0) {
return nullptr; return nullptr;
} else if (just_read_pointer) { } else if (just_read_pointer) {