mirror of
https://github.com/fumiama/base16384.git
synced 2026-06-05 02:00:31 +08:00
fix: encode bufsz (#19)
This commit is contained in:
@@ -43,7 +43,7 @@ typedef enum base16384_err_t base16384_err_t;
|
||||
|
||||
#undef define_base16384_err_t
|
||||
|
||||
#define BASE16384_ENCBUFSZ (BUFSIZ*1024/7*7)
|
||||
#define BASE16384_ENCBUFSZ (BUFSIZ*1024/7*7+7)
|
||||
#define BASE16384_DECBUFSZ (BUFSIZ*1024/8*8+16)
|
||||
|
||||
// base16384_encode_len calc min buf size to fill encode result
|
||||
|
||||
6
file.c
6
file.c
@@ -62,7 +62,7 @@ base16384_err_t base16384_encode_file(const char* input, const char* output, cha
|
||||
return base16384_err_fopen_output_file;
|
||||
}
|
||||
if(!inputsize || inputsize > BASE16384_ENCBUFSZ) { // stdin or big file, use encbuf & fread
|
||||
inputsize = BASE16384_ENCBUFSZ/8*8;
|
||||
inputsize = BASE16384_ENCBUFSZ-7;
|
||||
#if defined _WIN32 || defined __cosmopolitan
|
||||
}
|
||||
#endif
|
||||
@@ -113,7 +113,7 @@ base16384_err_t base16384_encode_fp(FILE* input, FILE* output, char* encbuf, cha
|
||||
if(!output) {
|
||||
return base16384_err_fopen_output_file;
|
||||
}
|
||||
off_t inputsize = BASE16384_ENCBUFSZ/8*8;
|
||||
off_t inputsize = BASE16384_ENCBUFSZ-7;
|
||||
size_t cnt = 0;
|
||||
fputc(0xFE, output);
|
||||
fputc(0xFF, output);
|
||||
@@ -133,7 +133,7 @@ base16384_err_t base16384_encode_fd(int input, int output, char* encbuf, char* d
|
||||
if(output < 0) {
|
||||
return base16384_err_fopen_output_file;
|
||||
}
|
||||
off_t inputsize = BASE16384_ENCBUFSZ/8*8;
|
||||
off_t inputsize = BASE16384_ENCBUFSZ-7;
|
||||
size_t cnt = 0;
|
||||
write(output, "\xfe\xff", 2);
|
||||
while((cnt = read(input, encbuf, inputsize)) > 0) {
|
||||
|
||||
Reference in New Issue
Block a user