fio assumes opses aren't dynamically allocated which means malloc'd
engine here never gets freed.
According to
46a67478 and
a8075704, the point of get_ioengine() is
how non-static ops gets initialized by g++, but not how space for ops
gets allocated, thus it should just define a static global variable
within "C" scope and pass the address of ops to a caller via **.
Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
#ifdef FIO_EXTERNAL_ENGINE
extern "C" {
#ifdef FIO_EXTERNAL_ENGINE
extern "C" {
+static struct ioengine_ops ioengine;
void get_ioengine(struct ioengine_ops **ioengine_ptr)
{
void get_ioengine(struct ioengine_ops **ioengine_ptr)
{
- struct ioengine_ops *ioengine;
-
- *ioengine_ptr = (struct ioengine_ops *) malloc(sizeof(struct ioengine_ops));
- ioengine = *ioengine_ptr;
-
- ioengine->name = "cpp_null";
- ioengine->version = FIO_IOOPS_VERSION;
- ioengine->queue = fio_null_queue;
- ioengine->commit = fio_null_commit;
- ioengine->getevents = fio_null_getevents;
- ioengine->event = fio_null_event;
- ioengine->init = fio_null_init;
- ioengine->cleanup = fio_null_cleanup;
- ioengine->open_file = fio_null_open;
- ioengine->flags = FIO_DISKLESSIO | FIO_FAKEIO;
+ *ioengine_ptr = &ioengine;
+
+ ioengine.name = "cpp_null";
+ ioengine.version = FIO_IOOPS_VERSION;
+ ioengine.queue = fio_null_queue;
+ ioengine.commit = fio_null_commit;
+ ioengine.getevents = fio_null_getevents;
+ ioengine.event = fio_null_event;
+ ioengine.init = fio_null_init;
+ ioengine.cleanup = fio_null_cleanup;
+ ioengine.open_file = fio_null_open;
+ ioengine.flags = FIO_DISKLESSIO | FIO_FAKEIO;
}
}
#endif /* FIO_EXTERNAL_ENGINE */
}
}
#endif /* FIO_EXTERNAL_ENGINE */