Эх сурвалжийг харах

Fix the inconsistent behavior between Spine vector's setSize and std::vector's resize, which causes the Spine vector to allocate additional space upfront. (#2830)

bofeng-song 4 сар өмнө
parent
commit
7fd1e5340c

+ 5 - 1
spine-cpp/spine-cpp/include/spine/Vector.h

@@ -77,7 +77,11 @@ namespace spine {
 			size_t oldSize = _size;
 			_size = newSize;
 			if (_capacity < newSize) {
-				_capacity = (int) (_size * 1.75f);
+				if (_capacity == 0) {
+					_capacity = _size;
+				} else {
+					_capacity = (int) (_size * 1.75f);
+				}
 				if (_capacity < 8) _capacity = 8;
 				_buffer = spine::SpineExtension::realloc<T>(_buffer, _capacity, __FILE__, __LINE__);
 			}