override public Object unpack(Info vi, csBuffer opb) { // also responsible for range checking InfoMapping0 info = new InfoMapping0(); // !!!! if (opb.read(1) != 0) { info.submaps = opb.read(4) + 1; } else { info.submaps = 1; } if (opb.read(1) != 0) { info.coupling_steps = opb.read(8) + 1; for (int i = 0; i < info.coupling_steps; i++) { int testM = opb.read(ilog(vi.channels)); int testA = opb.read(ilog(vi.channels)); info.coupling_mag[i] = testM; info.coupling_ang[i] = testA; if (testM < 0 || testA < 0 || testM >= vi.channels || testA >= vi.channels) { //goto err_out; info.free(); return(null); } } } if (opb.read(2) > 0) { /* 2,3:reserved */ //goto err_out; info.free(); return(null); } if (info.submaps > 1) { for (int i = 0; i < vi.channels; i++) { info.chmuxlist[i] = opb.read(4); if (info.chmuxlist[i] >= info.submaps) { //goto err_out; info.free(); return(null); } } } for (int i = 0; i < info.submaps; i++) { info.timesubmap[i] = opb.read(8); if (info.timesubmap[i] >= vi.times) { //goto err_out; info.free(); return(null); } info.floorsubmap[i] = opb.read(8); if (info.floorsubmap[i] >= vi.floors) { //goto err_out; info.free(); return(null); } info.residuesubmap[i] = opb.read(8); if (info.residuesubmap[i] >= vi.residues) { //goto err_out; info.free(); return(null); } } return(info); //err_out: //free_info(info); //return(NULL); }
public override Object unpack(Info vi, csBuffer opb) { // also responsible for range checking InfoMapping0 info=new InfoMapping0(); // !!!! if(opb.read(1)!=0) { info.submaps=opb.read(4)+1; } else { info.submaps=1; } if(opb.read(1)!=0) { info.coupling_steps=opb.read(8)+1; for(int i=0;i<info.coupling_steps;i++) { int testM=info.coupling_mag[i]=opb.read(ilog2(vi.channels)); int testA=info.coupling_ang[i]=opb.read(ilog2(vi.channels)); if(testM<0 || testA<0 || testM==testA || testM>=vi.channels || testA>=vi.channels) { //goto err_out; info.free(); return(null); } } } if(opb.read(2)>0) { /* 2,3:reserved */ //goto err_out; info.free(); return(null); } if(info.submaps>1) { for(int i=0;i<vi.channels;i++) { info.chmuxlist[i]=opb.read(4); if(info.chmuxlist[i]>=info.submaps) { //goto err_out; info.free(); return(null); } } } for(int i=0;i<info.submaps;i++) { info.timesubmap[i]=opb.read(8); if(info.timesubmap[i]>=vi.times) { //goto err_out; info.free(); return(null); } info.floorsubmap[i]=opb.read(8); if(info.floorsubmap[i]>=vi.floors) { //goto err_out; info.free(); return(null); } info.residuesubmap[i]=opb.read(8); if(info.residuesubmap[i]>=vi.residues) { //goto err_out; info.free(); return(null); } } return info; //err_out: //free_info(info); //return(NULL); }
// Also responsible for range checking public override object unpack(Info vi, csBuffer opb) { InfoMapping0 info = new InfoMapping0(); if (opb.read(1) != 0) { info.submaps = opb.read(4) + 1; } else { info.submaps = 1; } if (opb.read(1) != 0) { info.coupling_steps = opb.read(8) + 1; for (int i = 0; i < info.coupling_steps; i++) { int testM = info.coupling_mag[i] = opb.read(Util.ilog2(vi.Channels)); int testA = info.coupling_ang[i] = opb.read(Util.ilog2(vi.Channels)); if (testM < 0 || testA < 0 || testM == testA || testM >= vi.Channels || testA >= vi.Channels) { info.free(); return(null); } } } if (opb.read(2) > 0) { /* 2,3:reserved */ info.free(); return(null); } if (info.submaps > 1) { for (int i = 0; i < vi.Channels; i++) { info.chmuxlist[i] = opb.read(4); if (info.chmuxlist[i] >= info.submaps) { info.free(); return(null); } } } for (int i = 0; i < info.submaps; i++) { info.timesubmap[i] = opb.read(8); if (info.timesubmap[i] >= vi.times) { info.free(); return(null); } info.floorsubmap[i] = opb.read(8); if (info.floorsubmap[i] >= vi.floors) { info.free(); return(null); } info.residuesubmap[i] = opb.read(8); if (info.residuesubmap[i] >= vi.residues) { info.free(); return(null); } } return(info); }