vppinfra: introduce clib_mem_vm_ext_free() to avoid fd leaks
[vpp.git] / src / vppinfra / linux / mem.c
index bceb3b2..2d968fa 100644 (file)
@@ -252,6 +252,17 @@ done:
   return err;
 }
 
+void
+clib_mem_vm_ext_free (clib_mem_vm_alloc_t * a)
+{
+  if (a != 0)
+    {
+      clib_mem_vm_free (a->addr, 1 << a->log2_page_size);
+      if (a->fd != -1)
+       close (a->fd);
+    }
+}
+
 u64 *
 clib_mem_vm_get_paddr (void *mem, int log2_page_size, int n_pages)
 {