Commit 104d269a by Aaron Leung

Keeping a registry of allocations.

parent e73dc124
......@@ -15,7 +15,7 @@ using std::endl;
namespace Sass {
size_t Node::allocations = 0;
Node Node::clone() const
Node Node::clone(vector<vector<Node>*>& registry) const
{
Node n(*this);
if (has_children) {
......@@ -25,6 +25,7 @@ namespace Sass {
for (int i = 0; i < size(); ++i) {
n << at(i).clone();
}
registry.push_back(n.content.children);
}
return n;
}
......
......@@ -199,12 +199,13 @@ namespace Sass {
Node(Type t) // flags or booleans
{ clear(); type = t; }
Node(Type t, unsigned int ln, size_t s = 0) // nodes with children
Node(Type t, vector<vector<Node>*>& registry, unsigned int ln, size_t s = 0) // nodes with children
{
clear();
type = t;
line_number = ln;
content.children = new vector<Node>;
registry.push_back(content.children);
content.children->reserve(s);
has_children = true;
++allocations;
......@@ -236,12 +237,13 @@ namespace Sass {
content.dimension.unit = tok.begin;
}
Node(unsigned int ln, double r, double g, double b, double a = 1.0) // colors
Node(vector<vector<Node>*>& registry, unsigned int ln, double r, double g, double b, double a = 1.0) // colors
{
clear();
type = numeric_color;
line_number = ln;
content.children = new vector<Node>;
registry.push_back(content.children);
content.children->reserve(4);
content.children->push_back(Node(ln, r));
content.children->push_back(Node(ln, g));
......
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