# HG changeset patch # User Paul Boddie # Date 1677953007 -3600 # Node ID 0acb88011ba2084e54d993ceaa2fab34afe07775 # Parent 1175ee059120ae089d491eb0c5678e6e744889cf Added close method and resource deallocation. diff -r 1175ee059120 -r 0acb88011ba2 libexec/include/exec/internal_pager.h --- a/libexec/include/exec/internal_pager.h Sat Mar 04 19:02:34 2023 +0100 +++ b/libexec/include/exec/internal_pager.h Sat Mar 04 19:03:27 2023 +0100 @@ -42,6 +42,10 @@ virtual void *interface() { return static_cast(this); } + /* Resource methods. */ + + virtual void close(); + /* Notification methods, implementing PagerObject. */ virtual long exception(l4_exc_regs_t regs, diff -r 1175ee059120 -r 0acb88011ba2 libexec/lib/src/internal_pager.cc --- a/libexec/lib/src/internal_pager.cc Sat Mar 04 19:02:34 2023 +0100 +++ b/libexec/lib/src/internal_pager.cc Sat Mar 04 19:03:27 2023 +0100 @@ -23,6 +23,7 @@ #include #include +#include #include #include @@ -52,6 +53,27 @@ +/* Close the pager. */ + +void InternalPager::close() +{ + printf("Internal pager closing...\n"); + + /* Unmap all regions. */ + + MappedRegions::iterator it; + + for (it = _regions.begin(); it != _regions.end(); it++) + { + MappedRegion &r = it->second; + + printf("Free %lx\n", r.ds); + ipc_cap_free_um(r.ds); + } +} + + + /* Handle a general exception. */ long InternalPager::exception(l4_exc_regs_t regs, l4_snd_fpage_t *region)