#include <stdlib.h>
+#include <string.h>
#include "io_u_queue.h"
+#include "smalloc.h"
-bool io_u_qinit(struct io_u_queue *q, unsigned int nr)
+bool io_u_qinit(struct io_u_queue *q, unsigned int nr, bool shared)
{
- q->io_us = calloc(nr, sizeof(struct io_u *));
+ if (shared)
+ q->io_us = smalloc(nr * sizeof(struct io_u *));
+ else
+ q->io_us = calloc(nr, sizeof(struct io_u *));
+
if (!q->io_us)
return false;
return true;
}
-void io_u_qexit(struct io_u_queue *q)
+void io_u_qexit(struct io_u_queue *q, bool shared)
{
- free(q->io_us);
+ if (shared)
+ sfree(q->io_us);
+ else
+ free(q->io_us);
}
bool io_u_rinit(struct io_u_ring *ring, unsigned int nr)