Skip to content

Commit

Permalink
Merge pull request #1 from TileDB-Inc/ss/cpp-guidelines
Browse files Browse the repository at this point in the history
Add C++ Style Guide
  • Loading branch information
Shelnutt2 authored and ihnorton committed Aug 24, 2022
1 parent c4e5b8c commit 808b97b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
22 changes: 22 additions & 0 deletions doc/dev/style/Memory.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Memory Guidelines

## Pointers and Allocations

The use of `new` or `malloc` is forbidden unless justifcation and a team
agreement on an exception is granted. Inplace a smart pointer should be used.

That is a `unique_ptr`, `shared_ptr` or `weak_ptr` should be used in all cases.
With `weak_ptr` being rarely used.

In the core TileDB library we have our own `tdb_unique_ptr` and `tdb_shared_ptr`
that must be used inplace of the `stl` versions.

`make_unique_ptr` or `make_shared_ptr` is the preferred, exception safe, method
of creating the smart pointers.

Extreme care must be given to all allocations. Even when using STL containers
like `std::vector` thoughtful consideration must be given for the dynamic
allocations that will occur.

If we are only allocating one megabyte or less _strongly_ consider fixed
allocations instead. Fixed allocation help to avoid fragmentation of the heap.
14 changes: 14 additions & 0 deletions doc/dev/style/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# C++ Style Guide


When in double and not in conflict with this document, follow [C++ Core Guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines)

## C++ Standards

Where possible we should use up to C++17. Some external packages, such as PDAL are
limited in what they can use. Where we control the environment we should strive
for C++17 usage.

## Memory Handling

See [Memory.md](Memory.md)

0 comments on commit 808b97b

Please sign in to comment.