Skip to content
This repository has been archived by the owner on Aug 24, 2020. It is now read-only.

C++ migration: Object lifetimes #12

Open
davidgraeff opened this issue Jul 16, 2018 · 0 comments
Open

C++ migration: Object lifetimes #12

davidgraeff opened this issue Jul 16, 2018 · 0 comments

Comments

@davidgraeff
Copy link

davidgraeff commented Jul 16, 2018

Wakaama uses structs a lot. But because C lacks constructors and destructors, a lot of boilerplate code just allocates/inits/deinits/frees those structs in various success and error code paths.

  • The use of proper classes with constructors/destructors solves object lifetime tracking.
  • The use of unique_ptr, shared_ptr reduces explicit destructor requirements
  • The use of string_view (C++ backport, use of C++14 native if available) / string instead of raw const char* pointers make it obvious which string are owned by a structure

See https://github.com/martinmoene/string-view-lite

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Development

No branches or pull requests

1 participant