From 098ae26d16188b276af77b8bfe9975fcabe8d7f4 Mon Sep 17 00:00:00 2001 From: max-001 Date: Thu, 7 Nov 2024 10:10:07 +0100 Subject: Added code styles --- contributing.md | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/contributing.md b/contributing.md index cd1b6a6..c7f836e 100644 --- a/contributing.md +++ b/contributing.md @@ -541,6 +541,53 @@ that you can click on to open them. #include ``` +-
+ Ensure exception safety by using RAII classes +
GoodBad
+ + ```cpp + std::unique_ptr foo = std::make_unique(); + ``` + + + ```cpp + Foo* foo = new Foo(); + // ... + delete foo; + ``` +
+-
+ Do not use malloc, calloc, or free (instead use new and delete) +
GoodBad
+ + ```cpp + Foo* foo = new Foo(); + delete foo; + ``` + + + ```cpp + Foo* foo = (Foo*)malloc(sizeof(Foo)); + free(foo); + ``` +
+-
+ Prefix member variables with this-> +
GoodBad
+ + ```cpp + void Foo::set_value(int value) { + this->value = value; + } + ``` + + + ```cpp + void Foo::set_value(int value) { + value = value; + } + ``` +
## CMakeLists-specific -- cgit v1.2.3 From 0756fe048916e696431e1ae99f95ada06d0de7a0 Mon Sep 17 00:00:00 2001 From: max-001 Date: Thu, 7 Nov 2024 10:10:44 +0100 Subject: Fix --- contributing.md | 1 - 1 file changed, 1 deletion(-) diff --git a/contributing.md b/contributing.md index c7f836e..9f39e41 100644 --- a/contributing.md +++ b/contributing.md @@ -523,7 +523,6 @@ that you can click on to open them. -
Use angle brackets (<>) only for including system headers and double quotes ("") for including other engine files. - > [!NOTE] > Only files in the examples folder should include engine headers with angle > brackets -- cgit v1.2.3 From dc093939558e2d71ad3dd322f1f75dfba893783f Mon Sep 17 00:00:00 2001 From: max-001 Date: Thu, 7 Nov 2024 10:11:09 +0100 Subject: Fix --- contributing.md | 1 + 1 file changed, 1 insertion(+) diff --git a/contributing.md b/contributing.md index 9f39e41..c7f836e 100644 --- a/contributing.md +++ b/contributing.md @@ -523,6 +523,7 @@ that you can click on to open them. -
Use angle brackets (<>) only for including system headers and double quotes ("") for including other engine files. + > [!NOTE] > Only files in the examples folder should include engine headers with angle > brackets -- cgit v1.2.3