diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2019-09-11 01:11:04 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2019-09-11 01:11:04 +0300 |
commit | a20818be9ec660588af325d82e515ebb75bd9905 (patch) | |
tree | cf0766e19fa5ee4380f2236ab4bf088b7cd5d330 /reclaim.c | |
parent | fe3a50824e878995999462843aff679d52e9f61b (diff) | |
download | bdwgc-a20818be9ec660588af325d82e515ebb75bd9905.tar.gz |
Workaround 'argument to function is always 1' cppcheck false positives
* allchblk.c (GC_print_hblkfreelist): Replace "while(p!=0)" with
"while(p)"; add a marker that the change is for cppcheck.
* allchblk.c (GC_free_block_ending_at, GC_add_to_fl, GC_split_block,
GC_allochblk_nth, GC_freehblk): Replace "if(p!=0)" with "if(p)".
* alloc.c (GC_set_fl_marks): Likewise.
* extra/MacOS.c (GC_MacFreeTemporaryMemory): Likewise.
* mallocx.c (GC_generic_malloc_many): Likewise.
* allchblk.c (GC_allochblk_nth): Replace "if(0==p)" with "if(p){}else".
* malloc.c (GC_free): Likewise.
* malloc.c (GC_generic_malloc_uncollectable): Replace
"if(0==p)return 0;<code>;return p;" with "if(p){<code>}return p;".
* mallocx.c (GC_generic_malloc_many): Replace "p+=v;while((p2=*p)!=0)"
with "for(p+=v;(p2=*p)!=0;)".
* reclaim.c (GC_continue_reclaim, GC_reclaim_all): Likewise.
Diffstat (limited to 'reclaim.c')
-rw-r--r-- | reclaim.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -710,9 +710,10 @@ GC_INNER void GC_continue_reclaim(word sz /* granules */, int kind) struct hblk ** rlh = ok -> ok_reclaim_list; void **flh = &(ok -> ok_freelist[sz]); - if (rlh == 0) return; /* No blocks of this kind. */ - rlh += sz; - while ((hbp = *rlh) != 0) { + if (NULL == rlh) + return; /* No blocks of this kind. */ + + for (rlh += sz; (hbp = *rlh) != NULL; ) { hhdr = HDR(hbp); *rlh = hhdr -> hb_next; GC_reclaim_small_nonempty_block(hbp, hhdr -> hb_sz, FALSE); @@ -751,8 +752,7 @@ GC_INNER GC_bool GC_reclaim_all(GC_stop_func stop_func, GC_bool ignore_old) rlp = ok -> ok_reclaim_list; if (rlp == 0) continue; for (sz = 1; sz <= MAXOBJGRANULES; sz++) { - rlh = rlp + sz; - while ((hbp = *rlh) != 0) { + for (rlh = rlp + sz; (hbp = *rlh) != NULL; ) { if (stop_func != (GC_stop_func)0 && (*stop_func)()) { return(FALSE); } |