1 #include "localobjects.h"
4 void REVERT_OBJ(struct ___Object___ * obj) {
5 int type=((int *)obj)[0];
6 struct ___Object___ * copyobj=obj->___localcopy___;
7 if(((int)copyobj)==1) {
8 obj->___localcopy___=NULL;
9 obj->___nextobject___=NULL;
10 } else if (type<NUMCLASSES) {
11 /* We have a normal object */
12 int size=classsize[type];
13 memcpy(obj, copyobj, size);
15 /* We have an array */
16 struct ArrayObject *ao=(struct ArrayObject *)obj;
17 int elementsize=classsize[type];
18 int length=ao->___length___;
19 int size=sizeof(struct ArrayObject)+length*elementsize;
20 memcpy(obj, copyobj, size);
25 void COPY_OBJ(struct garbagelist * gl, struct ___Object___ *obj) {
27 void COPY_OBJ(struct ___Object___ *obj) {
29 int type=((int *)obj)[0];
30 if (type<NUMCLASSES) {
31 /* We have a normal object */
32 int size=classsize[type];
34 int ptrarray[]={1, (int) gl, (int) obj};
35 struct ___Object___ * newobj=mygcmalloc((struct garbagelist *)ptrarray, size);
37 struct ___Object___ * newobj=FREEMALLOC(size);
40 memcpy(newobj, (struct ___Object___ *) ptrarray[2], size);
41 ((struct ___Object___*)ptrarray[2])->___localcopy___=newobj;
43 memcpy(newobj, obj, size);
44 obj->___localcopy___=newobj;
47 /* We have an array */
48 struct ArrayObject *ao=(struct ArrayObject *)obj;
49 int elementsize=classsize[type];
50 int length=ao->___length___;
51 int size=sizeof(struct ArrayObject)+length*elementsize;
53 int ptrarray[]={1, (int) gl, (int) obj};
54 struct ___Object___ * newobj=mygcmalloc((struct garbagelist *)ptrarray, size);
56 struct ___Object___ * newobj=FREEMALLOC(size);
59 memcpy(newobj, (struct ___Object___ *) ptrarray[2], size);
60 ((struct ___Object___*)ptrarray[2])->___localcopy___=newobj;
62 memcpy(newobj, obj, size);
63 obj->___localcopy___=newobj;