Eliminate 'memory leak' code defect for scratch-allocated memory
authorIvan Maidanski <ivmai@mail.ru>
Thu, 22 Dec 2016 08:05:41 +0000 (11:05 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Thu, 22 Dec 2016 08:05:41 +0000 (11:05 +0300)
commitfde97b79c8681ef27bd731ef42766589ce892e66
tree7e0d7fc176c4104f4116e7618ceb2b9f2e4d8f75
parent495b4fe5c2ee1767f20c8db7ec42a2c1ad04737c
Eliminate 'memory leak' code defect for scratch-allocated memory

Reuse memory allocated by GC_scratch_alloc and GET_MEM in GC heap
if possible.

* backgraph.c (push_in_progress): Replace in_progress_size==0 with
in_progress_space==NULL (to ensure BCOPY argument is non-NULL);
eliminate code duplication regarding GC_add_to_our_memory call;
call GC_scratch_recycle_no_gww (for old in_progress_space value) unless
GWW_VDB (and remove corresponding FIXME).
* dyn_load.c [IRIX5 || USE_PROC_FOR_LIBRARIES && !LINUX]
(GC_register_dynamic_libraries): Call GC_scratch_recycle_no_gww (for
old addr_map and current_sz values).
* include/private/gc_priv.h [!GWW_VDB] (GC_scratch_recycle_no_gww): New
internal macro.
* include/private/gc_priv.h (GC_scratch_recycle_inner): New prototype.
* mark.c (GC_scratch_recycle_inner): New function (move code portion
from alloc_mark_stack).
* mark.c (alloc_mark_stack): Call GC_scratch_recycle_inner (if
recycle_old).
* os_dep.c [NEED_PROC_MAPS] (GC_get_maps): Call GC_scratch_recycle_no_gww
(for old maps_buf and maps_buf_sz values).
* os_dep.c [PROC_VDB] (GC_read_dirty): Call GC_scratch_recycle_no_gww
(for old GC_proc_buf and GC_proc_buf_size values).
backgraph.c
dyn_load.c
include/private/gc_priv.h
mark.c
os_dep.c