1 #include "localobjects.h"
4 void REVERT_OBJ(struct ___Object___ * obj) {
5 int type=((int *)obj)[0];
6 struct ___Object___ * copyobj=obj->___localcopy___;
8 /* We have a normal object */
9 int size=classsize[type];
10 memcpy(obj, copyobj, size);
12 /* We have an array */
13 struct ArrayObject *ao=(struct ArrayObject *)obj;
14 int elementsize=classsize[type];
15 int length=ao->___length___;
16 int size=sizeof(struct ArrayObject)+length*elementsize;
17 memcpy(obj, copyobj, size);
22 void COPY_OBJ(struct garbagelist * gl, struct ___Object___ *obj) {
24 void COPY_OBJ(struct ___Object___ *obj) {
26 int type=((int *)obj)[0];
27 if (type<NUMCLASSES) {
28 /* We have a normal object */
29 int size=classsize[type];
31 int ptrarray[]={1, (int) gl, (int) obj};
32 struct ___Object___ * newobj=mygcmalloc((struct garbagelist *)ptrarray, size);
34 struct ___Object___ * newobj=FREEMALLOC(size);
36 memcpy(newobj, (struct ___Object___ *) ptrarray[2], size);
37 ((struct ___Object___*)ptrarray[2])->___localcopy___=newobj;
39 /* We have an array */
40 struct ArrayObject *ao=(struct ArrayObject *)obj;
41 int elementsize=classsize[type];
42 int length=ao->___length___;
43 int size=sizeof(struct ArrayObject)+length*elementsize;
45 int ptrarray[]={1, (int) gl, (int) obj};
46 struct ___Object___ * newobj=mygcmalloc((struct garbagelist *)ptrarray, size);
48 struct ___Object___ * newobj=FREEMALLOC(size);
50 memcpy(newobj, (struct ___Object___ *) ptrarray[2], size);
51 ((struct ___Object___*)ptrarray[2])->___localcopy___=newobj;