Fixed a lazySlot bug where lazy slots in different objects end up pointing to the...
[io/quag.git] / libs / iovm / source / IoTag.c
blob28119101d78a9dbf2bd24eb637323c11d8ea135b
1 /*
2 docCopyright("Steve Dekorte", 2002)
3 docLicense("BSD revised")
4 */
6 #define IOTAG_C 1
7 #include "IoTag.h"
8 #undef IOTAG_C
10 #include "IoObject.h"
11 #include "IoState.h"
12 #include <string.h>
14 IoTag *IoTag_new(void)
16 IoTag *self = (IoTag *)io_calloc(1, sizeof(IoTag));
17 #ifdef IOMESSAGE_INLINE_PERFORM
18 self->performFunc = NULL;
19 #else
20 self->performFunc = (IoTagPerformFunc *)IoObject_perform;
21 #endif
22 //self->recyclableInstances = Stack_new();
23 //self->maxRecyclableInstances = 10000;
24 return self;
27 IoTag *IoTag_newWithName_(const char *name)
29 IoTag *self = IoTag_new();
30 IoTag_name_(self, name);
31 return self;
34 void IoTag_free(IoTag *self)
36 //printf("io_free tag %p\n", (void *)self);
37 //printf("%s\n", self->name ? self->name : "NULL");
39 if (self->tagCleanupFunc)
41 (self->tagCleanupFunc)(self);
44 if (self->name)
46 io_free(self->name);
47 self->name = NULL;
50 //Stack_free(self->recyclableInstances);
51 io_free(self);
54 void IoTag_name_(IoTag *self, const char *name)
56 self->name = strcpy((char *)io_realloc(self->name, strlen(name)+1), name);
59 const char *IoTag_name(IoTag *self)
61 return self->name;
64 void IoTag_mark(IoTag *self)
67 if (Stack_count(self->recyclableInstances))
69 Stack_do_(self->recyclableInstances, (StackDoCallback *)IoObject_shouldMark);