From 16c31df7122df448bb68fe25a5244b9b8a22c22c Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sat, 28 Nov 2015 22:55:24 +0000 Subject: [PATCH] Array bug fix --- README.md | 2 +- gb.hpp | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index a05ec2e..70a2462 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ gb single-file public domain libraries for C & C++ library | latest version | category | languages | description ----------------|----------------|----------|-----------|------------- **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_ini.h** | 0.91a | misc | C, C++ | A simple ini file loader library for C & C++ diff --git a/gb.hpp b/gb.hpp index 56237cf..3a39f4d 100644 --- a/gb.hpp +++ b/gb.hpp @@ -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 /* @@ -1532,10 +1532,10 @@ Array::Array(const Array& other) , capacity(0) , data(nullptr) { - const auto count = other.count; - array::set_capacity(this, count); - memory::copy_array(other.data, count, data); - count = n; + const auto new_count = other.count; + array::set_capacity(this, new_count); + memory::copy_array(other.data, new_count, data); + this->count = new_count; } template @@ -1565,9 +1565,9 @@ Array::operator=(const Array& other) { if (allocator == nullptr) allocator = other.allocator; - const auto count = other.count; - array::resize(this, count); - memory::copy_count(other.data, count, data); + const auto new_count = other.count; + array::resize(this, new_count); + memory::copy_array(other.data, new_count, data); return *this; } @@ -3265,9 +3265,9 @@ free(String str) { if (str == nullptr) return; - + string::Header* h = string::header(str); - + if (h->allocator) dealloc(h->allocator, h); } @@ -4348,6 +4348,7 @@ __GB_NAMESPACE_END /* Version History: + 0.25a - Array bug fix 0.25 - Faster Heap_Allocator for Windows using HeapAlloc 0.24b - Even More Hash_Table Bug Fixes 0.24a - Hash_Table Bug Fixes