From dcdf8605d3aa867c2cdf80065da5d6aa7ed2817a Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Thu, 1 Apr 2010 17:45:26 +0300 Subject: [PATCH] kvm: Free memory on exit Free memory on exit so that valgrind reports are easier to read. Signed-off-by: Pekka Enberg --- tools/kvm/include/kvm/kvm.h | 1 + tools/kvm/kvm.c | 6 ++++++ tools/kvm/main.c | 2 ++ 3 files changed, 9 insertions(+) diff --git a/tools/kvm/include/kvm/kvm.h b/tools/kvm/include/kvm/kvm.h index f20988ac3e3e..f8101f9df165 100644 --- a/tools/kvm/include/kvm/kvm.h +++ b/tools/kvm/include/kvm/kvm.h @@ -31,6 +31,7 @@ struct kvm { }; struct kvm *kvm__init(void); +void kvm__delete(struct kvm *self); void kvm__setup_cpuid(struct kvm *self); void kvm__enable_singlestep(struct kvm *self); bool kvm__load_kernel(struct kvm *kvm, const char *kernel_filename, const char *kernel_cmdline); diff --git a/tools/kvm/kvm.c b/tools/kvm/kvm.c index e22c46eeb511..142b1265bab9 100644 --- a/tools/kvm/kvm.c +++ b/tools/kvm/kvm.c @@ -88,6 +88,12 @@ static struct kvm *kvm__new(void) return self; } +void kvm__delete(struct kvm *self) +{ + free(self->ram_start); + free(self); +} + struct kvm *kvm__init(void) { struct kvm_userspace_memory_region mem; diff --git a/tools/kvm/main.c b/tools/kvm/main.c index 402d76940c8b..aa25bd81ebdb 100644 --- a/tools/kvm/main.c +++ b/tools/kvm/main.c @@ -92,5 +92,7 @@ exit_kvm: kvm__show_registers(kvm); kvm__show_code(kvm); + kvm__delete(kvm); + return 0; } -- 2.39.5