From cf5b9c00a56fe64ef87d7f4fd0f81e3a50106de8 Mon Sep 17 00:00:00 2001 From: Grahame White <57143548+Grahame-student@users.noreply.github.com> Date: Fri, 5 Mar 2021 16:28:24 +0000 Subject: [PATCH 1/3] Update ExtremeC_examples_chapter8_3_person.c Free the memory the person pointer is pointing at. Otherwise when student_dtor() calls person_dtor() the memory will not be released, resulting in a memory leak --- .../ExtremeC_examples_chapter8_3_person.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ch08-inheritance-and-polymorphism/ExtremeC_examples_chapter8_3_person.c b/ch08-inheritance-and-polymorphism/ExtremeC_examples_chapter8_3_person.c index 16704cb..4f6bfb8 100644 --- a/ch08-inheritance-and-polymorphism/ExtremeC_examples_chapter8_3_person.c +++ b/ch08-inheritance-and-polymorphism/ExtremeC_examples_chapter8_3_person.c @@ -28,7 +28,7 @@ void person_ctor(person_t* person, // Destructor void person_dtor(person_t* person) { - // Nothing to do + free(person); } // Behavior functions From 7188aa5af06fe8270446df1827b2438a238849ab Mon Sep 17 00:00:00 2001 From: Grahame White <57143548+Grahame-student@users.noreply.github.com> Date: Fri, 5 Mar 2021 16:37:06 +0000 Subject: [PATCH 2/3] Revert "Update ExtremeC_examples_chapter8_3_person.c" --- .../ExtremeC_examples_chapter8_3_person.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ch08-inheritance-and-polymorphism/ExtremeC_examples_chapter8_3_person.c b/ch08-inheritance-and-polymorphism/ExtremeC_examples_chapter8_3_person.c index 4f6bfb8..16704cb 100644 --- a/ch08-inheritance-and-polymorphism/ExtremeC_examples_chapter8_3_person.c +++ b/ch08-inheritance-and-polymorphism/ExtremeC_examples_chapter8_3_person.c @@ -28,7 +28,7 @@ void person_ctor(person_t* person, // Destructor void person_dtor(person_t* person) { - free(person); + // Nothing to do } // Behavior functions From b5fa8c6575147e095d8e72b829f08d04b9d4e2e2 Mon Sep 17 00:00:00 2001 From: Grahame White <57143548+Grahame-student@users.noreply.github.com> Date: Fri, 5 Mar 2021 16:38:17 +0000 Subject: [PATCH 3/3] Update ExtremeC_examples_chapter8_2_person.c --- .../ExtremeC_examples_chapter8_2_person.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ch08-inheritance-and-polymorphism/ExtremeC_examples_chapter8_2_person.c b/ch08-inheritance-and-polymorphism/ExtremeC_examples_chapter8_2_person.c index 4e8b5db..3fa912c 100644 --- a/ch08-inheritance-and-polymorphism/ExtremeC_examples_chapter8_2_person.c +++ b/ch08-inheritance-and-polymorphism/ExtremeC_examples_chapter8_2_person.c @@ -24,7 +24,7 @@ void person_ctor(person_t* person, // Destructor void person_dtor(person_t* person) { - // Nothing to do + free(person); } // Behavior functions