aboutsummaryrefslogtreecommitdiff
path: root/backend/util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'backend/util.cpp')
-rw-r--r--backend/util.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/backend/util.cpp b/backend/util.cpp
new file mode 100644
index 0000000..4a55f63
--- /dev/null
+++ b/backend/util.cpp
@@ -0,0 +1,14 @@
+#include <stdlib.h>
+
+#include "util.h"
+
+void safe_free(void * & ptr) {
+ if (ptr == nullptr) return;
+ free(ptr);
+ ptr = nullptr;
+}
+void safe_free(const char * & ptr) {
+ auto x = static_cast<void *>(const_cast<char *>(ptr));
+ safe_free(x);
+}
+