diff options
-rw-r--r-- | backends/fs/fs.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/backends/fs/fs.cpp b/backends/fs/fs.cpp index ecb8f50aab..445bea8efe 100644 --- a/backends/fs/fs.cpp +++ b/backends/fs/fs.cpp @@ -24,6 +24,10 @@ #include "backends/fs/fs.h" #include "common/util.h" + +static AbstractFilesystemNode *_rootNode = 0; +static int *_rootRefCount = 0; + FilesystemNode AbstractFilesystemNode::wrap(AbstractFilesystemNode *node) { FilesystemNode wrapper(node); return wrapper; @@ -35,8 +39,13 @@ FilesystemNode::FilesystemNode(AbstractFilesystemNode *realNode) { } FilesystemNode::FilesystemNode() { - _realNode = getRoot(); - _refCount = new int(1); + if (_rootNode == 0) { + _rootNode = getRoot(); + _rootRefCount = new int(1); + } + _realNode = _rootNode; + _refCount = _rootRefCount; + ++(*_refCount); } FilesystemNode::FilesystemNode(const FilesystemNode &node) |