Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Unity-Technologies/bdwgc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2016-10-04 23:27:53 +0300
committerIvan Maidanski <ivmai@mail.ru>2016-10-04 23:27:53 +0300
commit03bb5fb61138482085be2330c4da9491a081ec52 (patch)
tree35e44a0858e5532f68b7609ced2e3bc14f865558 /alloc.c
parente248d685833a498e7dc0938bca47f08dfa611cd5 (diff)
Eliminate more 'scope of variable can be reduced' cppcheck style warnings
* allchblk.c (GC_compute_large_free_bytes, GC_print_hblkfreelist, free_list_index_of, GC_dump_regions, GC_add_to_fl, GC_unmap_old, GC_allochblk_nth): Move local variable declaration to the inner scope where the variable is actually used. * alloc.c (GC_maybe_gc, GC_collect_a_little_inner, GC_set_fl_marks, GC_clear_fl_marks): Likewise. * dyn_load.c (GC_register_dynamic_libraries): Likewise. * finalize.c (GC_ignore_self_finalize_mark_proc, GC_register_finalizer_inner, GC_dump_finalization_links, GC_dump_finalization, GC_make_disappearing_links_disappear, GC_remove_dangling_disappearing_links, GC_invoke_finalizers): Likewise. * headers.c (GC_install_counts): Likewise. * malloc.c (GC_malloc_kind_global, GC_generic_malloc_uncollectable, GC_free): Likewise. * mark.c (GC_push_all_eager, GC_push_marked1, GC_push_marked2, GC_push_marked4): Likewise. * mark_rts.c (GC_next_exclusion, GC_exclude_static_roots_inner, GC_push_conditional_with_exclusions): Likewise. * misc.c (GC_base, GC_parse_mem_size_arg, GC_write): Likewise. * os_dep.c (GC_repeat_read, GC_get_maps, GC_least_described_address, GC_register_root_section, GC_register_data_segments): Likewise. * reclaim.c (GC_reclaim_block, GC_start_reclaim): Likewise. * finalize.c (ITERATE_DL_HASHTBL_BEGIN): Declare prev_dl local variable.
Diffstat (limited to 'alloc.c')
-rw-r--r--alloc.c59
1 files changed, 26 insertions, 33 deletions
diff --git a/alloc.c b/alloc.c
index d3f5943e..a5dc6778 100644
--- a/alloc.c
+++ b/alloc.c
@@ -356,11 +356,11 @@ STATIC void GC_finish_collection(void);
*/
STATIC void GC_maybe_gc(void)
{
- static int n_partial_gcs = 0;
-
GC_ASSERT(I_HOLD_LOCK());
ASSERT_CANCEL_DISABLED();
if (GC_should_collect()) {
+ static int n_partial_gcs = 0;
+
if (!GC_incremental) {
/* FIXME: If possible, GC_default_stop_func should be used here */
GC_try_to_collect_inner(GC_never_stop_func);
@@ -532,12 +532,13 @@ STATIC int GC_deficit = 0;/* The number of extra calls to GC_mark_some */
GC_INNER void GC_collect_a_little_inner(int n)
{
- int i;
IF_CANCEL(int cancel_state;)
if (GC_dont_gc) return;
DISABLE_CANCEL(cancel_state);
if (GC_incremental && GC_collection_in_progress()) {
+ int i;
+
for (i = GC_deficit; i < GC_RATE*n; i++) {
if (GC_mark_some((ptr_t)0)) {
/* Need to finish a collection */
@@ -762,19 +763,15 @@ STATIC GC_bool GC_stopped_mark(GC_stop_func stop_func)
/* Set all mark bits for the free list whose first entry is q */
GC_INNER void GC_set_fl_marks(ptr_t q)
{
- struct hblk *h, *last_h;
- hdr *hhdr;
- IF_PER_OBJ(size_t sz;)
- unsigned bit_no;
-
- if (q != NULL) {
- h = HBLKPTR(q);
- last_h = h;
- hhdr = HDR(h);
- IF_PER_OBJ(sz = hhdr->hb_sz;)
-
- for (;;) {
- bit_no = MARK_BIT_NO((ptr_t)q - (ptr_t)h, sz);
+ if (q != NULL) {
+ struct hblk *h = HBLKPTR(q);
+ struct hblk *last_h = h;
+ hdr *hhdr = HDR(h);
+ IF_PER_OBJ(size_t sz = hhdr->hb_sz;)
+
+ for (;;) {
+ unsigned bit_no = MARK_BIT_NO((ptr_t)q - (ptr_t)h, sz);
+
if (!mark_bit_from_hdr(hhdr, bit_no)) {
set_mark_bit_from_hdr(hhdr, bit_no);
++hhdr -> hb_n_marks;
@@ -790,8 +787,8 @@ GC_INNER void GC_set_fl_marks(ptr_t q)
hhdr = HDR(h);
IF_PER_OBJ(sz = hhdr->hb_sz;)
}
- }
- }
+ }
+ }
}
#if defined(GC_ASSERTIONS) && defined(THREADS) && defined(THREAD_LOCAL_ALLOC)
@@ -840,19 +837,15 @@ GC_INNER void GC_set_fl_marks(ptr_t q)
/* Decrement GC_bytes_found by number of bytes on free list. */
STATIC void GC_clear_fl_marks(ptr_t q)
{
- struct hblk *h, *last_h;
- hdr *hhdr;
- size_t sz;
- unsigned bit_no;
-
- if (q != NULL) {
- h = HBLKPTR(q);
- last_h = h;
- hhdr = HDR(h);
- sz = hhdr->hb_sz; /* Normally set only once. */
-
- for (;;) {
- bit_no = MARK_BIT_NO((ptr_t)q - (ptr_t)h, sz);
+ if (q != NULL) {
+ struct hblk *h = HBLKPTR(q);
+ struct hblk *last_h = h;
+ hdr *hhdr = HDR(h);
+ size_t sz = hhdr->hb_sz; /* Normally set only once. */
+
+ for (;;) {
+ unsigned bit_no = MARK_BIT_NO((ptr_t)q - (ptr_t)h, sz);
+
if (mark_bit_from_hdr(hhdr, bit_no)) {
size_t n_marks = hhdr -> hb_n_marks - 1;
clear_mark_bit_from_hdr(hhdr, bit_no);
@@ -877,8 +870,8 @@ STATIC void GC_clear_fl_marks(ptr_t q)
hhdr = HDR(h);
sz = hhdr->hb_sz;
}
- }
- }
+ }
+ }
}
#if defined(GC_ASSERTIONS) && defined(THREADS) && defined(THREAD_LOCAL_ALLOC)