Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
timeshift: reallocate segment on close to release unused tail
  • Loading branch information
perexg committed Dec 20, 2015
1 parent d822a74 commit c9212c3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/timeshift/timeshift_filemgr.c
Expand Up @@ -151,13 +151,22 @@ int timeshift_filemgr_makedirs ( int index, char *buf, size_t len )
*/
void timeshift_filemgr_close ( timeshift_file_t *tsf )
{
uint8_t *ram;
ssize_t r = timeshift_write_eof(tsf);
if (r > 0) {
tsf->size += r;
atomic_add_u64(&timeshift_total_size, r);
if (tsf->ram)
atomic_add_u64(&timeshift_total_ram_size, r);
}
if (tsf->ram) {
/* maintain unused memory block */
ram = realloc(tsf->ram, tsf->woff);
if (ram) {
tsf->ram = ram;
tsf->ram_size = tsf->woff;
}
}
if (tsf->wfd >= 0)
close(tsf->wfd);
tsf->wfd = -1;
Expand Down

0 comments on commit c9212c3

Please sign in to comment.