示例#1
0
/**
 * Create a new buffer object.
 *
 * size: Indices the buffer should accomodate.
 **/
ebuf_t *
ebuf_create(size_t size)
{
	ebuf_t *ret;
	GLuint handle;
	int memfail;

	if (! size)
		return NULL;

	glGenBuffers(1, &handle);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, handle);
	glBufferData(GL_ELEMENT_ARRAY_BUFFER, size * sizeof(uint16_t), NULL,
		     GL_STATIC_DRAW);
	memfail = CHECK_GL_MEM;

	if (current_ebuf)
		ebuf_do_activate(current_ebuf);

	if (memfail)
		return NULL;

	ret = xmalloc(sizeof(ebuf_t));
	ret->gl_handle = handle;
	ret->size = size;

	refcount_init(&ret->refcount);
	refcount_add_destructor(&ret->refcount, ebuf_destructor, ret);

	intervals_init(&ret->free);
	interval_set(&ret->free, 0, size);

	return ret;
}
	ABWT_table(INTTYPE iv)
		: interval(iv)
		, char_size(256)
		, c_function(char_size, 0)//, occ_function(bwt_size/interval+1, std::vector<INTTYPE>(char_size, 0))//, location_table(bwt_size/interval+1,0)
		, c_functions()
		, get_c_time()
		, get_occ_time()
		//, mtable {{'A',0},{'C',1},{'G',2},{'T',3}}
		//, occ_jbwt(256, std::vector<INTTYPE>(256,0))
		, mtable(256)
		, occ_jbwt(256, std::vector< std::vector<INTTYPE> >(5,std::vector<INTTYPE>(256,0) ) )
		, occ_char({'A','C','G','T'})

	{
		interval_set(interval);
		mtable['A']=0;
		mtable['C']=1;
		mtable['G']=2;
		mtable['T']=3;
	}
示例#3
0
/*
 * range constructor
 *
 * \param	min		starting nid of the range
 * \param	max		ending nid of the range
 * \param	nodemap		nodemap that contains this range
 * \retval	lu_nid_range on success, NULL on failure
 */
struct lu_nid_range *range_create(lnet_nid_t start_nid, lnet_nid_t end_nid,
				  struct lu_nodemap *nodemap)
{
	struct lu_nid_range *range;

	if (LNET_NIDNET(start_nid) != LNET_NIDNET(end_nid) ||
	    LNET_NIDADDR(start_nid) > LNET_NIDADDR(end_nid))
		return NULL;

	OBD_ALLOC_PTR(range);
	if (range == NULL) {
		CERROR("cannot allocate lu_nid_range of size %zu bytes\n",
		       sizeof(*range));
		return NULL;
	}

	range->rn_id = atomic_inc_return(&range_highest_id);
	range->rn_nodemap = nodemap;
	interval_set(&range->rn_node, start_nid, end_nid);
	INIT_LIST_HEAD(&range->rn_list);

	return range;
}
示例#4
0
/**
 * Create a new free region and add it to a buffer's lists.
 **/
void
ebuf_drop_data(ebuf_t *buffer, size_t offset, size_t size)
{
	interval_set(&buffer->free, offset, size);
}