fix write_len/read_len

This commit is contained in:
lixianjing 2019-08-29 10:55:16 +08:00
parent 6d49eaebf3
commit 5447f2fb8d
4 changed files with 10 additions and 11 deletions

View File

@ -58,15 +58,7 @@ int main(int argc, char* argv[]) {
}
#endif
#if defined(WIN32)
#if !defined(NDEBUG)
{
AllocConsole();
FILE* fp = NULL;
freopen_s(&fp, "CONOUT$", "w+t", stdout);
}
#endif /*NDEBUG*/
#endif /*WIN32*/
TK_ENABLE_CONSOLE();
tk_init(lcd_w, lcd_h, APP_SIMULATOR, NULL, NULL);
#endif

View File

@ -45,7 +45,7 @@ int32_t tk_istream_read_len(tk_istream_t* stream, uint8_t* buff, uint32_t max_si
do {
read_bytes = tk_istream_read(stream, buff + offset, remain_bytes);
if (read_bytes < 0) {
if (read_bytes <= 0) {
break;
}

View File

@ -45,7 +45,7 @@ int32_t tk_ostream_write_len(tk_ostream_t* stream, const uint8_t* buff, uint32_t
do {
write_bytes = tk_ostream_write(stream, buff + offset, remain_bytes);
if (write_bytes < 0) {
if (write_bytes <= 0) {
break;
}

View File

@ -329,4 +329,11 @@ typedef uint32_t (*tk_get_time_t)();
typedef uint32_t (*tk_get_time_ms_t)();
typedef void (*tk_sleep_ms_t)(uint32_t ms);
#if defined(WIN32) && !defined(NDEBUG)
#define TK_ENABLE_CONSOLE() {AllocConsole(); FILE* fp = NULL; freopen_s(&fp, "CONOUT$", "w+t", stdout);}
#else
#define TK_ENABLE_CONSOLE()
#endif /*WIN32 && !NDEBUG*/
#endif /*TYPES_DEF_H*/