高温氦气物性补全;三通四通能量计算bug修正
This commit is contained in:
1 parent
6fc9afe41d
commit
2b07d996cf
133 files changed
+5230
-253310
No files matched your search
@@ -62,22 +62,27 @@ int native_json_write_number(FILE *file, double value) {
|
||||
return length>0 && write_bytes(file,text,(size_t)length);
|
||||
}
|
||||
|
||||
int native_json_write_array(FILE *file, const double *values, size_t count, size_t stride) {
|
||||
int native_json_write_values(FILE *file, const double *values, size_t count, size_t stride, int leading_comma) {
|
||||
if (!file || ferror(file) || (count && !values)) return 0;
|
||||
if (count>1 && (!stride || stride>(size_t)PTRDIFF_MAX/sizeof(double)/(count-1))) return 0;
|
||||
char buffer[65536];
|
||||
size_t used=1;
|
||||
buffer[0]='[';
|
||||
size_t used=0;
|
||||
for (size_t i=0;i<count;i++) {
|
||||
if (used>sizeof(buffer)-NATIVE_JSON_DOUBLE_CAPACITY-2) {
|
||||
if (!write_bytes(file,buffer,used)) return 0;
|
||||
used=0;
|
||||
}
|
||||
if (i) buffer[used++]=',';
|
||||
if (i || leading_comma) buffer[used++]=',';
|
||||
int length=native_json_format_double(buffer+used,values[i*stride]);
|
||||
if (!length) return 0;
|
||||
used+=(size_t)length;
|
||||
}
|
||||
buffer[used++]=']';
|
||||
return write_bytes(file,buffer,used);
|
||||
}
|
||||
|
||||
int native_json_write_array(FILE *file, const double *values, size_t count, size_t stride) {
|
||||
if (!file || ferror(file) || (count && !values)) return 0;
|
||||
if (count>1 && (!stride || stride>(size_t)PTRDIFF_MAX/sizeof(double)/(count-1))) return 0;
|
||||
if (fputc('[',file)==EOF) return 0;
|
||||
return native_json_write_values(file,values,count,stride,0) && fputc(']',file)!=EOF;
|
||||
}
|
||||
Reference in new issue
Block a user