diff mbox

[02/11] acpi_table_add(): extract acpi_tables init to separate function

Message ID 1340828587-15201-3-git-send-email-ehabkost@redhat.com
State New
Headers show

Commit Message

Eduardo Habkost June 27, 2012, 8:22 p.m. UTC
No behavior change, just code movement.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 hw/acpi.c |   14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/hw/acpi.c b/hw/acpi.c
index 21e573b..6180c7a 100644
--- a/hw/acpi.c
+++ b/hw/acpi.c
@@ -72,6 +72,15 @@  static void strzcpy(char *dst, const char *src, size_t size)
     memcpy(dst, src, len);
 }
 
+/* Init acpi_tables if necessary */
+static void init_acpi_tables(void)
+{
+    if (!acpi_tables) {
+        acpi_tables_len = sizeof(uint16_t);
+        acpi_tables = g_malloc0(acpi_tables_len);
+    }
+}
+
 /* XXX fixme: this function uses obsolete argument parsing interface */
 int acpi_table_add(const char *t)
 {
@@ -101,10 +110,7 @@  int acpi_table_add(const char *t)
         return -1;
     }
 
-    if (!acpi_tables) {
-        acpi_tables_len = sizeof(uint16_t);
-        acpi_tables = g_malloc0(acpi_tables_len);
-    }
+    init_acpi_tables();
 
     allen = acpi_tables_len;
     start = allen;