From c3eb532439e8af11326db174713cd581dec885d6 Mon Sep 17 00:00:00 2001 From: Rangi42 Date: Wed, 28 Feb 2024 12:25:38 -0500 Subject: [PATCH] Use copy constructor for file stack node --- src/asm/fstack.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/asm/fstack.cpp b/src/asm/fstack.cpp index c39e64fe..f05bfde7 100644 --- a/src/asm/fstack.cpp +++ b/src/asm/fstack.cpp @@ -201,15 +201,11 @@ bool yywrap(void) // If the node is referenced, we can't edit it; duplicate it if (context.fileInfo->referenced) { - struct FileStackNode *copy = new(std::nothrow) struct FileStackNode(); - - if (!copy) + context.fileInfo = new(std::nothrow) struct FileStackNode(*context.fileInfo); + if (!context.fileInfo) fatalerror("Failed to duplicate REPT file node: %s\n", strerror(errno)); // Copy all info but the referencing - *copy = *context.fileInfo; // Also copies `context.fileInfo->iters()` - copy->referenced = false; - - context.fileInfo = copy; + context.fileInfo->referenced = false; } std::vector &fileInfoIters = context.fileInfo->iters();