diff mbox

[1/2] add qemu_ram_free_from_ptr

Message ID 1291151039-10966-2-git-send-email-cam@cs.ualberta.ca (mailing list archive)
State New, archived
Headers show

Commit Message

Cam Macdonell Nov. 30, 2010, 9:03 p.m. UTC
None
diff mbox

Patch

diff --git a/cpu-common.h b/cpu-common.h
index a543b5d..3f802e1 100644
--- a/cpu-common.h
+++ b/cpu-common.h
@@ -44,6 +44,7 @@  ram_addr_t qemu_ram_alloc_from_ptr(DeviceState *dev, const char *name,
                         ram_addr_t size, void *host);
 ram_addr_t qemu_ram_alloc(DeviceState *dev, const char *name, ram_addr_t size);
 void qemu_ram_free(ram_addr_t addr);
+void qemu_ram_free_from_ptr(ram_addr_t addr);
 /* This should only be used for ram local to a device.  */
 void *qemu_get_ram_ptr(ram_addr_t addr);
 /* This should not be used by devices.  */
diff --git a/exec.c b/exec.c
index db9ff55..1f5c8f8 100644
--- a/exec.c
+++ b/exec.c
@@ -2875,6 +2875,19 @@  ram_addr_t qemu_ram_alloc(DeviceState *dev, const char *name, ram_addr_t size)
     return qemu_ram_alloc_from_ptr(dev, name, size, NULL);
 }
 
+void qemu_ram_free_from_ptr(ram_addr_t addr)
+{
+    RAMBlock *block;
+
+    QLIST_FOREACH(block, &ram_list.blocks, next) {
+        if (addr == block->offset) {
+            QLIST_REMOVE(block, next);
+            qemu_free(block);
+            return;
+        }
+    }
+}
+
 void qemu_ram_free(ram_addr_t addr)
 {
     RAMBlock *block;