From 95213cd3829fb2565c8b492c7eeb44a421df7bc7 Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 27 Oct 2014 13:55:14 -0400 Subject: [PATCH] c++ style memory allocations/deallocations --- src/geometry/sprite_atlas.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/geometry/sprite_atlas.cpp b/src/geometry/sprite_atlas.cpp index 10922790c..22e6a29a0 100644 --- a/src/geometry/sprite_atlas.cpp +++ b/src/geometry/sprite_atlas.cpp @@ -53,7 +53,7 @@ bool SpriteAtlas::resize(const float newRatio) { } } - free(old_data); + ::operator delete(old_data); dirty = true; // Mark all sprite images as in need of update @@ -154,7 +154,8 @@ void SpriteAtlas::allocate() { if (!data) { dimension w = static_cast(width * pixelRatio); dimension h = static_cast(height * pixelRatio); - data = (uint32_t *)calloc(w * h, sizeof(uint32_t)); + data = static_cast(::operator new(w * h * sizeof(uint32_t))); + std::fill(data, data + w * h, 0); } } @@ -268,9 +269,5 @@ SpriteAtlas::~SpriteAtlas() { glDeleteTextures(1, &texture); texture = 0; - - if (data) { - free(data); - data = nullptr; - } + ::operator delete(data), data = nullptr; }