Commit d97b611a by Aaron Leung

Fixed an error in the refactored clone method. Now it deep-copies for real.

parent 5fb94280
...@@ -16,10 +16,12 @@ namespace Sass { ...@@ -16,10 +16,12 @@ namespace Sass {
Node_Impl* Node_Factory::alloc_Node_Impl(Node_Impl* ip) Node_Impl* Node_Factory::alloc_Node_Impl(Node_Impl* ip)
{ {
Node_Impl* ip_cpy = new Node_Impl(*ip); Node_Impl* ip_cpy = new Node_Impl(*ip);
pool_.push_back(ip_cpy);
if (ip_cpy->has_children) { if (ip_cpy->has_children) {
for (size_t i = 0, S = ip_cpy->size(); i < S; ++i) { for (size_t i = 0, S = ip_cpy->size(); i < S; ++i) {
Node n(ip_cpy->at(i)); Node n(ip_cpy->at(i));
n.ip_ = alloc_Node_Impl(n.ip_); // n.ip_ = alloc_Node_Impl(n.ip_);
ip_cpy->at(i) = (*this)(n);
} }
} }
return ip_cpy; return ip_cpy;
......
...@@ -48,7 +48,19 @@ int main() ...@@ -48,7 +48,19 @@ int main()
cout << num4[3].numeric_value() << endl; cout << num4[3].numeric_value() << endl;
num4[3] = new_Node("", 0, 0.4567); num4[3] = new_Node("", 0, 0.4567);
cout << num3[3].numeric_value() << endl; cout << num3[3].numeric_value() << endl;
cout << num4[3].numeric_value() << endl; cout << num4[3].numeric_value() << endl << endl;
Node block1(new_Node(Node::block, "block", 1, 2));
block1 << num2 << num4;
Node block2(new_Node(block1));
cout << (block1 == block2) << endl;
cout << block1[1][3].numeric_value() << endl;
cout << block2[1][3].numeric_value() << endl;
block2[1][3] = new_Node("", 0, .9876);
cout << block1[1][3].numeric_value() << endl;
cout << block2[1][3].numeric_value() << endl;
new_Node.free(); new_Node.free();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment