diff options
| author | Paul Eggert | 2019-03-11 08:20:54 -0700 |
|---|---|---|
| committer | Paul Eggert | 2019-03-11 08:21:41 -0700 |
| commit | 93c0527a6afbdd5228ff5590d03a35f738a47d18 (patch) | |
| tree | bd332905ea335f461e7071fc18357621a538b74d /src | |
| parent | 95373b69b34f9756d2f05b19798b763d22aa5f0a (diff) | |
| download | emacs-93c0527a6afbdd5228ff5590d03a35f738a47d18.tar.gz emacs-93c0527a6afbdd5228ff5590d03a35f738a47d18.zip | |
Fix a small pdumper memory leak
* src/pdumper.c (dump_mmap_reset): Free the private area here ...
(dump_mm_heap_cb_release): ... instead of here.
(dump_mmap_release_heap): Simplify by avoiding a local.
(dump_mmap_contiguous): Reindent GNU style.
Diffstat (limited to 'src')
| -rw-r--r-- | src/pdumper.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/pdumper.c b/src/pdumper.c index dd272a0389d..36a06d98288 100644 --- a/src/pdumper.c +++ b/src/pdumper.c | |||
| @@ -1950,7 +1950,7 @@ dump_field_fixup_later (struct dump_context *ctx, | |||
| 1950 | const void *in_start, | 1950 | const void *in_start, |
| 1951 | const void *in_field) | 1951 | const void *in_field) |
| 1952 | { | 1952 | { |
| 1953 | // TODO: more error checking | 1953 | /* TODO: more error checking. */ |
| 1954 | (void) field_relpos (in_start, in_field); | 1954 | (void) field_relpos (in_start, in_field); |
| 1955 | } | 1955 | } |
| 1956 | 1956 | ||
| @@ -2067,7 +2067,7 @@ dump_interval_tree (struct dump_context *ctx, | |||
| 2067 | #if CHECK_STRUCTS && !defined (HASH_interval_1B38941C37) | 2067 | #if CHECK_STRUCTS && !defined (HASH_interval_1B38941C37) |
| 2068 | # error "interval changed. See CHECK_STRUCTS comment." | 2068 | # error "interval changed. See CHECK_STRUCTS comment." |
| 2069 | #endif | 2069 | #endif |
| 2070 | // TODO: output tree breadth-first? | 2070 | /* TODO: output tree breadth-first? */ |
| 2071 | struct interval out; | 2071 | struct interval out; |
| 2072 | dump_object_start (ctx, &out, sizeof (out)); | 2072 | dump_object_start (ctx, &out, sizeof (out)); |
| 2073 | DUMP_FIELD_COPY (&out, tree, total_length); | 2073 | DUMP_FIELD_COPY (&out, tree, total_length); |
| @@ -4100,7 +4100,7 @@ types. */) | |||
| 4100 | /* We want to consolidate certain object types that we know are very likely | 4100 | /* We want to consolidate certain object types that we know are very likely |
| 4101 | to be modified. */ | 4101 | to be modified. */ |
| 4102 | ctx->flags.defer_hash_tables = true; | 4102 | ctx->flags.defer_hash_tables = true; |
| 4103 | // ctx->flags.defer_symbols = true; XXX | 4103 | /* ctx->flags.defer_symbols = true; XXX */ |
| 4104 | 4104 | ||
| 4105 | /* These objects go into special sections. */ | 4105 | /* These objects go into special sections. */ |
| 4106 | ctx->flags.defer_cold_objects = true; | 4106 | ctx->flags.defer_cold_objects = true; |
| @@ -4701,7 +4701,9 @@ dump_mmap_reset (struct dump_memory_map *map) | |||
| 4701 | { | 4701 | { |
| 4702 | map->mapping = NULL; | 4702 | map->mapping = NULL; |
| 4703 | map->release = NULL; | 4703 | map->release = NULL; |
| 4704 | void *private = map->private; | ||
| 4704 | map->private = NULL; | 4705 | map->private = NULL; |
| 4706 | free (private); | ||
| 4705 | } | 4707 | } |
| 4706 | 4708 | ||
| 4707 | static void | 4709 | static void |
| @@ -4723,17 +4725,13 @@ dump_mm_heap_cb_release (struct dump_memory_map_heap_control_block *cb) | |||
| 4723 | { | 4725 | { |
| 4724 | eassert (cb->refcount > 0); | 4726 | eassert (cb->refcount > 0); |
| 4725 | if (--cb->refcount == 0) | 4727 | if (--cb->refcount == 0) |
| 4726 | { | 4728 | free (cb->mem); |
| 4727 | free (cb->mem); | ||
| 4728 | free (cb); | ||
| 4729 | } | ||
| 4730 | } | 4729 | } |
| 4731 | 4730 | ||
| 4732 | static void | 4731 | static void |
| 4733 | dump_mmap_release_heap (struct dump_memory_map *map) | 4732 | dump_mmap_release_heap (struct dump_memory_map *map) |
| 4734 | { | 4733 | { |
| 4735 | struct dump_memory_map_heap_control_block *cb = map->private; | 4734 | dump_mm_heap_cb_release (map->private); |
| 4736 | dump_mm_heap_cb_release (cb); | ||
| 4737 | } | 4735 | } |
| 4738 | 4736 | ||
| 4739 | /* Implement dump_mmap using malloc and read. */ | 4737 | /* Implement dump_mmap using malloc and read. */ |
| @@ -4932,9 +4930,7 @@ dump_mmap_contiguous ( | |||
| 4932 | total_size += maps[i].spec.size; | 4930 | total_size += maps[i].spec.size; |
| 4933 | } | 4931 | } |
| 4934 | 4932 | ||
| 4935 | return (VM_SUPPORTED ? | 4933 | return (VM_SUPPORTED ? dump_mmap_contiguous_vm : dump_mmap_contiguous_heap) |
| 4936 | dump_mmap_contiguous_vm : | ||
| 4937 | dump_mmap_contiguous_heap) | ||
| 4938 | (maps, nr_maps, total_size); | 4934 | (maps, nr_maps, total_size); |
| 4939 | } | 4935 | } |
| 4940 | 4936 | ||