void RetypeBag(Bag bag, UInt new_type) { BagHeader * header = BAG_HEADER(bag); UInt old_type = header->type; /* change the size-type word */ header->type = new_type; { int old_gctype, new_gctype; UInt size; void *new_mem, *old_mem; old_gctype = TabMarkTypeBags[old_type]; new_gctype = TabMarkTypeBags[new_type]; if (old_gctype != new_gctype) { size = SIZE_BAG(bag) + sizeof(BagHeader); new_mem = AllocateBagMemory(new_gctype, new_type, size); old_mem = PTR_BAG(bag); old_mem = ((char *)old_mem) - sizeof(BagHeader); memcpy(new_mem, old_mem, size); SET_PTR_BAG(bag, (void *)(((char *)new_mem) + sizeof(BagHeader))); } } #ifdef HPCGAP switch (DSInfoBags[new_type]) { case DSI_PUBLIC: REGION(bag) = NULL; break; } #endif // HPCGAP }
void MarkWeakPointerObj( Obj wp) { Int i; /* can't use the stored length here, in case we are in the middle of copying */ for (i = 1; i <= (SIZE_BAG(wp)/sizeof(Obj))-1; i++) MarkBagWeakly(ELM_WPOBJ(wp,i)); }
void MarkAllSubBagsDefault(Bag bag) { MarkArrayOfBags(CONST_PTR_BAG(bag), SIZE_BAG(bag) / sizeof(Bag)); }
void MarkAllButFirstSubBags(Bag bag) { MarkArrayOfBags(CONST_PTR_BAG(bag) + 1, SIZE_BAG(bag) / sizeof(Bag) - 1); }