mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
cc39f709ce
This allows us to use non-C member variables. Convert a number of pointers to unique_ptr<>s. Code in uemis-downloader.cpp had to be refactored, because it mixed owning and non-owning pointers. Mad. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
24 lines
726 B
C++
24 lines
726 B
C++
// SPDX-License-Identifier: GPL-2.0
|
|
// Convenience classes defining owning pointers to C-objects that
|
|
// automatically clean up the objects if the pointers go out of
|
|
// scope. Based on unique_ptr<>.
|
|
// In the future, we should replace these by real destructors.
|
|
#ifndef OWNING_PTR_H
|
|
#define OWNING_PTR_H
|
|
|
|
#include <memory>
|
|
#include <cstdlib>
|
|
|
|
struct dive_trip;
|
|
|
|
void free_trip(struct dive_trip *);
|
|
|
|
// Classes used to automatically call the appropriate free_*() function for owning pointers that go out of scope.
|
|
struct TripDeleter {
|
|
void operator()(dive_trip *t) { free_trip(t); }
|
|
};
|
|
|
|
// Owning pointers to dive, dive_trip, dive_site and event objects.
|
|
using OwningTripPtr = std::unique_ptr<dive_trip, TripDeleter>;
|
|
|
|
#endif
|