Mercurial > hg > th-libs
comparison th_ioctx_mem.c @ 694:0fc5ddaccc57
Implement fclose() in mem ioctx, with an context flag for freeing the memory
on fclose().
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 09 Mar 2020 18:55:54 +0200 |
parents | a622d21833e1 |
children | e73200c4584a |
comparison
equal
deleted
inserted
replaced
693:a622d21833e1 | 694:0fc5ddaccc57 |
---|---|
41 | 41 |
42 return THERR_OK; | 42 return THERR_OK; |
43 } | 43 } |
44 | 44 |
45 | 45 |
46 static void th_mem_fclose(th_ioctx *ctx) | |
47 { | |
48 if (ctx->memFree) | |
49 th_free_r(&ctx->memData); | |
50 } | |
51 | |
52 | |
46 static BOOL th_mem_realloc(th_ioctx *ctx, const size_t newSize) | 53 static BOOL th_mem_realloc(th_ioctx *ctx, const size_t newSize) |
47 { | 54 { |
48 size_t grow; | 55 size_t grow; |
49 | 56 |
50 // Check write flag | 57 // Check write flag |
220 const th_ioctx_ops th_mem_io_ops = | 227 const th_ioctx_ops th_mem_io_ops = |
221 { | 228 { |
222 "MemIO", | 229 "MemIO", |
223 | 230 |
224 th_mem_fopen, | 231 th_mem_fopen, |
225 NULL, | 232 th_mem_fclose, |
226 | 233 |
227 th_mem_freset, | 234 th_mem_freset, |
228 th_mem_ferror, | 235 th_mem_ferror, |
229 th_mem_fseek, | 236 th_mem_fseek, |
230 th_mem_fsize, | 237 th_mem_fsize, |