Skip to content
Snippets Groups Projects
Commit 54be2062 authored by Dor Laor's avatar Dor Laor
Browse files

Use a free_deleter for unique_prt

There was a bug caused by calling um.get() in the destructor
still left the unique_ptr armed with the pointer. Using free_deleter
is cleaner and works too.
parent ce35ec3f
No related branches found
No related tags found
No related merge requests found
...@@ -184,10 +184,13 @@ namespace virtio { ...@@ -184,10 +184,13 @@ namespace virtio {
struct virtio_net_req { struct virtio_net_req {
struct virtio_net::virtio_net_hdr hdr; struct virtio_net::virtio_net_hdr hdr;
sglist payload; sglist payload;
std::unique_ptr<struct mbuf> um; struct free_deleter {
void operator()(struct mbuf *m) {m_freem(m);}
};
std::unique_ptr<struct mbuf, free_deleter> um;
virtio_net_req() {memset(&hdr,0,sizeof(hdr));}; virtio_net_req() {memset(&hdr,0,sizeof(hdr));};
~virtio_net_req() {if (um) m_freem(um.get());}
}; };
void virtio_net::receiver() { void virtio_net::receiver() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment