Skip to content
This repository was archived by the owner on Oct 2, 2020. It is now read-only.
This repository was archived by the owner on Oct 2, 2020. It is now read-only.

Stacks and Buffers Require Memory Micro-Mangement #3

@joebobmiles

Description

@joebobmiles

In the current subleqc source code, stacks and buffers require their memory to be micro-managed. While allocations are automatically handled by the Push() (for stack) and Append() (for buffer) functions, stacks and buffers still require their memory to be manually freed by calling their respective Empty() functions, which perform the operation of deleting their allocated pointers.

This means the code is cluttered with some strangely placed Empty() calls that don't contextually or semantically make sense unless you already know that Empty() frees the memory allocated to the stack or buffer. Additionally, calling Empty() does a lot of extra work that isn't necessary when a stack or buffer is going out of scope and doesn't need that extra work to be done.

Another problem is that I've been lazy and haven't populated the code with nearly enough Empty()s. This means that the assembler is loaded with memory leaks. Harmless memory leaks, but they're still there and should be eradicated.

There are two options I see to fixing this:

  1. Give stacks and buffers destructors that delete allocated memory when they fall out of scope, OR
  2. Create a function whose sole purpose is to free allocated memory so that we have a function to call that frees the memory and does nothing else.

I personally vote for option 1.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingenhancementNew feature or requestgood first issueGood for newcomers

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions