summaryrefslogtreecommitdiff
path: root/library/DataDefs.cpp
diff options
context:
space:
mode:
authorAlexander Gavrilov2012-03-25 15:48:18 +0400
committerAlexander Gavrilov2012-03-25 15:48:18 +0400
commit0412aaebe4266d9d1ed07ac4d6083ba360b90a45 (patch)
tree4f27a00302b7b0837a1b4ea0156056c90987f9ad /library/DataDefs.cpp
parent7209e4d3f2c3fc51d176131aa9da1654f211fed0 (diff)
downloaddfhack-0412aaebe4266d9d1ed07ac4d6083ba360b90a45.tar.gz
dfhack-0412aaebe4266d9d1ed07ac4d6083ba360b90a45.tar.bz2
dfhack-0412aaebe4266d9d1ed07ac4d6083ba360b90a45.tar.xz
Add a delete() method to the objects in the lua wrapper.
Diffstat (limited to 'library/DataDefs.cpp')
-rw-r--r--library/DataDefs.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/library/DataDefs.cpp b/library/DataDefs.cpp
index 712d4563..3d635474 100644
--- a/library/DataDefs.cpp
+++ b/library/DataDefs.cpp
@@ -51,6 +51,11 @@ void type_identity::do_copy_pod(void *tgt, const void *src) {
memmove(tgt, src, size);
};
+bool type_identity::do_destroy_pod(void *obj) {
+ free(obj);
+ return true;
+}
+
void *type_identity::allocate() {
if (can_allocate())
return do_allocate();
@@ -65,6 +70,13 @@ bool type_identity::copy(void *tgt, const void *src) {
return false;
}
+bool type_identity::destroy(void *obj) {
+ if (can_allocate() && obj)
+ return do_destroy(obj);
+ else
+ return false;
+}
+
void *enum_identity::do_allocate() {
void *p = malloc(byte_size());
memcpy(p, &first_item_value, std::min(byte_size(), sizeof(int64_t)));