From f142e9a9c6ba493c09a282544da8715b3656648e Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Tue, 20 Jul 2021 07:24:07 +0200 Subject: core: C++-ify membuffer C-style memory management is a pain and nearly nobody seems to get it right. Add a C++-version of membuffer that frees the buffer when it gets out-of-scope. Originally, I was thinking about conditionally adding a constructor/destructor pair when compiling with C++. But then decided to create a derived class membufferpp, because it would be extremely confusing to have behavioral change when changing a source from from C to C++ or vice-versa. Also add a comment about the dangers of returned pointer: They become dangling on changes to the membuffer. Signed-off-by: Berthold Stoeger --- Subsurface-mobile.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Subsurface-mobile.pro') diff --git a/Subsurface-mobile.pro b/Subsurface-mobile.pro index 598e94e4c..2e1b6a959 100644 --- a/Subsurface-mobile.pro +++ b/Subsurface-mobile.pro @@ -86,7 +86,7 @@ SOURCES += subsurface-mobile-main.cpp \ core/divesite.c \ core/equipment.c \ core/gas.c \ - core/membuffer.c \ + core/membuffer.cpp \ core/selection.cpp \ core/sha1.c \ core/string-format.cpp \ -- cgit v1.2.3-70-g09d2