intel: make intel_instance own an icd_instance
authorChia-I Wu <olv@lunarg.com>
Sat, 21 Feb 2015 06:19:23 +0000 (14:19 +0800)
committerChia-I Wu <olv@lunarg.com>
Thu, 5 Mar 2015 21:20:31 +0000 (14:20 -0700)
intel_instance is now correctly allocated by icd_instance.

icd/intel/instance.c
icd/intel/instance.h
icd/intel/intel.h

index 641beea..fce3bf9 100644 (file)
@@ -100,24 +100,38 @@ static void intel_instance_remove_gpus(struct intel_instance *instance)
 
 static void intel_instance_destroy(struct intel_instance *instance)
 {
+    struct icd_instance *icd = instance->icd;
+
     intel_instance_remove_gpus(instance);
-    icd_free(instance);
+    icd_instance_free(icd, instance);
+
+    icd_instance_destroy(icd);
 }
 
 static struct intel_instance *intel_instance_create(const XGL_APPLICATION_INFO *app_info,
                                                     const XGL_ALLOC_CALLBACKS *alloc_cb)
 {
     struct intel_instance *instance;
+    struct icd_instance *icd;
 
     intel_debug_init();
 
-    instance = icd_alloc(sizeof(*instance), 0, XGL_SYSTEM_ALLOC_API_OBJECT);
-    if (!instance)
+    icd = icd_instance_create(app_info, alloc_cb);
+    if (!icd)
         return NULL;
 
+    instance = icd_instance_alloc(icd, sizeof(*instance), 0,
+            XGL_SYSTEM_ALLOC_API_OBJECT);
+    if (!instance) {
+        icd_instance_destroy(icd);
+        return NULL;
+    }
+
     memset(instance, 0, sizeof(*instance));
     intel_handle_init(&instance->handle, XGL_DBG_OBJECT_INSTANCE);
 
+    instance->icd = icd;
+
     icd_allocator_init(alloc_cb);
 
     return instance;
index 98ce0fa..d0284c1 100644 (file)
@@ -35,6 +35,8 @@ struct intel_gpu;
 struct intel_instance {
     struct intel_handle handle;
 
+    struct icd_instance *icd;
+
     struct intel_gpu *gpus;
 };
 
index 7f890a5..ccd96ac 100644 (file)
@@ -43,6 +43,7 @@
 #include "icd-alloc.h"
 #include "icd-bil.h"
 #include "icd-format.h"
+#include "icd-instance.h"
 #include "icd-log.h"
 #include "icd-utils.h"