]> granicus.if.org Git - gc/commitdiff
Remove redundant check of GC_free argument in register_finalizer
authorIvan Maidanski <ivmai@mail.ru>
Tue, 10 Sep 2019 20:09:29 +0000 (23:09 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 10 Sep 2019 20:09:29 +0000 (23:09 +0300)
(code refactoring)

This also works around "Argument new_fo to function GC_free is always 1"
cppcheck false positive.

* finalize.c [!DBG_HDRS_ALL] (GC_register_finalizer_inner): Do not
check new_fo is non-NULL before GC_free(new_fo) call.

finalize.c

index 0dde1a69cd4d606276d684ce5d1882e66e59bfd3..c8708b95093e03709690148ec6ad775a02a29b65 100644 (file)
@@ -775,10 +775,8 @@ STATIC void GC_register_finalizer_inner(void * obj,
             GC_dirty(GC_fnlz_roots.fo_head + index);
           UNLOCK();
 #         ifndef DBG_HDRS_ALL
-            if (EXPECT(new_fo != 0, FALSE)) {
               /* Free unused new_fo returned by GC_oom_fn() */
               GC_free((void *)new_fo);
-            }
 #         endif
           return;
         }