int ret;
io_u = __get_io_u(td);
- io_u->file = &td->files[0];
+ io_u->file = td->files[0];
assert(io_u);
hdr = &io_u->hdr;
dprint(FD_FILE, "add file %s\n", fname);
- td->files = realloc(td->files, (cur_files + 1) * sizeof(*f));
-
- f = &td->files[cur_files];
+ f = malloc(sizeof(*f));
memset(f, 0, sizeof(*f));
f->fd = -1;
+ td->files = realloc(td->files, (cur_files + 1) * sizeof(f));
+
+ td->files[cur_files] = f;
+
/*
* init function, io engine may not be loaded yet
*/
int thread_number;
int groupid;
struct thread_stat ts;
- struct fio_file *files;
+ struct fio_file **files;
unsigned int files_index;
unsigned int nr_open_files;
unsigned int nr_done_files;
#define for_each_td(td, i) \
for ((i) = 0, (td) = &threads[0]; (i) < (int) thread_number; (i)++, (td)++)
#define for_each_file(td, f, i) \
- for ((i) = 0, (f) = &(td)->files[0]; (i) < (td)->o.nr_files; (i)++, (f)++)
+ for ((i) = 0, (f) = (td)->files[0]; (i) < (td)->o.nr_files; (i)++, (f)++)
#define fio_assert(td, cond) do { \
if (!(cond)) { \
long r = os_random_long(&td->next_file_state);
fno = (unsigned int) ((double) td->o.nr_files * (r / (RAND_MAX + 1.0)));
- f = &td->files[fno];
+ f = td->files[fno];
if (f->flags & FIO_FILE_DONE)
continue;
struct fio_file *f;
do {
- f = &td->files[td->next_file];
+ f = td->files[td->next_file];
td->next_file++;
if (td->next_file >= td->o.nr_files)
* invalid ddir, this is a file action
*/
if (ipo->ddir == DDIR_INVAL) {
- struct fio_file *f = &td->files[ipo->fileno];
+ struct fio_file *f = td->files[ipo->fileno];
if (ipo->file_action == FIO_LOG_OPEN_FILE) {
assert(!td_io_open_file(td, f));
io_u->offset = ipo->offset;
io_u->buflen = ipo->len;
io_u->ddir = ipo->ddir;
- io_u->file = &td->files[ipo->fileno];
+ io_u->file = td->files[ipo->fileno];
get_file(io_u->file);
dprint(FD_IO, "iolog: get %llu/%lu/%s\n", io_u->offset,