Array bug fix

This commit is contained in:
gingerBill 2015-11-28 22:55:24 +00:00
parent 2159ae399a
commit 16c31df712
2 changed files with 12 additions and 11 deletions

View File

@ -5,7 +5,7 @@ gb single-file public domain libraries for C & C++
library | latest version | category | languages | description library | latest version | category | languages | description
----------------|----------------|----------|-----------|------------- ----------------|----------------|----------|-----------|-------------
**gb_string.h** | 0.93 | strings | C, C++ | A better string library for C & C++ **gb_string.h** | 0.93 | strings | C, C++ | A better string library for C & C++
**gb.hpp** | 0.25 | misc | C++11 | (Experimental) A C++11 helper library without STL geared towards game development **gb.hpp** | 0.25a | misc | C++11 | (Experimental) A C++11 helper library without STL geared towards game development
**gb_math.hpp** | 0.02b | math | C++11 | A C++11 math library geared towards game development **gb_math.hpp** | 0.02b | math | C++11 | A C++11 math library geared towards game development
**gb_ini.h** | 0.91a | misc | C, C++ | A simple ini file loader library for C & C++ **gb_ini.h** | 0.91a | misc | C, C++ | A simple ini file loader library for C & C++

21
gb.hpp
View File

@ -1,4 +1,4 @@
// gb.hpp - v0.25 - public domain C++11 helper library - no warranty implied; use at your own risk // gb.hpp - v0.25a - public domain C++11 helper library - no warranty implied; use at your own risk
// (Experimental) A C++11 helper library without STL geared towards game development // (Experimental) A C++11 helper library without STL geared towards game development
/* /*
@ -1532,10 +1532,10 @@ Array<T>::Array(const Array<T>& other)
, capacity(0) , capacity(0)
, data(nullptr) , data(nullptr)
{ {
const auto count = other.count; const auto new_count = other.count;
array::set_capacity(this, count); array::set_capacity(this, new_count);
memory::copy_array(other.data, count, data); memory::copy_array(other.data, new_count, data);
count = n; this->count = new_count;
} }
template <typename T> template <typename T>
@ -1565,9 +1565,9 @@ Array<T>::operator=(const Array<T>& other)
{ {
if (allocator == nullptr) if (allocator == nullptr)
allocator = other.allocator; allocator = other.allocator;
const auto count = other.count; const auto new_count = other.count;
array::resize(this, count); array::resize(this, new_count);
memory::copy_count(other.data, count, data); memory::copy_array(other.data, new_count, data);
return *this; return *this;
} }
@ -3265,9 +3265,9 @@ free(String str)
{ {
if (str == nullptr) if (str == nullptr)
return; return;
string::Header* h = string::header(str); string::Header* h = string::header(str);
if (h->allocator) if (h->allocator)
dealloc(h->allocator, h); dealloc(h->allocator, h);
} }
@ -4348,6 +4348,7 @@ __GB_NAMESPACE_END
/* /*
Version History: Version History:
0.25a - Array bug fix
0.25 - Faster Heap_Allocator for Windows using HeapAlloc 0.25 - Faster Heap_Allocator for Windows using HeapAlloc
0.24b - Even More Hash_Table Bug Fixes 0.24b - Even More Hash_Table Bug Fixes
0.24a - Hash_Table Bug Fixes 0.24a - Hash_Table Bug Fixes