MCPcopy Create free account
hub / github.com/Singular/Singular / newstruct_serialize

Function newstruct_serialize

Singular/newstruct.cc:602–642  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

600*/
601
602BOOLEAN newstruct_serialize(blackbox *b, void *d, si_link f)
603{
604 newstruct_desc dd=(newstruct_desc)b->data;
605 sleftv l;
606 l.Init();
607 l.rtyp=STRING_CMD;
608 l.data=(void*)getBlackboxName(dd->id);
609 f->m->Write(f, &l);
610 lists ll=(lists)d;
611 int Ll=lSize(ll);
612 l.rtyp=INT_CMD;
613 l.data=(void*)(long)Ll;
614 f->m->Write(f, &l);
615 // set all entries corresponding to "real" members to 1 in rings
616 char *rings=(char*)omAlloc0(Ll+1);
617 newstruct_member elem=dd->member;
618 while (elem!=NULL)
619 {
620 rings[elem->pos]='\1';
621 elem=elem->next;
622 }
623 int i;
624 BOOLEAN ring_changed=FALSE;
625 ring save_ring=currRing;
626 for(i=0;i<=Ll;i++)
627 {
628 if (rings[i]=='\0') // ring entry for pos i+1
629 {
630 if (ll->m[i].data!=NULL)
631 {
632 ring_changed=TRUE;
633 f->m->SetRing(f,(ring)ll->m[i].data,TRUE);
634 }
635 }
636 f->m->Write(f,&(ll->m[i]));
637 }
638 omFreeSize(rings,Ll+1);
639 if (ring_changed && (save_ring!=NULL))
640 f->m->SetRing(f,save_ring,FALSE);
641 return FALSE;
642}
643
644BOOLEAN newstruct_deserialize(blackbox **, void **d, si_link f)
645{

Callers

nothing calls this directly

Calls 5

getBlackboxNameFunction · 0.85
lSizeFunction · 0.85
omAlloc0Function · 0.85
InitMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected