- ZeroMemory(wd, sizeof(*wd));
- wd->aio_events = malloc((td->o.iodepth + 1) * sizeof(struct io_u *));
- ZeroMemory(wd->aio_events, (td->o.iodepth + 1) * sizeof(struct io_u *));
+ if (!rc) {
+ wd->aio_events = malloc(td->o.iodepth * sizeof(struct io_u*));
+ if (wd->aio_events == NULL)
+ rc = 1;
+ }
+
+ if (!rc) {
+ wd->io_handles = malloc(2 * td->o.iodepth * sizeof(HANDLE));
+ if (wd->io_handles == NULL)
+ rc = 1;
+ }
+
+ if (!rc) {
+ wd->ovls = malloc(2 * td->o.iodepth * sizeof(FIO_OVERLAPPED));
+ if (wd->ovls == NULL)
+ rc = 1;
+ }
+
+ if (!rc) {
+ /* Create an auto-reset event */
+ wd->iocomplete_event = CreateEvent(NULL, FALSE, FALSE, NULL);
+ if (wd->iocomplete_event == NULL)
+ rc = 1;
+ }
+
+ if (!rc) {
+ osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ GetVersionEx(&osInfo);
+
+ if (osInfo.dwMajorVersion >= 6)
+ wd->have_cancelioex = TRUE;
+ else
+ wd->have_cancelioex = FALSE;
+ }
+
+ if (rc) {
+ PrintError(__func__);
+ if (wd != NULL) {
+ if (wd->ovls != NULL)
+ free(wd->ovls);
+ if (wd->io_handles != NULL)
+ free(wd->io_handles);
+ if (wd->aio_events != NULL)
+ free(wd->aio_events);
+
+ free(wd);
+ }
+ }