Ejemplo n.º 1
0
/**
 * Clear for reuse, avoids re-allocation when an arena may
 * otherwise be free'd and recreated.
 */
void BLI_memarena_clear(MemArena *ma)
{
	if (ma->bufs) {
		unsigned char *curbuf_prev;
		size_t curbuf_used;

		if (ma->bufs->next) {
			BLI_linklist_freeN(ma->bufs->next);
			ma->bufs->next = NULL;
		}

		curbuf_prev = ma->curbuf;
		ma->curbuf = ma->bufs->link;
		memarena_curbuf_align(ma);

		/* restore to original size */
		curbuf_used = (size_t)(curbuf_prev - ma->curbuf);
		ma->cursize += curbuf_used;

		if (ma->use_calloc) {
			memset(ma->curbuf, 0, curbuf_used);
		}
	}

#ifdef WITH_MEM_VALGRIND
	VALGRIND_DESTROY_MEMPOOL(ma);
	VALGRIND_CREATE_MEMPOOL(ma, 0, false);
#endif

}
Ejemplo n.º 2
0
void BLI_memarena_free(MemArena *ma)
{
	BLI_linklist_freeN(ma->bufs);

#ifdef WITH_MEM_VALGRIND
	VALGRIND_DESTROY_MEMPOOL(ma);
#endif

	MEM_freeN(ma);
}
static int knifeproject_exec(bContext *C, wmOperator *op)
{
	ARegion *ar = CTX_wm_region(C);
	Scene *scene = CTX_data_scene(C);
	Object *obedit = CTX_data_edit_object(C);
	BMEditMesh *em = BKE_editmesh_from_object(obedit);
	const bool cut_through = RNA_boolean_get(op->ptr, "cut_through");

	LinkNode *polys = NULL;

	CTX_DATA_BEGIN (C, Object *, ob, selected_objects)
	{
		if (ob != obedit) {
			polys = knifeproject_poly_from_object(ar, scene, ob, polys);
		}
	}
	CTX_DATA_END;

	if (polys) {
		EDBM_mesh_knife(C, polys, true, cut_through);

		/* select only tagged faces */
		BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, false);

		/* not essential, but switch out of vertex mode since the
		 * selected regions wont be nicely isolated after flushing.
		 * note: call after de-select to avoid selection flushing */
		EDBM_selectmode_disable(scene, em, SCE_SELECT_VERTEX, SCE_SELECT_EDGE);

		BM_mesh_elem_hflag_enable_test(em->bm, BM_FACE, BM_ELEM_SELECT, true, false, BM_ELEM_TAG);

		BM_mesh_select_mode_flush(em->bm);

		BLI_linklist_freeN(polys);

		return OPERATOR_FINISHED;
	}
	else {
		BKE_report(op->reports, RPT_ERROR, "No other selected objects found to use for projection");
		return OPERATOR_CANCELLED;
	}
}
Ejemplo n.º 4
0
/*
 * Frees memory from a previous call to BLI_file_read_as_lines.
 */
void BLI_file_free_lines(LinkNode *lines)
{
	BLI_linklist_freeN(lines);
}