From c948c1e23a2e278ab4d547329055131cafcd7720 Mon Sep 17 00:00:00 2001 From: Dario Manesku Date: Sat, 7 Mar 2015 21:10:17 +0100 Subject: [PATCH] Added isValid(_handle). --- include/bx/handlealloc.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/bx/handlealloc.h b/include/bx/handlealloc.h index 050590f..25e250e 100644 --- a/include/bx/handlealloc.h +++ b/include/bx/handlealloc.h @@ -66,6 +66,14 @@ namespace bx return invalid; } + bool isValid(uint16_t _handle) + { + uint16_t* sparse = &m_handles[MaxHandlesT]; + uint16_t index = sparse[_handle]; + + return (index < m_numHandles && m_handles[index] == _handle); + } + void free(uint16_t _handle) { BX_CHECK(0 < m_numHandles, "Freeing invalid handle %d.", _handle); @@ -139,6 +147,14 @@ namespace bx return invalid; } + bool isValid(uint16_t _handle) + { + uint16_t* sparse = &m_handles[m_maxHandles]; + uint16_t index = sparse[_handle]; + + return (index < m_numHandles && m_handles[index] == _handle); + } + void free(uint16_t _handle) { uint16_t* sparse = &m_handles[m_maxHandles];