icd: remove unused icd-alloc.[ch]
authorChia-I Wu <olv@lunarg.com>
Sun, 22 Feb 2015 06:41:03 +0000 (14:41 +0800)
committerChia-I Wu <olv@lunarg.com>
Thu, 5 Mar 2015 21:20:31 +0000 (14:20 -0700)
icd/common/CMakeLists.txt
icd/common/icd-alloc.c [deleted file]
icd/common/icd-alloc.h [deleted file]

index 151a578..1c760b7 100644 (file)
@@ -3,7 +3,6 @@ if (WIN32)
 endif()
 
 set(sources
-    icd-alloc.c
     icd-format.c
     icd-instance.c
     icd-log.c
diff --git a/icd/common/icd-alloc.c b/icd/common/icd-alloc.c
deleted file mode 100644 (file)
index a54828b..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * XGL
- *
- * Copyright (C) 2014 LunarG, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- *   Chia-I Wu <olv@lunarg.com>
- */
-
-#define _ISOC11_SOURCE /* for aligned_alloc() */
-#include <stdlib.h>
-#include <string.h>
-
-#include "icd-utils.h"
-#include "icd-alloc.h"
-
-struct icd_allocator {
-    bool initialized;
-    XGL_ALLOC_CALLBACKS callbacks;
-};
-
-static void * XGLAPI default_alloc(void *user_data, size_t size, size_t alignment,
-                           XGL_SYSTEM_ALLOC_TYPE allocType)
-{
-    if (alignment <= 1) {
-        return malloc(size);
-    } else if (u_is_pow2((uint32_t) alignment)) {
-        if (alignment < sizeof(void *)) {
-            assert(u_is_pow2(sizeof(void*)));
-            alignment = sizeof(void *);
-        }
-
-        size = (size + alignment - 1) & ~(alignment - 1);
-
-#if defined(PLATFORM_LINUX)
-        return aligned_alloc(alignment, size);
-#else
-               return _aligned_malloc(size, alignment);
-#endif
-    }
-    else {
-        return NULL;
-    }
-}
-
-static void XGLAPI default_free(void *user_data, void *ptr)
-{
-    free(ptr);
-}
-
-static struct icd_allocator icd_allocator = {
-    .callbacks = {
-        .pfnAlloc = default_alloc,
-        .pfnFree = default_free,
-    }
-};
-
-XGL_RESULT icd_allocator_init(const XGL_ALLOC_CALLBACKS *alloc_cb)
-{
-    if (icd_allocator.initialized) {
-        const XGL_ALLOC_CALLBACKS default_cb = {
-            NULL, default_alloc, default_free
-        };
-
-        if (!alloc_cb)
-            alloc_cb = &default_cb;
-
-        return (memcmp(&icd_allocator.callbacks, alloc_cb, sizeof(*alloc_cb)))
-            ? XGL_ERROR_INVALID_POINTER : XGL_SUCCESS;
-    }
-
-    if (alloc_cb)
-        icd_allocator.callbacks = *alloc_cb;
-    icd_allocator.initialized = true;
-
-    return XGL_SUCCESS;
-}
-
-uint32_t icd_allocator_get_id(void)
-{
-    return icd_allocator.initialized;
-}
-
-void *icd_alloc(size_t size, size_t alignment, XGL_SYSTEM_ALLOC_TYPE type)
-{
-    return icd_allocator.callbacks.pfnAlloc(icd_allocator.callbacks.pUserData,
-            size, alignment, type);
-}
-
-void icd_free(void *ptr)
-{
-    icd_allocator.callbacks.pfnFree(icd_allocator.callbacks.pUserData, ptr);
-}
diff --git a/icd/common/icd-alloc.h b/icd/common/icd-alloc.h
deleted file mode 100644 (file)
index 8a28ae1..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * XGL
- *
- * Copyright (C) 2014 LunarG, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- *    Chia-I Wu <olv@lunarg.com>
- */
-
-#ifndef ICD_ALLOC_H
-#define ICD_ALLOC_H
-
-#include "icd.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-XGL_RESULT icd_allocator_init(const XGL_ALLOC_CALLBACKS *alloc_cb);
-uint32_t icd_allocator_get_id(void);
-
-void *icd_alloc(size_t size, size_t alignment, XGL_SYSTEM_ALLOC_TYPE type);
-void icd_free(void *ptr);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* ICD_ALLOC_H */