Does anyone have any tips on catching a memory leak in general? I know where the leak is coming from (approximately), but I've no idea how to fix it.
For what it's worth, I'm writing (for learning-the-language purposes) a stack, and hoping to grow it into a basic interpreter. I had gotten it to the point where it wasn't leaking earlier, however I (obviously) changed something that has recaused it to leak. I expect this to be in this to be in the add method of my LinkedList class, however concerning my previous issues were actually with my smart pointer and node class, I've included them as well.
I've included the parts I believe are to blame, however if they in fact aren't to blame, the full project can be located here: https://github.com/headlessgargoyle/Interpreter
I figured it had something to do with the sPtr class (at least in part). That being said, I'm still not entirely sure how to actually solve the issue. I've tried a few different methods, and all of them continue to leak.
@ne555, while I can't say I was able to get your code to work for me, I do appreciate the effort (even with a lack of care, which I can respect). That being said, I'll admit that I don't have the best understanding of the difference of the types of pointers (I did mention I was doing this for educational purposes, yes?). Honestly, reference counting seemed like a good idea for general purpose use, though I can see why it wouldn't need to be used for a linked last.
Though, for my use, wouldn't a shared pointer make it easier to reorganize the list and traverse it?
However, changing your list implementation would simplify the methods a lot
Implementing a list using a header node (that will not hold any value) and making it circular, makes that after an increment you always reach a node.
That simplifies some operations, as you don't need to check for invalid pointer, or threat the header in an special way