icd: assign each allocator a unique id

It can be used to determine if an object is allocated by the current
allocator.
diff --git a/icd/common/icd.c b/icd/common/icd.c
index 7dd8103..0d279f8 100644
--- a/icd/common/icd.c
+++ b/icd/common/icd.c
@@ -50,7 +50,7 @@
     bool break_on_warning;
 
     XGL_ALLOC_CALLBACKS alloc_callbacks;
-    bool alloc_callbacks_initialized;
+    int init_count;
 };
 
 static XGL_VOID *default_alloc(XGL_VOID *user_data,
@@ -217,9 +217,14 @@
     return res;
 }
 
-XGL_RESULT icd_set_alloc_callbacks(const XGL_ALLOC_CALLBACKS *alloc_cb)
+XGL_RESULT icd_set_allocator(const XGL_ALLOC_CALLBACKS *alloc_cb)
 {
-    if (icd.alloc_callbacks_initialized) {
+    if (icd.init_count) {
+        /*
+         * The spec says: Changing the callbacks on subsequent calls to
+         * xglInitAndEnumerateGpus() causes it to fail with
+         * XGL_ERROR_INVALID_POINTER error.
+         */
         return (memcmp(&icd.alloc_callbacks, alloc_cb, sizeof(*alloc_cb))) ?
             XGL_ERROR_INVALID_POINTER : XGL_SUCCESS;
     }
@@ -227,11 +232,16 @@
     if (alloc_cb)
         icd.alloc_callbacks = *alloc_cb;
 
-    icd.alloc_callbacks_initialized = true;
+    icd.init_count++;
 
     return XGL_SUCCESS;
 }
 
+int icd_get_allocator_id(void)
+{
+    return icd.init_count;
+}
+
 void *icd_alloc(XGL_SIZE size, XGL_SIZE alignment,
                 XGL_SYSTEM_ALLOC_TYPE type)
 {
diff --git a/icd/common/icd.h b/icd/common/icd.h
index 323d956..00916e5 100644
--- a/icd/common/icd.h
+++ b/icd/common/icd.h
@@ -63,7 +63,8 @@
 
 void icd_clear_msg_callbacks(void);
 
-XGL_RESULT icd_set_alloc_callbacks(const XGL_ALLOC_CALLBACKS *alloc_cb);
+XGL_RESULT icd_set_allocator(const XGL_ALLOC_CALLBACKS *alloc_cb);
+int icd_get_allocator_id(void);
 
 void *icd_alloc(XGL_SIZE size, XGL_SIZE alignment,
                 XGL_SYSTEM_ALLOC_TYPE type);
diff --git a/icd/intel/init_driver.c b/icd/intel/init_driver.c
index 0a56edc..9096012 100644
--- a/icd/intel/init_driver.c
+++ b/icd/intel/init_driver.c
@@ -73,7 +73,7 @@
     XGL_RESULT ret;
     XGL_UINT count = 0;
 
-    ret = icd_set_alloc_callbacks(pAllocCb);
+    ret = icd_set_allocator(pAllocCb);
     if (ret != XGL_SUCCESS)
         return ret;