summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2022-10-20 00:33:18 +0300
committerIvan Maidanski <ivmai@mail.ru>2022-10-20 00:40:08 +0300
commit16260f977ff75d60f547e2ffb9522a475e38a4da (patch)
tree5c47515f6f3421e7cdcd3e76d5ca0f6cdbf86c62
parent94d3d5cbb1face170c5687013184937c2efc9a5f (diff)
downloadbdwgc-16260f977ff75d60f547e2ffb9522a475e38a4da.tar.gz
Eliminate 'parameter can be declared as const pointer' cppcheck warnings
(refactoring) * allchblk.c (free_list_index_of): Add const to pointer argument. * backgraph.c (is_in_progress): Likewise. * include/private/gc_priv.h [MSWIN32 || MSWINCE || CYGWIN32] (GC_is_heap_base): Likewise. * os_dep.c [USE_WINALLOC && !REDIRECT_MALLOC] (GC_is_malloc_heap_base): Likewise. * os_dep.c [MSWIN32 || MSWINCE || CYGWIN32] (GC_is_heap_base): Likewise. * os_dep.c [CHECKSUMS && (GWW_VDB || SOFT_VDB) || PROC_VDB] (GC_or_pages): Likewise. * finalize.c (GC_grow_table): Add const to entries_ptr argument. * os_dep.c [USE_WINALLOC && !REDIRECT_MALLOC] (GC_is_malloc_heap_base): Change while loop to for.
-rw-r--r--allchblk.c2
-rw-r--r--backgraph.c2
-rw-r--r--finalize.c2
-rw-r--r--include/private/gc_priv.h2
-rw-r--r--os_dep.c11
5 files changed, 9 insertions, 10 deletions
diff --git a/allchblk.c b/allchblk.c
index 81c5af89..a0a3f313 100644
--- a/allchblk.c
+++ b/allchblk.c
@@ -164,7 +164,7 @@ STATIC int GC_hblk_fl_from_blocks(word blocks_needed)
/* Return the free list index on which the block described by the header */
/* appears, or -1 if it appears nowhere. */
-static int free_list_index_of(hdr *wanted)
+static int free_list_index_of(const hdr *wanted)
{
int i;
diff --git a/backgraph.c b/backgraph.c
index f45eb505..6eac9c8e 100644
--- a/backgraph.c
+++ b/backgraph.c
@@ -166,7 +166,7 @@ static void push_in_progress(ptr_t p)
in_progress_space[n_in_progress++] = p;
}
-static GC_bool is_in_progress(ptr_t p)
+static GC_bool is_in_progress(const char *p)
{
size_t i;
for (i = 0; i < n_in_progress; ++i) {
diff --git a/finalize.c b/finalize.c
index a8e0ad4a..1dac0ec9 100644
--- a/finalize.c
+++ b/finalize.c
@@ -91,7 +91,7 @@ GC_API void GC_CALL GC_push_finalizer_structures(void)
/* current size. May be a no-op. *table is a pointer to an array of */
/* hash headers. We update both *table and *log_size_ptr on success. */
STATIC void GC_grow_table(struct hash_chain_entry ***table,
- unsigned *log_size_ptr, word *entries_ptr)
+ unsigned *log_size_ptr, const word *entries_ptr)
{
word i;
struct hash_chain_entry *p;
diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h
index 0188bc28..99bfbc9a 100644
--- a/include/private/gc_priv.h
+++ b/include/private/gc_priv.h
@@ -1777,7 +1777,7 @@ GC_EXTERN size_t GC_page_size;
#if defined(MSWIN32) || defined(MSWINCE) || defined(CYGWIN32)
GC_EXTERN SYSTEM_INFO GC_sysinfo;
- GC_INNER GC_bool GC_is_heap_base(void *p);
+ GC_INNER GC_bool GC_is_heap_base(const void *p);
#endif
GC_EXTERN word GC_black_list_spacing;
diff --git a/os_dep.c b/os_dep.c
index de7ccc20..b5e5ba4d 100644
--- a/os_dep.c
+++ b/os_dep.c
@@ -1826,13 +1826,12 @@ void GC_register_data_segments(void)
/* Is p the base of one of the malloc heap sections we already know */
/* about? */
- STATIC GC_bool GC_is_malloc_heap_base(void *p)
+ STATIC GC_bool GC_is_malloc_heap_base(const void *p)
{
- struct GC_malloc_heap_list *q = GC_malloc_heap_l;
+ struct GC_malloc_heap_list *q;
- while (0 != q) {
+ for (q = GC_malloc_heap_l; q != NULL; q = q -> next) {
if (q -> allocation_base == p) return TRUE;
- q = q -> next;
}
return FALSE;
}
@@ -1901,7 +1900,7 @@ void GC_register_data_segments(void)
/* Is p the start of either the malloc heap, or of one of our */
/* heap sections? */
- GC_INNER GC_bool GC_is_heap_base(void *p)
+ GC_INNER GC_bool GC_is_heap_base(const void *p)
{
int i;
@@ -2946,7 +2945,7 @@ GC_API GC_push_other_roots_proc GC_CALL GC_get_push_other_roots(void)
#if (defined(CHECKSUMS) && (defined(GWW_VDB) || defined(SOFT_VDB))) \
|| defined(PROC_VDB)
/* Add all pages in pht2 to pht1. */
- STATIC void GC_or_pages(page_hash_table pht1, page_hash_table pht2)
+ STATIC void GC_or_pages(page_hash_table pht1, const word *pht2)
{
unsigned i;
for (i = 0; i < PHT_SIZE; i++) pht1[i] |= pht2[i];