diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-12-10 13:06:00 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-12-10 13:16:42 +0300 |
commit | 602250d9fe796ff5e762a4880a0be97ef3f4b139 (patch) | |
tree | 5fce5daba548ca93990d87303480ea913b3acb93 /source/blender/blenkernel/intern/CCGSubSurf.h | |
parent | 47788b5e68b7b0f2b7a061a1dae8f4b1995b67e2 (diff) |
Fix T42748: Crash in subsurf, threaded access
Allocating the iterator from a BLI_memarena wasn't threadsafe.
Change the API to use stack memory for iterators.
Thanks to @mont29 for finding exact cause of the bug.
Diffstat (limited to 'source/blender/blenkernel/intern/CCGSubSurf.h')
-rw-r--r-- | source/blender/blenkernel/intern/CCGSubSurf.h | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/CCGSubSurf.h b/source/blender/blenkernel/intern/CCGSubSurf.h index fdf6d2df99f..2b86a2a66b2 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.h +++ b/source/blender/blenkernel/intern/CCGSubSurf.h @@ -53,6 +53,13 @@ typedef struct CCGAllocatorIFC { void (*release) (CCGAllocatorHDL a); } CCGAllocatorIFC; +/* private, so we can allocate on the stack */ +typedef struct _EHashIterator { + struct _EHash *eh; + int curBucket; + struct _EHEntry *curEntry; +} EHashIterator; + /***/ typedef enum { @@ -163,27 +170,24 @@ int ccgSubSurf_getNumFinalFaces (const CCGSubSurf *ss); /***/ -typedef struct CCGVertIterator CCGVertIterator; -typedef struct CCGEdgeIterator CCGEdgeIterator; -typedef struct CCGFaceIterator CCGFaceIterator; +typedef struct _EHashIterator CCGVertIterator; +typedef struct _EHashIterator CCGEdgeIterator; +typedef struct _EHashIterator CCGFaceIterator; -CCGVertIterator* ccgSubSurf_getVertIterator (CCGSubSurf *ss); -CCGEdgeIterator* ccgSubSurf_getEdgeIterator (CCGSubSurf *ss); -CCGFaceIterator* ccgSubSurf_getFaceIterator (CCGSubSurf *ss); +void ccgSubSurf_initVertIterator(CCGSubSurf *ss, CCGVertIterator *viter); +void ccgSubSurf_initEdgeIterator(CCGSubSurf *ss, CCGEdgeIterator *eiter); +void ccgSubSurf_initFaceIterator(CCGSubSurf *ss, CCGFaceIterator *fiter); CCGVert* ccgVertIterator_getCurrent (CCGVertIterator *vi); int ccgVertIterator_isStopped (CCGVertIterator *vi); void ccgVertIterator_next (CCGVertIterator *vi); -void ccgVertIterator_free (CCGVertIterator *vi); CCGEdge* ccgEdgeIterator_getCurrent (CCGEdgeIterator *ei); int ccgEdgeIterator_isStopped (CCGEdgeIterator *ei); void ccgEdgeIterator_next (CCGEdgeIterator *ei); -void ccgEdgeIterator_free (CCGEdgeIterator *ei); CCGFace* ccgFaceIterator_getCurrent (CCGFaceIterator *fi); int ccgFaceIterator_isStopped (CCGFaceIterator *fi); void ccgFaceIterator_next (CCGFaceIterator *fi); -void ccgFaceIterator_free (CCGFaceIterator *fi); #endif /* __CCGSUBSURF_H__ */ |