Reduces memory occupation with many files.

This commit is contained in:
Andrea Mazzoleni 2013-02-26 21:26:45 +01:00
parent a41443b6b6
commit b7bedc8b60
5 changed files with 43 additions and 3 deletions

9
elem.c
View file

@ -331,7 +331,7 @@ struct snapraid_file* file_alloc(unsigned block_size, const char* sub, uint64_t
block_off_t i;
file = malloc_nofail(sizeof(struct snapraid_file));
pathcpy(file->sub, sizeof(file->sub), sub);
file->sub = strdup_nofail(sub);
file->size = size;
file->blockmax = (size + block_size - 1) / block_size;
file->mtime_sec = mtime_sec;
@ -352,10 +352,17 @@ struct snapraid_file* file_alloc(unsigned block_size, const char* sub, uint64_t
void file_free(struct snapraid_file* file)
{
free(file->sub);
free(file->blockvec);
free(file);
}
void file_rename(struct snapraid_file* file, const char* sub)
{
free(file->sub);
file->sub = strdup_nofail(sub);
}
const char* file_name(struct snapraid_file* file)
{
const char* r = strrchr(file->sub, '/');