From: Hermet Park Date: Sat, 1 May 2021 03:52:32 +0000 (+0900) Subject: examples: fix wrong data size conversion. X-Git-Tag: submit/tizen/20210510.051321~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9e087f639f9c52ccb69830abe030aedcbacc8c53;p=platform%2Fcore%2Fgraphics%2Ftizenvg.git examples: fix wrong data size conversion. pointer size becomes 32 to 64 bits up to machines. it has to be 32 bits. --- diff --git a/src/examples/Masking.cpp b/src/examples/Masking.cpp index 6140a2b..4112d99 100644 --- a/src/examples/Masking.cpp +++ b/src/examples/Masking.cpp @@ -27,8 +27,6 @@ /* Drawing Commands */ /************************************************************************/ -uint32_t *data = nullptr; - void tvgDrawCmds(tvg::Canvas* canvas) { if (!canvas) return; @@ -87,8 +85,8 @@ void tvgDrawCmds(tvg::Canvas* canvas) //Image ifstream file(EXAMPLE_DIR"/rawimage_200x300.raw"); if (!file.is_open()) return; - data = (uint32_t*) malloc(sizeof(uint32_t) * (200 * 300)); - file.read(reinterpret_cast(data), sizeof (data) * 200 * 300); + auto data = (uint32_t*) malloc(sizeof(uint32_t) * (200 * 300)); + file.read(reinterpret_cast(data), sizeof (uint32_t) * 200 * 300); file.close(); auto image = tvg::Picture::gen(); @@ -111,6 +109,8 @@ void tvgDrawCmds(tvg::Canvas* canvas) mask4->fill(255, 255, 255, 70); image->composite(move(mask4), tvg::CompositeMethod::AlphaMask); if (canvas->push(move(image)) != tvg::Result::Success) return; + + free(data); } @@ -214,8 +214,6 @@ int main(int argc, char **argv) //Terminate ThorVG Engine tvg::Initializer::term(tvg::CanvasEngine::Sw); - if (data) free(data); - } else { cout << "engine is not supported" << endl; } diff --git a/src/examples/PictureRaw.cpp b/src/examples/PictureRaw.cpp index e65087a..8575e4f 100644 --- a/src/examples/PictureRaw.cpp +++ b/src/examples/PictureRaw.cpp @@ -27,8 +27,6 @@ /* Drawing Commands */ /************************************************************************/ -uint32_t *data = nullptr; - void tvgDrawCmds(tvg::Canvas* canvas) { if (!canvas) return; @@ -44,8 +42,8 @@ void tvgDrawCmds(tvg::Canvas* canvas) ifstream file(path); if (!file.is_open()) return ; - data = (uint32_t*)malloc(sizeof(uint32_t) * (200*300)); - file.read(reinterpret_cast(data), sizeof (data) * 200 * 300); + auto data = (uint32_t*)malloc(sizeof(uint32_t) * (200*300)); + file.read(reinterpret_cast(data), sizeof (uint32_t) * 200 * 300); file.close(); auto picture = tvg::Picture::gen();