Enlightenment CVS committal
Author : cedric
Project : e17
Module : proto/eina
Dir : e17/proto/eina/src/lib
Modified Files:
eina_mempool.c
Log Message:
Cleanup the mempool stuff.
===================================================================
RCS file: /cvs/e/e17/proto/eina/src/lib/eina_mempool.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- eina_mempool.c 30 Jul 2008 13:35:49 -0000 1.2
+++ eina_mempool.c 31 Jul 2008 17:00:56 -0000 1.3
@@ -17,11 +17,11 @@
Eina_Mempool_Backend *backend;
void *backend_data;
};
-static Eina_Mempool * _new_from_buffer(const char *name, void *buffer,
- unsigned int size, const char *options, va_list args)
+static Eina_Mempool *
+_new_from_buffer(const char *module, const char *context, const char *options,
va_list args)
{
Eina_List *l;
-
+
/* load the module with filename == name */
for (l = _modules; l; l = eina_list_next(l))
{
@@ -29,7 +29,7 @@
m = eina_list_data(l);
/* check if the requested module name exists */
- if (!strncmp(eina_module_name_get(m), name, strlen(name)))
+ if (!strncmp(eina_module_name_get(m), module, strlen(module) +
1))
{
Eina_Mempool *mp;
@@ -37,7 +37,7 @@
eina_module_load(m);
mp->module = m;
mp->backend = eina_module_symbol_get(m, "mp_backend");
- mp->backend_data = mp->backend->init(buffer, size,
options, args);
+ mp->backend_data = mp->backend->init(context, options,
args);
return mp;
}
@@ -50,7 +50,8 @@
/**
*
*/
-EAPI int eina_mempool_init(void)
+EAPI int
+eina_mempool_init(void)
{
if (!_init_count)
{
@@ -62,7 +63,8 @@
/**
*
*/
-EAPI int eina_mempool_shutdown(void)
+EAPI int
+eina_mempool_shutdown(void)
{
if (!_init_count)
return _init_count;
@@ -77,38 +79,18 @@
/**
*
*/
-EAPI Eina_Mempool * eina_mempool_new_from_buffer(const char *name, void
*buffer,
- unsigned int size, const char *options, ...)
-{
- Eina_Mempool *mp;
- va_list args;
-
- assert(name);
- assert(buffer);
-
- va_start(args, options);
- mp = _new_from_buffer(name, buffer, size, options, args);
- va_end(args);
-
- return mp;
-}
-/**
- *
- */
-EAPI Eina_Mempool * eina_mempool_new(const char *name, unsigned int size,
const char
- *options, ...)
+EAPI Eina_Mempool *
+eina_mempool_new(const char *name, const char *context, const char *options,
...)
{
Eina_Mempool *mp;
- void *buffer;
va_list args;
-
+
assert(name);
-
- buffer = malloc(sizeof(char) * size);
+
va_start(args, options);
- mp = _new_from_buffer(name, buffer, size, options, args);
+ mp = _new_from_buffer(name, context, options, args);
va_end(args);
-
+
return mp;
}
/**
@@ -116,10 +98,8 @@
*/
EAPI void eina_mempool_delete(Eina_Mempool *mp)
{
- Eina_List *l;
-
assert(mp);
-
+
mp->backend->shutdown(mp->backend_data);
eina_module_unload(mp->module);
free(mp);
@@ -129,7 +109,10 @@
*/
EAPI void * eina_mempool_realloc(Eina_Mempool *mp, void *element, unsigned int
size)
{
-
+ assert(mp);
+ assert(mp->backend->realloc);
+
+ return mp->backend->realloc(mp->backend_data, element, size);
}
/**
*
@@ -138,7 +121,7 @@
{
assert(mp);
assert(mp->backend->alloc);
-
+
return mp->backend->alloc(mp->backend_data, size);
}
/**
@@ -148,6 +131,6 @@
{
assert(mp);
assert(mp->backend->free);
-
+
mp->backend->free(mp->backend_data, element);
}
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs