* evas: Remove Evas data type. You should now use Eina.

SVN revision: 41083
This commit is contained in:
Cedric BAIL 2009-06-17 15:46:27 +00:00
parent 3ec50d3bdc
commit 010621dd4a
7 changed files with 2 additions and 366 deletions

View File

@ -41,8 +41,6 @@
* @todo finish api documentation
*/
#include <Evas_Data.h>
typedef enum _Evas_Callback_Type
{
EVAS_CALLBACK_MOUSE_IN, /**< Mouse In Event */

View File

@ -1,6 +1,6 @@
MAINTAINERCLEANFILES = Makefile.in
SUBDIRS = canvas data cache cserve file engines imaging include
SUBDIRS = canvas cache cserve file engines imaging include
EVAS_STATIC_MODULE =
EVAS_STATIC_LIBADD =
@ -178,7 +178,7 @@ AM_CFLAGS = @WIN32_CFLAGS@
lib_LTLIBRARIES = libevas.la
include_HEADERS = Evas.h Evas_Data.h
include_HEADERS = Evas.h
libevas_la_SOURCES = main.c
@ -190,7 +190,6 @@ endif
libevas_la_LIBADD = \
canvas/libevas_canvas.la \
data/libevas_data.la \
file/libevas_file.la \
cache/libevas_cache.la \
imaging/libevas_imaging.la \
@ -209,7 +208,6 @@ $(EVAS_STATIC_LIBADD) \
libevas_la_DEPENDENCIES = \
canvas/libevas_canvas.la \
data/libevas_data.la \
file/libevas_file.la \
cache/libevas_cache.la \
imaging/libevas_imaging.la \

View File

@ -1,6 +0,0 @@
Makefile.in
Makefile
.deps
.libs
*.la
*.lo

View File

@ -1,19 +0,0 @@
MAINTAINERCLEANFILES = Makefile.in
AM_CPPFLAGS = -I. \
-I$(top_srcdir)/src/lib \
-I$(top_srcdir)/src/lib/include \
-DPACKAGE_BIN_DIR=\"$(bindir)\" \
-DPACKAGE_LIB_DIR=\"$(libdir)\" \
-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
@FREETYPE_CFLAGS@ @EINA_CFLAGS@
noinst_LTLIBRARIES = libevas_data.la
libevas_data_la_SOURCES = \
evas_array_hash.c \
evas_mempool.c
libevas_data_la_DEPENDENCIES = $(top_builddir)/config.h
EXTRA_DIST = evas_mempool.h

View File

@ -1,122 +0,0 @@
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdlib.h>
#include "Evas_Data.h"
#define EAH_BUCKETS 256
#define EAH_HASH(key) \
( key % EAH_BUCKETS )
typedef struct _Evas_Array_Hash_El Evas_Array_Hash_El;
struct _Evas_Array_Hash
{
Evas_Array_Hash_El *buckets[EAH_BUCKETS];
};
struct _Evas_Array_Hash_El
{
int data_max;
int data_count;
int *data;
};
/*
These functions provide an interface for a simple hash. The hash
is and array of int array pointers. Right now that hash size is 256.
The hash size is static. The key and data are ints.
Keys must be added in ascending order because the search function
assumes that the hash buckets are sorted.
*/
EAPI Evas_Array_Hash *
evas_array_hash_new(void)
{
Evas_Array_Hash *hash;
hash = calloc(1, sizeof(Evas_Array_Hash));
return hash;
}
EAPI void
evas_array_hash_free(Evas_Array_Hash *hash)
{
int i;
for (i = 0; i < EAH_BUCKETS; i++)
{
if (hash->buckets[i])
{
free(hash->buckets[i]->data);
free(hash->buckets[i]);
}
}
free(hash);
}
EAPI void
evas_array_hash_add(Evas_Array_Hash *hash, int key, int data)
{
int hash_val;
Evas_Array_Hash_El *el;
hash_val = EAH_HASH(key);
el = hash->buckets[hash_val];
if (!el)
{
el = malloc(sizeof(Evas_Array_Hash_El));
el->data_max = 4;
el->data = malloc(sizeof(int) * el->data_max);
el->data_count = 0;
hash->buckets[hash_val] = el;
}
else if (el->data_count == el->data_max)
{
el->data_max *= 2;
el->data = realloc(el->data, sizeof(int) * el->data_max);
}
el->data[el->data_count++] = key;
el->data[el->data_count++] = data;
}
EAPI int
evas_array_hash_search(Evas_Array_Hash *hash, int key)
{
int hash_val;
Evas_Array_Hash_El *el;
int low, high, i, val;
hash_val = EAH_HASH(key);
el = hash->buckets[hash_val];
if (!el)
return 0;
/* Binary Search the bucket for key */
low = 0;
high = ( el->data_count / 2 ) - 1;
while ( high >= low )
{
i = (high + low) / 2;
val = el->data[i << 1];
if (val == key)
return el->data[(i << 1) + 1];
else if (val > key)
high = i - 1;
else
low = i + 1;
}
return 0;
}

View File

@ -1,188 +0,0 @@
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#include "Evas_Data.h"
#include "evas_mempool.h"
//#define NOPOOL
typedef struct _Pool Pool;
struct _Pool
{
int usage;
void *base;
Pool *prev, *next;
};
Pool *
_evas_mp_pool_new(Evas_Mempool *pool)
#ifdef NOPOOL
{
static Pool thepool;
return &thepool;
}
#else
{
Pool *p;
void **ptr;
int item_alloc, i;
item_alloc = ((pool->item_size + sizeof(void *) - 1) / sizeof(void *)) * sizeof(void *);
p = malloc(sizeof(Pool) + (pool->pool_size * item_alloc));
ptr = (void **)(((unsigned char *)p) + sizeof(Pool));
p->usage = 0;
p->base = ptr;
for (i = 0; i < pool->pool_size - 1; i++)
{
*ptr = (void **)(((unsigned char *)ptr) + item_alloc);
ptr = *ptr;
}
*ptr = NULL;
return p;
}
#endif
void
_evas_mp_pool_free(Pool *p)
#ifdef NOPOOL
{
}
#else
{
free(p);
}
#endif
void *
evas_mempool_malloc(Evas_Mempool *pool, int size)
#ifdef NOPOOL
{
return malloc(size);
}
#else
{
Pool *p;
void *mem;
for (p = pool->first; p; p = p->next) // look 4 pool from 2nd bucket on
{
if (p->base) // base is not NULL - has a free slot
{
if (p->prev)
{
if (pool->last == p) pool->last = p->prev;
p->prev->next = p->next;
p->prev = NULL;
p->next = pool->first;
p->next->prev = p;
pool->first = p;
}
break;
}
}
if (!p) // we have reached the end of the list - no free pools
{
p = _evas_mp_pool_new(pool);
if (!p) return NULL;
p->prev = NULL;
p->next = pool->first;
if (p->next) p->next->prev = p;
if (!pool->last) pool->last = p;
pool->first = p;
}
mem = p->base; // this points to the next free block - so take it
p->base = *((void **)mem); // base now points to the next free block
if (!p->base) // move to end - it just filled up
{
if (p->next)
{
if (p->prev) p->prev->next = p->next;
else pool->first = p->next;
p->next->prev = p->prev;
((Pool *)pool->last)->next = p;
p->prev = pool->last;
p->next = NULL;
pool->last = p;
}
}
p->usage++;
pool->usage++;
return mem;
}
#endif
void
evas_mempool_free(Evas_Mempool *pool, void *ptr)
#ifdef NOPOOL
{
free(ptr);
}
#else
{
Pool *p;
void *pmem;
int item_alloc, psize;
item_alloc = ((pool->item_size + sizeof(void *) - 1) / sizeof(void *)) * sizeof(void *);
psize = item_alloc * pool->pool_size;
for (p = (Pool *)(pool->first); p; p = p->next) // look 4 pool
{
pmem = (void *)(((unsigned char *)p) + sizeof(Pool)); // pool mem base
if ((ptr >= pmem) && ((unsigned char *)ptr < (((unsigned char *)pmem) + psize))) // is it in pool mem?
{
*((void **)ptr) = p->base; // freed node points to prev free node
p->base = ptr; // next free node is now the one we freed
p->usage--;
pool->usage--;
if (p->usage == 0) // free bucket
{
if (p->prev) p->prev->next = p->next;
if (p->next) p->next->prev = p->prev;
if (pool->last == p) pool->last = p->prev;
if (pool->first == p) pool->first = p->next;
_evas_mp_pool_free(p);
}
else
{
if (p->prev) // if not the first - move to front
{
p->prev->next = p->next;
if (p->next) p->next->prev = p->prev;
if (pool->last == p) pool->last = p->prev;
p->prev = NULL;
p->next = pool->first;
p->next->prev = p;
pool->first = p;
}
}
break;
}
}
}
#endif
void *
evas_mempool_calloc(Evas_Mempool *pool, int size)
#ifdef NOPOOL
{
return calloc(1, size);
}
#else
{
void *mem;
mem = evas_mempool_malloc(pool, size);
memset(mem, 0, size);
return mem;
}
#endif

View File

@ -1,25 +0,0 @@
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#ifndef _EVAS_MEMPOOL_H
#define _EVAS_MEMPOOL_H
typedef struct _Evas_Mempool Evas_Mempool;
struct _Evas_Mempool
{
int item_size;
int pool_size;
int usage;
void *first, *last;
};
void *evas_mempool_malloc(Evas_Mempool *pool, int size);
void evas_mempool_free(Evas_Mempool *pool, void *ptr);
void *evas_mempool_calloc(Evas_Mempool *pool, int size);
#endif /* _EVAS_MEMPOOL_H */