mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-02 09:40:15 +00:00
implement fbuf_flush()
This commit is contained in:
parent
c223367073
commit
19f8496221
@ -243,6 +243,23 @@ fbuf_free(fbuf* f){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// attempt to write the contents of |f| to the FILE |fp|, if there are any
|
||||||
|
// contents. reset the fbuf either way. if |flushfp| is set, fflush(fp).
|
||||||
|
static inline int
|
||||||
|
fbuf_flush(fbuf* f, FILE* fp, bool flushfp){
|
||||||
|
int ret = 0;
|
||||||
|
if(f->used){
|
||||||
|
if(fwrite(f->buf, f->used, 1, fp) != 1){
|
||||||
|
ret = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(flushfp && ret == 0 && fflush(fp) == EOF){
|
||||||
|
ret = -1;
|
||||||
|
}
|
||||||
|
fbuf_reset(f);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// attempt to write the contents of |f| to the FILE |fp|, if there are any
|
// attempt to write the contents of |f| to the FILE |fp|, if there are any
|
||||||
// contents, and free the fbuf either way. if |flushfp| is set, fflush(fp).
|
// contents, and free the fbuf either way. if |flushfp| is set, fflush(fp).
|
||||||
static inline int
|
static inline int
|
||||||
|
Loading…
Reference in New Issue
Block a user