Code Monkey home page Code Monkey logo

Comments (1)

stohrendorf avatar stohrendorf commented on May 25, 2024
  1. please use code markup
  2. the std::make_pair(ACT_WEAPON9, "ACT_WEAPON9"), etc. can be replaced with a temporary macro like #define ENUM_MEMBER(name) std::make_pair(name, #name)
  3. you can't construct an std::string from a nullptr
  4. using an array means you rely upon ACTIONS being contiguous and starting from 0
  5. you also need to ensure that the ordering of the members matches exactly the enum members
  6. ... unless you meant to write a loop in Controls_ActionToStr; in this case, ACT_LASTINDEX should be the default if you don't find a matching entry in the array
  7. or use a plain std::map<ACTION, std::string> which you actually want to do here, but performance of small maps (less than ~100 elements) is far inferior to linear scans
  8. std::strncpy does not guarantee that it will create a NUL-terminated string if the source (excluding the terminator) has the same length or is larger than the destination, so you'd need to assert that the source length is less than 128

from opentomb.

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.