summaryrefslogtreecommitdiff
path: root/specific.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2018-03-15 23:16:36 +0300
committerIvan Maidanski <ivmai@mail.ru>2018-03-15 23:16:36 +0300
commitd194e44fec13f92baefe66c2e2f14521627a9679 (patch)
treec041f1b7c26709eee730c1b5cbdd39c69274a419 /specific.c
parentcb963c22aa03c2d6f664ef8d7880852559d52ffd (diff)
downloadbdwgc-d194e44fec13f92baefe66c2e2f14521627a9679.tar.gz
Add assertions to ensure ADD_CALL_CHAIN is called holding the lock
(code refactoring) * alloc.c (GC_collect_a_little_inner, GC_allocobj): Add assertion that the allocation lock is held. * dbg_mlc.c (GC_store_debug_info_inner): Likewise. * dbg_mlc.c [DBG_HDRS_ALL] (GC_debug_generic_malloc_inner, GC_debug_generic_malloc_inner_ignore_off_page): Likewise. * finalize.c [!GC_TOGGLE_REFS_NOT_NEEDED] (ensure_toggleref_capacity): Likewise. * specific.c [USE_CUSTOM_SPECIFIC] (GC_key_create_inner): Likewise. * alloc.c (GC_allocobj): Remove comment (about the lock). * dbg_mlc.c [DBG_HDRS_ALL] (GC_debug_generic_malloc_inner): Likewise.
Diffstat (limited to 'specific.c')
-rw-r--r--specific.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/specific.c b/specific.c
index eca2d937..0ded0360 100644
--- a/specific.c
+++ b/specific.c
@@ -27,11 +27,13 @@ GC_INNER int GC_key_create_inner(tsd ** key_ptr)
{
int i;
int ret;
- tsd * result = (tsd *)MALLOC_CLEAR(sizeof(tsd));
+ tsd * result;
+ GC_ASSERT(I_HOLD_LOCK());
/* A quick alignment check, since we need atomic stores */
GC_ASSERT((word)(&invalid_tse.next) % sizeof(tse *) == 0);
- if (0 == result) return ENOMEM;
+ result = (tsd *)MALLOC_CLEAR(sizeof(tsd));
+ if (NULL == result) return ENOMEM;
ret = pthread_mutex_init(&result->lock, NULL);
if (ret != 0) return ret;
for (i = 0; i < TS_CACHE_SIZE; ++i) {