]> git.mdlowis.com Git - proto/gir.git/commitdiff
Start implementing the world of the vm
authorMichael D. Lowis <mike@mdlowis.com>
Wed, 27 May 2015 02:29:42 +0000 (22:29 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Wed, 27 May 2015 02:29:42 +0000 (22:29 -0400)
source/world.c [new file with mode: 0644]

diff --git a/source/world.c b/source/world.c
new file mode 100644 (file)
index 0000000..de7f18b
--- /dev/null
@@ -0,0 +1,32 @@
+/**
+  @file world.c.c
+  @brief See header for details
+  */
+//#include "world.h"
+
+#include "map.h"
+
+typedef struct {
+    map_t* parent;
+    map_t* self;
+    uint8_t data[];
+} object_t;
+
+void object_free(void* obj)
+{
+    object_t* object = (object_t*)obj;
+    if (object->parent)
+        mem_release(object->parent);
+    if (object->self)
+        mem_release(object->self);
+}
+
+object_t* object_clone(object_t* parent)
+{
+    object_t* obj = (object_t*)mem_allocate(sizeof(object_t), &object_free);
+    obj->parent = (NULL == parent) ? NULL : mem_retain(parent->self);
+    obj->self   = map_new(NULL, NULL);
+    return obj;
+}
+
+