diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2018-05-16 11:49:33 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2018-05-16 11:49:33 +0300 |
commit | 888b7da8d2c504ab0f5d0163a58c6e29f5f86f22 (patch) | |
tree | fcbe14b37317db284d7d2b352013777e3e82b913 /typd_mlc.c | |
parent | e7ba62e0de0d0c42c3732c7b7e82a92e679648a9 (diff) | |
download | bdwgc-888b7da8d2c504ab0f5d0163a58c6e29f5f86f22.tar.gz |
Remove code duplication in gcj_malloc and malloc_explicitly_typed
(code refactoring)
* gcj_mlc.c [GC_GCJ_SUPPORT] (GC_gcj_malloc): Store
ptr_to_struct_containing_descr in a single place of code.
* typd_mlc.c (GC_malloc_explicitly_typed_ignore_off_page): Store d (to
the object) in a single place of code.
Diffstat (limited to 'typd_mlc.c')
-rw-r--r-- | typd_mlc.c | 16 |
1 files changed, 7 insertions, 9 deletions
@@ -636,15 +636,13 @@ GC_API GC_ATTR_MALLOC void * GC_CALL GC_bytes_allocd += GRANULES_TO_BYTES((word)lg); UNLOCK(); } - ((word *)op)[GRANULES_TO_WORDS(lg) - 1] = d; - } else { - op = (ptr_t)GENERAL_MALLOC_IOP(lb, GC_explicit_kind); - if (op != NULL) { - lg = BYTES_TO_GRANULES(GC_size(op)); - ((word *)op)[GRANULES_TO_WORDS(lg) - 1] = d; - } - } - return op; + } else { + op = (ptr_t)GENERAL_MALLOC_IOP(lb, GC_explicit_kind); + if (NULL == op) return NULL; + lg = BYTES_TO_GRANULES(GC_size(op)); + } + ((word *)op)[GRANULES_TO_WORDS(lg) - 1] = d; + return op; } GC_API GC_ATTR_MALLOC void * GC_CALL GC_calloc_explicitly_typed(size_t n, |