Mercurial > forge
comparison extra/NaN/src/xptopen.cpp @ 12692:13815b367946 octave-forge
use size_t instead of mwSize/mwIndex whenever possible
author | schloegl |
---|---|
date | Sat, 12 Sep 2015 14:59:20 +0000 |
parents | e4374feb2e3f |
children | 49e9ace39874 |
comparison
equal
deleted
inserted
replaced
12691:6d6285a2a633 | 12692:13815b367946 |
---|---|
931 HeadLen2 = NS*sz2; | 931 HeadLen2 = NS*sz2; |
932 if (HeadLen2 % 80) HeadLen2 = (HeadLen2 / 80 + 1) * 80; | 932 if (HeadLen2 % 80) HeadLen2 = (HeadLen2 / 80 + 1) * 80; |
933 H2 = (char*) realloc(H2,HeadLen2); | 933 H2 = (char*) realloc(H2,HeadLen2); |
934 memset(H2,0,HeadLen2); | 934 memset(H2,0,HeadLen2); |
935 | 935 |
936 mwIndex M = 0; | 936 size_t M = 0; |
937 mxArray **F = (mxArray**) mxMalloc(NS*sizeof(mxArray*)); | 937 mxArray **F = (mxArray**) mxMalloc(NS*sizeof(mxArray*)); |
938 char **Fstr = (char**) malloc(NS*sizeof(char*)); | 938 char **Fstr = (char**) malloc(NS*sizeof(char*)); |
939 size_t *MAXLEN = (size_t*) malloc(NS*sizeof(size_t*)); | 939 size_t *MAXLEN = (size_t*) malloc(NS*sizeof(size_t*)); |
940 for (uint16_t k = 0; k < NS; k++) { | 940 for (uint16_t k = 0; k < NS; k++) { |
941 Fstr[k] = NULL; | 941 Fstr[k] = NULL; |
952 *(int16_t*)(H2+k*sz2) = b_endian_u16(2); | 952 *(int16_t*)(H2+k*sz2) = b_endian_u16(2); |
953 *(int16_t*)(H2+k*sz2+4) = b_endian_u16(mxGetN(F[k])); | 953 *(int16_t*)(H2+k*sz2+4) = b_endian_u16(mxGetN(F[k])); |
954 } | 954 } |
955 else if (mxIsCell(F[k])) { | 955 else if (mxIsCell(F[k])) { |
956 size_t maxlen = 0; | 956 size_t maxlen = 0; |
957 for (mwIndex m = 0; m<M; m++) { | 957 for (size_t m = 0; m<M; m++) { |
958 mxArray *f = mxGetCell(F[k],m); | 958 mxArray *f = mxGetCell(F[k],m); |
959 if (mxIsChar(f) || mxIsEmpty(f)) { | 959 if (mxIsChar(f) || mxIsEmpty(f)) { |
960 size_t len = mxGetNumberOfElements(f); | 960 size_t len = mxGetNumberOfElements(f); |
961 if (maxlen<len) maxlen = len; | 961 if (maxlen<len) maxlen = len; |
962 } | 962 } |
976 | 976 |
977 count = fwrite(H0, 1, HeadLen0, fid); | 977 count = fwrite(H0, 1, HeadLen0, fid); |
978 count += fwrite(H2, 1, HeadLen2, fid); | 978 count += fwrite(H2, 1, HeadLen2, fid); |
979 /* write OBS header line */ | 979 /* write OBS header line */ |
980 count += fwrite(LO, 1, strlen(LO), fid); | 980 count += fwrite(LO, 1, strlen(LO), fid); |
981 for (mwIndex m = 0; m < M; m++) { | 981 for (size_t m = 0; m < M; m++) { |
982 for (uint16_t k = 0; k < NS; k++) { | 982 for (uint16_t k = 0; k < NS; k++) { |
983 | 983 |
984 if (*(int16_t*)(H2+k*sz2) == b_endian_u16(1)) { | 984 if (*(int16_t*)(H2+k*sz2) == b_endian_u16(1)) { |
985 // numeric | 985 // numeric |
986 uint64_t u64 = b_endian_u64(d2xpt(*(mxGetPr(F[k])+m))); | 986 uint64_t u64 = b_endian_u64(d2xpt(*(mxGetPr(F[k])+m))); |