Giter Site home page Giter Site logo

Comments (5)

emoon avatar emoon commented on June 24, 2024

Hey,

Thanks for the report!

I think the prefer fix is is to allow the LinearAllocator to grow. What could be done is just to bump the size and then add the ability to grow. I think this will be pretty rate to happen so it should be fine really (as the realloced LinearAllocator will always be alive the resizing may just happen a very few times)

So to outline it:

In LinearAllocator_allocAligned we should check if there is enough space left. If there isn't we should just realloc the buffer and bump the size times two and store the new size. I think this should be just a few lines of code to implement.

Would you be willing to do a PR with the fix? (I'm currently in the middle of dealing with a flooded basement so I don't have a setup for it right now :( )

from rocket.

vcaputo avatar vcaputo commented on June 24, 2024

I'm a bit preoccupied at the moment, but wanted to at least document the issue upstream before completely forgetting about it, since I already bumped the malloc() here to stop the bleeding.

I still want to get the multiclient changes merged upstream so maybe when I'm back on that side of things if this isn't already fixed I'll do that too...

Good luck with the flooding! I've helped family with that in the past, sucks.

from rocket.

emoon avatar emoon commented on June 24, 2024

Thanks!

from rocket.

vcaputo avatar vcaputo commented on June 24, 2024

So to outline it:

In LinearAllocator_allocAligned we should check if there is enough space left. If there isn't we should just realloc the buffer and bump the size times two and store the new size. I think this should be just a few lines of code to implement.

A problem with that simple approach is it would invalidate all the outstanding pointers already handed out via LinearAllocator_allocZero().

And since the existing API is for the caller to provide the space to LinearAllocator_create(), it's awkward at best to make LinearAllocator enlarge/replace that space. The scratchpad use case isn't even passing in a heap-allocated pointer...

It could all be changed to add a new chunk of space when exhausted, chaining to the previous for cleanup handling... but it'll require LinearAllocator_create() owning the memory and not taking it as an input... or maybe if you pass NULL as the space to indicate it's growable, and LinearAllocator allocates it for you, the scratchpad would then be non-growable.

The only sane thing to do without changing the existing dead-simple API is simply enlarge the malloc().

from rocket.

emoon avatar emoon commented on June 24, 2024

Yeah, that makes sense. Lets just bump the the malloc.

from rocket.

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.