From 0b7c51b992943a8fd0e9003cd4e36bcfd86e3ae7 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Fri, 24 Aug 2012 22:12:34 +0000 Subject: [PATCH] ofsdiofisdoifods --- src/array.h | 35 +++++++++++++++++++++++++++++++---- src/ticker.cpp | 2 +- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/array.h b/src/array.h index 873116c5..29520930 100644 --- a/src/array.h +++ b/src/array.h @@ -44,7 +44,14 @@ public: { for (int i = 0; i < m_count; i++) m_data[i].~Element(); - delete[] reinterpret_cast(m_data); + if (sizeof(Element) & 1) + delete[] (uint8_t *)(m_data); + else if (sizeof(Element) & 2) + delete[] (uint16_t *)(m_data); + else if (sizeof(Element) & 4) + delete[] (uint32_t *)(m_data); + else + delete[] (uint64_t *)(m_data); } ArrayBase(ArrayBase const& that) : m_data(0), m_count(0), m_reserved(0) @@ -174,15 +181,35 @@ public: if (toreserve <= (int)m_reserved) return; - Element *tmp = reinterpret_cast - (new uint8_t [sizeof(Element) * toreserve]); + Element *tmp; + if (sizeof(Element) & 1) + tmp = (Element *) + (new uint8_t [sizeof(Element) * toreserve]); + else if (sizeof(Element) & 2) + tmp = (Element *) + (new uint16_t [sizeof(Element) / 2 * toreserve]); + else if (sizeof(Element) & 4) + tmp = (Element *) + (new uint32_t [sizeof(Element) / 4 * toreserve]); + else + tmp = (Element *) + (new uint64_t [sizeof(Element) / 8 * toreserve]); for (int i = 0; i < m_count; i++) { new(&tmp[i]) Element(m_data[i]); m_data[i].~Element(); } if (m_data) - delete[] reinterpret_cast(m_data); + { + if (sizeof(Element) & 1) + delete[] (uint8_t *)(m_data); + else if (sizeof(Element) & 2) + delete[] (uint16_t *)(m_data); + else if (sizeof(Element) & 4) + delete[] (uint32_t *)(m_data); + else + delete[] (uint64_t *)(m_data); + } m_data = tmp; m_reserved = toreserve; } diff --git a/src/ticker.cpp b/src/ticker.cpp index 85873ecd..673be9bc 100644 --- a/src/ticker.cpp +++ b/src/ticker.cpp @@ -165,7 +165,7 @@ void *TickerData::GameThreadMain(void * /* p */) Profiler::Start(Profiler::STAT_TICK_GAME); -#if 0 +#if 1 Log::Debug("-------------------------------------\n"); for (int i = 0; i < Entity::ALLGROUP_END; i++) {