[geary/mjog/problem-report-memory-fixes: 2/3] Geary.Logging.Record: Add copy constructor



commit b0be1a79b1e04b38f4f9eb448d3058a0d30cc202
Author: Michael Gratton <mike vee net>
Date:   Sun Mar 1 21:39:04 2020 +1100

    Geary.Logging.Record: Add copy constructor

 src/engine/api/geary-logging.vala | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
---
diff --git a/src/engine/api/geary-logging.vala b/src/engine/api/geary-logging.vala
index 11f7b09d..dcdfd76c 100644
--- a/src/engine/api/geary-logging.vala
+++ b/src/engine/api/geary-logging.vala
@@ -208,6 +208,36 @@ public class Record {
         this.states.length = state_count;
     }
 
+    /**
+     * Copy constructor.
+     *
+     * Copies all properties of the given record except its next
+     * record.
+     */
+    public Record.copy(Record other) {
+        this.domain = other.domain;
+        this.account = other.account;
+        this.service = other.service;
+        this.folder = other.folder;
+        this.flags = other.flags;
+        this.message = other.message;
+        this.source_filename = other.source_filename;
+        this.source_line_number = other.source_line_number;
+        this.source_function = other.source_function;
+        this.levels = other.levels;
+        this.timestamp = other.timestamp;
+
+        // Kept null deliberately so that we don't get a stack blowout
+        // copying large record chains and code that does copy records
+        // can copy only a fixed number.
+        // this.next
+
+        this.states = other.states;
+        this.filled = other.filled;
+        this.old_log_api = other.old_log_api;
+    }
+
+
     /**
      * Sets the well-known logging source properties.
      *


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]