sw_engine: optimize memory allocation. 38/236938/1
authorHermet Park <chuneon.park@samsung.com>
Tue, 23 Jun 2020 09:59:12 +0000 (18:59 +0900)
committerHermet Park <chuneon.park@samsung.com>
Tue, 23 Jun 2020 09:59:12 +0000 (18:59 +0900)
there are a logical wrong that memory increase size,
it correct that also tune the number to reduce memory allocation time.

Now scene transform test works smoothly.

Change-Id: If0674e33426d794546801a96ad9de711b5de0dcd

src/lib/sw_engine/tvgSwRle.cpp

index 5d7d5a7..5bb3a31 100644 (file)
@@ -147,9 +147,9 @@ static void _genSpan(SwRleData* rle, SwSpan* spans, uint32_t count)
     /* alloc is required to prevent free and reallocation */
     /* when the rle needs to be regenerated because of attribute change. */
     if (rle->alloc < newSize) {
-        rle->spans = static_cast<SwSpan*>(realloc(rle->spans, (count + rle->size) << 2 * sizeof(SwSpan)));
+        rle->alloc = (newSize * 2);
+        rle->spans = static_cast<SwSpan*>(realloc(rle->spans, rle->alloc * sizeof(SwSpan)));
         assert(rle->spans);
-        rle->alloc = rle->size + (count << 2);
     }
 
     //copy the new spans to the allocated memory