2011-11-29 Mike McCormack
* Allow quitting before entering the glib version of the main loop
+
+2011-12-02 Mike Blumenkrantz
+
+ * Use mempools for allocations
+Ecore 1.2.0
+
+Changes since Ecore 1.1.0:
+--------------------------
+
+Improvements:
+ * ecore:
+ - most allocations moved to mempools
+
+
Ecore 1.1.0
Changes since Ecore 1.0.0:
libecore_la_SOURCES = \
ecore.c \
+ecore_alloc.c \
ecore_anim.c \
ecore_app.c \
ecore_events.c \
}
if (getenv("ECORE_FPS_DEBUG")) _ecore_fps_debug = 1;
if (_ecore_fps_debug) _ecore_fps_debug_init();
+ if (!ecore_mempool_init()) goto shutdown_mempool;
_ecore_main_loop_init();
_ecore_signal_init();
_ecore_thread_init();
return _ecore_init_count;
+shutdown_mempool:
+ ecore_mempool_shutdown();
shutdown_log_dom:
eina_shutdown();
shutdown_evil:
_ecore_memory_max_free);
}
#endif
-
+ ecore_mempool_shutdown();
eina_log_domain_unregister(_ecore_log_dom);
_ecore_log_dom = -1;
eina_shutdown();
--- /dev/null
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <Eina.h>
+#include "Ecore.h"
+#include "ecore_private.h"
+
+typedef struct _Ecore_Mempool Ecore_Mempool;
+struct _Ecore_Mempool
+{
+ const char *name;
+ Eina_Mempool *mp;
+ size_t size;
+};
+
+#define GENERIC_ALLOC_FREE(TYPE, Type) \
+ Ecore_Mempool Type##_mp = { #TYPE, NULL, sizeof (TYPE) }; \
+ TYPE * \
+ Type##_calloc(unsigned int num) \
+ { \
+ return eina_mempool_calloc(Type##_mp.mp, num * sizeof (TYPE)); \
+ } \
+ void \
+ Type##_mp_free(TYPE *e) \
+ { \
+ eina_mempool_free(Type##_mp.mp, e); \
+ }
+
+GENERIC_ALLOC_FREE(Ecore_Animator, ecore_animator);
+GENERIC_ALLOC_FREE(Ecore_Event_Handler, ecore_event_handler);
+GENERIC_ALLOC_FREE(Ecore_Event_Filter, ecore_event_filter);
+GENERIC_ALLOC_FREE(Ecore_Event, ecore_event);
+GENERIC_ALLOC_FREE(Ecore_Idle_Exiter, ecore_idle_exiter);
+GENERIC_ALLOC_FREE(Ecore_Idle_Enterer, ecore_idle_enterer);
+GENERIC_ALLOC_FREE(Ecore_Idler, ecore_idler);
+GENERIC_ALLOC_FREE(Ecore_Job, ecore_job);
+GENERIC_ALLOC_FREE(Ecore_Timer, ecore_timer);
+GENERIC_ALLOC_FREE(Ecore_Poller, ecore_poller);
+GENERIC_ALLOC_FREE(Ecore_Pipe, ecore_pipe);
+GENERIC_ALLOC_FREE(Ecore_Fd_Handler, ecore_fd_handler);
+#ifdef _WIN32
+GENERIC_ALLOC_FREE(Ecore_Win32_Handler, ecore_win32_handler);
+#endif
+
+static Ecore_Mempool *mempool_array[] = {
+ &ecore_animator_mp,
+ &ecore_event_handler_mp,
+ &ecore_event_filter_mp,
+ &ecore_event_mp,
+ &ecore_idle_exiter_mp,
+ &ecore_idle_enterer_mp,
+ &ecore_idler_mp,
+ &ecore_job_mp,
+ &ecore_timer_mp,
+ &ecore_poller_mp,
+ &ecore_pipe_mp,
+ &ecore_fd_handler_mp,
+#ifdef _WIN32
+ &ecore_win32_handler_mp
+#endif
+};
+
+Eina_Bool
+ecore_mempool_init(void)
+{
+ const char *choice;
+ unsigned int i;
+
+ choice = getenv("EINA_MEMPOOL");
+ if ((!choice) || (!choice[0]))
+ choice = "chained_mempool";
+
+ for (i = 0; i < sizeof (mempool_array) / sizeof (mempool_array[0]); ++i)
+ {
+ retry:
+ mempool_array[i]->mp = eina_mempool_add(choice, mempool_array[i]->name, NULL, mempool_array[i]->size, 64);
+ if (!mempool_array[i]->mp)
+ {
+ if (!strcmp(choice, "pass_through"))
+ {
+ ERR("Falling back to pass through ! Previously tried '%s' mempool.", choice);
+ choice = "pass_through";
+ goto retry;
+ }
+ else
+ {
+ ERR("Impossible to allocate mempool '%s' !", choice);
+ return EINA_FALSE;
+ }
+ }
+ }
+ return EINA_TRUE;
+}
+
+void
+ecore_mempool_shutdown(void)
+{
+ unsigned int i;
+
+ for (i = 0; i < sizeof (mempool_array) / sizeof (mempool_array[0]); ++i)
+ {
+ eina_mempool_del(mempool_array[i]->mp);
+ mempool_array[i]->mp = NULL;
+ }
+}
+
#include "Ecore.h"
#include "ecore_private.h"
-struct _Ecore_Animator
-{
- EINA_INLIST;
- ECORE_MAGIC;
-
- Ecore_Task_Cb func;
- void *data;
-
- double start, run;
- Ecore_Timeline_Cb run_func;
- void *run_data;
-
- Eina_Bool delete_me : 1;
- Eina_Bool suspended : 1;
-};
-
static Eina_Bool _ecore_animator_run(void *data);
static Eina_Bool _ecore_animator(void *data);
eina_inlist_remove(EINA_INLIST_GET(animators),
EINA_INLIST_GET(animator));
ECORE_MAGIC_SET(animator, ECORE_MAGIC_NONE);
- free(animator);
+ ecore_animator_mp_free(animator);
animators_delete_me--;
if (animators_delete_me == 0) break;
}
Ecore_Animator *animator = NULL;
if (!func) return animator;
- animator = calloc(1, sizeof(Ecore_Animator));
+ animator = ecore_animator_calloc(1);
if (!animator) return animator;
ECORE_MAGIC_SET(animator, ECORE_MAGIC_ANIMATOR);
animator->func = func;
animator = animators;
animators = (Ecore_Animator *)eina_inlist_remove(EINA_INLIST_GET(animators), EINA_INLIST_GET(animators));
ECORE_MAGIC_SET(animator, ECORE_MAGIC_NONE);
- free(animator);
+ ecore_animator_mp_free(animator);
}
}
static int inpurge = 0;
-struct _Ecore_Event_Handler
-{
- EINA_INLIST;
- ECORE_MAGIC;
- int type;
- Ecore_Event_Handler_Cb func;
- void *data;
- int references;
- Eina_Bool delete_me : 1;
-};
-
-struct _Ecore_Event_Filter
-{
- EINA_INLIST;
- ECORE_MAGIC;
- Ecore_Data_Cb func_start;
- Ecore_Filter_Cb func_filter;
- Ecore_End_Cb func_end;
- void *loop_data;
- void *data;
- int references;
- Eina_Bool delete_me : 1;
-};
-
-struct _Ecore_Event
-{
- EINA_INLIST;
- ECORE_MAGIC;
- int type;
- void *event;
- Ecore_End_Cb func_free;
- void *data;
- int references;
- Eina_Bool delete_me : 1;
-};
-
static int events_num = 0;
static Ecore_Event *events = NULL;
static Ecore_Event *event_current = NULL;
if (!func) goto unlock;
if ((type <= ECORE_EVENT_NONE) || (type >= event_id_max)) goto unlock;
- eh = calloc(1, sizeof(Ecore_Event_Handler));
+ eh = ecore_event_handler_calloc(1);
if (!eh) goto unlock;
ECORE_MAGIC_SET(eh, ECORE_MAGIC_EVENT_HANDLER);
eh->type = type;
new_handlers = realloc(event_handlers, event_handlers_alloc_num * sizeof(Ecore_Event_Handler *));
if (!new_handlers)
{
- free(eh);
+ ecore_event_handler_mp_free(eh);
goto unlock;
}
event_handlers = new_handlers;
static void
_ecore_event_generic_free(void *data __UNUSED__,
void *event)
-{
+{ /* DO NOT MEMPOOL FREE THIS */
free (event);
}
_ecore_lock();
if (!func_filter) goto unlock;
- ef = calloc(1, sizeof(Ecore_Event_Filter));
+ ef = ecore_event_filter_calloc(1);
if (!ef) goto unlock;
ECORE_MAGIC_SET(ef, ECORE_MAGIC_EVENT_FILTER);
ef->func_start = func_start;
{
event_handlers[i] = (Ecore_Event_Handler *)eina_inlist_remove(EINA_INLIST_GET(event_handlers[i]), EINA_INLIST_GET(event_handlers[i]));
ECORE_MAGIC_SET(eh, ECORE_MAGIC_NONE);
- if (!eh->delete_me) free(eh);
+ if (!eh->delete_me) ecore_event_handler_mp_free(eh);
}
}
EINA_LIST_FREE(event_handlers_delete_list, eh)
- free(eh);
+ ecore_event_handler_mp_free(eh);
if (event_handlers) free(event_handlers);
event_handlers = NULL;
event_handlers_num = 0;
{
event_filters = (Ecore_Event_Filter *)eina_inlist_remove(EINA_INLIST_GET(event_filters), EINA_INLIST_GET(event_filters));
ECORE_MAGIC_SET(ef, ECORE_MAGIC_NONE);
- free(ef);
+ ecore_event_filter_mp_free(ef);
}
event_filters_delete_me = 0;
event_filter_current = NULL;
{
Ecore_Event *e;
- e = calloc(1, sizeof(Ecore_Event));
+ e = ecore_event_calloc(1);
if (!e) return NULL;
ECORE_MAGIC_SET(e, ECORE_MAGIC_EVENT);
e->type = type;
if (event->func_free) _ecore_call_end_cb(event->func_free, event->data, event->event);
events = (Ecore_Event *)eina_inlist_remove(EINA_INLIST_GET(events), EINA_INLIST_GET(event));
ECORE_MAGIC_SET(event, ECORE_MAGIC_NONE);
- free(event);
+ ecore_event_mp_free(event);
events_num--;
return data;
}
event_filters = (Ecore_Event_Filter *)eina_inlist_remove(EINA_INLIST_GET(event_filters), EINA_INLIST_GET(ef));
ECORE_MAGIC_SET(ef, ECORE_MAGIC_NONE);
- free(ef);
+ ecore_event_filter_mp_free(ef);
}
}
if (!deleted_in_use)
event_handlers[eh->type] = (Ecore_Event_Handler *)eina_inlist_remove(EINA_INLIST_GET(event_handlers[eh->type]), EINA_INLIST_GET(eh));
ECORE_MAGIC_SET(eh, ECORE_MAGIC_NONE);
- free(eh);
+ ecore_event_handler_mp_free(eh);
}
}
#include "Ecore.h"
#include "ecore_private.h"
-struct _Ecore_Idle_Enterer
-{
- EINA_INLIST;
- ECORE_MAGIC;
- Ecore_Task_Cb func;
- void *data;
- int references;
- Eina_Bool delete_me : 1;
-};
-
static Ecore_Idle_Enterer *idle_enterers = NULL;
static Ecore_Idle_Enterer *idle_enterer_current = NULL;
static int idle_enterers_delete_me = 0;
_ecore_lock();
if (!func) goto unlock;
- ie = calloc(1, sizeof(Ecore_Idle_Enterer));
+ ie = ecore_idle_enterer_calloc(1);
if (!ie) goto unlock;
ECORE_MAGIC_SET(ie, ECORE_MAGIC_IDLE_ENTERER);
ie->func = func;
_ecore_lock();
if (!func) goto unlock;
- ie = calloc(1, sizeof(Ecore_Idle_Enterer));
+ ie = ecore_idle_enterer_calloc(1);
if (!ie) goto unlock;
ECORE_MAGIC_SET(ie, ECORE_MAGIC_IDLE_ENTERER);
ie->func = func;
{
idle_enterers = (Ecore_Idle_Enterer *)eina_inlist_remove(EINA_INLIST_GET(idle_enterers), EINA_INLIST_GET(idle_enterers));
ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE);
- free(ie);
+ ecore_idle_enterer_mp_free(ie);
}
idle_enterers_delete_me = 0;
idle_enterer_current = NULL;
idle_enterers = (Ecore_Idle_Enterer *)eina_inlist_remove(EINA_INLIST_GET(idle_enterers), EINA_INLIST_GET(ie));
ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE);
- free(ie);
+ ecore_idle_enterer_mp_free(ie);
}
}
if (!deleted_idler_enterers_in_use)
#include "Ecore.h"
#include "ecore_private.h"
-struct _Ecore_Idle_Exiter
-{
- EINA_INLIST;
- ECORE_MAGIC;
- Ecore_Task_Cb func;
- void *data;
- int references;
- Eina_Bool delete_me : 1;
-};
-
static Ecore_Idle_Exiter *idle_exiters = NULL;
static Ecore_Idle_Exiter *idle_exiter_current = NULL;
static int idle_exiters_delete_me = 0;
_ecore_lock();
if (!func) goto unlock;
- ie = calloc(1, sizeof(Ecore_Idle_Exiter));
+ ie = ecore_idle_exiter_calloc(1);
if (!ie) goto unlock;
ECORE_MAGIC_SET(ie, ECORE_MAGIC_IDLE_EXITER);
ie->func = func;
{
idle_exiters = (Ecore_Idle_Exiter *)eina_inlist_remove(EINA_INLIST_GET(idle_exiters), EINA_INLIST_GET(idle_exiters));
ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE);
- free(ie);
+ ecore_idle_exiter_mp_free(ie);
}
idle_exiters_delete_me = 0;
idle_exiter_current = NULL;
idle_exiters = (Ecore_Idle_Exiter *)eina_inlist_remove(EINA_INLIST_GET(idle_exiters), EINA_INLIST_GET(ie));
ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE);
- free(ie);
+ ecore_idle_exiter_mp_free(ie);
}
}
if (!deleted_idler_exiters_in_use)
#include "Ecore.h"
#include "ecore_private.h"
-struct _Ecore_Idler
-{
- EINA_INLIST;
- ECORE_MAGIC;
- Ecore_Task_Cb func;
- void *data;
- int references;
- Eina_Bool delete_me : 1;
-};
-
static Ecore_Idler *idlers = NULL;
static Ecore_Idler *idler_current = NULL;
static int idlers_delete_me = 0;
_ecore_lock();
if (!func) goto unlock;
- ie = calloc(1, sizeof(Ecore_Idler));
+ ie = ecore_idler_calloc(1);
if (!ie) goto unlock;
ECORE_MAGIC_SET(ie, ECORE_MAGIC_IDLER);
ie->func = func;
{
idlers = (Ecore_Idler *)eina_inlist_remove(EINA_INLIST_GET(idlers), EINA_INLIST_GET(idlers));
ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE);
- free(ie);
+ ecore_idler_mp_free(ie);
}
idlers_delete_me = 0;
idler_current = NULL;
idlers = (Ecore_Idler *)eina_inlist_remove(EINA_INLIST_GET(idlers), EINA_INLIST_GET(ie));
ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE);
- free(ie);
+ ecore_idler_mp_free(ie);
}
}
if (!deleted_idlers_in_use)
static int ecore_event_job_type = 0;
static Ecore_Event_Handler *_ecore_job_handler = NULL;
-struct _Ecore_Job
-{
- ECORE_MAGIC;
- Ecore_Event *event;
- Ecore_Cb func;
- void *data;
-};
-
void
_ecore_job_init(void)
{
if (!func) return NULL;
- job = calloc(1, sizeof(Ecore_Job));
+ job = ecore_job_calloc(1);
if (!job) return NULL;
ECORE_MAGIC_SET(job, ECORE_MAGIC_JOB);
job->event = ecore_event_add(ecore_event_job_type, job, _ecore_job_event_free, NULL);
if (!job->event)
{
- free(job);
+ ecore_job_mp_free(job);
return NULL;
}
job->func = func;
static void
_ecore_job_event_free(void *data __UNUSED__,
- void *ev)
+ void *job)
{
- free(ev);
+ ecore_job_mp_free(job);
}
#define NS_PER_SEC (1000.0 * 1000.0 * 1000.0)
-struct _Ecore_Fd_Handler
-{
- EINA_INLIST;
- ECORE_MAGIC;
- Ecore_Fd_Handler *next_ready;
- int fd;
- Ecore_Fd_Handler_Flags flags;
- Ecore_Fd_Cb func;
- void *data;
- Ecore_Fd_Cb buf_func;
- void *buf_data;
- Ecore_Fd_Prep_Cb prep_func;
- void *prep_data;
- int references;
- Eina_Bool read_active : 1;
- Eina_Bool write_active : 1;
- Eina_Bool error_active : 1;
- Eina_Bool delete_me : 1;
-#if defined(USE_G_MAIN_LOOP)
- GPollFD gfd;
-#endif
-};
-
-#ifdef _WIN32
-struct _Ecore_Win32_Handler
-{
- EINA_INLIST;
- ECORE_MAGIC;
- HANDLE h;
- Ecore_Win32_Handle_Cb func;
- void *data;
- int references;
- Eina_Bool delete_me : 1;
-};
-#endif
-
#ifndef USE_G_MAIN_LOOP
static int _ecore_main_select(double timeout);
#endif
if ((fd < 0) || (flags == 0) || (!func)) goto unlock;
- fdh = calloc(1, sizeof(Ecore_Fd_Handler));
+ fdh = ecore_fd_handler_calloc(1);
if (!fdh) goto unlock;
ECORE_MAGIC_SET(fdh, ECORE_MAGIC_FD_HANDLER);
fdh->next_ready = NULL;
{
int err = errno;
ERR("Failed to add poll on fd %d (errno = %d: %s)!", fd, err, strerror(err));
- free(fdh);
+ ecore_fd_handler_mp_free(fdh);
fdh = NULL;
goto unlock;
}
if (!h || !func) return NULL;
- wh = calloc(1, sizeof(Ecore_Win32_Handler));
+ wh = ecore_win32_handler_calloc(1);
if (!wh) return NULL;
ECORE_MAGIC_SET(wh, ECORE_MAGIC_WIN32_HANDLER);
wh->h = (HANDLE)h;
fd_handlers = (Ecore_Fd_Handler *)eina_inlist_remove(EINA_INLIST_GET(fd_handlers),
EINA_INLIST_GET(fdh));
ECORE_MAGIC_SET(fdh, ECORE_MAGIC_NONE);
- free(fdh);
+ ecore_fd_handler_mp_free(fdh);
}
if (fd_handlers_with_buffer)
fd_handlers_with_buffer = eina_list_free(fd_handlers_with_buffer);
win32_handlers = (Ecore_Win32_Handler *)eina_inlist_remove(EINA_INLIST_GET(win32_handlers),
EINA_INLIST_GET(wh));
ECORE_MAGIC_SET(wh, ECORE_MAGIC_NONE);
- free(wh);
+ ecore_win32_handler_mp_free(wh);
}
win32_handlers_delete_me = EINA_FALSE;
win32_handler_current = NULL;
fd_handlers = (Ecore_Fd_Handler *)
eina_inlist_remove(EINA_INLIST_GET(fd_handlers), EINA_INLIST_GET(fdh));
ECORE_MAGIC_SET(fdh, ECORE_MAGIC_NONE);
- free(fdh);
+ ecore_fd_handler_mp_free(fdh);
fd_handlers_to_delete = eina_list_remove_list(fd_handlers_to_delete, l);
}
}
eina_inlist_remove(EINA_INLIST_GET(win32_handlers),
EINA_INLIST_GET(wh));
ECORE_MAGIC_SET(wh, ECORE_MAGIC_NONE);
- free(wh);
+ ecore_win32_handler_mp_free(wh);
}
}
if (!deleted_in_use) win32_handlers_delete_me = EINA_FALSE;
#endif /* ! _WIN32 */
-struct _Ecore_Pipe
-{
- ECORE_MAGIC;
- int fd_read;
- int fd_write;
- Ecore_Fd_Handler *fd_handler;
- const void *data;
- Ecore_Pipe_Cb handler;
- unsigned int len;
- int handling;
- size_t already_read;
- void *passed_data;
- int message;
- Eina_Bool delete_me : 1;
-};
static Eina_Bool _ecore_pipe_read(void *data,
Ecore_Fd_Handler *fd_handler);
if (!handler) return NULL;
- p = (Ecore_Pipe *)calloc(1, sizeof(Ecore_Pipe));
+ p = ecore_pipe_calloc(1);
if (!p) return NULL;
if (pipe(fds))
{
- free(p);
+ ecore_pipe_mp_free(p);
return NULL;
}
if (p->fd_read != PIPE_FD_INVALID) pipe_close(p->fd_read);
if (p->fd_write != PIPE_FD_INVALID) pipe_close(p->fd_write);
data = (void *)p->data;
- free(p);
+ ecore_pipe_mp_free(p);
return data;
}
#include "Ecore.h"
#include "ecore_private.h"
-struct _Ecore_Poller
-{
- EINA_INLIST;
- ECORE_MAGIC;
- int ibit;
- unsigned char delete_me : 1;
- Ecore_Task_Cb func;
- void *data;
-};
-
static Ecore_Timer *timer = NULL;
static int min_interval = -1;
static int interval_incr = 0;
if (poller->delete_me)
{
pollers[i] = (Ecore_Poller *)eina_inlist_remove(EINA_INLIST_GET(pollers[i]), EINA_INLIST_GET(poller));
- free(poller);
+ ecore_poller_mp_free(poller);
poller_delete_count--;
changes++;
if (poller_delete_count <= 0) break;
if (!func) return NULL;
if (interval < 1) interval = 1;
- poller = calloc(1, sizeof(Ecore_Poller));
+ poller = ecore_poller_calloc(1);
if (!poller) return NULL;
ECORE_MAGIC_SET(poller, ECORE_MAGIC_POLLER);
/* interval MUST be a power of 2, so enforce it */
/* not in loop so safe - delete immediately */
data = poller->data;
pollers[poller->ibit] = (Ecore_Poller *)eina_inlist_remove(EINA_INLIST_GET(pollers[poller->ibit]), EINA_INLIST_GET(poller));
- free(poller);
+ ecore_poller_mp_free(poller);
_ecore_poller_next_tick_eval();
return data;
}
while ((poller = pollers[i]))
{
pollers[i] = (Ecore_Poller *)eina_inlist_remove(EINA_INLIST_GET(pollers[i]), EINA_INLIST_GET(pollers[i]));
- free(poller);
+ ecore_poller_mp_free(poller);
}
}
}
#define ECORE_MAGIC_WIN32_HANDLER 0xf7e8f1a3
#define ECORE_MAGIC_JOB 0x76543210
+typedef unsigned int Ecore_Magic;
#define ECORE_MAGIC Ecore_Magic __magic
#define ECORE_MAGIC_SET(d, m) (d)->__magic = (m)
#define ECORE_MAGIC_CHECK(d, m) ((d) && ((d)->__magic == (m)))
#define ECORE_MAGIC_FAIL(d, m, fn) _ecore_magic_fail((d), (d) ? (d)->__magic : 0, (m), (fn));
+#include "ecore_types.h"
+
/* undef the following, we want our version */
#undef FREE
#define FREE(ptr) free(ptr); ptr = NULL;
return; \
}
-typedef unsigned int Ecore_Magic;
-
EAPI void _ecore_magic_fail(const void *d,
Ecore_Magic m,
Ecore_Magic req_m,
extern Eina_Bool _ecore_glib_always_integrate;
extern Ecore_Select_Function main_loop_select;
+Eina_Bool ecore_mempool_init(void);
+void ecore_mempool_shutdown(void);
+#define GENERIC_ALLOC_FREE_HEADER(TYPE, Type) \
+ TYPE *Type##_calloc(unsigned int); \
+ void Type##_mp_free(TYPE *e);
+
+GENERIC_ALLOC_FREE_HEADER(Ecore_Animator, ecore_animator);
+GENERIC_ALLOC_FREE_HEADER(Ecore_Event_Handler, ecore_event_handler);
+GENERIC_ALLOC_FREE_HEADER(Ecore_Event_Filter, ecore_event_filter);
+GENERIC_ALLOC_FREE_HEADER(Ecore_Event, ecore_event);
+GENERIC_ALLOC_FREE_HEADER(Ecore_Idle_Exiter, ecore_idle_exiter);
+GENERIC_ALLOC_FREE_HEADER(Ecore_Idle_Enterer, ecore_idle_enterer);
+GENERIC_ALLOC_FREE_HEADER(Ecore_Idler, ecore_idler);
+GENERIC_ALLOC_FREE_HEADER(Ecore_Job, ecore_job);
+GENERIC_ALLOC_FREE_HEADER(Ecore_Timer, ecore_timer);
+GENERIC_ALLOC_FREE_HEADER(Ecore_Poller, ecore_poller);
+GENERIC_ALLOC_FREE_HEADER(Ecore_Pipe, ecore_pipe);
+GENERIC_ALLOC_FREE_HEADER(Ecore_Fd_Handler, ecore_fd_handler);
+#ifdef _WIN32
+GENERIC_ALLOC_FREE_HEADER(Ecore_Win32_Handler, ecore_win32_handler);
+#endif
+
#endif
#include "Ecore.h"
#include "ecore_private.h"
-#ifdef WANT_ECORE_TIMER_DUMP
-# include <string.h>
-# include <execinfo.h>
-# define ECORE_TIMER_DEBUG_BT_NUM 64
-typedef void (*Ecore_Timer_Bt_Func)();
-#endif
-
-struct _Ecore_Timer
-{
- EINA_INLIST;
- ECORE_MAGIC;
- double in;
- double at;
- double pending;
- Ecore_Task_Cb func;
- void *data;
-
-#ifdef WANT_ECORE_TIMER_DUMP
- Ecore_Timer_Bt_Func timer_bt[ECORE_TIMER_DEBUG_BT_NUM];
- int timer_bt_num;
-#endif
-
- int references;
- unsigned char delete_me : 1;
- unsigned char just_added : 1;
- unsigned char frozen : 1;
-};
-
static void _ecore_timer_set(Ecore_Timer *timer,
double at,
double in,
_ecore_lock();
if (!func) goto unlock;
if (in < 0.0) in = 0.0;
- timer = calloc(1, sizeof(Ecore_Timer));
+ timer = ecore_timer_calloc(1);
if (!timer) goto unlock;
ECORE_MAGIC_SET(timer, ECORE_MAGIC_TIMER);
now = ecore_time_get();
if (!func) return timer;
if (in < 0.0) in = 0.0;
- timer = calloc(1, sizeof(Ecore_Timer));
+ timer = ecore_timer_calloc(1);
if (!timer) return timer;
ECORE_MAGIC_SET(timer, ECORE_MAGIC_TIMER);
now = ecore_loop_time_get();
if (timer->delete_me)
timers_delete_me--;
- free(timer);
+ ecore_timer_mp_free(timer);
return data;
}
{
timers = (Ecore_Timer *)eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timers));
ECORE_MAGIC_SET(timer, ECORE_MAGIC_NONE);
- free(timer);
+ ecore_timer_mp_free(timer);
}
while ((timer = suspended))
{
suspended = (Ecore_Timer *)eina_inlist_remove(EINA_INLIST_GET(suspended), EINA_INLIST_GET(suspended));
ECORE_MAGIC_SET(timer, ECORE_MAGIC_NONE);
- free(timer);
+ ecore_timer_mp_free(timer);
}
timer_current = NULL;
}
timers = (Ecore_Timer *)eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer));
ECORE_MAGIC_SET(timer, ECORE_MAGIC_NONE);
- free(timer);
+ ecore_timer_mp_free(timer);
timers_delete_me--;
done++;
if (timers_delete_me == 0) return;
}
suspended = (Ecore_Timer *)eina_inlist_remove(EINA_INLIST_GET(suspended), EINA_INLIST_GET(timer));
ECORE_MAGIC_SET(timer, ECORE_MAGIC_NONE);
- free(timer);
+ ecore_timer_mp_free(timer);
timers_delete_me--;
done++;
if (timers_delete_me == 0) return;
--- /dev/null
+#ifndef ECORE_TYPES_H
+#define ECORE_TYPES_H
+
+#ifdef WANT_ECORE_TIMER_DUMP
+# include <string.h>
+# include <execinfo.h>
+# define ECORE_TIMER_DEBUG_BT_NUM 64
+typedef void (*Ecore_Timer_Bt_Func)();
+#endif
+
+struct _Ecore_Animator
+{
+ EINA_INLIST;
+ ECORE_MAGIC;
+
+ Ecore_Task_Cb func;
+ void *data;
+
+ double start, run;
+ Ecore_Timeline_Cb run_func;
+ void *run_data;
+
+ Eina_Bool delete_me : 1;
+ Eina_Bool suspended : 1;
+};
+
+struct _Ecore_Event_Handler
+{
+ EINA_INLIST;
+ ECORE_MAGIC;
+ int type;
+ Ecore_Event_Handler_Cb func;
+ void *data;
+ int references;
+ Eina_Bool delete_me : 1;
+};
+
+struct _Ecore_Event_Filter
+{
+ EINA_INLIST;
+ ECORE_MAGIC;
+ Ecore_Data_Cb func_start;
+ Ecore_Filter_Cb func_filter;
+ Ecore_End_Cb func_end;
+ void *loop_data;
+ void *data;
+ int references;
+ Eina_Bool delete_me : 1;
+};
+
+struct _Ecore_Event
+{
+ EINA_INLIST;
+ ECORE_MAGIC;
+ int type;
+ void *event;
+ Ecore_End_Cb func_free;
+ void *data;
+ int references;
+ Eina_Bool delete_me : 1;
+};
+
+struct _Ecore_Idle_Enterer
+{
+ EINA_INLIST;
+ ECORE_MAGIC;
+ Ecore_Task_Cb func;
+ void *data;
+ int references;
+ Eina_Bool delete_me : 1;
+};
+
+struct _Ecore_Idle_Exiter
+{
+ EINA_INLIST;
+ ECORE_MAGIC;
+ Ecore_Task_Cb func;
+ void *data;
+ int references;
+ Eina_Bool delete_me : 1;
+};
+
+struct _Ecore_Idler
+{
+ EINA_INLIST;
+ ECORE_MAGIC;
+ Ecore_Task_Cb func;
+ void *data;
+ int references;
+ Eina_Bool delete_me : 1;
+};
+
+struct _Ecore_Job
+{
+ ECORE_MAGIC;
+ Ecore_Event *event;
+ Ecore_Cb func;
+ void *data;
+};
+
+struct _Ecore_Fd_Handler
+{
+ EINA_INLIST;
+ ECORE_MAGIC;
+ Ecore_Fd_Handler *next_ready;
+ int fd;
+ Ecore_Fd_Handler_Flags flags;
+ Ecore_Fd_Cb func;
+ void *data;
+ Ecore_Fd_Cb buf_func;
+ void *buf_data;
+ Ecore_Fd_Prep_Cb prep_func;
+ void *prep_data;
+ int references;
+ Eina_Bool read_active : 1;
+ Eina_Bool write_active : 1;
+ Eina_Bool error_active : 1;
+ Eina_Bool delete_me : 1;
+#if defined(USE_G_MAIN_LOOP)
+ GPollFD gfd;
+#endif
+};
+
+#ifdef _WIN32
+struct _Ecore_Win32_Handler
+{
+ EINA_INLIST;
+ ECORE_MAGIC;
+ HANDLE h;
+ Ecore_Win32_Handle_Cb func;
+ void *data;
+ int references;
+ Eina_Bool delete_me : 1;
+};
+#endif
+
+struct _Ecore_Pipe
+{
+ ECORE_MAGIC;
+ int fd_read;
+ int fd_write;
+ Ecore_Fd_Handler *fd_handler;
+ const void *data;
+ Ecore_Pipe_Cb handler;
+ unsigned int len;
+ int handling;
+ size_t already_read;
+ void *passed_data;
+ int message;
+ Eina_Bool delete_me : 1;
+};
+
+struct _Ecore_Poller
+{
+ EINA_INLIST;
+ ECORE_MAGIC;
+ int ibit;
+ unsigned char delete_me : 1;
+ Ecore_Task_Cb func;
+ void *data;
+};
+
+struct _Ecore_Timer
+{
+ EINA_INLIST;
+ ECORE_MAGIC;
+ double in;
+ double at;
+ double pending;
+ Ecore_Task_Cb func;
+ void *data;
+
+#ifdef WANT_ECORE_TIMER_DUMP
+ Ecore_Timer_Bt_Func timer_bt[ECORE_TIMER_DEBUG_BT_NUM];
+ int timer_bt_num;
+#endif
+
+ int references;
+ unsigned char delete_me : 1;
+ unsigned char just_added : 1;
+ unsigned char frozen : 1;
+};
+
+#endif