From aabfaeb28ccbc3016aa17d0934b0affb721286cf Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Mon, 6 Jun 2022 20:01:41 +0300 Subject: Specify that internal allocations failure is unlikely (refactoring) * finalize.c [!GC_NO_FINALIZATION] (GC_register_disappearing_link_inner): Assume failure of allocation (resulting in NULL or GC_oom_fn call) is unlikely. * malloc.c [DBG_HDRS_ALL || GC_GCJ_SUPPORT || !GC_NO_FINALIZATION] (GC_generic_malloc_inner_ignore_off_page): Likewise. * malloc.c (GC_generic_malloc): Likewise. * malloc.c [REDIRECT_MALLOC && !REDIRECT_MALLOC_IN_HEADER] (calloc, strdup, strndup): Likewise. * mallocx.c (GC_realloc, GC_memalign, GC_strdup, GC_strndup): Likewise. * mallocx.c [GC_REQUIRE_WCSDUP] (GC_wcsdup): Likewise. * specific.c [USE_CUSTOM_SPECIFIC] (GC_setspecific): Likewise. * typd_mlc.c (GC_make_sequence_descriptor, GC_make_descriptor): Likewise. * malloc.c [REDIRECT_MALLOC && !REDIRECT_MALLOC_IN_HEADER] (calloc): Expect that lb and n are not greater than GC_SQRT_SIZE_MAX. * typd_mlc.c (GC_calloc_explicitly_typed): Likewise. * typd_mlc.c (GC_add_ext_descriptor): Assume that resizing of GC_ext_descriptors[] is rare. * typd_mlc.c (GC_calloc_explicitly_typed): Do not call GC_make_array_descriptor() if n * lb > GC_SIZE_MAX. * malloc.c [REDIRECT_MALLOC && !REDIRECT_MALLOC_IN_HEADER && !strndup] (strndup): Expect that len is not greater than size. * mallocx.c (GC_strndup): Likewise. * typd_mlc.c (GC_make_sequence_descriptor): Reformat code. --- specific.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'specific.c') diff --git a/specific.c b/specific.c index d4c0ef46..2a1f954e 100644 --- a/specific.c +++ b/specific.c @@ -59,7 +59,7 @@ GC_INNER int GC_setspecific(tsd * key, void * value) GC_dont_gc++; /* disable GC */ entry = (volatile tse *)MALLOC_CLEAR(sizeof(tse)); GC_dont_gc--; - if (0 == entry) return ENOMEM; + if (EXPECT(NULL == entry, FALSE)) return ENOMEM; pthread_mutex_lock(&(key -> lock)); /* Could easily check for an existing entry here. */ -- cgit v1.2.1