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);
37 memcpy(newobj, (struct ___Object___ *) ptrarray[2], size);
38 ((struct ___Object___*)ptrarray[2])->___localcopy___=newobj;
40 memcpy(newobj, obj, size);
41 obj->___localcopy___=newobj;
44 /* We have an array */
45 struct ArrayObject *ao=(struct ArrayObject *)obj;
46 int elementsize=classsize[type];
47 int length=ao->___length___;
48 int size=sizeof(struct ArrayObject)+length*elementsize;
50 int ptrarray[]={1, (int) gl, (int) obj};
51 struct ___Object___ * newobj=mygcmalloc((struct garbagelist *)ptrarray, size);
53 struct ___Object___ * newobj=FREEMALLOC(size);
56 memcpy(newobj, (struct ___Object___ *) ptrarray[2], size);
57 ((struct ___Object___*)ptrarray[2])->___localcopy___=newobj;
59 memcpy(newobj, obj, size);
60 obj->___localcopy___=newobj;