Git Product home page Git Product logo

Comments (2)

orangeduck avatar orangeduck commented on July 19, 2024

Hey,

Thanks! Of course it is perseonal preference, but I think in C typically you don't cast the result of malloc, although this is needed in C++ and also I understand if various extensions or whatever require you to cast the result. Casts from sizeof etc could be a problem but it depends on the context. I think in general I'd rather do without any non-essential casts for the main repo as I think it can clutter the code.

Probably I should be checking the return value of realloc/malloc as you're right - the parser could run out of memory if it goes into an infinite loop - and people might be using this on smaller embedded systems. So if you feel like making a pull request for that, that would be cool.

Although I think in practice checking the return value of malloc/realloc is sometimes pretty useless. And you have to be careful because realloc can return NULL in two cases - either if out of memory of if (much more likely) you request to resize to 0 bytes. This always comes up for dynamically sized arrays because when you pop all the items they return to size zero.

Thanks,

Dam

from mpc.

hellerve avatar hellerve commented on July 19, 2024

Hey,

thanks for the in-depth insight. Of course all your points are valid. As long as it's an informed decision, I'm down with every of your design choices. Just keep in mind that users of extremely picky makefile templates like me(with pedantic always switched on) might run into problems(although I cannot recall which extension specifically broke compiling).

Cheers

from mpc.

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.