Use automatic allocation for DS args

This commit is contained in:
Rangi42
2024-02-22 21:21:05 -05:00
committed by Sylvie
parent b1aa98b43d
commit 843f3394c8
4 changed files with 22 additions and 49 deletions

View File

@@ -11,6 +11,7 @@
#include <stdlib.h>
#include <string>
#include <string.h>
#include <vector>
#include "asm/fstack.hpp"
#include "asm/main.hpp"
@@ -694,7 +695,7 @@ void sect_RelByte(struct Expression *expr, uint32_t pcShift)
// Output several copies of a relocatable byte. Checking will be done to see if
// it is an absolute value in disguise.
void sect_RelBytes(uint32_t n, struct Expression *exprs, size_t size)
void sect_RelBytes(uint32_t n, std::vector<struct Expression> &exprs)
{
if (!checkcodesection())
return;
@@ -702,18 +703,18 @@ void sect_RelBytes(uint32_t n, struct Expression *exprs, size_t size)
return;
for (uint32_t i = 0; i < n; i++) {
struct Expression *expr = &exprs[i % size];
struct Expression &expr = exprs[i % exprs.size()];
if (!rpn_isKnown(expr)) {
createPatch(PATCHTYPE_BYTE, expr, i);
if (!rpn_isKnown(&expr)) {
createPatch(PATCHTYPE_BYTE, &expr, i);
writebyte(0);
} else {
writebyte(expr->val);
writebyte(expr.val);
}
}
for (size_t i = 0; i < size; i++)
rpn_Free(&exprs[i]);
for (struct Expression &expr : exprs)
rpn_Free(&expr);
}
// Output a relocatable word. Checking will be done to see if