From: Michael D. Lowis Date: Wed, 27 May 2015 02:29:42 +0000 (-0400) Subject: Start implementing the world of the vm X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=c16a56c39f76bc6bda54607f5ca6a8142f554462;p=proto%2Fgir.git Start implementing the world of the vm --- diff --git a/source/world.c b/source/world.c new file mode 100644 index 0000000..de7f18b --- /dev/null +++ b/source/world.c @@ -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; +} + +