2008-10-27 13:24:12 -07:00
|
|
|
/* EINA - EFL data type library
|
|
|
|
* Copyright (C) 2007-2008 Cedric BAIL, Carsten Haitzler
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library;
|
|
|
|
* if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2009-06-05 21:22:21 -07:00
|
|
|
#include <stdio.h>
|
2008-10-27 13:24:12 -07:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2009-06-08 01:27:33 -07:00
|
|
|
#include "eina_config.h"
|
2008-10-27 13:24:12 -07:00
|
|
|
#include "eina_rectangle.h"
|
|
|
|
#include "eina_magic.h"
|
|
|
|
#include "eina_inlist.h"
|
|
|
|
#include "eina_private.h"
|
2008-12-26 10:31:14 -08:00
|
|
|
#include "eina_safety_checks.h"
|
2009-04-09 08:51:32 -07:00
|
|
|
#include "eina_mempool.h"
|
2009-06-22 06:16:51 -07:00
|
|
|
#include "eina_list.h"
|
2008-10-27 13:24:12 -07:00
|
|
|
|
|
|
|
/*============================================================================*
|
|
|
|
* Local *
|
|
|
|
*============================================================================*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @cond LOCAL
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define EINA_RECTANGLE_POOL_MAGIC 0x1578FCB0
|
|
|
|
#define EINA_RECTANGLE_ALLOC_MAGIC 0x1578FCB1
|
|
|
|
|
|
|
|
typedef struct _Eina_Rectangle_Alloc Eina_Rectangle_Alloc;
|
|
|
|
|
|
|
|
struct _Eina_Rectangle_Pool
|
|
|
|
{
|
|
|
|
Eina_Inlist *head;
|
2009-06-22 06:16:51 -07:00
|
|
|
Eina_List *empty;
|
2008-10-28 08:28:46 -07:00
|
|
|
void *data;
|
2008-10-27 13:24:12 -07:00
|
|
|
|
|
|
|
unsigned int references;
|
|
|
|
int w;
|
|
|
|
int h;
|
2009-06-24 06:38:25 -07:00
|
|
|
|
|
|
|
Eina_Bool sorted;
|
* eina/src/include/eina_array.h,
* eina/src/include/eina_f16p16.h,
* eina/src/include/eina_accessor.h,
* eina/src/include/eina_list.h,
* eina/src/include/eina_iterator.h,
* eina/src/lib/eina_rectangle.c,
* eina/src/lib/eina_list.c,
* eina/src/lib/eina_array.c,
* eina/src/lib/eina_hash.c,
* eina/src/lib/eina_module.c,
* eina/src/lib/eina_stringshare.c,
* eina/src/lib/eina_benchmark.c: Fix for windows compilation.
SVN revision: 38663
2009-01-20 07:56:48 -08:00
|
|
|
EINA_MAGIC
|
2008-10-27 13:24:12 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _Eina_Rectangle_Alloc
|
|
|
|
{
|
|
|
|
EINA_INLIST;
|
|
|
|
Eina_Rectangle_Pool *pool;
|
* eina/src/include/eina_array.h,
* eina/src/include/eina_f16p16.h,
* eina/src/include/eina_accessor.h,
* eina/src/include/eina_list.h,
* eina/src/include/eina_iterator.h,
* eina/src/lib/eina_rectangle.c,
* eina/src/lib/eina_list.c,
* eina/src/lib/eina_array.c,
* eina/src/lib/eina_hash.c,
* eina/src/lib/eina_module.c,
* eina/src/lib/eina_stringshare.c,
* eina/src/lib/eina_benchmark.c: Fix for windows compilation.
SVN revision: 38663
2009-01-20 07:56:48 -08:00
|
|
|
EINA_MAGIC
|
2008-10-27 13:24:12 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#define EINA_MAGIC_CHECK_RECTANGLE_POOL(d) \
|
|
|
|
do { \
|
|
|
|
if (!EINA_MAGIC_CHECK((d), EINA_RECTANGLE_POOL_MAGIC)) \
|
|
|
|
EINA_MAGIC_FAIL((d), EINA_RECTANGLE_POOL_MAGIC); \
|
|
|
|
} while (0);
|
|
|
|
|
|
|
|
#define EINA_MAGIC_CHECK_RECTANGLE_ALLOC(d) \
|
|
|
|
do { \
|
|
|
|
if (!EINA_MAGIC_CHECK((d), EINA_RECTANGLE_ALLOC_MAGIC)) \
|
|
|
|
EINA_MAGIC_FAIL((d), EINA_RECTANGLE_ALLOC_MAGIC); \
|
|
|
|
} while (0);
|
|
|
|
|
2009-04-09 08:51:32 -07:00
|
|
|
static int _eina_rectangle_init_count = 0;
|
2009-06-22 06:16:51 -07:00
|
|
|
static Eina_Mempool *_eina_rectangle_alloc_mp = NULL;
|
2009-04-09 08:51:32 -07:00
|
|
|
static Eina_Mempool *_eina_rectangle_mp = NULL;
|
|
|
|
|
2009-06-24 06:38:25 -07:00
|
|
|
static int
|
|
|
|
_eina_rectangle_cmp(const Eina_Rectangle *r1, const Eina_Rectangle *r2)
|
2008-10-27 13:24:12 -07:00
|
|
|
{
|
2009-06-24 06:38:25 -07:00
|
|
|
return (r2->w * r2->h) - (r1->w * r1->h);
|
2008-10-27 13:24:12 -07:00
|
|
|
}
|
|
|
|
|
2009-06-24 06:38:25 -07:00
|
|
|
static Eina_List *
|
|
|
|
_eina_rectangle_merge_list(Eina_List *empty, Eina_Rectangle *r)
|
2008-10-27 13:24:12 -07:00
|
|
|
{
|
2009-06-24 06:38:25 -07:00
|
|
|
Eina_Rectangle *match;
|
|
|
|
Eina_List *l;
|
2008-10-27 13:24:12 -07:00
|
|
|
|
2009-06-24 06:38:25 -07:00
|
|
|
if (r->w == 0 || r->h == 0)
|
|
|
|
{
|
|
|
|
eina_rectangle_free(r);
|
|
|
|
return empty;
|
|
|
|
}
|
2008-10-27 13:24:12 -07:00
|
|
|
|
2009-06-24 06:38:25 -07:00
|
|
|
EINA_LIST_FOREACH(empty, l, match)
|
2008-10-27 13:24:12 -07:00
|
|
|
{
|
2009-06-24 06:38:25 -07:00
|
|
|
if (match->x == r->x && match->w == r->w)
|
2008-10-27 13:24:12 -07:00
|
|
|
{
|
2009-06-24 06:38:25 -07:00
|
|
|
if (match->y > r->y)
|
|
|
|
match->y = r->y;
|
|
|
|
match->h += r->h;
|
|
|
|
|
|
|
|
eina_rectangle_free(r);
|
|
|
|
|
|
|
|
empty = eina_list_remove_list(empty, l);
|
|
|
|
|
|
|
|
return _eina_rectangle_merge_list(empty, match);
|
2008-10-27 13:24:12 -07:00
|
|
|
}
|
2009-06-24 06:38:25 -07:00
|
|
|
else if (match->y == r->y && match->h == r->h)
|
2008-10-27 13:24:12 -07:00
|
|
|
{
|
2009-06-24 06:38:25 -07:00
|
|
|
if (match->x > r->x)
|
|
|
|
match->x = r->x;
|
|
|
|
match->w += r->w;
|
|
|
|
|
|
|
|
eina_rectangle_free(r);
|
|
|
|
|
|
|
|
empty = eina_list_remove_list(empty, l);
|
|
|
|
|
|
|
|
return _eina_rectangle_merge_list(empty, match);
|
2008-10-27 13:24:12 -07:00
|
|
|
}
|
2009-06-24 06:38:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return eina_list_append(empty, r);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_List *
|
|
|
|
_eina_rectangle_empty_space_find(Eina_List *empty, int w, int h, int *x, int *y)
|
|
|
|
{
|
|
|
|
Eina_Rectangle *r;
|
|
|
|
Eina_List *l;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(empty, l, r)
|
|
|
|
{
|
|
|
|
if (r->w >= w && r->h >= h)
|
2008-10-27 13:24:12 -07:00
|
|
|
{
|
2009-06-24 06:38:25 -07:00
|
|
|
/* Remove l from empty */
|
|
|
|
empty = eina_list_remove_list(empty, l);
|
|
|
|
/* Remember x and y */
|
|
|
|
*x = r->x;
|
|
|
|
*y = r->y;
|
|
|
|
/* Split r in 2 rectangle if needed (only the empty one) and insert them */
|
|
|
|
if (r->w == w)
|
|
|
|
{
|
|
|
|
r->y += h;
|
|
|
|
r->h -= h;
|
|
|
|
empty = _eina_rectangle_merge_list(empty, r);
|
|
|
|
}
|
|
|
|
else if (r->h == h)
|
|
|
|
{
|
|
|
|
r->x += w;
|
|
|
|
r->w -= w;
|
|
|
|
empty = _eina_rectangle_merge_list(empty, r);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int x1, y1, w1, h1;
|
|
|
|
int x2, y2, w2, h2;
|
|
|
|
|
|
|
|
x1 = r->x + w;
|
|
|
|
y1 = r->y;
|
|
|
|
w1 = r->w - w;
|
|
|
|
/* h1 could be h or r->h */
|
|
|
|
x2 = r->x;
|
|
|
|
y2 = r->y + h;
|
|
|
|
/* w2 could be w or r->w */
|
|
|
|
h2 = r->h - h;
|
|
|
|
|
|
|
|
if (w1 * r->h > h2 * r->w)
|
|
|
|
{
|
|
|
|
h1 = r->h;
|
|
|
|
w2 = w;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
h1 = h;
|
|
|
|
w2 = r->w;
|
|
|
|
}
|
|
|
|
|
|
|
|
EINA_RECTANGLE_SET(r, x1, y1, w1, h1);
|
|
|
|
empty = _eina_rectangle_merge_list(empty, r);
|
|
|
|
|
|
|
|
r = eina_rectangle_new(x2, y2, w2, h2);
|
|
|
|
if (r) empty = _eina_rectangle_merge_list(empty, r);
|
|
|
|
}
|
|
|
|
/* Return empty */
|
|
|
|
return empty;
|
2008-10-27 13:24:12 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-24 06:38:25 -07:00
|
|
|
*x = -1;
|
|
|
|
*y = -1;
|
|
|
|
return empty;
|
2008-10-27 13:24:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @endcond
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*============================================================================*
|
|
|
|
* Global *
|
|
|
|
*============================================================================*/
|
|
|
|
|
|
|
|
/*============================================================================*
|
|
|
|
* API *
|
|
|
|
*============================================================================*/
|
|
|
|
|
2009-06-22 06:16:51 -07:00
|
|
|
EAPI Eina_Rectangle *
|
|
|
|
eina_rectangle_new(int x, int y, int w, int h)
|
|
|
|
{
|
|
|
|
Eina_Rectangle *rect;
|
|
|
|
|
2009-06-24 09:56:49 -07:00
|
|
|
rect = eina_mempool_malloc(_eina_rectangle_mp, sizeof (Eina_Rectangle));
|
2009-06-22 06:16:51 -07:00
|
|
|
if (!rect) return NULL;
|
|
|
|
|
|
|
|
EINA_RECTANGLE_SET(rect, x, y, w, h);
|
|
|
|
|
|
|
|
return rect;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
eina_rectangle_free(Eina_Rectangle *rect)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN(rect);
|
|
|
|
eina_mempool_free(_eina_rectangle_mp, rect);
|
|
|
|
}
|
|
|
|
|
2008-10-27 13:24:12 -07:00
|
|
|
EAPI Eina_Rectangle_Pool *
|
2009-06-22 06:16:51 -07:00
|
|
|
eina_rectangle_pool_new(int w, int h)
|
2008-10-27 13:24:12 -07:00
|
|
|
{
|
|
|
|
Eina_Rectangle_Pool *new;
|
|
|
|
|
|
|
|
new = malloc(sizeof (Eina_Rectangle_Pool));
|
|
|
|
if (!new) return NULL;
|
|
|
|
|
|
|
|
new->head = NULL;
|
2009-06-22 06:46:05 -07:00
|
|
|
new->empty = eina_list_append(NULL, eina_rectangle_new(0, 0, w, h));
|
2008-10-27 13:24:12 -07:00
|
|
|
new->references = 0;
|
|
|
|
new->w = w;
|
|
|
|
new->h = h;
|
|
|
|
|
|
|
|
EINA_MAGIC_SET(new, EINA_RECTANGLE_POOL_MAGIC);
|
|
|
|
|
|
|
|
return new;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
2009-06-22 06:16:51 -07:00
|
|
|
eina_rectangle_pool_free(Eina_Rectangle_Pool *pool)
|
2008-10-27 13:24:12 -07:00
|
|
|
{
|
|
|
|
Eina_Rectangle_Alloc *del;
|
|
|
|
|
2008-12-26 10:31:14 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(pool);
|
2008-10-27 13:24:12 -07:00
|
|
|
while (pool->head)
|
|
|
|
{
|
|
|
|
del = (Eina_Rectangle_Alloc*) pool->head;
|
|
|
|
|
|
|
|
pool->head = (EINA_INLIST_GET(del))->next;
|
|
|
|
|
2009-04-09 08:51:32 -07:00
|
|
|
EINA_MAGIC_SET(del, EINA_MAGIC_NONE);
|
2009-06-22 06:16:51 -07:00
|
|
|
eina_mempool_free(_eina_rectangle_alloc_mp, del);
|
2008-10-27 13:24:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
MAGIC_FREE(pool);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI int
|
|
|
|
eina_rectangle_pool_count(Eina_Rectangle_Pool *pool)
|
|
|
|
{
|
2008-12-26 10:31:14 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(pool, 0);
|
2008-10-27 13:24:12 -07:00
|
|
|
return pool->references;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Eina_Rectangle *
|
|
|
|
eina_rectangle_pool_request(Eina_Rectangle_Pool *pool, int w, int h)
|
|
|
|
{
|
|
|
|
Eina_Rectangle_Alloc *new;
|
|
|
|
Eina_Rectangle *rect;
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
|
2008-12-26 10:31:14 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(pool, NULL);
|
|
|
|
|
2009-06-24 06:38:25 -07:00
|
|
|
if (w <= 0 || h <= 0) return NULL;
|
2008-10-27 13:24:12 -07:00
|
|
|
if (w > pool->w || h > pool->h) return NULL;
|
|
|
|
|
2009-06-24 06:38:25 -07:00
|
|
|
/* Sort empty if dirty */
|
|
|
|
if (pool->sorted)
|
|
|
|
{
|
|
|
|
pool->empty = eina_list_sort(pool->empty, 0, EINA_COMPARE_CB(_eina_rectangle_cmp));
|
|
|
|
pool->sorted = EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
pool->empty = _eina_rectangle_empty_space_find(pool->empty, w, h, &x, &y);
|
|
|
|
if (x == -1) return NULL;
|
|
|
|
pool->sorted = EINA_FALSE;
|
2008-10-27 13:24:12 -07:00
|
|
|
|
2009-06-24 09:56:49 -07:00
|
|
|
new = eina_mempool_malloc(_eina_rectangle_alloc_mp,
|
|
|
|
sizeof (Eina_Rectangle_Alloc) + sizeof (Eina_Rectangle));
|
2008-10-27 13:24:12 -07:00
|
|
|
if (!new) return NULL;
|
|
|
|
|
|
|
|
rect = (Eina_Rectangle*) (new + 1);
|
|
|
|
eina_rectangle_coords_from(rect, x, y, w, h);
|
|
|
|
|
|
|
|
pool->head = eina_inlist_prepend(pool->head, EINA_INLIST_GET(new));
|
|
|
|
pool->references++;
|
|
|
|
|
|
|
|
new->pool = pool;
|
|
|
|
|
|
|
|
EINA_MAGIC_SET(new, EINA_RECTANGLE_ALLOC_MAGIC);
|
|
|
|
|
|
|
|
return rect;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
eina_rectangle_pool_release(Eina_Rectangle *rect)
|
|
|
|
{
|
|
|
|
Eina_Rectangle_Alloc *era = ((Eina_Rectangle_Alloc *) rect) - 1;
|
2009-06-24 06:38:25 -07:00
|
|
|
Eina_Rectangle *r;
|
2008-10-27 13:24:12 -07:00
|
|
|
|
2008-12-26 10:31:14 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(rect);
|
|
|
|
|
2008-10-27 13:24:12 -07:00
|
|
|
EINA_MAGIC_CHECK_RECTANGLE_ALLOC(era);
|
|
|
|
EINA_MAGIC_CHECK_RECTANGLE_POOL(era->pool);
|
|
|
|
|
|
|
|
era->pool->references--;
|
|
|
|
era->pool->head = eina_inlist_remove(era->pool->head, EINA_INLIST_GET(era));
|
|
|
|
|
2009-06-24 06:38:25 -07:00
|
|
|
r = eina_rectangle_new(rect->x, rect->y, rect->w, rect->h);
|
|
|
|
if (r)
|
|
|
|
{
|
|
|
|
era->pool->empty = _eina_rectangle_merge_list(era->pool->empty, r);
|
|
|
|
era->pool->sorted = EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2009-04-09 08:51:32 -07:00
|
|
|
EINA_MAGIC_SET(era, EINA_MAGIC_NONE);
|
2009-06-22 06:16:51 -07:00
|
|
|
eina_mempool_free(_eina_rectangle_alloc_mp, era);
|
2008-10-27 13:24:12 -07:00
|
|
|
}
|
|
|
|
|
2008-10-28 08:28:46 -07:00
|
|
|
EAPI Eina_Rectangle_Pool *
|
|
|
|
eina_rectangle_pool_get(Eina_Rectangle *rect)
|
|
|
|
{
|
|
|
|
Eina_Rectangle_Alloc *era = ((Eina_Rectangle_Alloc *) rect) - 1;
|
|
|
|
|
2008-12-26 10:31:14 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(rect, NULL);
|
2008-10-28 08:28:46 -07:00
|
|
|
|
|
|
|
EINA_MAGIC_CHECK_RECTANGLE_ALLOC(era);
|
|
|
|
EINA_MAGIC_CHECK_RECTANGLE_POOL(era->pool);
|
|
|
|
|
|
|
|
return era->pool;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
eina_rectangle_pool_data_set(Eina_Rectangle_Pool *pool, const void *data)
|
|
|
|
{
|
|
|
|
EINA_MAGIC_CHECK_RECTANGLE_POOL(pool);
|
2008-12-26 10:31:14 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(pool);
|
2008-10-28 08:28:46 -07:00
|
|
|
|
|
|
|
pool->data = (void*) data;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void *
|
|
|
|
eina_rectangle_pool_data_get(Eina_Rectangle_Pool *pool)
|
|
|
|
{
|
|
|
|
EINA_MAGIC_CHECK_RECTANGLE_POOL(pool);
|
2008-12-26 10:31:14 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(pool, NULL);
|
2008-10-28 08:28:46 -07:00
|
|
|
|
|
|
|
return pool->data;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Eina_Bool
|
|
|
|
eina_rectangle_pool_geometry_get(Eina_Rectangle_Pool *pool, int *w, int *h)
|
|
|
|
{
|
|
|
|
if (!pool) return EINA_FALSE;
|
|
|
|
|
|
|
|
EINA_MAGIC_CHECK_RECTANGLE_POOL(pool);
|
2008-12-26 10:31:14 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(pool, EINA_FALSE);
|
2008-10-28 08:28:46 -07:00
|
|
|
|
|
|
|
if (w) *w = pool->w;
|
|
|
|
if (h) *h = pool->h;
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2009-04-09 08:51:32 -07:00
|
|
|
EAPI int
|
|
|
|
eina_rectangle_init(void)
|
|
|
|
{
|
|
|
|
const char *choice;
|
|
|
|
|
|
|
|
_eina_rectangle_init_count++;
|
|
|
|
|
|
|
|
if (_eina_rectangle_init_count > 1) return _eina_rectangle_init_count;
|
|
|
|
|
2009-06-05 21:22:21 -07:00
|
|
|
if (!eina_error_init())
|
|
|
|
{
|
2009-06-24 06:38:25 -07:00
|
|
|
EINA_ERROR_PERR("Could not initialize eina error module.\n");
|
2009-06-05 21:22:21 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (!eina_mempool_init())
|
|
|
|
{
|
|
|
|
EINA_ERROR_PERR("Could not initialize eina mempool module.\n");
|
|
|
|
goto mempool_init_error;
|
|
|
|
}
|
2009-04-09 08:51:32 -07:00
|
|
|
|
|
|
|
#ifdef EINA_DEFAULT_MEMPOOL
|
|
|
|
choice = "pass_through";
|
|
|
|
#else
|
|
|
|
if (!(choice = getenv("EINA_MEMPOOL")))
|
|
|
|
choice = "chained_mempool";
|
|
|
|
#endif
|
|
|
|
|
2009-06-24 09:56:49 -07:00
|
|
|
_eina_rectangle_alloc_mp = eina_mempool_add(choice, "rectangle-alloc", NULL,
|
2009-06-05 21:22:21 -07:00
|
|
|
sizeof (Eina_Rectangle_Alloc) + sizeof (Eina_Rectangle), 42);
|
2009-06-22 06:16:51 -07:00
|
|
|
if (!_eina_rectangle_alloc_mp)
|
|
|
|
{
|
|
|
|
EINA_ERROR_PERR("ERROR: Mempool for rectangle cannot be allocated in list init.\n");
|
|
|
|
goto init_error;
|
|
|
|
}
|
|
|
|
|
2009-06-24 09:56:49 -07:00
|
|
|
_eina_rectangle_mp = eina_mempool_add(choice, "rectangle", NULL, sizeof (Eina_Rectangle), 256);
|
2009-04-09 08:51:32 -07:00
|
|
|
if (!_eina_rectangle_mp)
|
|
|
|
{
|
2009-06-05 21:22:21 -07:00
|
|
|
EINA_ERROR_PERR("ERROR: Mempool for rectangle cannot be allocated in list init.\n");
|
|
|
|
goto init_error;
|
2009-04-09 08:51:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return _eina_rectangle_init_count;
|
2009-06-05 21:22:21 -07:00
|
|
|
|
|
|
|
init_error:
|
|
|
|
eina_mempool_shutdown();
|
|
|
|
mempool_init_error:
|
|
|
|
eina_error_shutdown();
|
|
|
|
|
|
|
|
return 0;
|
2009-04-09 08:51:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI int
|
|
|
|
eina_rectangle_shutdown(void)
|
|
|
|
{
|
|
|
|
--_eina_rectangle_init_count;
|
|
|
|
|
|
|
|
if (_eina_rectangle_init_count) return _eina_rectangle_init_count;
|
|
|
|
|
2009-06-24 09:56:49 -07:00
|
|
|
eina_mempool_del(_eina_rectangle_alloc_mp);
|
|
|
|
eina_mempool_del(_eina_rectangle_mp);
|
2009-04-09 08:51:32 -07:00
|
|
|
|
|
|
|
eina_mempool_shutdown();
|
|
|
|
eina_error_shutdown();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2008-10-27 13:24:12 -07:00
|
|
|
|