From 3b8e3d1459edb9fbf8df4b6055023b0d0905a15f Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Sun, 2 Sep 2012 17:18:01 +0400 Subject: [PATCH] Fix wrong assumptions in lua wrapper for BitArray. --- library/include/BitArray.h | 4 ++-- library/include/DataIdentity.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library/include/BitArray.h b/library/include/BitArray.h index fd9bd98fc..ff68ea1d1 100644 --- a/library/include/BitArray.h +++ b/library/include/BitArray.h @@ -64,7 +64,7 @@ namespace DFHack if (newsize == size) return; uint8_t* mem = (uint8_t *) realloc(bits, newsize); - if(!mem) + if(!mem && newsize != 0) throw std::bad_alloc(); bits = mem; if (newsize > size) @@ -207,7 +207,7 @@ namespace DFHack else { T* mem = (T*) realloc(m_data, sizeof(T)*new_size); - if(!mem) + if(!mem && new_size != 0) throw std::bad_alloc(); m_data = mem; } diff --git a/library/include/DataIdentity.h b/library/include/DataIdentity.h index 0f5fd9e7c..21dc68d1a 100644 --- a/library/include/DataIdentity.h +++ b/library/include/DataIdentity.h @@ -390,7 +390,7 @@ namespace df } virtual bool resize(void *ptr, int size) { - ((container*)ptr)->resize(size); + ((container*)ptr)->resize(size*8); return true; }