macos std vector fix

This commit is contained in:
camila314 2022-12-01 13:53:17 -06:00
parent 74a8449533
commit cc84d821d9
2 changed files with 15 additions and 7 deletions
loader
include/Geode/c++stl
src/cocos2d-ext

View file

@ -311,7 +311,8 @@ namespace gd {
}
vector(std::vector<T> input) {
auto tmp = new T[input.size()];
std::allocator<T> alloc;
auto tmp = alloc.allocate(input.size());
m_start = tmp;
m_finish = m_start + input.size();
@ -323,7 +324,8 @@ namespace gd {
}
vector(std::initializer_list<T> const& input) {
auto tmp = new T[input.size()];
std::allocator<T> alloc;
auto tmp = alloc.allocate(input.size());
m_start = tmp;
m_finish = m_start + input.size();
m_capacity_end = m_start + input.size();
@ -331,11 +333,11 @@ namespace gd {
}
void clear() {
delete[] m_start;
auto tmp = new T[0];
m_start = tmp;
std::allocator<T> alloc;
alloc.deallocate(m_start, (m_finish - m_start) / 8);
m_start = alloc.allocate(1);
m_finish = m_start;
m_capacity_end = m_start;
m_capacity_end = m_start + 8;
}
T& front() {
@ -363,7 +365,9 @@ namespace gd {
vector() : vector(std::vector<T>()) {}
~vector() {
delete[] m_start;
for (auto i = m_start; i != m_finish; ++i) {
delete i;
}
}
protected:

View file

@ -36,6 +36,7 @@ void CCFileUtils::addPriorityPath(const char* path) {
void CCFileUtils::updatePaths() {
// add search paths that aren't in PATHS or PACKS to PATHS
for (auto& path : m_searchPathArray) {
bool isKnown = false;
for (auto& pack : PACKS) {
@ -60,10 +61,12 @@ void CCFileUtils::updatePaths() {
}
// clear old paths
m_searchPathArray.clear();
// make sure addSearchPath doesn't add to PACKS or PATHS
DONT_ADD_PATHS = true;
// add texture packs first
for (auto& pack : PACKS) {
for (auto& path : pack.m_paths) {
@ -75,6 +78,7 @@ void CCFileUtils::updatePaths() {
this->addSearchPath(path.c_str());
}
DONT_ADD_PATHS = false;
}
#pragma warning(pop)