move STACK_* macros into BLI_stackdefines.h

This commit is contained in:
2014-06-25 00:01:10 +10:00
parent d19d1b5497
commit c5ccbacdaa
12 changed files with 69 additions and 52 deletions

View File

@@ -40,6 +40,7 @@
#include "BLI_blenlib.h"
#include "BLI_edgehash.h"
#include "BLI_utildefines.h"
#include "BLI_stackdefines.h"
#include "BKE_pbvh.h"
#include "BKE_cdderivedmesh.h"
@@ -2770,17 +2771,7 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap, const int
MEM_freeN(oldv);
MEM_freeN(olde);
MEM_freeN(oldl);
MEM_freeN(oldp);
STACK_FREE(oldv);
STACK_FREE(olde);
STACK_FREE(oldl);
STACK_FREE(oldp);
STACK_FREE(mvert);
STACK_FREE(medge);
STACK_FREE(mloop);
STACK_FREE(mpoly);
MEM_freeN(oldp);;
BLI_edgehash_free(ehash, NULL);

View File

@@ -0,0 +1,55 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef __BLI_STACKDEFINES_H__
#define __BLI_STACKDEFINES_H__
/** \file BLI_stackdefines.h
* \ingroup bli
*/
/* simple stack */
#define STACK_DECLARE(stack) unsigned int _##stack##_index
#define STACK_INIT(stack) ((void)stack, (void)((_##stack##_index) = 0))
#define STACK_SIZE(stack) ((void)stack, (_##stack##_index))
#define STACK_PUSH(stack, val) (void)((stack)[(_##stack##_index)++] = val)
#define STACK_PUSH_RET(stack) ((void)stack, ((stack)[(_##stack##_index)++]))
#define STACK_PUSH_RET_PTR(stack) ((void)stack, &((stack)[(_##stack##_index)++]))
#define STACK_POP(stack) ((_##stack##_index) ? ((stack)[--(_##stack##_index)]) : NULL)
#define STACK_POP_PTR(stack) ((_##stack##_index) ? &((stack)[--(_##stack##_index)]) : NULL)
#define STACK_POP_DEFAULT(stack, r) ((_##stack##_index) ? ((stack)[--(_##stack##_index)]) : r)
/* take care, re-orders */
#define STACK_REMOVE(stack, i) \
if (--_##stack##_index != i) { \
stack[i] = stack[_##stack##_index]; \
} (void)0
#ifdef __GNUC__
#define STACK_SWAP(stack_a, stack_b) { \
SWAP(typeof(stack_a), stack_a, stack_b); \
SWAP(unsigned int, _##stack_a##_index, _##stack_b##_index); \
} (void)0
#else
#define STACK_SWAP(stack_a, stack_b) { \
SWAP(void *, stack_a, stack_b); \
SWAP(unsigned int, _##stack_a##_index, _##stack_b##_index); \
} (void)0
#endif
#endif /* __BLI_STACKDEFINES_H__ */

View File

@@ -332,34 +332,6 @@
#define UNPACK3OP(op, a) op((a)[0]), op((a)[1]), op((a)[2])
#define UNPACK4OP(op, a) op((a)[0]), op((a)[1]), op((a)[2]), op((a)[3])
/* simple stack */
#define STACK_DECLARE(stack) unsigned int _##stack##_index
#define STACK_INIT(stack) ((void)stack, (void)((_##stack##_index) = 0))
#define STACK_SIZE(stack) ((void)stack, (_##stack##_index))
#define STACK_PUSH(stack, val) (void)((stack)[(_##stack##_index)++] = val)
#define STACK_PUSH_RET(stack) ((void)stack, ((stack)[(_##stack##_index)++]))
#define STACK_PUSH_RET_PTR(stack) ((void)stack, &((stack)[(_##stack##_index)++]))
#define STACK_POP(stack) ((_##stack##_index) ? ((stack)[--(_##stack##_index)]) : NULL)
#define STACK_POP_PTR(stack) ((_##stack##_index) ? &((stack)[--(_##stack##_index)]) : NULL)
#define STACK_POP_DEFAULT(stack, r) ((_##stack##_index) ? ((stack)[--(_##stack##_index)]) : r)
#define STACK_FREE(stack) ((void)stack)
/* take care, re-orders */
#define STACK_REMOVE(stack, i) \
if (--_##stack##_index != i) { \
stack[i] = stack[_##stack##_index]; \
} (void)0
#ifdef __GNUC__
#define STACK_SWAP(stack_a, stack_b) { \
SWAP(typeof(stack_a), stack_a, stack_b); \
SWAP(unsigned int, _##stack_a##_index, _##stack_b##_index); \
} (void)0
#else
#define STACK_SWAP(stack_a, stack_b) { \
SWAP(void *, stack_a, stack_b); \
SWAP(unsigned int, _##stack_a##_index, _##stack_b##_index); \
} (void)0
#endif
/* array helpers */
#define ARRAY_LAST_ITEM(arr_start, arr_dtype, tot) \
(arr_dtype *)((char *)arr_start + (sizeof(*((arr_dtype *)NULL)) * (size_t)(tot - 1)))

View File

@@ -32,6 +32,7 @@
#include "BLI_array.h"
#include "BLI_alloca.h"
#include "BLI_smallhash.h"
#include "BLI_stackdefines.h"
#include "BLF_translation.h"
@@ -2113,8 +2114,6 @@ void bmesh_vert_separate(BMesh *bm, BMVert *v, BMVert ***r_vout, int *r_vout_len
}
#endif
STACK_FREE(stack);
BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) {
i = GET_INT_FROM_POINTER(BLI_smallhash_lookup(&visithash, (uintptr_t)e));
if (i == 0) {

View File

@@ -36,6 +36,7 @@
#include "BLI_math.h"
#include "BLI_alloca.h"
#include "BLI_linklist.h"
#include "BLI_stackdefines.h"
#include "bmesh.h"
#include "intern/bmesh_private.h"

View File

@@ -29,6 +29,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
#include "BLI_stackdefines.h"
#include "BLI_math.h"
#include "bmesh.h"
@@ -103,7 +104,6 @@ void bmo_bisect_plane_exec(BMesh *bm, BMOperator *op)
BM_vert_kill(bm, v);
}
STACK_FREE(vert_arr);
MEM_freeN(vert_arr);
}

View File

@@ -27,6 +27,7 @@
*/
#include "BLI_utildefines.h"
#include "BLI_stackdefines.h"
#include "BLI_alloca.h"
#include "BLI_linklist_stack.h"

View File

@@ -31,6 +31,7 @@
#include "BLI_math.h"
#include "BLI_array.h"
#include "BLI_alloca.h"
#include "BLI_stackdefines.h"
#include "BKE_customdata.h"
@@ -151,9 +152,6 @@ static void remdoubles_createface(BMesh *bm, BMFace *f, BMOpSlot *slot_targetmap
}
}
}
STACK_FREE(edges);
STACK_FREE(loops);
}
/**

View File

@@ -40,6 +40,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
#include "BLI_stackdefines.h"
#include "BLI_alloca.h"
#include "BLI_math.h"
#include "BLI_listbase.h"

View File

@@ -38,6 +38,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
#include "BLI_stackdefines.h"
#include "BLI_alloca.h"
#include "BLI_linklist.h"
#include "BLI_linklist_stack.h"
@@ -275,9 +276,9 @@ static void bm_face_bisect_verts(BMesh *bm, BMFace *f, const float plane[4], con
}
}
finally:
STACK_FREE(vert_split_arr);
finally:
(void)vert_split_arr;
}
/* -------------------------------------------------------------------- */

View File

@@ -28,8 +28,9 @@
* \ingroup modifiers
*/
#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BLI_stackdefines.h"
#include "BLI_math.h"
#include "BLI_string.h"
#include "MEM_guardedalloc.h"
@@ -623,7 +624,6 @@ static void initSystem(LaplacianDeformModifierData *lmd, Object *ob, DerivedMesh
memcpy(sys->index_anchors, index_anchors, sizeof(int) * total_anchors);
memcpy(sys->co, vertexCos, sizeof(float[3]) * numVerts);
MEM_freeN(index_anchors);
STACK_FREE(index_anchors);
lmd->vertexco = MEM_mallocN(sizeof(float[3]) * numVerts, "ModDeformCoordinates");
memcpy(lmd->vertexco, vertexCos, sizeof(float[3]) * numVerts);
lmd->total_verts = numVerts;

View File

@@ -35,6 +35,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
#include "BLI_stackdefines.h"
#include "BLI_bitmap.h"
#include "BLI_math.h"
@@ -813,9 +814,6 @@ static DerivedMesh *applyModifier(
MEM_freeN(edge_order);
}
STACK_FREE(new_vert_arr);
STACK_FREE(new_edge_arr);
if (old_vert_arr)
MEM_freeN(old_vert_arr);