[Spice-devel,spice-server,01/20] add a red_memslot_info_destroy function

Submitted by Frediano Ziglio on Nov. 24, 2016, 5:38 p.m.

Details

Message ID 20161124173907.3341-2-fziglio@redhat.com
State New
Headers show
Series "Start cleaning objects on destruction" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Frediano Ziglio Nov. 24, 2016, 5:38 p.m.
Allows to free RedMemSlotInfo structure

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
---
 server/memslot.c | 10 ++++++++++
 server/memslot.h |  1 +
 2 files changed, 11 insertions(+)

Patch hide | download patch | download mbox

diff --git a/server/memslot.c b/server/memslot.c
index 75cb75f..fdcd023 100644
--- a/server/memslot.c
+++ b/server/memslot.c
@@ -166,6 +166,16 @@  void memslot_info_init(RedMemSlotInfo *info,
                                        (info->mem_slot_bits + info->generation_bits));
 }
 
+void memslot_info_destroy(RedMemSlotInfo *info)
+{
+    uint32_t i;
+
+    for (i = 0; i < info->num_memslots_groups; ++i) {
+        free(info->mem_slots[i]);
+    }
+    free(info->mem_slots);
+}
+
 void memslot_info_add_slot(RedMemSlotInfo *info, uint32_t slot_group_id, uint32_t slot_id,
                            uint64_t addr_delta, unsigned long virt_start, unsigned long virt_end,
                            uint32_t generation)
diff --git a/server/memslot.h b/server/memslot.h
index 5046d0f..71f1210 100644
--- a/server/memslot.h
+++ b/server/memslot.h
@@ -66,6 +66,7 @@  void memslot_info_init(RedMemSlotInfo *info,
                        uint8_t generation_bits,
                        uint8_t id_bits,
                        uint8_t internal_groupslot_id);
+void memslot_info_destroy(RedMemSlotInfo *info);
 void memslot_info_add_slot(RedMemSlotInfo *info, uint32_t slot_group_id, uint32_t slot_id,
                            uint64_t addr_delta, unsigned long virt_start, unsigned long virt_end,
                            uint32_t generation);

Comments

I prefer commits where a symbol is introduced and used.
In this case the destroy function can be used in the qxl parsing test.

Ack with ^

Pavel

On Thu, 2016-11-24 at 17:38 +0000, Frediano Ziglio wrote:
> Allows to free RedMemSlotInfo structure
> 
> Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
> ---
>  server/memslot.c | 10 ++++++++++
>  server/memslot.h |  1 +
>  2 files changed, 11 insertions(+)
> 
> diff --git a/server/memslot.c b/server/memslot.c
> index 75cb75f..fdcd023 100644
> --- a/server/memslot.c
> +++ b/server/memslot.c
> @@ -166,6 +166,16 @@ void memslot_info_init(RedMemSlotInfo *info,
>                                         (info->mem_slot_bits + info-
> >generation_bits));
>  }
>  
> +void memslot_info_destroy(RedMemSlotInfo *info)
> +{
> +    uint32_t i;
> +
> +    for (i = 0; i < info->num_memslots_groups; ++i) {
> +        free(info->mem_slots[i]);
> +    }
> +    free(info->mem_slots);
> +}
> +
>  void memslot_info_add_slot(RedMemSlotInfo *info, uint32_t
> slot_group_id, uint32_t slot_id,
>                             uint64_t addr_delta, unsigned long
> virt_start, unsigned long virt_end,
>                             uint32_t generation)
> diff --git a/server/memslot.h b/server/memslot.h
> index 5046d0f..71f1210 100644
> --- a/server/memslot.h
> +++ b/server/memslot.h
> @@ -66,6 +66,7 @@ void memslot_info_init(RedMemSlotInfo *info,
>                         uint8_t generation_bits,
>                         uint8_t id_bits,
>                         uint8_t internal_groupslot_id);
> +void memslot_info_destroy(RedMemSlotInfo *info);
>  void memslot_info_add_slot(RedMemSlotInfo *info, uint32_t
> slot_group_id, uint32_t slot_id,
>                             uint64_t addr_delta, unsigned long
> virt_start, unsigned long virt_end,
>                             uint32_t generation);