From ec45a5e981c17d17271c0d40cbac7eb4a1db68de Mon Sep 17 00:00:00 2001 From: Erin Date: Sun, 4 Jun 2017 15:51:25 -0500 Subject: [PATCH] memory: private "cloning" of Frames --- src/arch/x86_64/memory/mod.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/arch/x86_64/memory/mod.rs b/src/arch/x86_64/memory/mod.rs index 35e6853..e059ad9 100644 --- a/src/arch/x86_64/memory/mod.rs +++ b/src/arch/x86_64/memory/mod.rs @@ -30,6 +30,13 @@ impl Frame { fn start_address(&self) -> usize { self.index * PAGE_SIZE } + + /// Clones the Frame; we implement this instead of deriving Clone since deriving clone + /// makes `.clone()` public, which would be illogical here (frames should not be cloned by end-users, + /// as that could be used to cause, *e.g.*, double-free errors with the `FrameAllocator`). + fn clone(&self) -> Frame { + Frame { index: self.index } + } } /// A trait which can be implemented by any frame allocator, to make the frame allocation system