diff options
author | Jan Kiszka <jan.kiszka@siemens.com> | 2012-02-29 19:14:23 +0100 |
---|---|---|
committer | Jan Kiszka <jan.kiszka@siemens.com> | 2012-03-13 14:05:49 +0100 |
commit | a68adc220603baffc355ecea8865b3ea9707ab00 (patch) | |
tree | f2f2c89ddcae603aff1cb0bd44ab169f4d06f4c4 /slirp/mbuf.c | |
parent | f37343197708d90f119007ce5ecc2503be9c04c1 (diff) |
slirp: Cleanup resources on instance removal
Close & free sockets when shutting down a slirp instance, also release
all buffers.
CC: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Diffstat (limited to 'slirp/mbuf.c')
-rw-r--r-- | slirp/mbuf.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/slirp/mbuf.c b/slirp/mbuf.c index c699c75096..4fefb043bf 100644 --- a/slirp/mbuf.c +++ b/slirp/mbuf.c @@ -32,6 +32,27 @@ m_init(Slirp *slirp) slirp->m_usedlist.m_next = slirp->m_usedlist.m_prev = &slirp->m_usedlist; } +void m_cleanup(Slirp *slirp) +{ + struct mbuf *m, *next; + + m = slirp->m_usedlist.m_next; + while (m != &slirp->m_usedlist) { + next = m->m_next; + if (m->m_flags & M_EXT) { + free(m->m_ext); + } + free(m); + m = next; + } + m = slirp->m_freelist.m_next; + while (m != &slirp->m_freelist) { + next = m->m_next; + free(m); + m = next; + } +} + /* * Get an mbuf from the free list, if there are none * malloc one |