write-op-impl.c 1.03 KB
Newer Older
1 2 3 4 5 6 7
/*
 * (C) 2017 The University of Chicago
 * 
 * See COPYRIGHT in top-level directory.
 */

#include <stdlib.h>
8
#include <string.h>
9 10
#include "mobject-store-config.h"
#include "libmobject-store.h"
Matthieu Dorier's avatar
Matthieu Dorier committed
11 12 13
#include "src/io-chain/write-op-impl.h"
#include "src/util/utlist.h"
#include "src/util/log.h"
14

15
mobject_store_write_op_t create_write_op(void)
16 17 18
{
	mobject_store_write_op_t write_op = 
		(mobject_store_write_op_t)calloc(1, sizeof(struct mobject_store_write_op));
19
	MOBJECT_ASSERT(write_op != MOBJECT_WRITE_OP_NULL, "Could not allocate write_op");
20 21 22
	write_op->actions     = (wr_action_base_t)0;
	write_op->bulk_handle = HG_BULK_NULL;
	write_op->num_actions = 0;
23
	write_op->ready       = 0;
24 25 26
	return write_op;
}

27
void release_write_op(mobject_store_write_op_t write_op)
28 29
{
	if(write_op == MOBJECT_WRITE_OP_NULL) return;
30 31 32

	if(write_op->bulk_handle != HG_BULK_NULL) 
		margo_bulk_free(write_op->bulk_handle);
33 34 35 36 37 38 39 40
	
	wr_action_base_t action, tmp;

	DL_FOREACH_SAFE(write_op->actions, action, tmp) {
		DL_DELETE(write_op->actions, action);
		free(action);
	}

41 42
	free(write_op);
}