Git Product home page Git Product logo

Comments (2)

FSMaxB avatar FSMaxB commented on September 18, 2024

Thanks for your feedback.

Sadly being compatible with C89 comes with some constraints. The safe functions like strncat etc. are not available, they have been introduced by C99, same goes for reducing the scope of variables. In C89 you have to declare all of your local variables at the beginning of a function. actually it is allowed to declare variables later, but they have to be in a new scope and before any statement, therefore your suggestion regarding the variable scope are valid C89.

Many of the magic numbers can be replaced by a sizeof("string literal"). That would make it much easier to see what's going on. Pull requests are welcome. Example:

/* reserve enough memory for a 64 bit integer + '/' and '\0' */
size_t retLen = strlen(found) + sizeof("/-9223372036854775808"); /* hm, now it is only 23, not 24 ... */

And I agree that less exit points from a function are desirable. But when making changes like that, you have to be really careful that you don't accidentally introduce new bugs. I'd be much more comfortable with these kinds of changes if there were proper unit tests with good test coverage, so I think this has a higher priority at the moment.

from cjson.

FSMaxB avatar FSMaxB commented on September 18, 2024

I'm closing this for know. It is not forgotten! I've been refactoring a lot of code already and I always try to follow good practices to my abilities. cJSON_Utils still looks like a mess, but I (or somebody else?) will eventually be able to tackle that as well. At least before the 2.0 release.

from cjson.

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.