void SampleNode::add(StackFrames& stackFrames, size_t bytes, size_t frame) { if(frame > currentFrame) { currentFrame = frame; } StackFrame top(stackFrames.front()); if(top.getFunction() == name) { stackFrames.pop_front(); if(stackFrames.empty()) { addAllocation(bytes); return; } StackFrame firstChild(stackFrames.front()); std::string function(firstChild.getFunction()); if(children.find(function) == children.end()) { children[function] = SampleNode(function); } SampleNode& childNode = children[function]; childNode.add(stackFrames, bytes, frame); } else { throw std::runtime_error("Invalid data"); } }