forked from enlightenment/efl
parent
27eccf0332
commit
75f4ccbbe5
|
@ -1167,6 +1167,7 @@ ecore-sdl.pc
|
|||
ecore-quartz.pc
|
||||
ecore-wince.pc
|
||||
ecore.pc
|
||||
ecore-data.pc
|
||||
doc/ecore.dox
|
||||
doc/Makefile
|
||||
src/Makefile
|
||||
|
@ -1192,6 +1193,7 @@ src/lib/ecore_file/Makefile
|
|||
src/lib/ecore_directfb/Makefile
|
||||
src/lib/ecore_win32/Makefile
|
||||
src/lib/ecore_wince/Makefile
|
||||
src/lib/ecore_data/Makefile
|
||||
README
|
||||
ecore.spec
|
||||
po/Makefile.in
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
|
||||
Name: ecore-data
|
||||
Description: Ecore data library
|
||||
Version: @VERSION@
|
||||
Libs: -L${libdir}
|
||||
Cflags: -I${includedir}
|
|
@ -18,4 +18,5 @@ ecore_evas \
|
|||
ecore_config \
|
||||
ecore_file \
|
||||
ecore_imf \
|
||||
ecore_imf_evas
|
||||
ecore_imf_evas \
|
||||
ecore_data
|
||||
|
|
|
@ -63,14 +63,6 @@
|
|||
#endif
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifndef TRUE
|
||||
# define TRUE 1
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
# define FALSE 0
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
|
@ -6,8 +6,6 @@ AM_CFLAGS = @WIN32_CFLAGS@ @EFL_PTHREAD_CFLAGS@
|
|||
lib_LTLIBRARIES = libecore.la
|
||||
include_HEADERS = \
|
||||
Ecore.h \
|
||||
Ecore_Data.h \
|
||||
Ecore_Str.h \
|
||||
Ecore_Getopt.h
|
||||
|
||||
libecore_la_SOURCES = \
|
||||
|
@ -16,25 +14,16 @@ ecore_anim.c \
|
|||
ecore_app.c \
|
||||
ecore_events.c \
|
||||
ecore_getopt.c \
|
||||
ecore_hash.c \
|
||||
ecore_idle_enterer.c \
|
||||
ecore_idle_exiter.c \
|
||||
ecore_idler.c \
|
||||
ecore_job.c \
|
||||
ecore_list.c \
|
||||
ecore_main.c \
|
||||
ecore_path.c \
|
||||
ecore_pipe.c \
|
||||
ecore_plugin.c \
|
||||
ecore_poll.c \
|
||||
ecore_sheap.c \
|
||||
ecore_signal.c \
|
||||
ecore_str.c \
|
||||
ecore_strbuf.c \
|
||||
ecore_time.c \
|
||||
ecore_timer.c \
|
||||
ecore_tree.c \
|
||||
ecore_value.c \
|
||||
ecore_thread.c \
|
||||
ecore_glib.c
|
||||
|
||||
|
|
|
@ -153,6 +153,18 @@ ecore_shutdown(void)
|
|||
return _ecore_init_count;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
ecore_print_warning(const char *function, const char *sparam)
|
||||
{
|
||||
WRN("***** Developer Warning ***** :\n"
|
||||
"\tThis program is calling:\n\n"
|
||||
"\t%s();\n\n"
|
||||
"\tWith the parameter:\n\n"
|
||||
"\t%s\n\n"
|
||||
"\tbeing NULL. Please fix your program.", function, sparam);
|
||||
if (getenv("ECORE_ERROR_ABORT")) abort();
|
||||
}
|
||||
|
||||
EAPI void
|
||||
_ecore_magic_fail(const void *d, Ecore_Magic m, Ecore_Magic req_m, const char *fname)
|
||||
{
|
||||
|
|
|
@ -1,155 +0,0 @@
|
|||
#include "ecore_private.h"
|
||||
#include "Ecore_Data.h"
|
||||
|
||||
static void ecore_string_free_cb(void *data);
|
||||
|
||||
static Ecore_Hash *ecore_strings = NULL;
|
||||
static int ecore_string_init_count = 0;
|
||||
|
||||
/**
|
||||
* @defgroup Ecore_String_Group String Instance Functions
|
||||
*
|
||||
* These functions allow you to store one copy of a string, and use it
|
||||
* throughout your program.
|
||||
*
|
||||
* This is a method to reduce the number of duplicated strings kept in
|
||||
* memory. It's pretty common for the same strings to be dynamically
|
||||
* allocated repeatedly between applications and libraries, especially in
|
||||
* circumstances where you could have multiple copies of a structure that
|
||||
* allocates the string. So rather than duplicating and freeing these
|
||||
* strings, you request a read-only pointer to an existing string and
|
||||
* only incur the overhead of a hash lookup.
|
||||
*
|
||||
* It sounds like micro-optimizing, but profiling has shown this can have
|
||||
* a significant impact as you scale the number of copies up. It improves
|
||||
* string creation/destruction speed, reduces memory use and decreases
|
||||
* memory fragmentation, so a win all-around.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Initialize the ecore string internal structure.
|
||||
* @return Zero on failure, non-zero on successful initialization.
|
||||
*/
|
||||
EAPI int
|
||||
ecore_string_init()
|
||||
{
|
||||
/*
|
||||
* No strings have been loaded at this point, so create the hash
|
||||
* table for storing string info for later.
|
||||
*/
|
||||
if (!ecore_string_init_count)
|
||||
{
|
||||
ecore_strings = ecore_hash_new(ecore_str_hash, ecore_str_compare);
|
||||
if (!ecore_strings)
|
||||
return 0;
|
||||
ecore_hash_free_value_cb_set(ecore_strings, ecore_string_free_cb);
|
||||
}
|
||||
ecore_string_init_count++;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves an instance of a string for use in an ecore program.
|
||||
* @param string The string to retrieve an instance of.
|
||||
* @return A pointer to an instance of the string on success.
|
||||
* @c NULL on failure.
|
||||
* @ingroup Ecore_String_Group
|
||||
*/
|
||||
EAPI const char *
|
||||
ecore_string_instance(const char *string)
|
||||
{
|
||||
Ecore_String *str;
|
||||
|
||||
CHECK_PARAM_POINTER_RETURN("string", string, NULL);
|
||||
|
||||
/*
|
||||
* Check for a previous instance of the string, if not found, create
|
||||
* it.
|
||||
*/
|
||||
str = ecore_hash_get(ecore_strings, string);
|
||||
if (!str)
|
||||
{
|
||||
int length;
|
||||
|
||||
/*
|
||||
* Allocate and initialize a new string reference.
|
||||
*/
|
||||
length = strlen(string) + 1;
|
||||
|
||||
str = (Ecore_String *)malloc(sizeof(Ecore_String) + length * sizeof(char));
|
||||
|
||||
str->string = (char*)(str + 1);
|
||||
str->references = 0;
|
||||
|
||||
memcpy(str->string, string, length);
|
||||
|
||||
ecore_hash_set(ecore_strings, str->string, str);
|
||||
}
|
||||
|
||||
str->references++;
|
||||
|
||||
return str->string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes that the given string has lost an instance.
|
||||
*
|
||||
* It will free the string if no other instances are left.
|
||||
*
|
||||
* @param string The given string.
|
||||
* @ingroup Ecore_String_Group
|
||||
*/
|
||||
EAPI void
|
||||
ecore_string_release(const char *string)
|
||||
{
|
||||
Ecore_String *str;
|
||||
|
||||
CHECK_PARAM_POINTER("string", string);
|
||||
|
||||
str = ecore_hash_get(ecore_strings, (char *)string);
|
||||
if (!str)
|
||||
return;
|
||||
|
||||
str->references--;
|
||||
if (str->references < 1)
|
||||
{
|
||||
ecore_hash_remove(ecore_strings, (char *)string);
|
||||
FREE(str);
|
||||
}
|
||||
}
|
||||
|
||||
EAPI void
|
||||
ecore_string_hash_dump_graph(void)
|
||||
{
|
||||
ecore_hash_dump_graph(ecore_strings);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
ecore_string_hash_dump_stats(void)
|
||||
{
|
||||
ecore_hash_dump_stats(ecore_strings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shutdown the ecore string internal structures
|
||||
*/
|
||||
EAPI void
|
||||
ecore_string_shutdown()
|
||||
{
|
||||
--ecore_string_init_count;
|
||||
if (!ecore_string_init_count)
|
||||
{
|
||||
ecore_hash_destroy(ecore_strings);
|
||||
ecore_strings = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ecore_string_free_cb(void *data)
|
||||
{
|
||||
Ecore_String *str;
|
||||
|
||||
str = data;
|
||||
FREE(str);
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir)/src/lib/ecore \
|
||||
@EINA_CFLAGS@
|
||||
|
||||
lib_LTLIBRARIES = libecore_data.la
|
||||
include_HEADERS = \
|
||||
Ecore_Data.h \
|
||||
Ecore_Str.h
|
||||
|
||||
libecore_data_la_SOURCES = \
|
||||
ecore_hash.c \
|
||||
ecore_list.c \
|
||||
ecore_path.c \
|
||||
ecore_plugin.c \
|
||||
ecore_sheap.c \
|
||||
ecore_strbuf.c \
|
||||
ecore_tree.c \
|
||||
ecore_value.c
|
||||
|
||||
libecore_data_la_LIBADD = @EINA_LIBS@
|
||||
libecore_data_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@ @ecore_release_info@
|
||||
|
|
@ -9,9 +9,9 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "Ecore_Data.h"
|
||||
#include "Ecore.h"
|
||||
#include "ecore_private.h"
|
||||
#include "Ecore_Data.h"
|
||||
|
||||
#define PRIME_TABLE_MAX 21
|
||||
#define PRIME_MIN 17
|
|
@ -50,18 +50,6 @@ EAPI const unsigned int ecore_prime_table[] =
|
|||
2097143, 4194301, 8388617, 16777213
|
||||
};
|
||||
|
||||
EAPI void
|
||||
ecore_print_warning(const char *function, const char *sparam)
|
||||
{
|
||||
WRN("***** Developer Warning ***** :\n"
|
||||
"\tThis program is calling:\n\n"
|
||||
"\t%s();\n\n"
|
||||
"\tWith the parameter:\n\n"
|
||||
"\t%s\n\n"
|
||||
"\tbeing NULL. Please fix your program.", function, sparam);
|
||||
if (getenv("ECORE_ERROR_ABORT")) abort();
|
||||
}
|
||||
|
||||
/**
|
||||
* Just casts the key to an unsigned int
|
||||
* @param key The key to return compute a hash value
|
Loading…
Reference in New Issue