diff options
| author | Tyge Løvset <[email protected]> | 2023-05-26 19:36:27 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2023-05-26 19:36:27 +0200 |
| commit | 8497b5497ecba2c2f1d368c9161ec52d4f03ae30 (patch) | |
| tree | 86bd77ae8b1911a5db07b624089ba62b53dfa7cb /misc/examples | |
| parent | 3f840ffe1c9d2df998e1cbcf6c87ea72fe23f97e (diff) | |
| download | STC-modified-8497b5497ecba2c2f1d368c9161ec52d4f03ae30.tar.gz STC-modified-8497b5497ecba2c2f1d368c9161ec52d4f03ae30.zip | |
Minor addition to coroutine API.
Diffstat (limited to 'misc/examples')
| -rw-r--r-- | misc/examples/coread.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/misc/examples/coread.c b/misc/examples/coread.c index ef6cd6ee..2585fb81 100644 --- a/misc/examples/coread.c +++ b/misc/examples/coread.c @@ -16,6 +16,7 @@ void file_read(struct file_read* g) { cco_routine(g) { g->fp = fopen(g->filename, "r"); + if (!g->fp) cco_return; g->line = cstr_init(); cco_await(!cstr_getline(&g->line, g->fp)); @@ -23,9 +24,8 @@ void file_read(struct file_read* g) cco_final: printf("finish\n"); cstr_drop(&g->line); - fclose(g->fp); + if (g->fp) fclose(g->fp); } - return; } int main(void) |
