diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2016-12-22 11:05:41 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2016-12-22 11:05:41 +0300 |
commit | fde97b79c8681ef27bd731ef42766589ce892e66 (patch) | |
tree | 7e0d7fc176c4104f4116e7618ceb2b9f2e4d8f75 /dyn_load.c | |
parent | 495b4fe5c2ee1767f20c8db7ec42a2c1ad04737c (diff) | |
download | bdwgc-fde97b79c8681ef27bd731ef42766589ce892e66.tar.gz |
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).
Diffstat (limited to 'dyn_load.c')
-rw-r--r-- | dyn_load.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -816,6 +816,8 @@ GC_INNER void GC_register_dynamic_libraries(void) ": fd = %d, errno = %d", fd, errno); } if (needed_sz >= current_sz) { + GC_scratch_recycle_no_gww(addr_map, + (size_t)current_sz * sizeof(prmap_t)); current_sz = needed_sz * 2 + 1; /* Expansion, plus room for 0 record */ addr_map = (prmap_t *)GC_scratch_alloc( |