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

Function lInsert0

Singular/lists.cc:87–115  ·  view source on GitHub ↗

2 * insert v into list ul, destroys u */

Source from the content-addressed store, hash-verified

85* insert v into list ul, destroys u
86*/
87lists lInsert0(lists ul, leftv v, int pos)
88{
89 if ((pos<0)||(v->rtyp==NONE))
90 return NULL;
91 lists l=(lists) omAllocBin(slists_bin);
92 l->Init(si_max(ul->nr+2,pos+1));
93 int i,j;
94
95 for(i=j=0;i<=ul->nr;i++,j++)
96 {
97 if(j==pos) j++;
98 l->m[j]=ul->m[i];
99 }
100 for(j=ul->nr+1;j<pos;j++)
101 l->m[j].rtyp=DEF_CMD;
102 // memset(&(l->m[pos]),0,sizeof(sleftv)); - done by Init
103 l->m[pos].rtyp=v->Typ();
104 l->m[pos].data=v->CopyD();
105 l->m[pos].flag=v->flag;
106 attr *a=v->Attribute();
107 if ((a!=NULL)&&(*a!=NULL))
108 {
109 l->m[pos].attribute=(*a)->Copy();
110 }
111 if (ul->m != NULL)
112 omFreeSize((ADDRESS)ul->m,(ul->nr+1)*sizeof(sleftv));
113 omFreeBin((ADDRESS)ul, slists_bin);
114 return l;
115}
116
117/*2
118* insert v into list u, at the beginning

Callers 3

lInsertFunction · 0.85
lInsert3Function · 0.85
lAppendFunction · 0.85

Calls 8

omAllocBinFunction · 0.85
si_maxFunction · 0.85
omFreeBinFunction · 0.85
AttributeMethod · 0.80
InitMethod · 0.45
TypMethod · 0.45
CopyDMethod · 0.45
CopyMethod · 0.45

Tested by

no test coverage detected