- Timestamp:
- Nov 30, 2008, 11:13:15 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20081124/Ohana/src/opihi/cmd.data/concat.c
r20839 r20859 19 19 Nin = ovec[0].Nelements; 20 20 ovec[0].Nelements++; 21 REALLOCATE (ovec[0].elements.Flt, opihi_flt, ovec[0].Nelements); 22 ovec[0].elements.Flt[Nin] = value; 21 if (ovec[0].type == OPIHI_FLT) { 22 REALLOCATE (ovec[0].elements.Flt, opihi_flt, ovec[0].Nelements); 23 ovec[0].elements.Flt[Nin] = value; 24 } else { 25 REALLOCATE (ovec[0].elements.Int, opihi_int, ovec[0].Nelements); 26 ovec[0].elements.Int[Nin] = value; 27 } 23 28 return (TRUE); 24 29 } … … 26 31 if ((ivec = SelectVector (argv[1], OLDVECTOR, TRUE)) == NULL) return (FALSE); 27 32 28 REALLOCATE (ovec[0].elements.Flt, opihi_flt, ovec[0].Nelements + ivec[0].Nelements); 29 for (j = ovec[0].Nelements, i = 0; i < ivec[0].Nelements; i++, j++) { 30 ovec[0].elements.Flt[j] = ivec[0].elements.Flt[i]; 33 // we have 4 cases: (ivec == flt or int) and (ovec == flt or int) 34 if ((ovec[0].type == OPIHI_FLT) && (ivec[0].type == OPIHI_FLT)) { 35 REALLOCATE (ovec[0].elements.Flt, opihi_flt, ovec[0].Nelements + ivec[0].Nelements); 36 for (j = ovec[0].Nelements, i = 0; i < ivec[0].Nelements; i++, j++) { 37 ovec[0].elements.Flt[j] = ivec[0].elements.Flt[i]; 38 } 31 39 } 40 if ((ovec[0].type == OPIHI_FLT) && (ivec[0].type == OPIHI_INT)) { 41 REALLOCATE (ovec[0].elements.Flt, opihi_flt, ovec[0].Nelements + ivec[0].Nelements); 42 for (j = ovec[0].Nelements, i = 0; i < ivec[0].Nelements; i++, j++) { 43 ovec[0].elements.Flt[j] = ivec[0].elements.Int[i]; 44 } 45 } 46 if ((ovec[0].type == OPIHI_INT) && (ivec[0].type == OPIHI_INT)) { 47 REALLOCATE (ovec[0].elements.Int, opihi_int, ovec[0].Nelements + ivec[0].Nelements); 48 for (j = ovec[0].Nelements, i = 0; i < ivec[0].Nelements; i++, j++) { 49 ovec[0].elements.Int[j] = ivec[0].elements.Int[i]; 50 } 51 } 52 53 // this case forces ovec to be raised to FLT 54 if ((ovec[0].type == OPIHI_INT) && (ivec[0].type == OPIHI_FLT)) { 55 ALLOCATE (temp, opihi_flt, ovec[0].Nelements + ivec[0].Nelements); 56 for (i = 0; i < ovec[0].Nelements; i++) { 57 temp[i] = ovec[0].elements.Int[i]; 58 } 59 ovec[0].type = OPIHI_FLT; 60 free (ovec[0].elements.Int); 61 ovec[0].elements.Flt = temp; 62 for (j = ovec[0].Nelements, i = 0; i < ivec[0].Nelements; i++, j++) { 63 ovec[0].elements.Flt[j] = ivec[0].elements.Flt[i]; 64 } 65 } 66 32 67 ovec[0].Nelements += ivec[0].Nelements; 33 34 68 return (TRUE); 35 36 69 }
Note:
See TracChangeset
for help on using the changeset viewer.
