mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-21 02:32:06 +00:00
Use copy constructor for file stack node
This commit is contained in:
@@ -201,15 +201,11 @@ bool yywrap(void)
|
|||||||
|
|
||||||
// If the node is referenced, we can't edit it; duplicate it
|
// If the node is referenced, we can't edit it; duplicate it
|
||||||
if (context.fileInfo->referenced) {
|
if (context.fileInfo->referenced) {
|
||||||
struct FileStackNode *copy = new(std::nothrow) struct FileStackNode();
|
context.fileInfo = new(std::nothrow) struct FileStackNode(*context.fileInfo);
|
||||||
|
if (!context.fileInfo)
|
||||||
if (!copy)
|
|
||||||
fatalerror("Failed to duplicate REPT file node: %s\n", strerror(errno));
|
fatalerror("Failed to duplicate REPT file node: %s\n", strerror(errno));
|
||||||
// Copy all info but the referencing
|
// Copy all info but the referencing
|
||||||
*copy = *context.fileInfo; // Also copies `context.fileInfo->iters()`
|
context.fileInfo->referenced = false;
|
||||||
copy->referenced = false;
|
|
||||||
|
|
||||||
context.fileInfo = copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<uint32_t> &fileInfoIters = context.fileInfo->iters();
|
std::vector<uint32_t> &fileInfoIters = context.fileInfo->iters();
|
||||||
|
|||||||
Reference in New Issue
Block a user