Giter Club home page Giter Club logo

Comments (2)

mtrebi avatar mtrebi commented on July 20, 2024

First of all, my apologies for the soooooo late reply. I've been really busy the last weeks. I am sorry.

Regarding your first question, the answer is Yes. You can use one single struct for both purposes. But, this will (unnecessarily) increase the amount of data used for the FreeList nodes and thus reducing the amount of data that could be potentially used by the allocator. However, is not that bad.

The answer to your second question is Yes, we should make sure that we have enough space to actually create a new node. I totally agree. (Bug spotted). In fact, if there's not enough space we should (a) reject the creation of the data block requested or (b) increase the FreeList size by performing an additional memory allocation by calling malloc.

Thanks for sharing your thoughts!

EDIT:
I've jut read your comment again and at the end you say:

I am just trying to figure out if it is necessary to have two headers and storing the block size repeatedly.

I would like to make sure that there's no confusion about this: Each block size is stored only once in either an AdditionalHeader or a FreeHeader. I decided to use to different structs to make it easier to understand. Maybe it wasnt the right decision...

from memory-allocators.

m110h avatar m110h commented on July 20, 2024

Secondly, in the alloc implementation of FreeListAllocator. When adding new block/node due to rest of available memory. Checking "rest > 0" is not enough I believe, because every block must have a header. I checked "rest > sizeof(AdditionalHeader)" instead of "rest > 0", since I only have one additional header. If 0 < rest < sizeof(AdditionalHeader) then we cannot make it a block right?

I solved this problem using if (rest >= (sizeof(Node)+alignment)) instead if (rest > 0).

from memory-allocators.

Related Issues (20)

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.