File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change 11/*
2- * Copyright (c) 2015, 2023 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2015, 2024 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
@@ -46,20 +46,24 @@ ZPhysicalMemory::ZPhysicalMemory()
4646
4747ZPhysicalMemory::ZPhysicalMemory (const ZPhysicalMemorySegment& segment)
4848 : _segments() {
49- add_segment (segment);
49+ _segments. append (segment);
5050}
5151
5252ZPhysicalMemory::ZPhysicalMemory (const ZPhysicalMemory& pmem)
53- : _segments() {
54- add_segments ( pmem);
53+ : _segments(pmem.nsegments() ) {
54+ _segments. appendAll (& pmem. _segments );
5555}
5656
5757const ZPhysicalMemory& ZPhysicalMemory::operator =(const ZPhysicalMemory& pmem) {
58- // Free segments
59- _segments.clear_and_deallocate ();
58+ // Check for self-assignment
59+ if (this == &pmem) {
60+ return *this ;
61+ }
6062
61- // Copy segments
62- add_segments (pmem);
63+ // Free and copy segments
64+ _segments.clear_and_deallocate ();
65+ _segments.reserve (pmem.nsegments ());
66+ _segments.appendAll (&pmem._segments );
6367
6468 return *this ;
6569}
You can’t perform that action at this time.
0 commit comments