summaryrefslogtreecommitdiff
path: root/src/lib/eina
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2018-01-16 09:35:43 -0800
committerCedric BAIL <cedric@osg.samsung.com>2018-01-16 09:54:04 -0800
commit1af649d57b18dfae89dcf4f79043eaf2bb8ce824 (patch)
tree423ccc8449b8badc29e54cef35c5615bdfd0dfb8 /src/lib/eina
parentd47610a7323dd357e57f26ca83014c7b39dd48e9 (diff)
downloadefl-1af649d57b18dfae89dcf4f79043eaf2bb8ce824.tar.gz
eina: make updating rectangle cache thread safe.
Diffstat (limited to 'src/lib/eina')
-rw-r--r--src/lib/eina/eina_rectangle.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/lib/eina/eina_rectangle.c b/src/lib/eina/eina_rectangle.c
index b6eadeb2f4..c7b89b524a 100644
--- a/src/lib/eina/eina_rectangle.c
+++ b/src/lib/eina/eina_rectangle.c
@@ -598,20 +598,21 @@ eina_rectangle_shutdown(void)
EAPI Eina_Rectangle *
eina_rectangle_new(int x, int y, int w, int h)
{
- Eina_Rectangle *rect;
+ Eina_Rectangle *rect = NULL;
if (_eina_rectangles)
{
eina_spinlock_take(&_eina_spinlock);
rect = eina_trash_pop(&_eina_rectangles);
- eina_spinlock_release(&_eina_spinlock);
_eina_rectangles_count--;
+ eina_spinlock_release(&_eina_spinlock);
}
- else
- rect = eina_mempool_malloc(_eina_rectangle_mp, sizeof (Eina_Rectangle));
if (!rect)
- return NULL;
+ rect = eina_mempool_malloc(_eina_rectangle_mp, sizeof (Eina_Rectangle));
+
+ if (!rect)
+ return NULL;
EINA_RECTANGLE_SET(rect, x, y, w, h);
@@ -629,8 +630,8 @@ eina_rectangle_free(Eina_Rectangle *rect)
{
eina_spinlock_take(&_eina_spinlock);
eina_trash_push(&_eina_rectangles, rect);
- eina_spinlock_release(&_eina_spinlock);
_eina_rectangles_count++;
+ eina_spinlock_release(&_eina_spinlock);
}
}