Updating built in Io code to use += instead of x = x + y
[io/quag.git] / libs / iovm / source / IoTag.c
blob7c9c59ab1c7d1c412d83f7f7c3f7740a9d212c79
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
23 self->referenceCount = 1;
24 //self->recyclableInstances = Stack_new();
25 //self->maxRecyclableInstances = 10000;
26 return self;
29 IoTag *IoTag_newWithName_(const char *name)
31 IoTag *self = IoTag_new();
32 IoTag_name_(self, name);
33 return self;
36 void IoTag_free(IoTag *self)
38 //printf("io_free tag %p\n", (void *)self);
39 //printf("%s\n", self->name ? self->name : "NULL");
40 if (--self->referenceCount > 0) {
41 return;
44 if (self->tagCleanupFunc)
46 (self->tagCleanupFunc)(self);
49 if (self->name)
51 io_free(self->name);
52 self->name = NULL;
55 //Stack_free(self->recyclableInstances);
56 io_free(self);
59 int IoTag_reference(IoTag *self)
61 return ++self->referenceCount;
64 void IoTag_name_(IoTag *self, const char *name)
66 self->name = strcpy((char *)io_realloc(self->name, strlen(name)+1), name);
69 const char *IoTag_name(IoTag *self)
71 return self->name;
74 void IoTag_mark(IoTag *self)
77 if (Stack_count(self->recyclableInstances))
79 Stack_do_(self->recyclableInstances, (StackDoCallback *)IoObject_shouldMark);