Giter VIP home page Giter VIP logo

rm's People

Contributors

yesmar avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

rm's Issues

Needs unit tests

The code works, but needs a proper test harness and set of end-to-end tests.

Heap operations are a detriment

I like the idea of this system, but the fact that it uses on calloc/realloc is a real drawback. Heap operations are slow. Given the fact that rm is used to track a stack of resource frames within the scope of a call, using the stack seems like a better idea. The real benefit of using the heap is the ability to arbitrarily grow the size of the stack of resource frames. That's not really a need of rm. Functions typically have a finitely small number of resources that need to be tracked. The number is typically known at compile time and doesn't change dynamically. Hence, the primary benefit of the current heap implementation is not needed. This seems like a perfect use case for C99's variable length arrays. We know the number of resources to be tracked at compile time so we can initialize the stack as a VLA with that as its maxsize property. (See Wikipedia for details.)

API is incomplete

Alexey Kutepov's implementation has API for replacing and getting rid of frames within the stack. This is a total violation of the classical stack ADT, but is completely necessary because of the variable nature of resource management requirements within a function. It is unrealistic to impose full stack unwinding on functions because they may need to deallocate things in a specific order under certain situations. Therefore, my implementation needs the ability to flexibly replace a resource while preserving its encapsulating frame. Given this requirement, it possibly makes better sense to select a different ADT, such as a red-black tree. That would add more complexity than is actually required. My functions typically track less than half a dozen resources, so a stack is acceptable.

Needs an rm_delete API

Just like the resource management stack has a rm_replace function, it needs an rm_delete function. rm_replace swaps one resource for another while preserving the containing resource frame, which is fine. But sometimes we simply need to deallocate a resource, closing any gap in the stack.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.