Implemented IO buffer control on win/unix system

This commit is contained in:
JackCarterSmith 2020-09-09 19:03:08 +02:00
parent a7e1fd65cf
commit 337fa39535
No known key found for this signature in database
GPG Key ID: B05F75E5934B1D7F
2 changed files with 15 additions and 4 deletions

View File

@ -130,10 +130,18 @@ int getSamplesFromFile(RS_IMAGE *img, FILE *f) {
int sample_bits = img->sampleBits;
int size = div(img->width*img->height*sample_bits, 8).quot;
if (f->_bufsiz >= ftell(f)+size) { //TODO: Check C equivalent
printf("[ERR] WARNING! Please fix size/sample.");
return EXIT_FAILURE;
}
#ifdef _WIN32
if (f->_bufsiz >= ftell(f)+size) {
printf("[ERR] WARNING! Please fix size/sample.");
return EXIT_FAILURE;
}
#else
if (__fbufsize(f) >= ftell(f)+size) {
printf("[ERR] WARNING! Please fix size/sample.");
return EXIT_FAILURE;
}
#endif
img->samples = calloc(1, size);
fread(img->samples, size, 1, f);

View File

@ -2,6 +2,9 @@
#define HMT_PARSER_H_
#include <stdio.h>
#ifndef _WIN32
#include <stdio_ext.h>
#endif
#include <stdlib.h>
#include "options.h"
#include "RS_images.h"