summaryrefslogtreecommitdiffstats
path: root/src/knot-ptr.cpp
diff options
context:
space:
mode:
authorLiam P. White <inkscapebrony@gmail.com>2014-08-08 13:13:58 +0000
committerLiam P. White <inkscapebrony@gmail.com>2014-08-08 13:13:58 +0000
commitc96a762f35cb9f14a6eac9180e7ebe4c43dcced9 (patch)
tree64dc2b1826f6018d74426436d620c35b77979af5 /src/knot-ptr.cpp
parentUpdate to experimental r13460 (diff)
parentSmall tweak to bbox calculation (diff)
downloadinkscape-c96a762f35cb9f14a6eac9180e7ebe4c43dcced9.tar.gz
inkscape-c96a762f35cb9f14a6eac9180e7ebe4c43dcced9.zip
Update to experimental r13464
(bzr r13090.1.99)
Diffstat (limited to 'src/knot-ptr.cpp')
-rw-r--r--src/knot-ptr.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/knot-ptr.cpp b/src/knot-ptr.cpp
new file mode 100644
index 000000000..de8118ba7
--- /dev/null
+++ b/src/knot-ptr.cpp
@@ -0,0 +1,25 @@
+#include <algorithm>
+#include <glib.h>
+#include <list>
+#include "knot-ptr.h"
+
+static std::list<void*> deleted_knots;
+
+void knot_deleted_callback(void* knot) {
+ if (std::find(deleted_knots.begin(), deleted_knots.end(), knot) == deleted_knots.end()) {
+ deleted_knots.push_back(knot);
+ }
+}
+
+void knot_created_callback(void* knot) {
+ std::list<void*>::iterator it = std::find(deleted_knots.begin(), deleted_knots.end(), knot);
+ if (it != deleted_knots.end()) {
+ deleted_knots.erase(it);
+ }
+}
+
+void check_if_knot_deleted(void* knot) {
+ if (std::find(deleted_knots.begin(), deleted_knots.end(), knot) != deleted_knots.end()) {
+ g_warning("Accessed knot after it was freed at %p", knot);
+ }
+}