summaryrefslogtreecommitdiff
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
parentd47610a7323dd357e57f26ca83014c7b39dd48e9 (diff)
eina: make updating rectangle cache thread safe.
-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)
598EAPI Eina_Rectangle * 598EAPI Eina_Rectangle *
599eina_rectangle_new(int x, int y, int w, int h) 599eina_rectangle_new(int x, int y, int w, int h)
600{ 600{
601 Eina_Rectangle *rect; 601 Eina_Rectangle *rect = NULL;
602 602
603 if (_eina_rectangles) 603 if (_eina_rectangles)
604 { 604 {
605 eina_spinlock_take(&_eina_spinlock); 605 eina_spinlock_take(&_eina_spinlock);
606 rect = eina_trash_pop(&_eina_rectangles); 606 rect = eina_trash_pop(&_eina_rectangles);
607 eina_spinlock_release(&_eina_spinlock);
608 _eina_rectangles_count--; 607 _eina_rectangles_count--;
608 eina_spinlock_release(&_eina_spinlock);
609 } 609 }
610 else
611 rect = eina_mempool_malloc(_eina_rectangle_mp, sizeof (Eina_Rectangle));
612 610
613 if (!rect) 611 if (!rect)
614 return NULL; 612 rect = eina_mempool_malloc(_eina_rectangle_mp, sizeof (Eina_Rectangle));
613
614 if (!rect)
615 return NULL;
615 616
616 EINA_RECTANGLE_SET(rect, x, y, w, h); 617 EINA_RECTANGLE_SET(rect, x, y, w, h);
617 618
@@ -629,8 +630,8 @@ eina_rectangle_free(Eina_Rectangle *rect)
629 { 630 {
630 eina_spinlock_take(&_eina_spinlock); 631 eina_spinlock_take(&_eina_spinlock);
631 eina_trash_push(&_eina_rectangles, rect); 632 eina_trash_push(&_eina_rectangles, rect);
632 eina_spinlock_release(&_eina_spinlock);
633 _eina_rectangles_count++; 633 _eina_rectangles_count++;
634 eina_spinlock_release(&_eina_spinlock);
634 } 635 }
635} 636}
636 637