Mercurial > hg > th-libs
comparison th_ioctx_mem.c @ 719:d51c277bea6b
Set th_ioctx::memAlloc to zero in th_mem_fclose() if memory is freed. This fixes the issue if file is reopened and th_mem_realloc() fails to notice that we have no allocated memory.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 11 Nov 2020 13:35:03 +0200 |
parents | ffd97ca9dfce |
children | ff724f45162a |
comparison
equal
deleted
inserted
replaced
718:ffd97ca9dfce | 719:d51c277bea6b |
---|---|
44 | 44 |
45 | 45 |
46 static void th_mem_fclose(th_ioctx *ctx) | 46 static void th_mem_fclose(th_ioctx *ctx) |
47 { | 47 { |
48 if (ctx->memFree) | 48 if (ctx->memFree) |
49 { | |
49 th_free_r(&ctx->memData); | 50 th_free_r(&ctx->memData); |
51 ctx->memAlloc = 0; | |
52 ctx->memSize = 0; | |
53 } | |
50 } | 54 } |
51 | 55 |
52 | 56 |
53 static BOOL th_mem_realloc(th_ioctx *ctx, const size_t newSize) | 57 static BOOL th_mem_realloc(th_ioctx *ctx, const size_t newSize) |
54 { | 58 { |