diff --git a/code/glTF2/glTF2Asset.inl b/code/glTF2/glTF2Asset.inl index a5fda587a..18263fbbe 100644 --- a/code/glTF2/glTF2Asset.inl +++ b/code/glTF2/glTF2Asset.inl @@ -515,18 +515,23 @@ inline size_t Buffer::AppendData(uint8_t *data, size_t length) { } inline void Buffer::Grow(size_t amount) { - if (amount <= 0) return; + if (amount <= 0) { + return; + } + + // Capacity is big enough if (capacity >= byteLength + amount) { byteLength += amount; return; } - // Shift operation is standard way to divide integer by 2, it doesn't cast it to float back and forth, also works for odd numbers, - // originally it would look like: static_cast(capacity * 1.5f) - capacity = std::max(capacity + (capacity >> 1), byteLength + amount); + // Just allocate data which we need + capacity = byteLength + amount; uint8_t *b = new uint8_t[capacity]; - if (mData) memcpy(b, mData.get(), byteLength); + if (nullptr != mData) { + memcpy(b, mData.get(), byteLength); + } mData.reset(b, std::default_delete()); byteLength += amount; } diff --git a/samples/SimpleOpenGL/Sample_SimpleOpenGL.c b/samples/SimpleOpenGL/Sample_SimpleOpenGL.c index a8a3532cf..e1a9be0d9 100644 --- a/samples/SimpleOpenGL/Sample_SimpleOpenGL.c +++ b/samples/SimpleOpenGL/Sample_SimpleOpenGL.c @@ -245,7 +245,7 @@ void do_motion (void) static int frames = 0; int time = glutGet(GLUT_ELAPSED_TIME); - angle += (time-prev_time)*0.01; + angle += (time-prev_time)*0.01f; prev_time = time; frames += 1;