svn update: 51390 (latest:51480)
authorJeahwan Kim <jae.hwan.kim@samsung.com>
Tue, 7 Sep 2010 23:56:29 +0000 (08:56 +0900)
committerJeahwan Kim <jae.hwan.kim@samsung.com>
Tue, 7 Sep 2010 23:56:29 +0000 (08:56 +0900)
158 files changed:
AUTHORS
COPYING
ChangeLog
Makefile.am
README
configure.ac
debian/SVN_REV
doc/Makefile.am
eina.pc.in
m4/efl_threads.m4 [new file with mode: 0644]
m4/efl_voltron.m4 [new file with mode: 0644]
src/include/Eina.h
src/include/Makefile.am
src/include/eina_accessor.h
src/include/eina_array.h
src/include/eina_benchmark.h
src/include/eina_binshare.h [new file with mode: 0644]
src/include/eina_config.h.in
src/include/eina_convert.h
src/include/eina_counter.h
src/include/eina_cpu.h
src/include/eina_error.h
src/include/eina_file.h
src/include/eina_fp.h
src/include/eina_hash.h
src/include/eina_inline_array.x
src/include/eina_inline_rbtree.x
src/include/eina_inline_str.x
src/include/eina_inline_stringshare.x
src/include/eina_inline_ustringshare.x [new file with mode: 0644]
src/include/eina_inlist.h
src/include/eina_iterator.h
src/include/eina_lalloc.h
src/include/eina_list.h
src/include/eina_log.h
src/include/eina_magic.h
src/include/eina_main.h
src/include/eina_matrixsparse.h
src/include/eina_mempool.h
src/include/eina_module.h
src/include/eina_quadtree.h
src/include/eina_rbtree.h
src/include/eina_rectangle.h
src/include/eina_safety_checks.h
src/include/eina_str.h
src/include/eina_strbuf.h
src/include/eina_stringshare.h
src/include/eina_tiler.h
src/include/eina_trash.h
src/include/eina_types.h
src/include/eina_unicode.h [new file with mode: 0644]
src/include/eina_ustrbuf.h [new file with mode: 0644]
src/include/eina_ustringshare.h [new file with mode: 0644]
src/lib/Makefile.am
src/lib/eina_accessor.c
src/lib/eina_array.c
src/lib/eina_benchmark.c
src/lib/eina_binshare.c [new file with mode: 0644]
src/lib/eina_convert.c
src/lib/eina_counter.c
src/lib/eina_cpu.c
src/lib/eina_error.c
src/lib/eina_file.c
src/lib/eina_fp.c
src/lib/eina_hamster.c
src/lib/eina_hash.c
src/lib/eina_inlist.c
src/lib/eina_iterator.c
src/lib/eina_lalloc.c
src/lib/eina_list.c
src/lib/eina_log.c
src/lib/eina_magic.c
src/lib/eina_main.c
src/lib/eina_matrixsparse.c
src/lib/eina_mempool.c
src/lib/eina_module.c
src/lib/eina_private.h [new file with mode: 0644]
src/lib/eina_quadtree.c
src/lib/eina_rbtree.c
src/lib/eina_rectangle.c
src/lib/eina_safety_checks.c
src/lib/eina_share_common.c [new file with mode: 0644]
src/lib/eina_share_common.h [new file with mode: 0644]
src/lib/eina_str.c
src/lib/eina_strbuf.c
src/lib/eina_strbuf_common.c [new file with mode: 0644]
src/lib/eina_strbuf_common.h [new file with mode: 0644]
src/lib/eina_strbuf_template_c.x [new file with mode: 0644]
src/lib/eina_stringshare.c
src/lib/eina_tiler.c
src/lib/eina_unicode.c [new file with mode: 0644]
src/lib/eina_ustrbuf.c [new file with mode: 0644]
src/lib/eina_ustringshare.c [new file with mode: 0644]
src/lib/eina_value.c
src/modules/mp/Makefile.am
src/modules/mp/buddy/eina_buddy.c
src/modules/mp/chained_pool/eina_chained_mempool.c
src/modules/mp/ememoa_fixed/eina_ememoa_fixed.c
src/modules/mp/ememoa_unknown/eina_ememoa_unknown.c
src/modules/mp/fixed_bitmap/eina_fixed_bitmap.c
src/modules/mp/one_big/Makefile.am [new file with mode: 0644]
src/modules/mp/one_big/eina_one_big.c [new file with mode: 0644]
src/modules/mp/pass_through/eina_pass_through.c
src/tests/Ecore_Data.h
src/tests/Evas_Data.h
src/tests/Makefile.am
src/tests/ecore_hash.c
src/tests/ecore_list.c
src/tests/ecore_sheap.c
src/tests/ecore_strings.c
src/tests/eina_bench.c
src/tests/eina_bench_array.c
src/tests/eina_bench_convert.c
src/tests/eina_bench_hash.c
src/tests/eina_bench_mempool.c
src/tests/eina_bench_quad.c
src/tests/eina_bench_rectangle_pool.c
src/tests/eina_bench_sort.c
src/tests/eina_bench_stringshare.c
src/tests/eina_bench_stringshare_e17.c
src/tests/eina_suite.c
src/tests/eina_suite.h
src/tests/eina_test_accessor.c
src/tests/eina_test_array.c
src/tests/eina_test_benchmark.c
src/tests/eina_test_binshare.c [new file with mode: 0644]
src/tests/eina_test_convert.c
src/tests/eina_test_counter.c
src/tests/eina_test_error.c
src/tests/eina_test_file.c
src/tests/eina_test_fp.c
src/tests/eina_test_hash.c
src/tests/eina_test_inlist.c
src/tests/eina_test_iterator.c
src/tests/eina_test_lalloc.c
src/tests/eina_test_list.c
src/tests/eina_test_log.c
src/tests/eina_test_magic.c
src/tests/eina_test_main.c
src/tests/eina_test_matrixsparse.c
src/tests/eina_test_mempool.c
src/tests/eina_test_module.c
src/tests/eina_test_module_dummy.c
src/tests/eina_test_quadtree.c
src/tests/eina_test_rbtree.c
src/tests/eina_test_rectangle.c
src/tests/eina_test_str.c
src/tests/eina_test_strbuf.c
src/tests/eina_test_stringshare.c
src/tests/eina_test_tiler.c
src/tests/eina_test_ustr.c [new file with mode: 0644]
src/tests/eina_test_ustringshare.c [new file with mode: 0644]
src/tests/evas_hash.c
src/tests/evas_list.c
src/tests/evas_mempool.c
src/tests/evas_mempool.h
src/tests/evas_object_list.c
src/tests/evas_stringshare.c

diff --git a/AUTHORS b/AUTHORS
index eae0bfb..8666800 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -13,3 +13,5 @@ Andre Dieb <andre.dieb@gmail.com>
 Raphael Kubo da Costa <kubo@profusion.mobi>
 Gustavo Chaves <glima@profusion.mobi>
 Fabiano Fidêncio <fidencio@profusion.mobi>
+Brett Nash <nash@nash.id.au>
+Tom Hacohen <tom@stosb.com>
diff --git a/COPYING b/COPYING
index cf546d2..f68e871 100644 (file)
--- a/COPYING
+++ b/COPYING
@@ -1,3 +1,21 @@
+Copyright notice for Eina:
+
+Copyright (C) 2008-2010 Jorge Luis Zapata and various contributors (see AUTHORS)
+
+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.
+
+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.
+
+Below is a copy of the GNU Lesser General Public License that is distributed
+along with this library. If you do not have a copy below, write to the Free
+Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
+02110-1301  USA
+\f
                  GNU LESSER GENERAL PUBLIC LICENSE
                       Version 2.1, February 1999
 
@@ -471,49 +489,3 @@ SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
 DAMAGES.
 
                     END OF TERMS AND CONDITIONS
-\f
-           How to Apply These Terms to Your New Libraries
-
-  If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change.  You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
-  To apply these terms, attach the following notices to the library.  It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
-    <one line to give the library's name and a brief idea of what it does.>
-    Copyright (C) <year>  <name of author>
-
-    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, write to the Free Software
-    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary.  Here is a sample; alter the names:
-
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the
-  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
-  <signature of Ty Coon>, 1 April 1990
-  Ty Coon, President of Vice
-
-That's all there is to it!
-
-
index e69de29..bbcf3c6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -0,0 +1,4 @@
+20YY-MM-2DD  NAME OF RELEASER
+
+       MAJOR.MINOR.MICRO release
+        
index f1b7a5c..13a6221 100644 (file)
@@ -19,16 +19,15 @@ ltmain.sh \
 missing
 
 pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = eina-0.pc
+pkgconfig_DATA = eina.pc
 
 EXTRA_DIST = \
 AUTHORS \
 COPYING \
-OLD-COPYING.PLAIN \
 README \
 $(pkgconfig_DATA) \
 autogen.sh \
-eina-0.pc.in \
+eina.pc.in \
 eina.spec \
 eina.spec.in \
 m4/ac_attribute.m4 \
@@ -37,8 +36,9 @@ m4/efl_compiler_flag.m4 \
 m4/efl_coverage.m4 \
 m4/efl_cpu.m4 \
 m4/efl_doxygen.m4 \
-m4/efl_pthread.m4 \
+m4/efl_fnmatch.m4 \
 m4/efl_tests.m4 \
+m4/efl_threads.m4 \
 m4/eina_bench.m4 \
 m4/eina_check.m4
 
diff --git a/README b/README
index bf7c137..9b2c7ac 100644 (file)
--- a/README
+++ b/README
@@ -1,2 +1,47 @@
-Data types library (List, hash, etc)
+Eina 1.0.0 ALPHA
 
+******************************************************************************
+
+ FOR ANY ISSUES PLEASE EMAIL:
+ enlightenment-devel@lists.sourceforge.net
+
+******************************************************************************
+
+Requirements:
+-------------
+Must have:
+ libc
+ libm
+ (For windows you also need: evil)
+
+Eina is a library providing data structure utilities for EFL that are meant
+to be lean, efficient and tailored to EFL's needs. This saves each
+library implementing its own custom datatype handling and duplicating
+the code. Some of the datatypes handles are:
+  Arrays (variable sized)
+  Hash tables
+  Inlined linked lists
+  Linked lists
+  Matricies
+  Quadtrees
+  Red/black trees
+  Stringbuffers (expandable string buffers)
+
+In addition Eina supports shared string token hashes with Stringshare
+and Unistringshare (standard ascii/utf8 strings and full unicode
+strings). It has a Trash pointer collector for deferring freeing until
+work is complete on a dataset, Unicode string wrapping and handling,
+UTF8 string parsing, 2D tile structure handling and rectangle
+utilities, module loading wrapper, Memory pools for faster allocation
+and less fragmentation of the heap, Output logging and selective
+aborting on critical enough states, fixed point math functions, CPU
+feature detection (like MMX, SSE, VFP, NEON etc.), Counters, binary
+token sharing and more.
+
+------------------------------------------------------------------------------
+COMPILING AND INSTALLING:
+
+  ./configure
+  make
+(do this as root unless you are installing in your users directories):
+  make install
index 036cfad..4ed3ee1 100644 (file)
@@ -1,25 +1,24 @@
 ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
 ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
-m4_define([v_maj], [0])
-m4_define([v_min], [9])
-m4_define([v_mic], [9])
-m4_define([v_rev], m4_esyscmd([(svnversion . | grep -v exported || echo 0) | awk -F : '{printf("%s\n", $1);}' | tr -d ' :MSP\n']))
+m4_define([v_maj], [1])
+m4_define([v_min], [0])
+m4_define([v_mic], [0])
+m4_define([v_rev], m4_esyscmd([(svnversion "${SVN_REPO_PATH:-.}" | grep -v export || echo 0) | awk -F : '{printf("%s\n", $1);}' | tr -d ' :MSP\n']))
 m4_if(v_rev, [0], [m4_define([v_rev], m4_esyscmd([git log 2> /dev/null | (grep -m1 git-svn-id || echo 0) | sed -e 's/.*@\([0-9]*\).*/\1/' | tr -d '\n']))])
 ##--   When released, remove the dnl on the below line
-dnl m4_undefine([v_rev])
+m4_undefine([v_rev])
 ##--   When doing snapshots - change soname. remove dnl on below line
-m4_define([relname], [ver-pre-svn-06])
-m4_define([v_rel], [-release relname])
+dnl m4_define([relname], [ver-pre-svn-07])
+dnl m4_define([v_rel], [-release relname])
 ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
-m4_ifdef([v_rev], [m4_define([v_ver], [v_maj.v_min.v_mic.v_rev])],
-[m4_define([v_ver], [v_maj.v_min.v_mic])])
+m4_ifdef([v_rev], [m4_define([v_ver], [v_maj.v_min.v_mic.v_rev])], [m4_define([v_ver], [v_maj.v_min.v_mic])])
 m4_define([lt_rev], m4_eval(v_maj + v_min))
 m4_define([lt_cur], v_mic)
 m4_define([lt_age], v_min)
 ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
 ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
  
-AC_INIT([eina], [v_ver], [enlightenment-devel@lists.sourceforge.net])
+AC_INIT([eina], [v_ver-alpha], [enlightenment-devel@lists.sourceforge.net])
 AC_PREREQ([2.59])
 AC_CONFIG_SRCDIR([configure.ac])
 AC_CONFIG_MACRO_DIR([m4])
@@ -62,7 +61,7 @@ case "$host_os" in
       MODULE_ARCH="$host_os-$host_cpu"
       ;;
    *)
-      MODULE_ARCH="$host_os-$host_cpu-$relname"
+      MODULE_ARCH="$host_os-$host_cpu-v_maj.v_min.v_mic"
       ;;
 esac
 AC_SUBST(MODULE_ARCH)
@@ -84,11 +83,20 @@ EFL_CHECK_CPU_SSE([have_sse="yes"], [have_sse="no"])
 EFL_CHECK_CPU_SSE2([have_sse2="yes"], [have_sse2="no"])
 EFL_CHECK_CPU_ALTIVEC([have_altivec="yes"], [have_altivec="no"])
 
-EFL_CHECK_PTHREAD(["yes"],
-   [have_pthread="yes"],
-   [have_pthread="no"],
-   [have_pthread_spinlock="yes"],
-   [have_pthread_spinlock="no"])
+EFL_CHECK_THREADS(
+   [
+    if test "x${_efl_have_posix_threads}" = "xyes" ; then
+       have_threads="POSIX"
+    else
+       if test "x${_efl_have_win32_threads}" = "xyes" ; then
+          have_threads="Win32"
+       else
+          have_threads="no"
+       fi
+    fi
+   ],
+   [have_threads="no"])
+EFL_CHECK_SPINLOCK([have_posix_threads_spinlock="yes"], [have_posix_threads_spinlock="no"])
 
 ### Additional options to configure
 
@@ -278,13 +286,25 @@ if test "x${enable_ememoa}" = "xyes" ; then
    )
 fi
 
+
 ### Checks for header files
 AC_HEADER_ASSERT
 AC_HEADER_DIRENT
 AC_HEADER_TIME
 
+
 ### Checks for types
+AC_CHECK_HEADER([inttypes.h],
+               [EINA_CONFIGURE_HAVE_INTTYPES_H="#define EINA_HAVE_INTTYPES_H"])
+AC_SUBST(EINA_CONFIGURE_HAVE_INTTYPES_H)
+
+AC_CHECK_HEADER([stdint.h],
+               [EINA_CONFIGURE_HAVE_STDINT_H="#define EINA_HAVE_STDINT_H"])
+AC_SUBST(EINA_CONFIGURE_HAVE_STDINT_H)
 
+AC_CHECK_SIZEOF(wchar_t)
+EINA_SIZEOF_WCHAR_T=$ac_cv_sizeof_wchar_t
+AC_SUBST(EINA_SIZEOF_WCHAR_T)
 
 ### Checks for structures
 
@@ -484,13 +504,15 @@ else
    enable_pass_through="no"
 fi
 
+enable_one_big="static"
+
 EINA_CHECK_MODULE([chained-pool],   [${enable_chained_pool}], [chained pool])
 EINA_CHECK_MODULE([ememoa-fixed],   [${enable_ememoa}],       [ememoa fixed])
 EINA_CHECK_MODULE([ememoa-unknown], [${enable_ememoa}],       [ememoa unknown])
 EINA_CHECK_MODULE([fixed-bitmap],   [no],                     [fixed bitmap])
 EINA_CHECK_MODULE([pass-through],   [${enable_pass_through}], [pass through])
 EINA_CHECK_MODULE([buddy],          [no],                     [buddy])
-
+EINA_CHECK_MODULE([one-big],        [${enable_one_big}],      [one big])
 
 ### Make the debug preprocessor configurable
 
@@ -528,7 +550,7 @@ AC_SUBST(requirement_eina)
 
 AC_CONFIG_FILES([
 Makefile
-eina-0.pc
+eina.pc
 eina.spec
 doc/Makefile
 src/Makefile
@@ -543,6 +565,7 @@ src/modules/mp/ememoa_unknown/Makefile
 src/modules/mp/pass_through/Makefile
 src/modules/mp/fixed_bitmap/Makefile
 src/modules/mp/buddy/Makefile
+src/modules/mp/one_big/Makefile
 src/tests/Makefile
 ])
 
@@ -566,7 +589,10 @@ echo "  Safety checks........: ${have_safety_checks}"
 echo "  Maximum log level....: ${with_max_log_level}"
 echo "  Report string usage..: ${have_stringshare_usage}"
 echo "  Default mempool......: ${have_default_mempool}"
-echo "  Thread Support.......: ${have_pthread} (spinlock: ${have_pthread_spinlock})"
+echo "  Thread Support.......: ${have_threads}"
+if test "${have_threads}" = "POSIX" ; then
+echo "    spinlock...........: ${have_posix_threads_spinlock}"
+fi
 echo "  Amalgamation.........: ${do_amalgamation}"
 echo "  Iconv support........: ${have_iconv}"
 echo
@@ -592,6 +618,7 @@ echo "    Ememoa unknown.....: ${enable_ememoa_unknown}"
 echo "    Fixed bitmap.......: ${enable_fixed_bitmap}"
 echo "    Pass through.......: ${enable_pass_through}"
 echo "    Buddy..............: ${enable_buddy}"
+echo "    One big............: ${enable_one_big}"
 echo
 echo "Compilation............: make (or gmake)"
 echo "  CPPFLAGS.............: $CPPFLAGS"
@@ -601,3 +628,4 @@ echo
 echo "Installation...........: make install (as root if needed, with 'su' or 'sudo')"
 echo "  prefix...............: $prefix"
 echo
+EFL_FORM_VOLTRON
index dd0e91d..a291957 100644 (file)
@@ -1,2 +1,2 @@
-Revision 49550
-Last Changed Rev 49540
+Revision 51480
+Last Changed Rev 51390
index ff2628c..25690be 100644 (file)
@@ -1,14 +1,26 @@
-
-MAINTAINERCLEANFILES = Makefile.in
+MAINTAINERCLEANFILES = Makefile.in 
 
 .PHONY: doc
 
+PACKAGE_DOCNAME = $(PACKAGE_TARNAME)-$(PACKAGE_VERSION)-doc
+
 if EFL_BUILD_DOC
 
+doc-clean:
+       rm -rf html/ latex/ man/ xml/ $(PACKAGE_DOCNAME).tar*
+        
 doc: all
-       rm -rf html/ latex/ man/
        $(efl_doxygen)
        cp img/* html/
+       rm -rf $(PACKAGE_DOCNAME).tar*
+       mkdir -p $(PACKAGE_DOCNAME)/doc
+       cp -R html/ latex/ man/ $(PACKAGE_DOCNAME)/doc
+       tar cf $(PACKAGE_DOCNAME).tar $(PACKAGE_DOCNAME)/
+       bzip2 -9 $(PACKAGE_DOCNAME).tar
+       rm -rf $(PACKAGE_DOCNAME)/
+       mv $(PACKAGE_DOCNAME).tar.bz2 $(top_srcdir)
+                        
+clean-local: doc-clean
 
 else
 
@@ -17,7 +29,4 @@ doc:
 
 endif
 
-clean-local:
-       @rm -rf html/ latex/ man/
-
 EXTRA_DIST = Doxyfile $(wildcard img/*.*) e.css head.html foot.html
index 6089ac6..1a5a745 100644 (file)
@@ -4,9 +4,9 @@ libdir=@libdir@
 includedir=@includedir@
 
 Name: Eina
-Description: Eina
+Description: A Library that implements fast data types and miscellaneous tools
 @pkgconfig_requires_private@: @requirement_eina@
 Version: @VERSION@
 Libs: -L${libdir} -leina
-Libs.private: -ldl
+Libs.private: @EFL_FNMATCH_LIBS@ @EFL_PTHREAD_LIBS@ -ldl
 Cflags: -I${includedir}/eina-@VMAJ@ -I${includedir}/eina-@VMAJ@/eina
diff --git a/m4/efl_threads.m4 b/m4/efl_threads.m4
new file mode 100644 (file)
index 0000000..2228f99
--- /dev/null
@@ -0,0 +1,196 @@
+dnl Copyright (C) 2010 Vincent Torri <vtorri at univ-evry dot fr>
+dnl rwlock code added by Mike Blumenkrantz <mike at zentific dot com>
+dnl This code is public domain and can be freely used or copied.
+
+dnl Macro that check if POSIX or Win32 threads library is available or not.
+
+dnl Usage: EFL_CHECK_THREADS(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
+dnl Call AC_SUBST(EFL_PTHREAD_CFLAGS)
+dnl Call AC_SUBST(EFL_PTHREAD_LIBS)
+dnl Defines EFL_HAVE_POSIX_THREADS or EFL_HAVE_WIN32_THREADS, and EFL_HAVE_THREADS
+
+AC_DEFUN([EFL_CHECK_THREADS],
+[
+
+dnl configure option
+
+AC_ARG_ENABLE([posix-threads],
+   [AC_HELP_STRING([--disable-posix-threads], [enable POSIX threads code @<:@default=auto@:>@])],
+   [
+    if test "x${enableval}" = "xyes" ; then
+       _efl_enable_posix_threads="yes"
+    else
+       _efl_enable_posix_threads="no"
+    fi
+   ],
+   [_efl_enable_posix_threads="auto"])
+
+AC_MSG_CHECKING([whether to build POSIX threads code])
+AC_MSG_RESULT([${_efl_enable_posix_threads}])
+
+AC_ARG_ENABLE([win32-threads],
+   [AC_HELP_STRING([--disable-win32-threads], [enable Win32 threads code @<:@default=no@:>@])],
+   [
+    if test "x${enableval}" = "xyes" ; then
+       _efl_enable_win32_threads="yes"
+    else
+       _efl_enable_win32_threads="no"
+    fi
+   ],
+   [_efl_enable_win32_threads="no"])
+
+AC_MSG_CHECKING([whether to build Windows threads code])
+AC_MSG_RESULT([${_efl_enable_win32_threads}])
+
+dnl
+dnl * no  + no
+dnl * yes + no  : win32: error,    other : pthread
+dnl * yes + yes : win32 : wthread, other : pthread
+dnl * no  + yes : win32 : wthread, other : error
+
+if  test "x${_efl_enable_posix_threads}" = "xyes" && test "x${_efl_enable_win32_threads}" = "xyes" ; then
+   case "$host_os" in
+      mingw*)
+         _efl_enable_posix_threads=no
+         ;;
+      *)
+         _efl_enable_win32_threads=no
+         ;;
+   esac
+fi
+
+if  test "x${_efl_enable_win32_threads}" = "xyes" ; then
+   case "$host_os" in
+      mingw*)
+         ;;
+      *)
+         AC_MSG_ERROR([Win32 threads support requested but non Windows system found.])
+         ;;
+   esac
+fi
+
+if  test "x${_efl_enable_posix_threads}" = "xyes" ; then
+   case "$host_os" in
+      mingw*)
+         AC_MSG_ERROR([POSIX threads support requested but Windows system found.])
+         ;;
+      *)
+         ;;
+   esac
+fi
+
+dnl check if the compiler supports POSIX threads
+
+case "$host_os" in
+   mingw*)
+      ;;
+   solaris*)
+      _efl_thread_cflags="-mt"
+      _efl_thread_libs="-mt"
+      ;;
+   *)
+      _efl_thread_cflags="-pthread"
+      _efl_thread_libs="-pthread"
+      ;;
+esac
+
+_efl_have_posix_threads="no"
+_efl_have_win32_threads="no"
+
+if test "x${_efl_enable_posix_threads}" = "xyes" || test "x${_efl_enable_posix_threads}" = "xauto" ; then
+
+   SAVE_CFLAGS=${CFLAGS}
+   CFLAGS="${CFLAGS} ${_efl_threads_cflags}"
+   SAVE_LIBS=${LIBS}
+   LIBS="${LIBS} ${_efl_threads_libs}"
+   AC_LINK_IFELSE(
+      [AC_LANG_PROGRAM([[
+#include <pthread.h>
+                       ]],
+                       [[
+pthread_t id;
+id = pthread_self();
+                       ]])],
+      [_efl_have_posix_threads="yes"],
+      [_efl_have_posix_threads="no"])
+   CFLAGS=${SAVE_CFLAGS}
+   LIBS=${SAVE_LIBS}
+
+fi
+
+AC_MSG_CHECKING([whether system support POSIX threads])
+AC_MSG_RESULT([${_efl_have_posix_threads}])
+if test "$x{_efl_enable_posix_threads}" = "xyes" && test "x${_efl_have_posix_threads}" = "xno"; then
+   AC_MSG_ERROR([POSIX threads support requested but not found.])
+fi
+
+EFL_PTHREAD_CFLAGS=""
+EFL_PTHREAD_LIBS=""
+if test "x${_efl_have_posix_threads}" = "xyes" ; then
+   EFL_PTHREAD_CFLAGS=${_efl_thread_cflags}
+   EFL_PTHREAD_LIBS=${_efl_thread_libs}
+fi
+
+AC_SUBST(EFL_PTHREAD_CFLAGS)
+AC_SUBST(EFL_PTHREAD_LIBS)
+
+if test "x${_efl_have_posix_threads}" = "xyes" ; then
+   AC_DEFINE([EFL_HAVE_POSIX_THREADS], [1], [Define to mention that POSIX threads are supported])
+fi
+
+
+if test "x${_efl_enable_win32_threads}" = "xyes" ; then
+   _efl_have_win32_threads="yes"
+   AC_DEFINE([EFL_HAVE_WIN32_THREADS], [1], [Define to mention that Win32 threads are supported])
+fi
+
+if test "x${_efl_have_posix_threads}" = "xyes" || test "x${_efl_have_win32_threads}" = "xyes" ; then
+   AC_DEFINE([EFL_HAVE_THREADS], [1], [Define to mention that POSIX or Win32 threads are supported])
+fi
+
+AS_IF([test "x$_efl_have_posix_threads" = "xyes" || test "x$_efl_have_win32_threads" = "xyes"], [$1], [$2])
+])
+
+dnl Usage: EFL_CHECK_SPINLOCK(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
+dnl Defines EFL_HAVE_POSIX_THREADS_SPINLOCK
+AC_DEFUN([EFL_CHECK_SPINLOCK],
+[
+
+dnl check if the compiler supports pthreads spinlock
+
+_efl_have_posix_threads_spinlock="no"
+
+if test "x${_efl_have_posix_threads}" = "xyes" ; then
+
+   SAVE_CFLAGS=${CFLAGS}
+   CFLAGS="${CFLAGS} ${EFL_PTHREAD_CFLAGS}"
+   SAVE_LIBS=${LIBS}
+   LIBS="${LIBS} ${EFL_PTHREAD_LIBS}"
+   AC_LINK_IFELSE(
+      [AC_LANG_PROGRAM([[
+#include <pthread.h>
+                       ]],
+                       [[
+pthread_spinlock_t lock;
+int res;
+res = pthread_spin_init(&lock, PTHREAD_PROCESS_PRIVATE);
+                       ]])],
+      [_efl_have_posix_threads_spinlock="yes"],
+      [_efl_have_posix_threads_spinlock="no"])
+   CFLAGS=${SAVE_CFLAGS}
+   LIBS=${SAVE_LIBS}
+
+fi
+
+AC_MSG_CHECKING([whether to build POSIX threads spinlock code])
+AC_MSG_RESULT([${_efl_have_posix_threads_spinlock}])
+if test "x${_efl_enable_posix_threads}" = "xyes" && test "x${_efl_have_posix_threads_spinlock}" = "xno" ; then
+   AC_MSG_WARN([POSIX threads support requested but spinlocks are not supported])
+fi
+
+if test "x${_efl_have_posix_threads_spinlock}" = "xyes" ; then
+   AC_DEFINE([EFL_HAVE_POSIX_THREADS_SPINLOCK], [1], [Define to mention that POSIX threads spinlocks are supported])
+fi
+AS_IF([test "x$_efl_have_posix_threads_spinlock" = "xyes"], [$1], [$2])
+])
+
diff --git a/m4/efl_voltron.m4 b/m4/efl_voltron.m4
new file mode 100644 (file)
index 0000000..c710466
--- /dev/null
@@ -0,0 +1,93 @@
+dnl EFL_FORM_VOLTRON
+dnl Outputs ascii art of Voltron if terminal has enough columns
+dnl
+dnl ascii art was found at http://www.codeismylife.com/ascii_voltron/5239.html
+dnl and is the work of its original author.
+
+AC_DEFUN([EFL_FORM_VOLTRON],
+[
+AC_ARG_ENABLE([voltron],
+   [AC_HELP_STRING([--enable-voltron], [enable forming of voltron when all files combine @<:@default=no@:>@])],
+   [
+    if test "x${enableval}" = "xyes" ; then
+       have_voltron="yes"
+    else
+       have_voltron="no"
+    fi
+   ],
+   [have_voltron="no"]
+)
+
+   if test "x$have_voltron" = "xyes" -a "x$do_amalgamation" = "xyes";then
+     echo "//////////////////////////////////////////////////////////////////////////////////////////////////////////////////"
+     echo "/////////////////////////////////////////////////////////////////////////////////////{#///////////////////////////"
+     echo "/////////////////////////////////////////////////////////////////////////////////// EN3 xx&HWx////////////////////"
+     echo "////////////////////////////////////////////////#{//xd3:& \/{:x////////////////////#WJNd_ HHNp#///////////////////"
+     echo "///////////////////////////////////////////////\x WDMMM EDDzEQp&^x ^^_x #///////////&37z^xHHH7_///////////////////"
+     echo "////////////////////////////////////////////////xPMMMMM LMMMLQQzzQDzH\{xx\{////////{x&H9@^&d^  {//////////////////"
+     echo "///////////////////////////////////////////^JLE:PMMMQ9N^EDMMMMMMMLzJJ^ @&dx////////#dHdN^x{/{x {//////////////////"
+     echo "//////////////////////////////////////////#LMMM EEE7p@H@NE777QMMMMMMM3H3_x/////////^HH3W^pH@x x///////////////////"
+     echo "//////////////////////////////////////////#MMLN_^: {/:L&\{:@7EWWWzMMM3H3_x////{:x ^3dd3 HHNENd^{//////////////////"
+     echo "//////////////////////////////////////////#WW7N^//////7Q:////{xHE93H3^^_ #////{H3H3JDdxx&H3Wz3:///////////////////"
+     echo "//////////////////////////////////////////_E93 ///////{^#/#{{{{{{#x37dx77x////{Hp3pd   _ xx_7H////////////////////"
+     echo "#/////////////////////////////////////////#&MHd{////////#x^ ^&__  xxzMJH9P ////{xx\#\:x\:d@_://///////////////////"
+     echo "3H #///////////////////////////////////////{pp^Jpx{///{ &&__^:{{:xxxx7MQNWpx///@x//{# xxx#///////////////////////#"
+     echo "3HN7Hx{//////////////////////////////////////\xd NQd#x \# &x{/x3pHHH&#&PP&@zNxx##:{////////////////////////////{ ^"
+     echo "HH{@37N_x{////////////////////////////////////x_//#zDxx x  //#    ^x#//#E9_P&p://////////////////////////////{\&:\\"
+     echo "H@/JMJ799H_:{/////////////////////////////////{\/// L7_xx^#/\LMMMMM3MLN@Mp7 dW{\////////////////////////////{  #^H"
+     echo "H^/PMMMD9773d^\{////////////////////////////////////dzWLp/{x7MMMMMEJMM7DMHD#^z&#//////////////////////////{x&\ dHH"
+     echo "H^{MMMMMMLEN33Hd_://////////////////////////////////#WNMLzzPPLMMMLHMML^NNNQW93JdE_ //////////////////////#_ :@H3HH"
+     echo "HdxWMMMMMMMMzWdHHpNH {/////////////////////////////{z99QEJDQJ7@EM3LMM37M9LHLMNL:^\{////////////////////{x_\_HHH&&x"
+     echo "HH_^zMMMMMMMML7dHH39zN_\//////////////////////////{WQLHEENpDPDLHQMMPHMDEzNMLWJ///////////////////////#_x d3Hd^dHx"
+     echo "/\@HH HLMMMMMMMM9 3HHHp9DJ&#////////////////////////xN_\LzPMMMLpPMMPdLMWLdMMNQ3/////////////////////{ ^x&dddd HHH "
+     echo "//{ HH@ 9MMMMMMLxdHHHHH3HpEQN /////////////////////:PL\/QMMMLE3LMMp#JMJJ9JMM&M //////////////////{#\ _ ^^&:x##HHHx"
+     echo "////:d3H_&PMMMMN&3HHHHHHHHHHWEJH\/////////////////{zMd//^EE {/xHEH&HMLHLHMMJpL#////////{#x _^^&WpHHHHH3HHNxHHxHHHx"
+     echo "/////#_HHH^WMMP3L9HHHHHHHHHHHHHWE7_{//////////////7Mz{///:7EWNEzPL3LMWQWDMM_zN/{\x ^& zLMDpHp973HHHHHH3HH7x3H dHHx"
+     echo "///////xHHH@_E&3D9N3H3HHHHHHHHHH3HW7dx///////////dMM ////#QJEEJJ9:Hp9dz^WdH_&d3p3HHHHdLQE3pNNHHHHHHHHH3HH9xHH &HHx"
+     echo "////////#@3H3^ HHN3WpHHHHHHHHHHHHHHH33d #/////// MM7//{x@pppH__ME_MME@xH3Hzz3H33HHHH@7pHH33HHHHHHHHHHH3HH9xHH__HHx"
+     echo "/////////{ HHHHHHHH333HHHHHHHHHHHHHHHHH33&x{///:Pz9HpWp@ :::{/pM^EMMML H3HELQ3H3HHHH_pHHHHHHHHHHHHHHHHHHp9\@d& HHx"
+     echo "///////////:dHHHHHHHH33HHHHHHHHHHHHHHHHHHHHd^\\H33d_x::##{/{x_PDxMMMME&HHHHH99H3HHHd&HHHHHHHHHHHHHHHHHH9Wx&^ x HHx"
+     echo "////////////{^HHHHHHHHHHHHHHHHHHHHHHHHHHH@&HN33@H77ppppppWW3&JMdHMMMMHHHHHHHHWHHHHH&3pWHHHHHHHHHH3HHHpz_ HHH3&xHHx"
+     echo "//////////////xHHHHHHHHHHHHHHHHHHHH3H3@d3p3@x:\{/# HN73& xx  DL\DMMML_HHHHHHHHpHHHpH7JHHHHHHH3p33d&_@d\ 3HHH3&:3Hx"
+     echo "///////////////#&HHHHHHHHHHHHHHHHHHHH_H7^x\//#^ddH3^Nz@_&&&&_MN MMMMJ@H3HHHHH3p3H3pQQ3Hd@_^   xx ^@dH&\{x@HH3_\HHx"
+     echo "////////////////{ HHHHHHHHHHHHHHH@ x{{z\/#^33d {Nz3:LPx&&&&^WMxNMMMM3HHH3N3Hp79zWH _ xx  _@dHHHHHHHHHHH^#{xd_{#@Hx"
+     echo "//////////////////\@HH3HHHHHH@^x#{: &&7_@ddH:7d@__&@Mp^&&&&xPz#LMMML&3HJMMzNH@^ ^&:@HHHHHHHHHHHHHHHHHHd&^{/////:Hx"
+     echo "/////////////{{{/{/{^dHHHd^x#{\ &HHH W ^@&Q9 _^ _d3QL ^   xWMW#dJMMz@HJMEx\x^HHHHHdx&HHHHHHHd&^ xx\#{//////////#Hx"
+     echo "/////////{x ^&:xEDW^ x#:## d^dH3HHHHxd_HHdMzHx# NMMM7x&dH_JLp7 {x\&@HHD@\:{#x ^HHHd&#x x\#{////////////////////{Hx"
+     echo "//////{#x^^&&\ _D9^x\{{:^NQP3HHHHHH pxHHd9MMdxx EMMM _^@@PD3PMMLEQH@3W& &^ x##\##{/////////////////////////////{@x"
+     echo "/////#:x^ @d:^^7N#{\ &HHWHH99HHHHHH:7 d&^LMM3^_dNpH_#^_3LEWMMMMMPddHpd:HHHH@  ^ x{#:////////////////////{x&////{x:"
+     echo "////:x ^x W:^^HWx3dHHHH333H39HHHH3@&&xxx@J7@#:_@&&d : ELp9MMMMMz&H333#dHHH3H\///{:3x##{/{##{/{#\\\##### W_{////^x/"
+     echo "//{ :x^ #E:^^&N\ELWHHH3dHHH3333HHH E\:xx__^_ d^EPML^dDPHDMMMMM7&H33N#&HHHHH /////{3//////////////////\3@{//////{//"
+     echo "/{ xx{x{7_ ^^N^xJNzN3Hp@HHHH39HH3H J: ^ NEQ__^zMMM9dLJ3LMMMML3@HHH9\ H3HHH&{/////^ ////////////////\3d{///////////"
+     echo "/x x///:9:^^p&x@3W3p3HHHpddd@H9HHH_Lx^ EMM7x&^MMMEEMWNMMMMMD@d3HH9 \HHHHHH //////7{//////////////#3H#/////////////"
+     echo "\_:#///@  ^d3^xHH33N3@x  ^&dH&@HHH M_^^MML&x_3QJWQLdzMMMMMJ_HH3HNd#@HHHHHHx/////:W/////////////{x #///////////////"
+     echo "^&:///{p\^_W^x&HWH^x &_HHHHHHd HHH PNx9LQ7W_3N779d\WMMMMMW&HHH3WN{_HHHHHH3://///p ////////////////////////////////"
+     echo "@dx////Ep3Np^\@_:^dHHHd^Hd_ :\xHH3&EP^3d@d3Hp7zLMQ_{ JMLd@HHHHpE:&HHHHHHHH\/////@{////////////////////////////////"
+     echo "H@ :#//DLMM9_: :HHHHH@^x#/////#HHHd_NNNJPMMMMMMMMMMQ&{d_HHHHH3zx@HHHHHHHHH#&@@@@7@@dpdx{//////////////////////////"
+     echo "dJx #//_E_d&&^::_d_x#//\///////&HHH_HPMMMMMMMMMMLJ7Wp@_HHHHHHz_ HHHHHHHHHHx7QzJE97^x{/////////////////////////////"
+     echo "^z_ {/\{_9   ^{\#//////:///////xHHH3H&7MMMPJN3d__@HHHHHHH3HH73:HHHHHHHHHH  ^  x#{@{///////////////////////////////"
+     echo "^dD \{ x#^7^x\/////////x///////#HH33HHHd3d37pHH3HHHHHHHHHHHp7#dHHHHHHHH&_EMMMMMMMPz7d #///////////////////////////"
+     echo "^^_73x ^ :xd^{/////////x////////_HHHHHH33NNWpp3HHHHHHHHHHHHE:^HHHHHH3H WMMMMMMMMDH7:\ JQ7d {//////////////////////"
+     echo "^^@JzE^\x^ :\x{////////_///\_WJHxHHHHHHHHHHH3HHHHHHHHHHHHH9&xHHHHHHd  9MMMMMMMMLJ J//xQ\7LMMQpx///////////////////"
+     echo " _3zLLLpx  x{///////{_ zH9PP9H {{dHHHHHHHHHHHHHHHHHHHHHHHp9#dHHH3H@x^zMMMMMMMMMPJ d//93DMMMMMMMQH\////////////////"
+     echo " x^NE9dxx x://///////#dNP_\/{^H79@pHHHHHHHHHHHHHHHHHHH3H3zx_HHHHHH_&DMMMMMMMMMMDE :/ 7QMMMMMMMMMMMJ&#/////////////"
+     echo " @3pQMp^7N^x//////////// __7LMMMM JHHHHHHHHHHHHH3HHHHH3H9@ HHHHHHH&LMMMMMMMMMMMP7^#{EWMMMMMMMMMMMMMML7 {//////////"
+     echo "^^^&HLWd7d {///////////#3LMMMMMMMHpJpHHHHHHHHHHH3JQJ7NDWE\HHHH3H@ QMMMMMMMMMMMMLp&##LMMMMMMMMMMMMMMMMMMPd{////////"
+     echo "3WNNN7pH99Wd #/////////pHMMMMMMMMD N993HH3HHHHHHHH9LMMMLx@3HHHH_ JMMMMMMMMMMMMMMd@##MMMMMMMMMMMMMMMMMMMMMQ{///////"
+     echo "MMMMM3ELMMMMLE@&@_x////EWMMMMMMMMM3JJpEN3HHHHHHHH7DDMMMH HHHHd ^NMMMMMMMMMMMMMMM_d{#MMMMMMMMMMMMMMMMMMMMM@////////"
+     echo "MMMM7{DMMMMD3JMMMMDJ /#DzMMMMMMMMML^Qz7W9p3pWN7799zJE7d\x_HH@:_HMMMMMMMMMMMMMMMWx3{\MMMMMMMMMMMMMMMMMMMMD{////////"
+     echo "MMML:HMMMM9@MMMLdHJEH{ PLMMMMMMMMMME&pNp^^_^  x   ^^__   \#x{&&LMMMMMMMMMMMMMMMJ:p{\MMMMMMMMMMMMMMMMMMMM_/////////"
+     echo "MMMW/7MMMM&LM3LdQz@JM33MMMMMMMMMMMMM&x _@dHHHHHHH@&_^ ^_  ^x:^LMMMMMMPQJ7Np333pW 3 xEDMMMMMMMMMMMMMMMMMJ//////////"
+     echo "MML\/EMMMP3_xNpJMM3^&WzMPMMMMMMMMMMML3x^^^^_&dH3W7EzPPpx\x\\xd333H&_&@pEQPLMMQPM7E9LHd@@3ELMMMMMMMMMMMM //////////"
+     echo "MM3//zMMMNW//QdMMM3 \#LQWMMMMMMMMDp@__&dd@@&__&&@dHpHd33 &x@33Hd@_^^^xMMMMMMM3pMx{HM x9/{\:@pNQMMMMMMMQ///////////"
+     echo "MMH::PMMMW7{/P_MMM7^{xM7^MMMMMMD@@W&&dH3Hx_x:7DzJ97Np &H^&x_dHd@&&@d3WMMMMMMME&M WMMN/7{/WHzMLEWWNELMMW///////////"
+     echo "_H_^^dNJzWH@/7HPMM@_/dD&@MMMLzp W@^7zE7pxHHN99EzQQ7_p9^H^_:&d&^   ^_&&MMMMMMMD M xMML#^x/{JMMMMMMMDW3Wx///////////"
+     echo "Hz^x::xx{/{x^p3dMQx /7N H3@^_@#dW#:_d@@HHHHHH3NPN&NLMQ H & NN799997WWzMMMMMMMLxM^&LMM^{&/#LMMMMMMMMMMLN^#/////////"
+     echo " x WpH@x\//////{@ { _^_@d^ ^__\dH MEH_d3HHHHHHN&3MMMMD H & H&&______ HMMMMMMMM P_3MMMN/&/#LMMMMMMMMMMMMML@////////"
+     echo "\{xH7x::\////////\7MM9@_^_@HHd d_ MMM9@7HHd@NWHp^WMMMDx3 & 3dHW7EzDLMLLDQzJE9NxHxxp33_/x{/NMMMMMMMMMMMMMMP#///////"
+     echo "# ^_ ^ ^x///////{9&MMJ^^^  ^_3xH_ MMM^73@_WQz93&@&@LLN_H __9WH&^ x:\#{\^&& {///{p//////////{x&WzLMMMMMMMMMH///////"
+     echo "^^  3^^^#///////H_LMME&@dHH@ _x3@xPMz&&_7MMMMLDJHx\ 3pd #{/////////{x@HH&\//////7{////{#////////{x&WzMMMMML#//////"
+     echo ": :d^^^x/////// &PMMM&_dd@&^^ {^W7^p xxH@@&__37NNW7NH^:xxxx   ^_&&@dHH&:////////p ////{^/////////////\&ELMM3//////"
+     echo "{\:xxxx#//////{Hp77p@ x#////////#&&  xx::\\:xxxx  ^_&&&&&@@@&&&&_____x//////////##/////&////////////////{^NQ#/////"
+   fi
+])
index ff00731..717e59c 100644 (file)
@@ -15,6 +15,7 @@
  *           Raphael Kubo da Costa <kubo@profusion.mobi>
  *           Tilman Sauerbeck <tilman@code-monkey.de>
  *           Vincent "caro" Torri  <vtorri at univ-evry dot fr>
+ *           Tom Hacohen <tom@stosb.com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -52,6 +53,7 @@
  * @author Raphael Kubo da Costa <kubo@@profusion.mobi>
  * @author Tilman Sauerbeck <tilman@@code-monkey.de>
  * @author Vincent "caro" Torri  <vtorri at univ-evry dot fr>
+ * @author Tom Hacohen <tom@@stosb.com>
  * @date 2008-2010
  *
  * @section eina_intro_sec Introduction
  * make it safer, log errors, manage memory more efficiently and more.
  */
 
+#include <dirent.h>
+
+#ifdef _WIN32
+# include <Evil.h>
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -129,7 +137,9 @@ extern "C" {
 #include "eina_error.h"
 #include "eina_log.h"
 #include "eina_array.h"
+#include "eina_binshare.h"
 #include "eina_stringshare.h"
+#include "eina_ustringshare.h"
 #include "eina_magic.h"
 #include "eina_counter.h"
 #include "eina_rbtree.h"
@@ -143,6 +153,8 @@ extern "C" {
 #include "eina_matrixsparse.h"
 #include "eina_str.h"
 #include "eina_strbuf.h"
+#include "eina_ustrbuf.h"
+#include "eina_unicode.h"
 #include "eina_quadtree.h"
 
 #ifdef __cplusplus
index 6022d43..98b12f2 100644 (file)
@@ -25,7 +25,10 @@ eina_counter.h \
 eina_inline_array.x \
 eina_magic.h \
 eina_stringshare.h \
+eina_binshare.h \
+eina_ustringshare.h \
 eina_inline_stringshare.x \
+eina_inline_ustringshare.x \
 eina_inline_list.x \
 eina_accessor.h \
 eina_convert.h \
@@ -46,6 +49,8 @@ eina_inline_tiler.x \
 eina_str.h \
 eina_inline_str.x \
 eina_strbuf.h \
+eina_ustrbuf.h \
+eina_unicode.h \
 eina_quadtree.h
 
 installed_mainheaderdir = $(includedir)/eina-@VMAJ@
@@ -55,5 +60,4 @@ installed_headersdir = $(includedir)/eina-@VMAJ@/eina
 dist_installed_headers_DATA = $(EINAHEADERS)
 
 EXTRA_DIST = \
-eina_config.h.in \
-eina_private.h
+eina_config.h.in
index 55952d4..4d2f92e 100644 (file)
  */
 typedef struct _Eina_Accessor Eina_Accessor;
 
-typedef Eina_Bool (*Eina_Accessor_Get_At_Callback)(Eina_Accessor *it, unsigned int index, void **data);
+typedef Eina_Bool (*Eina_Accessor_Get_At_Callback)(Eina_Accessor *it,
+                                                   unsigned int index,
+                                                   void **data);
 typedef void *(*Eina_Accessor_Get_Container_Callback)(Eina_Accessor *it);
 typedef void (*Eina_Accessor_Free_Callback)(Eina_Accessor *it);
+typedef Eina_Bool (*Eina_Accessor_Lock_Callback)(Eina_Accessor *it);
 
 struct _Eina_Accessor
 {
-   Eina_Accessor_Get_At_Callback        get_at EINA_ARG_NONNULL(1, 3) EINA_WARN_UNUSED_RESULT;
-   Eina_Accessor_Get_Container_Callback        get_container EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-   Eina_Accessor_Free_Callback          free EINA_ARG_NONNULL(1);
+#define EINA_ACCESSOR_VERSION 1
+   int version;
+
+   Eina_Accessor_Get_At_Callback get_at               EINA_ARG_NONNULL(1, 3) EINA_WARN_UNUSED_RESULT;
+   Eina_Accessor_Get_Container_Callback get_container EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+   Eina_Accessor_Free_Callback free                   EINA_ARG_NONNULL(1);
+
+   Eina_Accessor_Lock_Callback lock   EINA_WARN_UNUSED_RESULT;
+   Eina_Accessor_Lock_Callback unlock EINA_WARN_UNUSED_RESULT;
 
 #define EINA_MAGIC_ACCESSOR 0x98761232
    EINA_MAGIC
@@ -59,18 +68,20 @@ struct _Eina_Accessor
 #define FUNC_ACCESSOR_GET_AT(Function) ((Eina_Accessor_Get_At_Callback)Function)
 #define FUNC_ACCESSOR_GET_CONTAINER(Function) ((Eina_Accessor_Get_Container_Callback)Function)
 #define FUNC_ACCESSOR_FREE(Function) ((Eina_Accessor_Free_Callback)Function)
-
-
-EAPI void eina_accessor_free           (Eina_Accessor *accessor) EINA_ARG_NONNULL(1);
-
-EAPI Eina_Bool eina_accessor_data_get  (Eina_Accessor *accessor, unsigned int position, void **data) EINA_ARG_NONNULL(1) EINA_PURE;
-EAPI void *eina_accessor_container_get (Eina_Accessor *accessor) EINA_ARG_NONNULL(1) EINA_PURE;
-
-EAPI void eina_accessor_over           (Eina_Accessor *accessor,
-                                       Eina_Each cb,
-                                       unsigned int start,
-                                       unsigned int end,
-                                       const void *fdata) EINA_ARG_NONNULL(1, 2);
+#define FUNC_ACCESSOR_LOCK(Function) ((Eina_Accessor_Lock_Callback)Function)
+
+EAPI void      eina_accessor_free(Eina_Accessor *accessor) EINA_ARG_NONNULL(1);
+EAPI Eina_Bool eina_accessor_data_get(Eina_Accessor *accessor,
+                                      unsigned int position,
+                                      void **data) EINA_ARG_NONNULL(1);
+EAPI void *    eina_accessor_container_get(Eina_Accessor *accessor) EINA_ARG_NONNULL(1) EINA_PURE;
+EAPI void      eina_accessor_over(Eina_Accessor *accessor,
+                                  Eina_Each_Cb cb,
+                                  unsigned int start,
+                                  unsigned int end,
+                                  const void *fdata) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_accessor_lock(Eina_Accessor *accessor) EINA_ARG_NONNULL(1);
+EAPI Eina_Bool eina_accessor_unlock(Eina_Accessor *accessor) EINA_ARG_NONNULL(1);
 
 /**
  * @def EINA_ACCESSOR_FOREACH
@@ -121,7 +132,10 @@ EAPI void eina_accessor_over           (Eina_Accessor *accessor,
  *    rather in the accessors implementations to keep them as simple
  *    and fast as possible.
  */
-#define EINA_ACCESSOR_FOREACH(accessor, counter, data) for ((counter) = 0; eina_accessor_data_get((accessor), (counter), (void **)&(data)); (counter)++)
+#define EINA_ACCESSOR_FOREACH(accessor, counter, data)                 \
+  for ((counter) = 0;                                                  \
+       eina_accessor_data_get((accessor), (counter), (void **)&(data)); \
+       (counter)++)
 
 /**
  * @}
index 70010fb..7c7fc82 100644 (file)
@@ -65,30 +65,41 @@ typedef void **Eina_Array_Iterator;
  */
 struct _Eina_Array
 {
-   void                **data;   /**< Pointer to a vector of pointer to payload */
-   unsigned int   total;  /**< Total number of slot in the vector */
-   unsigned int   count;  /**< Number of activ slot in the vector */
-   unsigned int          step;   /**< How much must we grow the vector when it is full */
+#define EINA_ARRAY_VERSION 1
+   int version; /**< Should match EINA_ARRAY_VERSION used when compiled your apps, provided for ABI compatibility */
 
+   void **data; /**< Pointer to a vector of pointer to payload */
+   unsigned int total; /**< Total number of slots in the vector */
+   unsigned int count; /**< Number of active slots in the vector */
+   unsigned int step; /**< How much must we grow the vector when it is full */
    EINA_MAGIC
 };
 
-EAPI Eina_Array  *eina_array_new      (unsigned int step) EINA_WARN_UNUSED_RESULT EINA_MALLOC EINA_WARN_UNUSED_RESULT;
-EAPI void         eina_array_free     (Eina_Array *array) EINA_ARG_NONNULL(1);
-EAPI void         eina_array_step_set (Eina_Array *array, unsigned int step) EINA_ARG_NONNULL(1);
-EAPI void         eina_array_clean    (Eina_Array *array) EINA_ARG_NONNULL(1);
-EAPI void         eina_array_flush    (Eina_Array *array) EINA_ARG_NONNULL(1);
-EAPI Eina_Bool    eina_array_remove   (Eina_Array *array, Eina_Bool (*keep)(void *data, void *gdata), void *gdata) EINA_ARG_NONNULL(1, 2);
-
-static inline Eina_Bool     eina_array_push  (Eina_Array *array, const void *data) EINA_ARG_NONNULL(1, 2);
-static inline void         *eina_array_pop   (Eina_Array *array) EINA_ARG_NONNULL(1);
-static inline void         *eina_array_data_get (const Eina_Array *array, unsigned int idx) EINA_ARG_NONNULL(1);
-static inline void          eina_array_data_set (const Eina_Array *array, unsigned int idx, const void *data) EINA_ARG_NONNULL(1, 3);
-static inline unsigned int  eina_array_count_get (const Eina_Array *array) EINA_ARG_NONNULL(1);
-
-EAPI Eina_Iterator *eina_array_iterator_new (const Eina_Array *array) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Accessor *eina_array_accessor_new (const Eina_Array *array) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-
+EAPI Eina_Array *               eina_array_new(unsigned int step) EINA_WARN_UNUSED_RESULT EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Array *               eina_array_threadsafe_new(unsigned int step) EINA_WARN_UNUSED_RESULT EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+EAPI void                       eina_array_free(Eina_Array *array) EINA_ARG_NONNULL(1);
+EAPI void                       eina_array_step_set(Eina_Array *array,
+                                                    unsigned int sizeof_eina_array,
+                                                    unsigned int step) EINA_ARG_NONNULL(1);
+EAPI void                       eina_array_clean(Eina_Array *array) EINA_ARG_NONNULL(1);
+EAPI void                       eina_array_flush(Eina_Array *array) EINA_ARG_NONNULL(1);
+EAPI Eina_Bool                  eina_array_remove(Eina_Array *array,
+                                                  Eina_Bool(*keep)(void *data, void *gdata),
+                                                  void *gdata) EINA_ARG_NONNULL(1, 2);
+static inline Eina_Bool         eina_array_push(Eina_Array *array,
+                                                const void *data) EINA_ARG_NONNULL(1, 2);
+static inline void *            eina_array_pop(Eina_Array *array) EINA_ARG_NONNULL(1);
+static inline void *            eina_array_data_get(const Eina_Array *array,
+                                                    unsigned int idx) EINA_ARG_NONNULL(1);
+static inline void              eina_array_data_set(const Eina_Array *array,
+                                                    unsigned int idx,
+                                                    const void *data) EINA_ARG_NONNULL(1, 3);
+static inline unsigned int      eina_array_count_get(const Eina_Array *array) EINA_ARG_NONNULL(1);
+EAPI Eina_Iterator *            eina_array_iterator_new(const Eina_Array *array) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Accessor *            eina_array_accessor_new(const Eina_Array *array) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+static inline Eina_Bool                eina_array_foreach(Eina_Array *array,
+                                                   Eina_Each_Cb cb,
+                                                   void *data);
 /**
  * @def EINA_ARRAY_ITER_NEXT
  * @brief Macro to iterate over an array easily.
@@ -98,9 +109,9 @@ EAPI Eina_Accessor *eina_array_accessor_new (const Eina_Array *array) EINA_MALLO
  * @param item The data
  * @param iterator The iterator
  *
- * This macro allow the iteration over @p array in an easy way. It
+ * This macro allows the iteration over @p array in an easy way. It
  * iterates from the first element to the last one. @p index is an
- * integer that increase from 0 to the number of elements. @p item is
+ * integer that increases from 0 to the number of elements. @p item is
  * the data of each element of @p array, so it is a pointer to a type
  * chosen by the user. @p iterator is of type #Eina_Array_Iterator.
  *
@@ -122,7 +133,7 @@ EAPI Eina_Accessor *eina_array_accessor_new (const Eina_Array *array) EINA_MALLO
  * @endcode
  */
 #define EINA_ARRAY_ITER_NEXT(array, index, item, iterator)             \
-  for (index = 0, iterator = (array)->data; \
+  for (index = 0, iterator = (array)->data;                            \
        (index < eina_array_count_get(array)) && ((item = *((iterator)++))); \
        ++(index))
 
index 04cab9d..e0faa72 100644 (file)
@@ -55,13 +55,16 @@ typedef void (*Eina_Benchmark_Specimens)(int request);
  */
 #define EINA_BENCHMARK(function) ((Eina_Benchmark_Specimens)function)
 
-EAPI Eina_Benchmark *eina_benchmark_new(const char *name, const char *run);
-EAPI void eina_benchmark_free(Eina_Benchmark *bench);
-
-EAPI Eina_Bool eina_benchmark_register(Eina_Benchmark *bench, const char *name, Eina_Benchmark_Specimens bench_cb,
-                                      int count_start, int count_end, int count_set);
-
-EAPI Eina_Array *eina_benchmark_run(Eina_Benchmark *bench);
+EAPI Eina_Benchmark * eina_benchmark_new(const char *name,
+                                         const char *run);
+EAPI void             eina_benchmark_free(Eina_Benchmark *bench);
+EAPI Eina_Bool        eina_benchmark_register(Eina_Benchmark *bench,
+                                              const char *name,
+                                              Eina_Benchmark_Specimens bench_cb,
+                                              int count_start,
+                                              int count_end,
+                                              int count_set);
+EAPI Eina_Array *     eina_benchmark_run(Eina_Benchmark *bench);
 
 /**
  * @}
diff --git a/src/include/eina_binshare.h b/src/include/eina_binshare.h
new file mode 100644 (file)
index 0000000..a2ea501
--- /dev/null
@@ -0,0 +1,105 @@
+/* EINA - EFL data type library
+ * Copyright (C) 2002-2008 Carsten Haitzler, Jorge Luis Zapata Muga, Cedric Bail
+ *
+ * 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/>.
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright (C) 2008 Peter Wehrfritz
+ *
+ *  Permission is hereby granted, free of charge, to any person obtaining a copy
+ *  of this software and associated documentation files (the "Software"), to
+ *  deal in the Software without restriction, including without limitation the
+ *  rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ *  sell copies of the Software, and to permit persons to whom the Software is
+ *  furnished to do so, subject to the following conditions:
+ *
+ *  The above copyright notice and this permission notice shall be included in
+ *  all copies of the Software and its Copyright notices. In addition publicly
+ *  documented acknowledgment must be given that this software has been used if no
+ *  source code of this software is made available publicly. This includes
+ *  acknowledgments in either Copyright notices, Manuals, Publicity and Marketing
+ *  documents or any documentation provided with any product containing this
+ *  software. This License does not apply to any software that links to the
+ *  libraries provided by this software (statically or dynamically), but only to
+ *  the software provided.
+ *
+ *  Please see the OLD-COPYING.PLAIN for a plain-english explanation of this notice
+ *  and it's intent.
+ *
+ *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ *  THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ *  IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ *  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef EINA_BINSHARE_H_
+#define EINA_BINSHARE_H_
+
+#include "eina_types.h"
+
+/**
+ * @addtogroup Eina_Data_Types_Group Data Types
+ *
+ * @{
+ */
+
+/**
+ * @defgroup Eina_Binshare_Group Binary Share
+ *
+ * @{
+ */
+
+EAPI Eina_Bool    eina_binshare_init(void);
+EAPI Eina_Bool    eina_binshare_shutdown(void);
+EAPI const void * eina_binshare_add_length(const void *obj,
+                                          unsigned int olen) EINA_PURE EINA_WARN_UNUSED_RESULT;
+EAPI const void * eina_binshare_ref(const void *obj);
+EAPI void         eina_binshare_del(const void *obj);
+EAPI int          eina_binshare_length(const void *obj) EINA_WARN_UNUSED_RESULT;
+EAPI void         eina_binshare_dump(void);
+
+/**
+ * @brief Retrieve an instance of a blob for use in a program.
+ *
+ * @param   obj The binary blob to retrieve an instance of.
+ * @return  A pointer to an instance of the string on success.
+ *          @c NULL on failure.
+ *
+ * This macro retrieves an instance of @p obj. If @p obj is
+ * @c NULL, then @c NULL is returned. If @p obj is already stored, it
+ * is just returned and its reference counter is increased. Otherwise
+ * it is added to the blobs to be searched and a duplicated blob
+ * of @p obj is returned.
+ *
+ * This macro essentially calls eina_binshare_add_length with ptr and sizeof(*ptr)
+ * as the parameters. It's useful for pointers to structures.
+ *
+ * @see eina_stringshare_add_length()
+ */
+#define eina_binshare_add(ptr) eina_binshare_add_length(ptr, sizeof(*ptr))
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+#endif /* EINA_STRINGSHARE_H_ */
index 4f0b3c3..56331bb 100644 (file)
 #endif
 @EINA_CONFIGURE_SAFETY_CHECKS@
 
+#ifdef EINA_HAVE_INTTYPES_H
+# undef EINA_HAVE_INTTYPES_H
+#endif
+@EINA_CONFIGURE_HAVE_INTTYPES_H@
+
+#ifdef EINA_HAVE_STDINT_H
+# undef EINA_HAVE_STDINT_H
+#endif
+@EINA_CONFIGURE_HAVE_STDINT_H@
+
+#ifdef EINA_SIZEOF_WCHAR_T
+# undef EINA_SIZEOF_WCHAR_T
+#endif
+#define EINA_SIZEOF_WCHAR_T @EINA_SIZEOF_WCHAR_T@
+
 #endif /* EINA_CONFIG_H_ */
index cd935e1..8cd6433 100644 (file)
@@ -54,14 +54,20 @@ EAPI extern Eina_Error EINA_ERROR_CONVERT_0X_NOT_FOUND;
  */
 EAPI extern Eina_Error EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH;
 
-EAPI int eina_convert_itoa(int n, char *s)  EINA_ARG_NONNULL(2);
-EAPI int eina_convert_xtoa(unsigned int n, char *s) EINA_ARG_NONNULL(2);
+EAPI int       eina_convert_itoa(int n, char *s)  EINA_ARG_NONNULL(2);
+EAPI int       eina_convert_xtoa(unsigned int n, char *s) EINA_ARG_NONNULL(2);
 
-EAPI int eina_convert_dtoa(double d, char *des) EINA_ARG_NONNULL(2);
-EAPI Eina_Bool eina_convert_atod(const char *src, int length, long long *m, long *e)  EINA_ARG_NONNULL(1,3,4);
+EAPI int       eina_convert_dtoa(double d, char *des) EINA_ARG_NONNULL(2);
+EAPI Eina_Bool eina_convert_atod(const char *src,
+                                 int length,
+                                 long long *m,
+                                 long *e) EINA_ARG_NONNULL(1,3,4);
 
-EAPI int eina_convert_fptoa(Eina_F32p32 fp, char *des) EINA_ARG_NONNULL(2);
-EAPI Eina_Bool eina_convert_atofp(const char *src, int length, Eina_F32p32 *fp)  EINA_ARG_NONNULL(1,3);
+EAPI int       eina_convert_fptoa(Eina_F32p32 fp,
+                                  char *des) EINA_ARG_NONNULL(2);
+EAPI Eina_Bool eina_convert_atofp(const char *src,
+                                  int length,
+                                  Eina_F32p32 *fp) EINA_ARG_NONNULL(1,3);
 
 /**
  * @}
index c766b8f..fc7b23f 100644 (file)
  */
 typedef struct _Eina_Counter Eina_Counter;
 
-EAPI Eina_Counter *eina_counter_new(const char *name) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
-EAPI void eina_counter_free(Eina_Counter *counter) EINA_ARG_NONNULL(1);
-
-EAPI void eina_counter_start(Eina_Counter *counter) EINA_ARG_NONNULL(1);
-EAPI void eina_counter_stop(Eina_Counter *counter, int specimen) EINA_ARG_NONNULL(1);
-EAPI char *eina_counter_dump(Eina_Counter *counter) EINA_ARG_NONNULL(1);
+EAPI Eina_Counter * eina_counter_new(const char *name) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
+EAPI void           eina_counter_free(Eina_Counter *counter) EINA_ARG_NONNULL(1);
+EAPI void           eina_counter_start(Eina_Counter *counter) EINA_ARG_NONNULL(1);
+EAPI void           eina_counter_stop(Eina_Counter *counter,
+                                      int specimen) EINA_ARG_NONNULL(1);
+EAPI char *         eina_counter_dump(Eina_Counter *counter) EINA_ARG_NONNULL(1);
 
 /**
  * @}
index c637d93..ac32e1d 100644 (file)
 
 typedef enum _Eina_Cpu_Features
 {
-       EINA_CPU_MMX     = 0x00000001,
-       EINA_CPU_SSE     = 0x00000002,
-       EINA_CPU_SSE2    = 0x00000004,
-       EINA_CPU_SSE3    = 0x00000008,
-       /* TODO 3DNow! */
-       EINA_CPU_ALTIVEC = 0x00000010,
-       EINA_CPU_VIS     = 0x00000020,
-       EINA_CPU_NEON    = 0x00000040,
+   EINA_CPU_MMX = 0x00000001,
+   EINA_CPU_SSE = 0x00000002,
+   EINA_CPU_SSE2 = 0x00000004,
+   EINA_CPU_SSE3 = 0x00000008,
+   /* TODO 3DNow! */
+   EINA_CPU_ALTIVEC = 0x00000010,
+   EINA_CPU_VIS = 0x00000020,
+   EINA_CPU_NEON = 0x00000040,
 } Eina_Cpu_Features;
 
 EAPI Eina_Cpu_Features eina_cpu_features_get(void);
-EAPI int eina_cpu_count(void);
+EAPI int               eina_cpu_count(void);
 
 #endif /* EINA_CPU_H_ */
index 7c119d4..7b290de 100644 (file)
@@ -47,11 +47,12 @@ typedef int Eina_Error;
  */
 EAPI extern Eina_Error EINA_ERROR_OUT_OF_MEMORY;
 
-EAPI Eina_Error eina_error_msg_register(const char *msg) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Error eina_error_msg_static_register(const char *msg) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-
-EAPI Eina_Error eina_error_get(void);
-EAPI void eina_error_set(Eina_Error err);
+EAPI Eina_Error   eina_error_msg_register(const char *msg) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Error   eina_error_msg_static_register(const char *msg) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Bool    eina_error_msg_modify(Eina_Error error,
+                                       const char *msg) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Error   eina_error_get(void);
+EAPI void         eina_error_set(Eina_Error err);
 EAPI const char * eina_error_msg_get(Eina_Error error) EINA_PURE;
 
 /**
index 7011781..b7a4ef6 100644 (file)
 #ifndef EINA_FILE_H_
 #define EINA_FILE_H_
 
+#if defined (__MacOSX__) || defined (__FreeBSD__) || (defined (__MACH__) && \
+   defined (__APPLE__))
+# include <sys/syslimits.h>
+#endif
+
 #include "eina_types.h"
 #include "eina_array.h"
+#include "eina_iterator.h"
 
 /**
  * @addtogroup Eina_Tools_Group Tools
  * @typedef Eina_File_Dir_List_Cb
  * Type for a callback.
  */
+typedef struct _Eina_File_Direct_Info Eina_File_Direct_Info;
 typedef void (*Eina_File_Dir_List_Cb)(const char *name, const char *path, void *data);
 
+struct _Eina_File_Direct_Info
+{
+   size_t path_length; /* size of the whole path */
+   size_t name_length; /* size of the filename/basename component */
+   size_t name_start; /* where the filename/basename component starts */
+   char path[PATH_MAX];
+   const struct dirent *dirent;
+};
+
 /**
  * @def EINA_FILE_DIR_LIST_CB
  * @brief cast to an #Eina_File_Dir_List_Cb.
@@ -50,8 +66,13 @@ typedef void (*Eina_File_Dir_List_Cb)(const char *name, const char *path, void *
  */
 #define EINA_FILE_DIR_LIST_CB(function) ((Eina_File_Dir_List_Cb)function)
 
-EAPI Eina_Bool eina_file_dir_list(const char *dir, Eina_Bool recursive, Eina_File_Dir_List_Cb cb, void *data) EINA_ARG_NONNULL(1, 3);
-EAPI Eina_Array *eina_file_split(char *path) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
+EAPI Eina_Bool       eina_file_dir_list(const char *dir,
+                                        Eina_Bool recursive,
+                                        Eina_File_Dir_List_Cb cb,
+                                        void *data) EINA_ARG_NONNULL(1, 3);
+EAPI Eina_Array *    eina_file_split(char *path) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
+EAPI Eina_Iterator * eina_file_ls(const char *dir) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
+EAPI Eina_Iterator * eina_file_direct_ls(const char *dir) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
 
 /**
  * @}
index e362940..47dbaa4 100644 (file)
@@ -36,57 +36,72 @@ typedef int64_t Eina_F32p32;
 typedef int32_t Eina_F16p16;
 typedef int32_t Eina_F8p24;
 
-static inline Eina_F32p32 eina_f32p32_int_from(int32_t v);
-static inline int32_t eina_f32p32_int_to(Eina_F32p32 v);
-static inline Eina_F32p32 eina_f32p32_double_from(double v);
-static inline double eina_f32p32_double_to(Eina_F32p32 v);
-
-static inline Eina_F32p32 eina_f32p32_add(Eina_F32p32 a, Eina_F32p32 b);
-static inline Eina_F32p32 eina_f32p32_sub(Eina_F32p32 a, Eina_F32p32 b);
-static inline Eina_F32p32 eina_f32p32_mul(Eina_F32p32 a, Eina_F32p32 b);
-static inline Eina_F32p32 eina_f32p32_scale(Eina_F32p32 a, int b);
-static inline Eina_F32p32 eina_f32p32_div(Eina_F32p32 a, Eina_F32p32 b);
-static inline Eina_F32p32 eina_f32p32_sqrt(Eina_F32p32 a);
+static inline Eina_F32p32  eina_f32p32_int_from(int32_t v);
+static inline int32_t      eina_f32p32_int_to(Eina_F32p32 v);
+static inline Eina_F32p32  eina_f32p32_double_from(double v);
+static inline double       eina_f32p32_double_to(Eina_F32p32 v);
+
+static inline Eina_F32p32  eina_f32p32_add(Eina_F32p32 a,
+                                           Eina_F32p32 b);
+static inline Eina_F32p32  eina_f32p32_sub(Eina_F32p32 a,
+                                           Eina_F32p32 b);
+static inline Eina_F32p32  eina_f32p32_mul(Eina_F32p32 a,
+                                           Eina_F32p32 b);
+static inline Eina_F32p32  eina_f32p32_scale(Eina_F32p32 a,
+                                             int b);
+static inline Eina_F32p32  eina_f32p32_div(Eina_F32p32 a,
+                                           Eina_F32p32 b);
+static inline Eina_F32p32  eina_f32p32_sqrt(Eina_F32p32 a);
 static inline unsigned int eina_f32p32_fracc_get(Eina_F32p32 v);
 
 // dont use llabs - issues if not on 64bit
 #define eina_fp32p32_llabs(a) ((a < 0) ? -(a) : (a))
 
-EAPI Eina_F32p32 eina_f32p32_cos(Eina_F32p32 a);
-EAPI Eina_F32p32 eina_f32p32_sin(Eina_F32p32 a);
-
-static inline Eina_F16p16 eina_f16p16_int_from(int32_t v);
-static inline int32_t eina_f16p16_int_to(Eina_F16p16 v);
-static inline Eina_F16p16 eina_f16p16_float_from(float v);
-static inline float eina_f16p16_float_to(Eina_F16p16 v);
-
-static inline Eina_F16p16 eina_f16p16_add(Eina_F16p16 a, Eina_F16p16 b);
-static inline Eina_F16p16 eina_f16p16_sub(Eina_F16p16 a, Eina_F16p16 b);
-static inline Eina_F16p16 eina_f16p16_mul(Eina_F16p16 a, Eina_F16p16 b);
-static inline Eina_F16p16 eina_f16p16_scale(Eina_F16p16 a, int b);
-static inline Eina_F16p16 eina_f16p16_div(Eina_F16p16 a, Eina_F16p16 b);
-static inline Eina_F16p16 eina_f16p16_sqrt(Eina_F16p16 a);
+EAPI Eina_F32p32           eina_f32p32_cos(Eina_F32p32 a);
+EAPI Eina_F32p32           eina_f32p32_sin(Eina_F32p32 a);
+
+static inline Eina_F16p16  eina_f16p16_int_from(int32_t v);
+static inline int32_t      eina_f16p16_int_to(Eina_F16p16 v);
+static inline Eina_F16p16  eina_f16p16_float_from(float v);
+static inline float        eina_f16p16_float_to(Eina_F16p16 v);
+
+static inline Eina_F16p16  eina_f16p16_add(Eina_F16p16 a,
+                                           Eina_F16p16 b);
+static inline Eina_F16p16  eina_f16p16_sub(Eina_F16p16 a,
+                                           Eina_F16p16 b);
+static inline Eina_F16p16  eina_f16p16_mul(Eina_F16p16 a,
+                                           Eina_F16p16 b);
+static inline Eina_F16p16  eina_f16p16_scale(Eina_F16p16 a,
+                                             int b);
+static inline Eina_F16p16  eina_f16p16_div(Eina_F16p16 a,
+                                           Eina_F16p16 b);
+static inline Eina_F16p16  eina_f16p16_sqrt(Eina_F16p16 a);
 static inline unsigned int eina_f16p16_fracc_get(Eina_F16p16 v);
 
-static inline Eina_F8p24 eina_f8p24_int_from(int32_t v);
-static inline int32_t eina_f8p24_int_to(Eina_F8p24 v);
-static inline Eina_F8p24 eina_f8p24_float_from(float v);
-static inline float eina_f8p24_float_to(Eina_F8p24 v);
-
-static inline Eina_F8p24 eina_f8p24_add(Eina_F8p24 a, Eina_F8p24 b);
-static inline Eina_F8p24 eina_f8p24_sub(Eina_F8p24 a, Eina_F8p24 b);
-static inline Eina_F8p24 eina_f8p24_mul(Eina_F8p24 a, Eina_F8p24 b);
-static inline Eina_F8p24 eina_f8p24_scale(Eina_F8p24 a, int b);
-static inline Eina_F8p24 eina_f8p24_div(Eina_F8p24 a, Eina_F8p24 b);
-static inline Eina_F8p24 eina_f8p24_sqrt(Eina_F8p24 a);
+static inline Eina_F8p24   eina_f8p24_int_from(int32_t v);
+static inline int32_t      eina_f8p24_int_to(Eina_F8p24 v);
+static inline Eina_F8p24   eina_f8p24_float_from(float v);
+static inline float        eina_f8p24_float_to(Eina_F8p24 v);
+
+static inline Eina_F8p24   eina_f8p24_add(Eina_F8p24 a,
+                                          Eina_F8p24 b);
+static inline Eina_F8p24   eina_f8p24_sub(Eina_F8p24 a,
+                                          Eina_F8p24 b);
+static inline Eina_F8p24   eina_f8p24_mul(Eina_F8p24 a,
+                                          Eina_F8p24 b);
+static inline Eina_F8p24   eina_f8p24_scale(Eina_F8p24 a,
+                                            int b);
+static inline Eina_F8p24   eina_f8p24_div(Eina_F8p24 a,
+                                          Eina_F8p24 b);
+static inline Eina_F8p24   eina_f8p24_sqrt(Eina_F8p24 a);
 static inline unsigned int eina_f8p24_fracc_get(Eina_F8p24 v);
 
-static inline Eina_F32p32 eina_f16p16_to_f32p32(Eina_F16p16 a);
-static inline Eina_F32p32 eina_f8p24_to_f32p32(Eina_F8p24 a);
-static inline Eina_F16p16 eina_f32p32_to_f16p16(Eina_F32p32 a);
-static inline Eina_F16p16 eina_f8p24_to_f16p16(Eina_F8p24 a);
-static inline Eina_F8p24 eina_f32p32_to_f8p24(Eina_F32p32 a);
-static inline Eina_F8p24 eina_f16p16_to_f8p24(Eina_F16p16 a);
+static inline Eina_F32p32  eina_f16p16_to_f32p32(Eina_F16p16 a);
+static inline Eina_F32p32  eina_f8p24_to_f32p32(Eina_F8p24 a);
+static inline Eina_F16p16  eina_f32p32_to_f16p16(Eina_F32p32 a);
+static inline Eina_F16p16  eina_f8p24_to_f16p16(Eina_F8p24 a);
+static inline Eina_F8p24   eina_f32p32_to_f8p24(Eina_F32p32 a);
+static inline Eina_F8p24   eina_f16p16_to_f8p24(Eina_F16p16 a);
 
 #include "eina_inline_f32p32.x"
 #include "eina_inline_f16p16.x"
index f0c299c..0b5b316 100644 (file)
@@ -1,4 +1,3 @@
-
 /* EINA - EFL data type library
  * Copyright (C) 2002-2008 Carsten Haitzler, Gustavo Sverzut Barbieri,
  *                         Vincent Torri, Jorge Luis Zapata Muga, Cedric Bail
@@ -48,80 +47,115 @@ struct _Eina_Hash_Tuple
 {
    const void *key;
    void *data;
-
    unsigned int key_length;
 };
 
 typedef unsigned int (*Eina_Key_Length)(const void *key);
 #define EINA_KEY_LENGTH(Function) ((Eina_Key_Length)Function)
-typedef int (*Eina_Key_Cmp)(const void *key1, int key1_length,
-                           const void *key2, int key2_length);
+typedef int (*Eina_Key_Cmp)(const void *key1, int key1_length, const void *key2, int key2_length);
 #define EINA_KEY_CMP(Function) ((Eina_Key_Cmp)Function)
 typedef int (*Eina_Key_Hash)(const void *key, int key_length);
 #define EINA_KEY_HASH(Function) ((Eina_Key_Hash)Function)
+typedef Eina_Bool (*Eina_Hash_Foreach)(const Eina_Hash *hash, const void *key, void *data, void *fdata);
 
-EAPI Eina_Hash * eina_hash_new(Eina_Key_Length key_length_cb,
-                              Eina_Key_Cmp key_cmp_cb,
-                              Eina_Key_Hash key_hash_cb,
-                              Eina_Free_Cb data_free_cb,
-                              int buckets_power_size) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(2, 3);
-EAPI Eina_Hash * eina_hash_string_djb2_new(Eina_Free_Cb data_free_cb);
-EAPI Eina_Hash * eina_hash_string_superfast_new(Eina_Free_Cb data_free_cb);
-EAPI Eina_Hash * eina_hash_string_small_new(Eina_Free_Cb data_free_cb);
-EAPI Eina_Hash * eina_hash_int32_new(Eina_Free_Cb data_free_cb);
-EAPI Eina_Hash * eina_hash_int64_new(Eina_Free_Cb data_free_cb);
-EAPI Eina_Hash * eina_hash_pointer_new(Eina_Free_Cb data_free_cb);
-EAPI Eina_Hash * eina_hash_stringshared_new(Eina_Free_Cb data_free_cb);
-
-EAPI Eina_Bool   eina_hash_add(Eina_Hash *hash, const void *key, const void *data) EINA_ARG_NONNULL(1, 2, 3);
-EAPI Eina_Bool   eina_hash_direct_add(Eina_Hash *hash, const void *key, const void *data) EINA_ARG_NONNULL(1, 2, 3);
-EAPI Eina_Bool   eina_hash_del(Eina_Hash *hash, const void *key, const void *data) EINA_ARG_NONNULL(1);
-EAPI void      * eina_hash_find(const Eina_Hash *hash, const void *key) EINA_ARG_NONNULL(1, 2);
-EAPI void      * eina_hash_modify(Eina_Hash *hash, const void *key, const void *data) EINA_ARG_NONNULL(1, 2, 3);
-EAPI void        eina_hash_free(Eina_Hash *hash) EINA_ARG_NONNULL(1);
-EAPI int         eina_hash_population(const Eina_Hash *hash) EINA_ARG_NONNULL(1);
-
-EAPI Eina_Bool   eina_hash_add_by_hash(Eina_Hash *hash,
-                                      const void *key, int key_length, int key_hash,
-                                      const void *data)  EINA_ARG_NONNULL(1, 2, 5);
-EAPI Eina_Bool   eina_hash_direct_add_by_hash(Eina_Hash *hash,
-                                             const void *key, int key_length, int key_hash,
-                                             const void *data) EINA_ARG_NONNULL(1, 2, 5);
-
-EAPI Eina_Bool   eina_hash_del_by_key_hash(Eina_Hash *hash, const void *key, int key_length, int key_hash) EINA_ARG_NONNULL(1, 2);
-
-EAPI Eina_Bool   eina_hash_del_by_key(Eina_Hash *hash, const void *key) EINA_ARG_NONNULL(1, 2);
-EAPI Eina_Bool   eina_hash_del_by_data(Eina_Hash *hash, const void *data) EINA_ARG_NONNULL(1, 2);
-
-EAPI Eina_Bool   eina_hash_del_by_hash(Eina_Hash *hash,
-                                      const void *key, int key_length, int key_hash,
-                                      const void *data) EINA_ARG_NONNULL(1);
-EAPI void      * eina_hash_find_by_hash(const Eina_Hash *hash,
-                                       const void *key, int key_length, int key_hash) EINA_ARG_NONNULL(1, 2);
-EAPI void      * eina_hash_modify_by_hash(Eina_Hash *hash,
-                                         const void *key, int key_length, int key_hash,
-                                         const void *data) EINA_ARG_NONNULL(1, 2, 5);
-
+EAPI Eina_Hash *     eina_hash_new(Eina_Key_Length key_length_cb,
+                                   Eina_Key_Cmp key_cmp_cb,
+                                   Eina_Key_Hash key_hash_cb,
+                                   Eina_Free_Cb data_free_cb,
+                                   int buckets_power_size) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(2, 3);
+EAPI Eina_Hash *     eina_hash_string_djb2_new(Eina_Free_Cb data_free_cb);
+EAPI Eina_Hash *     eina_hash_string_superfast_new(Eina_Free_Cb data_free_cb);
+EAPI Eina_Hash *     eina_hash_string_small_new(Eina_Free_Cb data_free_cb);
+EAPI Eina_Hash *     eina_hash_int32_new(Eina_Free_Cb data_free_cb);
+EAPI Eina_Hash *     eina_hash_int64_new(Eina_Free_Cb data_free_cb);
+EAPI Eina_Hash *     eina_hash_pointer_new(Eina_Free_Cb data_free_cb);
+EAPI Eina_Hash *     eina_hash_stringshared_new(Eina_Free_Cb data_free_cb);
+EAPI Eina_Hash *     eina_hash_threadsafe_new(Eina_Key_Length key_length_cb,
+                                              Eina_Key_Cmp key_cmp_cb,
+                                              Eina_Key_Hash key_hash_cb,
+                                              Eina_Free_Cb data_free_cb,
+                                              int buckets_power_size) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(2, 3);
+EAPI Eina_Hash *     eina_hash_threadsafe_string_djb2_new(Eina_Free_Cb data_free_cb);
+EAPI Eina_Hash *     eina_hash_threadsafe_string_superfast_new(Eina_Free_Cb data_free_cb);
+EAPI Eina_Hash *     eina_hash_threadsafe_string_small_new(Eina_Free_Cb data_free_cb);
+EAPI Eina_Hash *     eina_hash_threadsafe_int32_new(Eina_Free_Cb data_free_cb);
+EAPI Eina_Hash *     eina_hash_threadsafe_int64_new(Eina_Free_Cb data_free_cb);
+EAPI Eina_Hash *     eina_hash_threadsafe_pointer_new(Eina_Free_Cb data_free_cb);
+EAPI Eina_Hash *     eina_hash_threadsafe_stringshared_new(Eina_Free_Cb data_free_cb);
+EAPI Eina_Bool       eina_hash_add(Eina_Hash *hash,
+                                   const void *key,
+                                   const void *data) EINA_ARG_NONNULL(1, 2, 3);
+EAPI Eina_Bool       eina_hash_direct_add(Eina_Hash *hash,
+                                          const void *key,
+                                          const void *data) EINA_ARG_NONNULL(1, 2, 3);
+EAPI Eina_Bool       eina_hash_del(Eina_Hash *hash,
+                                   const void *key,
+                                   const void *data) EINA_ARG_NONNULL(1);
+EAPI void *          eina_hash_find(const Eina_Hash *hash,
+                                    const void *key) EINA_ARG_NONNULL(1, 2);
+EAPI void *          eina_hash_modify(Eina_Hash *hash,
+                                      const void *key,
+                                      const void *data) EINA_ARG_NONNULL(1, 2, 3);
+EAPI void *          eina_hash_set(Eina_Hash *hash,
+                                   const void *key,
+                                   const void *data) EINA_ARG_NONNULL(1, 2, 3);
+EAPI Eina_Bool       eina_hash_move(Eina_Hash *hash,
+                                    const void *old_key,
+                                    const void *new_key) EINA_ARG_NONNULL(1, 2, 3);
+EAPI void            eina_hash_free(Eina_Hash *hash) EINA_ARG_NONNULL(1);
+EAPI void            eina_hash_free_buckets(Eina_Hash *hash) EINA_ARG_NONNULL(1);
+EAPI int             eina_hash_population(const Eina_Hash *hash) EINA_ARG_NONNULL(1);
+EAPI Eina_Bool       eina_hash_add_by_hash(Eina_Hash *hash,
+                                           const void *key,
+                                           int key_length,
+                                           int key_hash,
+                                           const void *data) EINA_ARG_NONNULL(1, 2, 5);
+EAPI Eina_Bool       eina_hash_direct_add_by_hash(Eina_Hash *hash,
+                                                  const void *key,
+                                                  int key_length,
+                                                  int key_hash,
+                                                  const void *data) EINA_ARG_NONNULL(1, 2, 5);
+EAPI Eina_Bool       eina_hash_del_by_key_hash(Eina_Hash *hash,
+                                               const void *key,
+                                               int key_length,
+                                               int key_hash) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool       eina_hash_del_by_key(Eina_Hash *hash,
+                                          const void *key) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool       eina_hash_del_by_data(Eina_Hash *hash,
+                                           const void *data) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool       eina_hash_del_by_hash(Eina_Hash *hash,
+                                           const void *key,
+                                           int key_length,
+                                           int key_hash,
+                                           const void *data) EINA_ARG_NONNULL(1);
+EAPI void *          eina_hash_find_by_hash(const Eina_Hash *hash,
+                                            const void *key,
+                                            int key_length,
+                                            int key_hash) EINA_ARG_NONNULL(1, 2);
+EAPI void *          eina_hash_modify_by_hash(Eina_Hash *hash,
+                                              const void *key,
+                                              int key_length,
+                                              int key_hash,
+                                              const void *data) EINA_ARG_NONNULL(1, 2, 5);
 EAPI Eina_Iterator * eina_hash_iterator_key_new(const Eina_Hash *hash) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
 EAPI Eina_Iterator * eina_hash_iterator_data_new(const Eina_Hash *hash) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
 EAPI Eina_Iterator * eina_hash_iterator_tuple_new(const Eina_Hash *hash) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-
-typedef Eina_Bool (*Eina_Hash_Foreach)(const Eina_Hash *hash, const void *key, void *data, void *fdata);
-EAPI void        eina_hash_foreach(const Eina_Hash *hash,
-                                  Eina_Hash_Foreach cb,
-                                  const void *fdata) EINA_ARG_NONNULL(1, 2);
-
-/* Paul Hsieh (http://www.azillionmonkeys.com/qed/hash.html) hash function
-   used by WebCore (http://webkit.org/blog/8/hashtables-part-2/) */
-EAPI int eina_hash_superfast(const char *key, int len) EINA_ARG_NONNULL(1);
-
+EAPI void            eina_hash_foreach(const Eina_Hash *hash,
+                                       Eina_Hash_Foreach cb,
+                                       const void *fdata) EINA_ARG_NONNULL(1, 2);
+/* Paul Hsieh (http://www.azillionmonkeys.com/qed/hash.html) hash function used by WebCore (http://webkit.org/blog/8/hashtables-part-2/) */
+EAPI int             eina_hash_superfast(const char *key,
+                                         int len) EINA_ARG_NONNULL(1);
 /* Hash function first reported by dan bernstein many years ago in comp.lang.c */
-static inline int eina_hash_djb2(const char *key, int len) EINA_ARG_NONNULL(1);
-static inline int eina_hash_djb2_len(const char *key, int *plen) EINA_ARG_NONNULL(1, 2);
-
+static inline int    eina_hash_djb2(const char *key,
+                                    int len) EINA_ARG_NONNULL(1);
+static inline int    eina_hash_djb2_len(const char *key,
+                                        int *plen) EINA_ARG_NONNULL(1, 2);
 /* Hash function from http://www.concentric.net/~Ttwang/tech/inthash.htm */
-static inline int eina_hash_int32(const unsigned int *pkey, int len) EINA_ARG_NONNULL(1);
-static inline int eina_hash_int64(const unsigned long int *pkey, int len) EINA_ARG_NONNULL(1);
+static inline int    eina_hash_int32(const unsigned int *pkey,
+                                     int len) EINA_ARG_NONNULL(1);
+static inline int    eina_hash_int64(const unsigned long int *pkey,
+                                     int len) EINA_ARG_NONNULL(1);
 
 #include "eina_inline_hash.x"
 
index 400da23..883d728 100644 (file)
@@ -19,6 +19,7 @@
 #ifndef EINA_INLINE_ARRAY_X_
 #define EINA_INLINE_ARRAY_X_
 
+#include <stdio.h>
 
 /**
  * @cond LOCAL
@@ -52,15 +53,18 @@ EAPI Eina_Bool eina_array_grow(Eina_Array *array);
  * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, #EINA_TRUE is
  * returned.
  */
+
 static inline Eina_Bool
 eina_array_push(Eina_Array *array, const void *data)
 {
    if (!data) return EINA_FALSE;
 
    if (EINA_UNLIKELY((array->count + 1) > array->total))
-     if (!eina_array_grow(array)) return EINA_FALSE;
+     if (!eina_array_grow(array))
+       return EINA_FALSE;
 
    array->data[array->count++] = (void*) data;
+
    return EINA_TRUE;
 }
 
@@ -79,8 +83,15 @@ eina_array_push(Eina_Array *array, const void *data)
 static inline void *
 eina_array_pop(Eina_Array *array)
 {
-   if (array->count <= 0) return NULL;
-   return array->data[--array->count];
+   void *ret = NULL;
+
+   if (array->count <= 0)
+     goto on_empty;
+
+   ret = array->data[--array->count];
+
+ on_empty:
+   return ret;
 }
 
 /**
@@ -101,13 +112,13 @@ eina_array_data_get(const Eina_Array *array, unsigned int idx)
 }
 
 /**
- * @brief Return the data at a given position in an array.
+ * @brief Set the data at a given position in an array.
  *
  * @param array The array.
  * @param idx The potition of the data to set.
  * @param data The data to set.
  *
- * This function returns the data at the position @p idx in @p
+ * This function sets the data at the position @p idx in @p
  * array. For performance reasons, there is no check of @p array or @p
  * idx. If it is @c NULL or invalid, the program may crash.
  */
@@ -134,6 +145,36 @@ eina_array_count_get(const Eina_Array *array)
 }
 
 /**
+ * @brief Provide a safe way to iterate over an array
+ *
+ * @param array The array to iterate over.
+ * @param cb The callback to call for each item.
+ * @param fdata The user data to pass to the callback.
+ * @return EINA_TRUE if it successfully iterate all items of the array.
+ *
+ * This function provide a safe way to iterate over an array. @p cb should
+ * return EINA_TRUE as long as you want the function to continue iterating,
+ * by returning EINA_FALSE it will stop and return EINA_FALSE as a result.
+ */
+static inline Eina_Bool
+eina_array_foreach(Eina_Array *array, Eina_Each_Cb cb, void *fdata)
+{
+   void *data;
+   Eina_Array_Iterator iterator;
+   unsigned int i;
+   Eina_Bool ret = EINA_TRUE;
+
+   EINA_ARRAY_ITER_NEXT(array, i, data, iterator)
+     if (cb(array, data, fdata) != EINA_TRUE)
+       {
+         ret = EINA_FALSE;
+         break;
+       }
+
+   return ret;
+}
+
+/**
  * @}
  */
 
index 3c55180..d5ae043 100644 (file)
@@ -26,10 +26,10 @@ eina_rbtree_inline_lookup(const Eina_Rbtree *root, const void *key, int length,
 
    while (root)
      {
-       result = cmp(root, key, length, (void*) data);
-       if (result == 0) return (Eina_Rbtree*) root;
+        result = cmp(root, key, length, (void*) data);
+        if (result == 0) return (Eina_Rbtree*) root;
 
-       root = root->son[result < 0 ? 0 : 1];
+        root = root->son[result < 0 ? 0 : 1];
      }
 
    return NULL;
index 27b3540..2daeb85 100644 (file)
@@ -48,6 +48,28 @@ eina_strlen_bounded(const char *str, size_t maxlen)
 }
 
 /**
+ * @brief Join two strings of known length.
+ *
+ * @param dst The buffer to store the result.
+ * @param size Size (in byte) of the buffer.
+ * @param sep The separator character to use.
+ * @param a First string to use, before @p sep.
+ * @param b Second string to use, after @p sep.
+ * @return The number of characters printed.
+ *
+ * This function is similar to eina_str_join_len(), but will compute
+ * the length of @p a  and @p b using strlen().
+ *
+ * @see eina_str_join_len()
+ * @see eina_str_join_static()
+ */
+static inline size_t
+eina_str_join(char *dst, size_t size, char sep, const char *a, const char *b)
+{
+   return eina_str_join_len(dst, size, sep, a, strlen(a), b, strlen(b));
+}
+
+/**
  * @}
  */
 
index 233df99..bfd7677 100644 (file)
@@ -19,6 +19,8 @@
 #ifndef EINA_STRINGSHARE_INLINE_H_
 #define EINA_STRINGSHARE_INLINE_H_
 
+#include <string.h>
+#include "eina_stringshare.h"
 /**
  * @addtogroup Eina_Stringshare_Group Stringshare
  *
  */
 
 /**
- * Replace the previously stringshared pointer with new content.
+ * Replace the previously stringshared pointer with new content.
  *
  * The string pointed by @a p_str should be previously stringshared or
  * @c NULL and it will be eina_stringshare_del(). The new string will
- * be eina_stringshare_add() and then assigned to @c *p_str.
+ * be passed to eina_stringshare_add() and then assigned to @c *p_str.
  *
  * @param p_str pointer to the stringhare to be replaced. Must not be
  *        @c NULL, but @c *p_str may be @c NULL as it is a valid
@@ -54,6 +56,35 @@ eina_stringshare_replace(const char **p_str, const char *news)
 }
 
 /**
+ * Replace the previously stringshared pointer with a new content.
+ *
+ * The string pointed by @a p_str should be previously stringshared or
+ * @c NULL and it will be eina_stringshare_del(). The new string will
+ * be passed to eina_stringshare_add_length() and then assigned to @c *p_str.
+ *
+ * @param p_str pointer to the stringhare to be replaced. Must not be
+ *        @c NULL, but @c *p_str may be @c NULL as it is a valid
+ *        stringshare handle.
+ * @param news new string to be stringshared, may be @c NULL.
+ * @param slen The string size (<= strlen(str)).
+ *
+ * @return #EINA_TRUE if the strings were different and thus replaced,
+ *         #EINA_FALSE if the strings were the same after shared.
+ */
+static inline Eina_Bool
+eina_stringshare_replace_length(const char **p_str, const char *news, unsigned int slen)
+{
+   if (*p_str == news) return EINA_FALSE;
+
+   news = eina_stringshare_add_length(news, slen);
+   eina_stringshare_del(*p_str);
+   if (*p_str == news)
+     return EINA_FALSE;
+   *p_str = news;
+   return EINA_TRUE;
+}
+
+/**
  * @}
  */
 
diff --git a/src/include/eina_inline_ustringshare.x b/src/include/eina_inline_ustringshare.x
new file mode 100644 (file)
index 0000000..ace6fdc
--- /dev/null
@@ -0,0 +1,93 @@
+/* EINA - EFL data type library
+ * Copyright (C) 2002-2008 Gustavo Sverzut Barbieri
+                           Tom Hacohen
+ *
+ * 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/>.
+ */
+
+#ifndef EINA_USTRINGSHARE_INLINE_H_
+#define EINA_USTRINGSHARE_INLINE_H_
+
+#include "eina_unicode.h"
+#include "eina_ustringshare.h"
+
+/**
+ * @addtogroup Eina_UStringshare_Group Unicode Stringshare
+ *
+ * @{
+ */
+
+/**
+ * Replace the previously stringshared pointer with new content.
+ *
+ * The string pointed by @a p_str should be previously stringshared or
+ * @c NULL and it will be eina_ustringshare_del(). The new string will
+ * be passed to eina_ustringshare_add() and then assigned to @c *p_str.
+ *
+ * @param p_str pointer to the stringhare to be replaced. Must not be
+ *        @c NULL, but @c *p_str may be @c NULL as it is a valid
+ *        stringshare handle.
+ * @param news new string to be stringshared, may be @c NULL.
+ *
+ * @return #EINA_TRUE if the strings were different and thus replaced,
+ *         #EINA_FALSE if the strings were the same after shared.
+ */
+static inline Eina_Bool
+eina_ustringshare_replace(const Eina_Unicode **p_str, const Eina_Unicode *news)
+{
+   if (*p_str == news) return EINA_FALSE;
+
+   news = eina_ustringshare_add(news);
+   eina_ustringshare_del(*p_str);
+   if (*p_str == news)
+     return EINA_FALSE;
+   *p_str = news;
+   return EINA_TRUE;
+}
+
+/**
+ * Replace the previously stringshared pointer with a new content.
+ *
+ * The string pointed by @a p_str should be previously stringshared or
+ * @c NULL and it will be eina_ustringshare_del(). The new string will
+ * be passed to eina_ustringshare_add_length() and then assigned to @c *p_str.
+ *
+ * @param p_str pointer to the stringhare to be replaced. Must not be
+ *        @c NULL, but @c *p_str may be @c NULL as it is a valid
+ *        stringshare handle.
+ * @param news new string to be stringshared, may be @c NULL.
+ * @param slen The string size (<= strlen(str)).
+ *
+ * @return #EINA_TRUE if the strings were different and thus replaced,
+ *         #EINA_FALSE if the strings were the same after shared.
+ */
+static inline Eina_Bool
+eina_ustringshare_replace_length(const Eina_Unicode **p_str, const Eina_Unicode *news, unsigned int slen)
+{
+   if (*p_str == news) return EINA_FALSE;
+
+   news = eina_ustringshare_add_length(news, slen);
+   eina_ustringshare_del(*p_str);
+   if (*p_str == news)
+     return EINA_FALSE;
+   *p_str = news;
+   return EINA_TRUE;
+}
+
+/**
+ * @}
+ */
+
+#endif /* EINA_USTRINGSHARE_INLINE_H_ */
index 635cae1..34ee0ed 100644 (file)
@@ -60,29 +60,45 @@ struct _Eina_Inlist
 };
 
 #define EINA_INLIST Eina_Inlist __in_list
-#define EINA_INLIST_GET(Inlist) (&((Inlist)->__in_list))
-#define EINA_INLIST_CONTAINER_GET(ptr, type) ((type *) ((char *) ptr - offsetof(type, __in_list)))
-
-EAPI Eina_Inlist * eina_inlist_append(Eina_Inlist *in_list, Eina_Inlist *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Inlist * eina_inlist_prepend(Eina_Inlist *in_list, Eina_Inlist *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Inlist * eina_inlist_append_relative(Eina_Inlist *in_list, Eina_Inlist *in_item, Eina_Inlist *in_relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Inlist * eina_inlist_prepend_relative(Eina_Inlist *in_list, Eina_Inlist *in_item, Eina_Inlist *in_relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Inlist * eina_inlist_remove(Eina_Inlist *in_list, Eina_Inlist *in_item) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Inlist * eina_inlist_find(Eina_Inlist *in_list, Eina_Inlist *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Inlist * eina_inlist_promote(Eina_Inlist *list, Eina_Inlist *item) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Inlist * eina_inlist_demote(Eina_Inlist *list, Eina_Inlist *item) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
-EAPI unsigned int eina_inlist_count(const Eina_Inlist *list) EINA_WARN_UNUSED_RESULT;
+#define EINA_INLIST_GET(Inlist) (& ((Inlist)->__in_list))
+#define EINA_INLIST_CONTAINER_GET(ptr, \
+                                  type) ((type *)((char *)ptr - \
+                                                  offsetof(type, __in_list)))
+
+EAPI Eina_Inlist *  eina_inlist_append(Eina_Inlist *in_list,
+                                       Eina_Inlist *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Inlist *  eina_inlist_prepend(Eina_Inlist *in_list,
+                                        Eina_Inlist *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Inlist *  eina_inlist_append_relative(Eina_Inlist *in_list,
+                                                Eina_Inlist *in_item,
+                                                Eina_Inlist *in_relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Inlist *  eina_inlist_prepend_relative(Eina_Inlist *in_list,
+                                                 Eina_Inlist *in_item,
+                                                 Eina_Inlist *in_relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Inlist *  eina_inlist_remove(Eina_Inlist *in_list,
+                                       Eina_Inlist *in_item) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Inlist *  eina_inlist_find(Eina_Inlist *in_list,
+                                     Eina_Inlist *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Inlist *  eina_inlist_promote(Eina_Inlist *list,
+                                        Eina_Inlist *item) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Inlist *  eina_inlist_demote(Eina_Inlist *list,
+                                       Eina_Inlist *item) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
+EAPI unsigned int   eina_inlist_count(const Eina_Inlist *list) EINA_WARN_UNUSED_RESULT;
 
 EAPI Eina_Iterator *eina_inlist_iterator_new(const Eina_Inlist *in_list) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
 EAPI Eina_Accessor *eina_inlist_accessor_new(const Eina_Inlist *in_list) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
 
 /* This two macros are helpers for the _FOREACH ones, don't use them */
-#define _EINA_INLIST_OFFSET(ref) ((char*)&(ref)->__in_list - (char*)(ref))
-#define _EINA_INLIST_CONTAINER(ref, ptr) (void*)((char*)(ptr) - _EINA_INLIST_OFFSET(ref))
-
-#define EINA_INLIST_FOREACH(list, l) for (l = NULL, l = (list ? _EINA_INLIST_CONTAINER(l, list) : NULL); l; l = (EINA_INLIST_GET(l)->next ? _EINA_INLIST_CONTAINER(l, EINA_INLIST_GET(l)->next) : NULL))
-#define EINA_INLIST_REVERSE_FOREACH(list, l) for (l = NULL, l = (list ? _EINA_INLIST_CONTAINER(l, list->last) : NULL); l; l = (EINA_INLIST_GET(l)->prev ? _EINA_INLIST_CONTAINER(l, EINA_INLIST_GET(l)->prev) : NULL))
-
+#define _EINA_INLIST_OFFSET(ref) ((char *)&(ref)->__in_list - (char *)(ref))
+#define _EINA_INLIST_CONTAINER(ref, ptr) (void *)((char *)(ptr) - \
+                                                  _EINA_INLIST_OFFSET(ref))
+
+#define EINA_INLIST_FOREACH(list, l) \
+   for (l = NULL, l = (list ? _EINA_INLIST_CONTAINER(l, list) : NULL); l; \
+        l = (EINA_INLIST_GET(l)->next ? _EINA_INLIST_CONTAINER(l, EINA_INLIST_GET(l)->next) : NULL))
+#define EINA_INLIST_REVERSE_FOREACH(list, l) \
+   for (l = NULL, l = (list ? _EINA_INLIST_CONTAINER(l, list->last) : NULL); \
+        l; l = (EINA_INLIST_GET(l)->prev ? _EINA_INLIST_CONTAINER(l, EINA_INLIST_GET(l)->prev) : NULL))
 
 /**
  * @}
index 68c5faf..15188be 100644 (file)
@@ -45,12 +45,19 @@ typedef struct _Eina_Iterator Eina_Iterator;
 typedef Eina_Bool (*Eina_Iterator_Next_Callback)(Eina_Iterator *it, void **data);
 typedef void *(*Eina_Iterator_Get_Container_Callback)(Eina_Iterator *it);
 typedef void (*Eina_Iterator_Free_Callback)(Eina_Iterator *it);
+typedef Eina_Bool (*Eina_Iterator_Lock_Callback)(Eina_Iterator *it);
 
 struct _Eina_Iterator
 {
-   Eina_Iterator_Next_Callback          next EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
+#define EINA_ITERATOR_VERSION 1
+   int version;
+
+   Eina_Iterator_Next_Callback next                   EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
    Eina_Iterator_Get_Container_Callback get_container EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-   Eina_Iterator_Free_Callback          free EINA_ARG_NONNULL(1);
+   Eina_Iterator_Free_Callback free                   EINA_ARG_NONNULL(1);
+
+   Eina_Iterator_Lock_Callback lock   EINA_WARN_UNUSED_RESULT;
+   Eina_Iterator_Lock_Callback unlock EINA_WARN_UNUSED_RESULT;
 
 #define EINA_MAGIC_ITERATOR 0x98761233
    EINA_MAGIC
@@ -58,17 +65,24 @@ struct _Eina_Iterator
 
 
 #define FUNC_ITERATOR_NEXT(Function) ((Eina_Iterator_Next_Callback)Function)
-#define FUNC_ITERATOR_GET_CONTAINER(Function) ((Eina_Iterator_Get_Container_Callback)Function)
+#define FUNC_ITERATOR_GET_CONTAINER(Function) (( \
+                                                  Eina_Iterator_Get_Container_Callback) \
+                                               Function)
 #define FUNC_ITERATOR_FREE(Function) ((Eina_Iterator_Free_Callback)Function)
+#define FUNC_ITERATOR_LOCK(Function) ((Eina_Iterator_Lock_Callback)Function)
+
+EAPI void      eina_iterator_free           (Eina_Iterator *iterator) EINA_ARG_NONNULL(1);
 
-EAPI void eina_iterator_free           (Eina_Iterator *iterator) EINA_ARG_NONNULL(1);
+EAPI void *    eina_iterator_container_get (Eina_Iterator *iterator) EINA_ARG_NONNULL(1) EINA_PURE;
+EAPI Eina_Bool eina_iterator_next      (Eina_Iterator *iterator,
+                                        void **data) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
 
-EAPI void *eina_iterator_container_get (Eina_Iterator *iterator) EINA_ARG_NONNULL(1) EINA_PURE;
-EAPI Eina_Bool eina_iterator_next      (Eina_Iterator *iterator, void **data) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
+EAPI void      eina_iterator_foreach        (Eina_Iterator *iterator,
+                                             Eina_Each_Cb callback,
+                                             const void *fdata) EINA_ARG_NONNULL(1, 2);
 
-EAPI void eina_iterator_foreach        (Eina_Iterator *iterator,
-                                       Eina_Each callback,
-                                       const void *fdata) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Bool eina_iterator_lock(Eina_Iterator *iterator) EINA_ARG_NONNULL(1);
+EAPI Eina_Bool eina_iterator_unlock(Eina_Iterator *iterator) EINA_ARG_NONNULL(1);
 
 /**
  * @def EINA_ITERATOR_FOREACH
@@ -112,7 +126,9 @@ EAPI void eina_iterator_foreach        (Eina_Iterator *iterator,
  *    rather in the iterators implementations to keep them as simple
  *    and fast as possible.
  */
-#define EINA_ITERATOR_FOREACH(itr, data) while (eina_iterator_next((itr), (void **)&(data)))
+#define EINA_ITERATOR_FOREACH(itr, \
+                              data) while (eina_iterator_next((itr), \
+                                                              (void **)&(data)))
 
 /**
  * @}
index df0fbd7..d41a9ed 100644 (file)
  * @{
  */
 
-typedef Eina_Bool (*Eina_Lalloc_Alloc) (void *user_data, int num);
+typedef Eina_Bool (*Eina_Lalloc_Alloc)(void *user_data, int num);
 #define EINA_LALLOC_ALLOC(function) ((Eina_Lalloc_Alloc)function)
-typedef void (*Eina_Lalloc_Free) (void *user_data);
+typedef void (*Eina_Lalloc_Free)(void *user_data);
 #define EINA_LALLOC_FREE(function) ((Eina_Lalloc_Free)function)
 
 typedef struct _Eina_Lalloc Eina_Lalloc;
 
-EAPI Eina_Lalloc *eina_lalloc_new(void *data, Eina_Lalloc_Alloc alloc_cb, Eina_Lalloc_Free free_cb, int num_init) EINA_ARG_NONNULL(2, 3);
-EAPI void eina_lalloc_free(Eina_Lalloc *a) EINA_ARG_NONNULL(1);
-EAPI Eina_Bool eina_lalloc_elements_add(Eina_Lalloc *a, int num) EINA_ARG_NONNULL(1);
-EAPI Eina_Bool eina_lalloc_element_add(Eina_Lalloc *a) EINA_ARG_NONNULL(1);
+EAPI Eina_Lalloc *eina_lalloc_new(void *data,
+                                  Eina_Lalloc_Alloc alloc_cb,
+                                  Eina_Lalloc_Free free_cb,
+                                  int num_init) EINA_ARG_NONNULL(2, 3);
+EAPI void         eina_lalloc_free(Eina_Lalloc *a) EINA_ARG_NONNULL(1);
+EAPI Eina_Bool    eina_lalloc_elements_add(Eina_Lalloc *a,
+                                           int num) EINA_ARG_NONNULL(1);
+EAPI Eina_Bool    eina_lalloc_element_add(Eina_Lalloc *a) EINA_ARG_NONNULL(1);
 
 /**
  * @}
index 5088c44..a549076 100644 (file)
@@ -60,7 +60,7 @@ typedef struct _Eina_List_Accounting Eina_List_Accounting;
  */
 struct _Eina_List /** A linked list node */
 {
-   void      *data; /**< Pointer to list element payload */
+   void *data; /**< Pointer to list element payload */
    Eina_List *next; /**< Next member in the list */
    Eina_List *prev; /**< Previous member in the list */
    Eina_List_Accounting *accounting; /**< Private list accounting info - don't touch */
@@ -75,46 +75,46 @@ struct _Eina_List_Accounting
    EINA_MAGIC
 };
 
-EAPI Eina_List *eina_list_append (Eina_List *list, const void *data) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_prepend (Eina_List *list, const void *data) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_append_relative (Eina_List *list, const void *data, const void *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_append_relative_list (Eina_List *list, const void *data, Eina_List *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_prepend_relative (Eina_List *list, const void *data, const void *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_prepend_relative_list (Eina_List *list, const void *data, Eina_List *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_sorted_insert(Eina_List *list, Eina_Compare_Cb func, const void *data) EINA_ARG_NONNULL(2, 3) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_remove (Eina_List *list, const void *data) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_remove_list (Eina_List *list, Eina_List *remove_list) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_promote_list (Eina_List *list, Eina_List *move_list) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_demote_list (Eina_List *list, Eina_List *move_list);
-EAPI void *eina_list_data_find(const Eina_List *list, const void *data) EINA_PURE EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_data_find_list (const Eina_List *list, const void *data) EINA_PURE EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_free (Eina_List *list);
-EAPI void *eina_list_nth(const Eina_List *list, unsigned int n) EINA_PURE EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_nth_list (const Eina_List *list, unsigned int n) EINA_PURE EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_reverse (Eina_List *list) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_reverse_clone(const Eina_List *list) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_clone(const Eina_List *list) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_sort (Eina_List *list, unsigned int size, Eina_Compare_Cb func) EINA_ARG_NONNULL(3) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_merge (Eina_List *left, Eina_List *right) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_sorted_merge(Eina_List *left, Eina_List *right, Eina_Compare_Cb func) EINA_ARG_NONNULL(3) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_List *eina_list_split_list(Eina_List *list, Eina_List *relative, Eina_List **right) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *               eina_list_append (Eina_List *list, const void *data) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *               eina_list_prepend (Eina_List *list, const void *data) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *               eina_list_append_relative (Eina_List *list, const void *data, const void *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *               eina_list_append_relative_list (Eina_List *list, const void *data, Eina_List *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *               eina_list_prepend_relative (Eina_List *list, const void *data, const void *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *               eina_list_prepend_relative_list (Eina_List *list, const void *data, Eina_List *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *               eina_list_sorted_insert(Eina_List *list, Eina_Compare_Cb func, const void *data) EINA_ARG_NONNULL(2,                     3) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *               eina_list_remove (Eina_List *list, const void *data) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *               eina_list_remove_list (Eina_List *list, Eina_List *remove_list) EINA_ARG_NONNULL(   2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *               eina_list_promote_list (Eina_List *list, Eina_List *move_list) EINA_ARG_NONNULL(   2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *               eina_list_demote_list (Eina_List *list, Eina_List *move_list);
+EAPI void *                    eina_list_data_find(const Eina_List *list, const void *data) EINA_PURE EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *               eina_list_data_find_list (const Eina_List *list, const void *data) EINA_PURE EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *               eina_list_free (Eina_List *list);
+EAPI void *                    eina_list_nth(const Eina_List *list, unsigned int n) EINA_PURE EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *               eina_list_nth_list (const Eina_List *list, unsigned int n) EINA_PURE EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *               eina_list_reverse (Eina_List *list) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *               eina_list_reverse_clone(const Eina_List *list) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *               eina_list_clone(const Eina_List *list) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *               eina_list_sort (Eina_List *list, unsigned int size, Eina_Compare_Cb func) EINA_ARG_NONNULL(3) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *               eina_list_merge (Eina_List *left, Eina_List *right) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *               eina_list_sorted_merge(Eina_List *left, Eina_List *right, Eina_Compare_Cb func) EINA_ARG_NONNULL(3) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_List *               eina_list_split_list(Eina_List *list, Eina_List *relative, Eina_List **right) EINA_WARN_UNUSED_RESULT;
 
 
-EAPI Eina_List *eina_list_search_sorted_near_list(const Eina_List *list, Eina_Compare_Cb func, const void *data, int *result_cmp);
-EAPI Eina_List *eina_list_search_sorted_list(const Eina_List *list, Eina_Compare_Cb func, const void *data);
-EAPI void *eina_list_search_sorted(const Eina_List *list, Eina_Compare_Cb func, const void *data);
-EAPI Eina_List *eina_list_search_unsorted_list(const Eina_List *list, Eina_Compare_Cb func, const void *data);
-EAPI void *eina_list_search_unsorted(const Eina_List *list, Eina_Compare_Cb func, const void *data);
+EAPI Eina_List *               eina_list_search_sorted_near_list(const Eina_List *list, Eina_Compare_Cb func, const void *data, int *result_cmp);
+EAPI Eina_List *               eina_list_search_sorted_list(const Eina_List *list, Eina_Compare_Cb func, const void *data);
+EAPI void *                    eina_list_search_sorted(const Eina_List *list, Eina_Compare_Cb func, const void *data);
+EAPI Eina_List *               eina_list_search_unsorted_list(const Eina_List *list, Eina_Compare_Cb func, const void *data);
+EAPI void *                    eina_list_search_unsorted(const Eina_List *list, Eina_Compare_Cb func, const void *data);
 
-static inline Eina_List *eina_list_last (const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT;
-static inline Eina_List *eina_list_next (const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT;
-static inline Eina_List *eina_list_prev (const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT;
-static inline void *eina_list_data_get(const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT;
-static inline unsigned int eina_list_count(const Eina_List *list) EINA_PURE;
+static inline Eina_List *               eina_list_last (const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT;
+static inline Eina_List *               eina_list_next (const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT;
+static inline Eina_List *               eina_list_prev (const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT;
+static inline void *                    eina_list_data_get(const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT;
+static inline unsigned int              eina_list_count(const Eina_List *list) EINA_PURE;
 
-EAPI Eina_Iterator *eina_list_iterator_new(const Eina_List *list) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Iterator *eina_list_iterator_reversed_new(const Eina_List *list) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Accessor *eina_list_accessor_new(const Eina_List *list) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Iterator *               eina_list_iterator_new(const Eina_List *list) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Iterator *               eina_list_iterator_reversed_new(const Eina_List *list) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Accessor *               eina_list_accessor_new(const Eina_List *list) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
 
 /**
  * @def EINA_LIST_FOREACH
@@ -156,7 +156,12 @@ EAPI Eina_Accessor *eina_list_accessor_new(const Eina_List *list) EINA_MALLOC EI
  *          For destructive operations such as this, consider
  *          using EINA_LIST_FOREACH_SAFE().
  */
-#define EINA_LIST_FOREACH(list, l, data) for (l = list, data = eina_list_data_get(l); l; l = eina_list_next(l), data = eina_list_data_get(l))
+#define EINA_LIST_FOREACH(list, l, data)       \
+  for (l = list,                               \
+        data = eina_list_data_get(l);          \
+       l;                                      \
+       l = eina_list_next(l),                  \
+        data = eina_list_data_get(l))
 
 /**
  * @def EINA_LIST_REVERSE_FOREACH
@@ -199,7 +204,12 @@ EAPI Eina_Accessor *eina_list_accessor_new(const Eina_List *list) EINA_MALLOC EI
  *          For destructive operations such as this, consider
  *          using EINA_LIST_REVERSE_FOREACH_SAFE().
  */
-#define EINA_LIST_REVERSE_FOREACH(list, l, data) for (l = eina_list_last(list), data = eina_list_data_get(l); l; l = eina_list_prev(l), data = eina_list_data_get(l))
+#define EINA_LIST_REVERSE_FOREACH(list, l, data)       \
+  for (l = eina_list_last(list),                       \
+        data = eina_list_data_get(l);                  \
+       l;                                              \
+       l = eina_list_prev(l),                          \
+        data = eina_list_data_get(l))
 
 /**
  * @def EINA_LIST_FOREACH_SAFE
@@ -236,7 +246,14 @@ EAPI Eina_Accessor *eina_list_accessor_new(const Eina_List *list) EINA_MALLOC EI
  *   }
  * @endcode
  */
-#define EINA_LIST_FOREACH_SAFE(list, l, l_next, data) for (l = list, l_next = eina_list_next(l), data = eina_list_data_get(l); l; l = l_next, l_next = eina_list_next(l), data = eina_list_data_get(l))
+#define EINA_LIST_FOREACH_SAFE(list, l, l_next, data)  \
+  for (l = list,                                       \
+        l_next = eina_list_next(l),                    \
+        data = eina_list_data_get(l);                  \
+       l;                                              \
+       l = l_next,                                     \
+        l_next = eina_list_next(l),                    \
+        data = eina_list_data_get(l))
 
 /**
  * @def EINA_LIST_REVERSE_FOREACH_SAFE
@@ -275,7 +292,14 @@ EAPI Eina_Accessor *eina_list_accessor_new(const Eina_List *list) EINA_MALLOC EI
  *   }
  * @endcode
  */
-#define EINA_LIST_REVERSE_FOREACH_SAFE(list, l, l_prev, data) for (l = eina_list_last(list), l_prev = eina_list_prev(l), data = eina_list_data_get(l); l; l = l_prev, l_prev = eina_list_prev(l), data = eina_list_data_get(l))
+#define EINA_LIST_REVERSE_FOREACH_SAFE(list, l, l_prev, data)  \
+  for (l = eina_list_last(list),                               \
+        l_prev = eina_list_prev(l),                            \
+        data = eina_list_data_get(l);                          \
+       l;                                                      \
+       l = l_prev,                                             \
+        l_prev = eina_list_prev(l),                            \
+        data = eina_list_data_get(l))
 
 /**
  * @def EINA_LIST_FREE
@@ -302,7 +326,11 @@ EAPI Eina_Accessor *eina_list_accessor_new(const Eina_List *list) EINA_MALLOC EI
  *
  * @see eina_list_free()
  */
-#define EINA_LIST_FREE(list, data) for (data = eina_list_data_get(list); list; list = eina_list_remove_list(list, list), data = eina_list_data_get(list))
+#define EINA_LIST_FREE(list, data)                     \
+  for (data = eina_list_data_get(list);                        \
+       list;                                           \
+       list = eina_list_remove_list(list, list),       \
+        data = eina_list_data_get(list))
 
 #include "eina_inline_list.x"
 
index b42c1be..15c1062 100644 (file)
@@ -55,6 +55,8 @@
  */
 EAPI extern int EINA_LOG_DOMAIN_GLOBAL;
 
+#ifndef EINA_LOG_DOMAIN_DEFAULT
+
 /**
  * @def EINA_LOG_DOMAIN_DEFAULT
  * This macro defines the domain to use with the macros EINA_LOG_DOM_DBG(),
@@ -102,9 +104,9 @@ EAPI extern int EINA_LOG_DOMAIN_GLOBAL;
  * @endcode
  *
  */
-#ifndef EINA_LOG_DOMAIN_DEFAULT
-#define EINA_LOG_DOMAIN_DEFAULT EINA_LOG_DOMAIN_GLOBAL
-#endif
+# define EINA_LOG_DOMAIN_DEFAULT EINA_LOG_DOMAIN_GLOBAL
+
+#endif /* EINA_LOG_DOMAIN_DEFAULT */
 
 
 /**
@@ -122,15 +124,21 @@ EAPI extern int EINA_LOG_DOMAIN_GLOBAL;
  *       header files.
  */
 #ifdef EINA_LOG_LEVEL_MAXIMUM
-#define EINA_LOG(DOM, LEVEL, fmt, ...)                                 \
-  do {                                                                 \
-     if (LEVEL <= EINA_LOG_LEVEL_MAXIMUM)                              \
-       eina_log_print(DOM, LEVEL, __FILE__, __FUNCTION__, __LINE__,    \
-                     fmt, ##__VA_ARGS__);                              \
+#define EINA_LOG(DOM, LEVEL, fmt, ...)                                  \
+  do {                                                                  \
+     if (LEVEL <= EINA_LOG_LEVEL_MAXIMUM) {                            \
+       eina_log_print(DOM, LEVEL, __FILE__, __FUNCTION__, __LINE__,    \
+                      fmt, ## __VA_ARGS__); }                          \
   } while (0)
 #else
-#define EINA_LOG(DOM, LEVEL, fmt, ...) \
-       eina_log_print(DOM, LEVEL, __FILE__, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__)
+#define EINA_LOG(DOM, LEVEL, fmt, ...)         \
+  eina_log_print(DOM,                          \
+                LEVEL,                         \
+                __FILE__,                      \
+                __FUNCTION__,                  \
+                __LINE__,                      \
+                fmt,                           \
+                ## __VA_ARGS__)
 #endif
 
 /**
@@ -138,43 +146,46 @@ EAPI extern int EINA_LOG_DOMAIN_GLOBAL;
  * Logs a message with level CRITICAL on the specified domain and format.
  */
 #define EINA_LOG_DOM_CRIT(DOM, fmt, ...) \
-       EINA_LOG(DOM, EINA_LOG_LEVEL_CRITICAL, fmt, ##__VA_ARGS__)
+   EINA_LOG(DOM, EINA_LOG_LEVEL_CRITICAL, fmt, ## __VA_ARGS__)
 
 /**
  * @def EINA_LOG_DOM_ERR(DOM, fmt, ...)
  * Logs a message with level ERROR on the specified domain and format.
  */
 #define EINA_LOG_DOM_ERR(DOM, fmt, ...) \
-       EINA_LOG(DOM, EINA_LOG_LEVEL_ERR, fmt, ##__VA_ARGS__)
+   EINA_LOG(DOM, EINA_LOG_LEVEL_ERR, fmt, ## __VA_ARGS__)
 
 /**
  * @def EINA_LOG_DOM_INFO(DOM, fmt, ...)
  * Logs a message with level INFO on the specified domain and format.
  */
 #define EINA_LOG_DOM_INFO(DOM, fmt, ...) \
-       EINA_LOG(DOM, EINA_LOG_LEVEL_INFO, fmt, ##__VA_ARGS__)
+   EINA_LOG(DOM, EINA_LOG_LEVEL_INFO, fmt, ## __VA_ARGS__)
 
 /**
  * @def EINA_LOG_DOM_DBG(DOM, fmt, ...)
  * Logs a message with level DEBUG on the specified domain and format.
  */
 #define EINA_LOG_DOM_DBG(DOM, fmt, ...) \
-       EINA_LOG(DOM, EINA_LOG_LEVEL_DBG, fmt, ##__VA_ARGS__)
+   EINA_LOG(DOM, EINA_LOG_LEVEL_DBG, fmt, ## __VA_ARGS__)
 
 /**
  * @def EINA_LOG_DOM_WARN(DOM, fmt, ...)
  * Logs a message with level WARN on the specified domain and format.
  */
 #define EINA_LOG_DOM_WARN(DOM, fmt, ...) \
-       EINA_LOG(DOM, EINA_LOG_LEVEL_WARN, fmt, ##__VA_ARGS__)
+   EINA_LOG(DOM, EINA_LOG_LEVEL_WARN, fmt, ## __VA_ARGS__)
 
 /**
  * @def EINA_LOG_CRIT(fmt, ...)
  * Logs a message with level CRITICAL on the default domain with the specified
  * format.
  */
-#define EINA_LOG_CRIT(fmt, ...) \
-       EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, EINA_LOG_LEVEL_CRITICAL, fmt, ##__VA_ARGS__)
+#define EINA_LOG_CRIT(fmt, ...)             \
+   EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, \
+            EINA_LOG_LEVEL_CRITICAL, \
+            fmt,                    \
+            ## __VA_ARGS__)
 
 /**
  * @def EINA_LOG_ERR(fmt, ...)
@@ -182,7 +193,7 @@ EAPI extern int EINA_LOG_DOMAIN_GLOBAL;
  * format.
  */
 #define EINA_LOG_ERR(fmt, ...) \
-       EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, EINA_LOG_LEVEL_ERR, fmt, ##__VA_ARGS__)
+   EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, EINA_LOG_LEVEL_ERR, fmt, ## __VA_ARGS__)
 
 /**
  * @def EINA_LOG_INFO(fmt, ...)
@@ -190,7 +201,7 @@ EAPI extern int EINA_LOG_DOMAIN_GLOBAL;
  * format.
  */
 #define EINA_LOG_INFO(fmt, ...) \
-       EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, EINA_LOG_LEVEL_INFO, fmt, ##__VA_ARGS__)
+   EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, EINA_LOG_LEVEL_INFO, fmt, ## __VA_ARGS__)
 
 /**
  * @def EINA_LOG_WARN(fmt, ...)
@@ -198,7 +209,7 @@ EAPI extern int EINA_LOG_DOMAIN_GLOBAL;
  * format.
  */
 #define EINA_LOG_WARN(fmt, ...) \
-       EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, EINA_LOG_LEVEL_WARN, fmt, ##__VA_ARGS__)
+   EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, EINA_LOG_LEVEL_WARN, fmt, ## __VA_ARGS__)
 
 /**
  * @def EINA_LOG_DBG(fmt, ...)
@@ -206,7 +217,7 @@ EAPI extern int EINA_LOG_DOMAIN_GLOBAL;
  * format.
  */
 #define EINA_LOG_DBG(fmt, ...) \
-       EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, EINA_LOG_LEVEL_DBG, fmt, ##__VA_ARGS__)
+   EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, EINA_LOG_LEVEL_DBG, fmt, ## __VA_ARGS__)
 
 /**
  * @typedef Eina_Log_Domain
@@ -220,13 +231,13 @@ typedef struct _Eina_Log_Domain Eina_Log_Domain;
  */
 struct _Eina_Log_Domain
 {
-   int level;              /**< Max level to log */
+   int level; /**< Max level to log */
    const char *domain_str; /**< Formatted string with color to print */
-   const char *name;       /**< Domain name */
-   size_t namelen;   /**< strlen(name) */
+   const char *name; /**< Domain name */
+   size_t namelen; /**< strlen(name) */
 
    /* Private */
-   Eina_Bool deleted:1;    /**< Flags deletion of domain, a free slot */
+   Eina_Bool deleted : 1; /**< Flags deletion of domain, a free slot */
 };
 
 EAPI void eina_log_threads_enable(void);
@@ -237,71 +248,131 @@ EAPI void eina_log_threads_enable(void);
  */
 typedef enum _Eina_Log_Level
 {
-       EINA_LOG_LEVEL_CRITICAL,           /**< Critical log level */
-       EINA_LOG_LEVEL_ERR,                /**< Error log level */
-       EINA_LOG_LEVEL_WARN,               /**< Warning log level */
-       EINA_LOG_LEVEL_INFO,               /**< Information log level */
-       EINA_LOG_LEVEL_DBG,                /**< Debug log level */
-       EINA_LOG_LEVELS,                   /**< Count of default log levels */
-       EINA_LOG_LEVEL_UNKNOWN = (-2147483647-1) /**< Unknown level */
+   EINA_LOG_LEVEL_CRITICAL, /**< Critical log level */
+   EINA_LOG_LEVEL_ERR, /**< Error log level */
+   EINA_LOG_LEVEL_WARN, /**< Warning log level */
+   EINA_LOG_LEVEL_INFO, /**< Information log level */
+   EINA_LOG_LEVEL_DBG, /**< Debug log level */
+   EINA_LOG_LEVELS, /**< Count of default log levels */
+   EINA_LOG_LEVEL_UNKNOWN = (-2147483647 - 1) /**< Unknown level */
 } Eina_Log_Level;
 
 /**
  * @typedef Eina_Log_Print_Cb
  * Type for print callbacks.
  */
-typedef void (*Eina_Log_Print_Cb)(const Eina_Log_Domain *d, Eina_Log_Level level,
-                                 const char *file, const char *fnc, int line,
-                                 const char *fmt, void *data, va_list args);
+typedef void (*Eina_Log_Print_Cb)(const Eina_Log_Domain *d,
+                                  Eina_Log_Level level,
+                                  const char *file, const char *fnc, int line,
+                                  const char *fmt, void *data, va_list args);
 
 /*
  * Customization
  */
-EAPI void      eina_log_print_cb_set(Eina_Log_Print_Cb cb, void *data) EINA_ARG_NONNULL(1);
-
-EAPI void      eina_log_level_set(int level);
-EAPI int       eina_log_level_get(void) EINA_WARN_UNUSED_RESULT;
-
-static inline Eina_Bool eina_log_level_check(int level);
-
-EAPI Eina_Bool eina_log_main_thread_check(void) EINA_CONST EINA_WARN_UNUSED_RESULT;
-
-EAPI void      eina_log_color_disable_set(Eina_Bool disabled);
-EAPI Eina_Bool eina_log_color_disable_get(void) EINA_WARN_UNUSED_RESULT;
-EAPI void      eina_log_file_disable_set(Eina_Bool disabled);
-EAPI Eina_Bool eina_log_file_disable_get(void) EINA_WARN_UNUSED_RESULT;
-EAPI void      eina_log_function_disable_set(Eina_Bool disabled);
-EAPI Eina_Bool eina_log_function_disable_get(void) EINA_WARN_UNUSED_RESULT;
-EAPI void      eina_log_abort_on_critical_set(Eina_Bool abort_on_critical);
-EAPI Eina_Bool eina_log_abort_on_critical_get(void) EINA_WARN_UNUSED_RESULT;
-EAPI void      eina_log_abort_on_critical_level_set(int critical_level);
-EAPI int       eina_log_abort_on_critical_level_get(void) EINA_WARN_UNUSED_RESULT;
-
-EAPI void      eina_log_domain_level_set(const char *domain_name, int level) EINA_ARG_NONNULL(1);
-EAPI int       eina_log_domain_level_get(const char *domain_name) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
-EAPI int       eina_log_domain_registered_level_get(int domain) EINA_WARN_UNUSED_RESULT;
-static inline Eina_Bool eina_log_domain_level_check(int domain, int level);
+EAPI void
+eina_log_print_cb_set(Eina_Log_Print_Cb cb, void *data) EINA_ARG_NONNULL(1);
+
+EAPI void
+eina_log_level_set(int level);
+EAPI int
+eina_log_level_get(void) EINA_WARN_UNUSED_RESULT;
+
+static inline Eina_Bool
+eina_log_level_check(int level);
+
+EAPI Eina_Bool
+eina_log_main_thread_check(void) EINA_CONST EINA_WARN_UNUSED_RESULT;
+
+EAPI void
+eina_log_color_disable_set(Eina_Bool disabled);
+EAPI Eina_Bool
+eina_log_color_disable_get(void) EINA_WARN_UNUSED_RESULT;
+EAPI void
+eina_log_file_disable_set(Eina_Bool disabled);
+EAPI Eina_Bool
+eina_log_file_disable_get(void) EINA_WARN_UNUSED_RESULT;
+EAPI void
+eina_log_function_disable_set(Eina_Bool disabled);
+EAPI Eina_Bool
+eina_log_function_disable_get(void) EINA_WARN_UNUSED_RESULT;
+EAPI void
+eina_log_abort_on_critical_set(Eina_Bool abort_on_critical);
+EAPI Eina_Bool
+eina_log_abort_on_critical_get(void) EINA_WARN_UNUSED_RESULT;
+EAPI void
+eina_log_abort_on_critical_level_set(int critical_level);
+EAPI int
+eina_log_abort_on_critical_level_get(void) EINA_WARN_UNUSED_RESULT;
+
+EAPI void
+eina_log_domain_level_set(const char *domain_name, int level) EINA_ARG_NONNULL(1);
+EAPI int
+eina_log_domain_level_get(const char *domain_name) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
+EAPI int
+eina_log_domain_registered_level_get(int domain) EINA_WARN_UNUSED_RESULT;
+static inline Eina_Bool
+eina_log_domain_level_check(int domain, int level);
 
 
 /*
  * Logging domains
  */
-EAPI int  eina_log_domain_register(const char *name, const char *color) EINA_ARG_NONNULL(1);
-EAPI void eina_log_domain_unregister(int domain);
+EAPI int
+eina_log_domain_register(const char *name, const char *color) EINA_ARG_NONNULL(1);
+EAPI void
+eina_log_domain_unregister(int domain);
 
 /*
  * Logging functions.
  */
-EAPI void eina_log_print(int domain, Eina_Log_Level level, const char *file, const char *function, int line, const char *fmt, ...) EINA_ARG_NONNULL(3, 4, 6) EINA_PRINTF(6, 7) EINA_NOINSTRUMENT;
-EAPI void eina_log_vprint(int domain, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, va_list args) EINA_ARG_NONNULL(3, 4, 6) EINA_NOINSTRUMENT;
+EAPI void
+eina_log_print(int domain,
+               Eina_Log_Level level,
+               const char *file,
+               const char *function,
+               int line,
+               const char *fmt,
+               ...) EINA_ARG_NONNULL(3, 4, 6) EINA_PRINTF(6, 7) EINA_NOINSTRUMENT;
+EAPI void
+eina_log_vprint(int domain,
+                Eina_Log_Level level,
+                const char *file,
+                const char *fnc,
+                int line,
+                const char *fmt,
+                va_list args) EINA_ARG_NONNULL(3, 4, 6) EINA_NOINSTRUMENT;
 
 
 /*
  * Logging methods (change how logging is done).
  */
-EAPI void eina_log_print_cb_stdout(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args);
-EAPI void eina_log_print_cb_stderr(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args);
-EAPI void eina_log_print_cb_file(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, void *data, va_list args);
+EAPI void
+eina_log_print_cb_stdout(const Eina_Log_Domain *d,
+                         Eina_Log_Level level,
+                         const char *file,
+                         const char *fnc,
+                         int line,
+                         const char *fmt,
+                         void *data,
+                         va_list args);
+EAPI void
+eina_log_print_cb_stderr(const Eina_Log_Domain *d,
+                         Eina_Log_Level level,
+                         const char *file,
+                         const char *fnc,
+                         int line,
+                         const char *fmt,
+                         void *data,
+                         va_list args);
+EAPI void
+eina_log_print_cb_file(const Eina_Log_Domain *d,
+                       Eina_Log_Level level,
+                       const char *file,
+                       const char *fnc,
+                       int line,
+                       const char *fmt,
+                       void *data,
+                       va_list args);
 
 #include "eina_inline_log.x"
 
index 7242921..dd1a9f3 100644 (file)
  * @{
  */
 
-typedef unsigned int               Eina_Magic;
+typedef unsigned int Eina_Magic;
 
 /**
  * @typedef Eina_Magic
  * An abstract type for a magic number.
  */
-EAPI const char* eina_magic_string_get(Eina_Magic magic) EINA_PURE EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Bool eina_magic_string_set(Eina_Magic magic, const char *magic_name) EINA_ARG_NONNULL(2);
-EAPI Eina_Bool eina_magic_string_static_set(Eina_Magic magic, const char *magic_name) EINA_ARG_NONNULL(2);
+EAPI const char *eina_magic_string_get(Eina_Magic magic) EINA_PURE EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Bool   eina_magic_string_set(Eina_Magic magic,
+                                       const char *magic_name) EINA_ARG_NONNULL(2);
+EAPI Eina_Bool   eina_magic_string_static_set(Eina_Magic magic,
+                                              const char *magic_name) EINA_ARG_NONNULL(2);
 
 /**
  * @def EINA_MAGIC_NONE
@@ -74,7 +76,7 @@ EAPI Eina_Bool eina_magic_string_static_set(Eina_Magic magic, const char *magic_
  *
  * If the magic feature of Eina is disabled, #EINA_MAGIC does nothing.
  */
-#define EINA_MAGIC     Eina_Magic __magic;
+#define EINA_MAGIC      Eina_Magic __magic;
 
 /**
  * @def EINA_MAGIC_SET(d, m)
@@ -109,10 +111,17 @@ EAPI Eina_Bool eina_magic_string_static_set(Eina_Magic magic, const char *magic_
  * If the magic feature of Eina is disabled, #EINA_MAGIC_FAIL does
  * nothing.
  */
-#define EINA_MAGIC_FAIL(d, m)      eina_magic_fail((void*)(d), (d) ? (d)->__magic : 0, (m), __FILE__, __FUNCTION__, __LINE__);
+#define EINA_MAGIC_FAIL(d, m)                  \
+  eina_magic_fail((void *)(d),                 \
+                 (d) ? (d)->__magic : 0,       \
+                 (m),                          \
+                 __FILE__,                     \
+                 __FUNCTION__,                 \
+                 __LINE__);
 
 EAPI void eina_magic_fail(void *d, Eina_Magic m, Eina_Magic req_m,
-                         const char *file, const char *fnc, int line) EINA_ARG_NONNULL(4, 5);
+                          const char *file, const char *fnc,
+                          int line) EINA_ARG_NONNULL(4, 5);
 
 #else
 
@@ -121,11 +130,11 @@ EAPI void eina_magic_fail(void *d, Eina_Magic m, Eina_Magic req_m,
  */
 
 #define EINA_MAGIC
-#define EINA_MAGIC_SET(d, m)       ((void) 0)
-#define EINA_MAGIC_CHECK(d, m)    (1)
-#define EINA_MAGIC_FAIL(d, m)      ((void) 0)
+#define EINA_MAGIC_SET(d, m)       ((void)0)
+#define EINA_MAGIC_CHECK(d, m)     (1)
+#define EINA_MAGIC_FAIL(d, m)      ((void)0)
 
-#define eina_magic_fail(d, m, req_m, file, fnx, line) ((void) 0)
+#define eina_magic_fail(d, m, req_m, file, fnx, line) ((void)0)
 
 /**
  * @endcond
index 29b0bb7..81d6d44 100644 (file)
 #ifndef EINA_MAIN_H_
 #define EINA_MAIN_H_
 
-
 #include "eina_types.h"
 
-#define EINA_VERSION_MAJOR 0
-#define EINA_VERSION_MINOR 9
-
-typedef struct _Eina_Version
-{
-   int major;
-   int minor;
-   int micro;
-   int revision;
-} Eina_Version;
-
-EAPI extern Eina_Version *eina_version;
-
 /**
  * @addtogroup Eina_Core_Group Core
  *
@@ -47,12 +33,35 @@ EAPI extern Eina_Version *eina_version;
  * @{
  */
 
-EAPI int eina_init(void);
+/**
+ * @def EINA_VERSION_MAJOR
+ * @brief Major version of Eina
+ */
+#define EINA_VERSION_MAJOR 1
 
-EAPI int eina_shutdown(void);
+/**
+ * @def EINA_VERSION_MINOR
+ * @brief Minor version of Eina
+ */
+#define EINA_VERSION_MINOR 0
 
-EAPI int eina_threads_init(void);
+/**
+ * @struct Eina_Version
+ * The version of Eina.
+ */
+typedef struct _Eina_Version
+{
+   int major;    /**< Major component of the version */
+   int minor;    /**< Minor component of the version */
+   int micro;    /**< Micro component of the version */
+   int revision; /**< Revision component of the version */
+} Eina_Version;
+
+EAPI extern Eina_Version *eina_version;
 
+EAPI int eina_init(void);
+EAPI int eina_shutdown(void);
+EAPI int eina_threads_init(void);
 EAPI int eina_threads_shutdown(void);
 
 /**
index 298bf38..cbf29cc 100644 (file)
@@ -63,39 +63,47 @@ typedef struct _Eina_Matrixsparse_Row Eina_Matrixsparse_Row;
  */
 typedef struct _Eina_Matrixsparse_Cell Eina_Matrixsparse_Cell;
 
-typedef struct _Eina_Matrixsparse_Item_Cell   Eina_Matrixsparse_Item_Cell;
-typedef struct _Eina_Matrixsparse_Item_Row    Eina_Matrixsparse_Item_Row;
+typedef struct _Eina_Matrixsparse_Item_Cell Eina_Matrixsparse_Item_Cell;
+typedef struct _Eina_Matrixsparse_Item_Row Eina_Matrixsparse_Item_Row;
 
 
 /* constructors and destructors */
-EAPI Eina_Matrixsparse      *eina_matrixsparse_new(unsigned long rows, unsigned long cols, void (*free_func)(void *user_data, void *cell_data), const void *user_data);
-EAPI void                    eina_matrixsparse_free(Eina_Matrixsparse *m);
+EAPI Eina_Matrixsparse *eina_matrixsparse_new(unsigned long rows,
+                                              unsigned long cols,
+                                              void (*free_func)(void *user_data,
+                                                                void *cell_data),
+                                              const void *user_data);
+EAPI void               eina_matrixsparse_free(Eina_Matrixsparse *m);
 
 /* size manipulation */
-EAPI void                    eina_matrixsparse_size_get(const Eina_Matrixsparse *m, unsigned long *rows, unsigned long *cols);
-EAPI Eina_Bool               eina_matrixsparse_size_set(Eina_Matrixsparse *m, unsigned long rows, unsigned long cols);
+EAPI void               eina_matrixsparse_size_get(const Eina_Matrixsparse *m,
+                                                   unsigned long *rows,
+                                                   unsigned long *cols);
+EAPI Eina_Bool          eina_matrixsparse_size_set(Eina_Matrixsparse *m,
+                                                   unsigned long rows,
+                                                   unsigned long cols);
 
 /* data getting */
-EAPI Eina_Bool              eina_matrixsparse_cell_idx_get(const Eina_Matrixsparse *m, unsigned long row, unsigned long col, Eina_Matrixsparse_Cell **cell);
-EAPI void                   *eina_matrixsparse_cell_data_get(const Eina_Matrixsparse_Cell *cell);
-EAPI void                   *eina_matrixsparse_data_idx_get(const Eina_Matrixsparse *m, unsigned long row, unsigned long col);
-EAPI Eina_Bool               eina_matrixsparse_cell_position_get(const Eina_Matrixsparse_Cell *cell, unsigned long *row, unsigned long *col);
+EAPI Eina_Bool          eina_matrixsparse_cell_idx_get(const Eina_Matrixsparse *m, unsigned long row, unsigned long col, Eina_Matrixsparse_Cell **cell);
+EAPI void *             eina_matrixsparse_cell_data_get(const Eina_Matrixsparse_Cell *cell);
+EAPI void *             eina_matrixsparse_data_idx_get(const Eina_Matrixsparse *m, unsigned long row, unsigned long col);
+EAPI Eina_Bool          eina_matrixsparse_cell_position_get(const Eina_Matrixsparse_Cell *cell, unsigned long *row, unsigned long *col);
 
 /* data setting */
-EAPI Eina_Bool               eina_matrixsparse_cell_data_replace(Eina_Matrixsparse_Cell *cell, const void *data, void **p_old);
-EAPI Eina_Bool               eina_matrixsparse_cell_data_set(Eina_Matrixsparse_Cell *cell, const void *data);
-EAPI Eina_Bool               eina_matrixsparse_data_idx_replace(Eina_Matrixsparse *m, unsigned long row, unsigned long col, const void *data, void **p_old);
-EAPI Eina_Bool               eina_matrixsparse_data_idx_set(Eina_Matrixsparse *m, unsigned long row, unsigned long col, const void *data);
+EAPI Eina_Bool eina_matrixsparse_cell_data_replace(Eina_Matrixsparse_Cell *cell, const void *data, void **p_old);
+EAPI Eina_Bool eina_matrixsparse_cell_data_set(Eina_Matrixsparse_Cell *cell, const void *data);
+EAPI Eina_Bool eina_matrixsparse_data_idx_replace(Eina_Matrixsparse *m, unsigned long row, unsigned long col, const void *data, void **p_old);
+EAPI Eina_Bool eina_matrixsparse_data_idx_set(Eina_Matrixsparse *m, unsigned long row, unsigned long col, const void *data);
 
 /* data deleting */
-EAPI Eina_Bool               eina_matrixsparse_row_idx_clear(Eina_Matrixsparse *m, unsigned long row);
-EAPI Eina_Bool               eina_matrixsparse_column_idx_clear(Eina_Matrixsparse *m, unsigned long col);
-EAPI Eina_Bool               eina_matrixsparse_cell_idx_clear(Eina_Matrixsparse *m, unsigned long row, unsigned long col);
-EAPI Eina_Bool               eina_matrixsparse_cell_clear(Eina_Matrixsparse_Cell *cell);
+EAPI Eina_Bool      eina_matrixsparse_row_idx_clear(Eina_Matrixsparse *m, unsigned long row);
+EAPI Eina_Bool      eina_matrixsparse_column_idx_clear(Eina_Matrixsparse *m, unsigned long col);
+EAPI Eina_Bool      eina_matrixsparse_cell_idx_clear(Eina_Matrixsparse *m, unsigned long row, unsigned long col);
+EAPI Eina_Bool      eina_matrixsparse_cell_clear(Eina_Matrixsparse_Cell *cell);
 
 /* iterators */
-EAPI Eina_Iterator          *eina_matrixsparse_iterator_new(const Eina_Matrixsparse *m);
-EAPI Eina_Iterator          *eina_matrixsparse_iterator_complete_new(const Eina_Matrixsparse *m);
+EAPI Eina_Iterator *eina_matrixsparse_iterator_new(const Eina_Matrixsparse *m);
+EAPI Eina_Iterator *eina_matrixsparse_iterator_complete_new(const Eina_Matrixsparse *m);
 
 /**
  * @}
index ee1382d..cc19e94 100644 (file)
@@ -49,18 +49,20 @@ typedef struct _Eina_Mempool_Backend Eina_Mempool_Backend;
 
 EAPI extern Eina_Error EINA_ERROR_NOT_MEMPOOL_MODULE;
 
-EAPI Eina_Mempool * eina_mempool_add(const char *module, const char *context, const char *options, ...) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
-EAPI void eina_mempool_del(Eina_Mempool *mp) EINA_ARG_NONNULL(1);
+EAPI Eina_Mempool *                     eina_mempool_add(const char *module,const char *context,const char *options,...) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
+EAPI void                               eina_mempool_del(Eina_Mempool *mp) EINA_ARG_NONNULL(1);
 
-static inline void * eina_mempool_realloc(Eina_Mempool *mp, void *element, unsigned int size) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-static inline void * eina_mempool_malloc(Eina_Mempool *mp, unsigned int size) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-static inline void eina_mempool_free(Eina_Mempool *mp, void *element) EINA_ARG_NONNULL(1);
+static inline void *                    eina_mempool_realloc(Eina_Mempool *mp,void *element,unsigned int size) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+static inline void *                    eina_mempool_malloc(Eina_Mempool *mp,unsigned int size) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+static inline void                      eina_mempool_free(Eina_Mempool *mp,void *element) EINA_ARG_NONNULL(1);
 
-EAPI void eina_mempool_gc(Eina_Mempool *mp) EINA_ARG_NONNULL(1);
-EAPI void eina_mempool_statistics(Eina_Mempool *mp) EINA_ARG_NONNULL(1);
+EAPI void                               eina_mempool_gc(Eina_Mempool *mp) EINA_ARG_NONNULL(1);
+EAPI void                               eina_mempool_statistics(Eina_Mempool *mp) EINA_ARG_NONNULL(1);
 
-EAPI Eina_Bool eina_mempool_register(Eina_Mempool_Backend *be) EINA_ARG_NONNULL(1);
-EAPI void eina_mempool_unregister(Eina_Mempool_Backend *be) EINA_ARG_NONNULL(1);
+EAPI Eina_Bool                          eina_mempool_register(Eina_Mempool_Backend *be) EINA_ARG_NONNULL(1);
+EAPI void                               eina_mempool_unregister(Eina_Mempool_Backend *be) EINA_ARG_NONNULL(1);
+
+EAPI unsigned int                       eina_mempool_alignof(unsigned int size);
 
 #include "eina_inline_mempool.x"
 
index c45bedf..2e78a51 100644 (file)
@@ -108,22 +108,36 @@ extern EAPI Eina_Error EINA_ERROR_WRONG_MODULE;
  */
 extern EAPI Eina_Error EINA_ERROR_MODULE_INIT_FAILED;
 
-EAPI Eina_Module * eina_module_new(const char *file) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
-EAPI Eina_Bool eina_module_free(Eina_Module *m) EINA_ARG_NONNULL(1);
-EAPI Eina_Bool eina_module_load(Eina_Module *module) EINA_ARG_NONNULL(1);
-EAPI Eina_Bool eina_module_unload(Eina_Module *m) EINA_ARG_NONNULL(1);
-EAPI void *eina_module_symbol_get(const Eina_Module *module, const char *symbol) EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
-EAPI const char * eina_module_file_get(const Eina_Module *m) EINA_PURE EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
-
-EAPI char *eina_module_symbol_path_get(const void *symbol, const char *sub_dir) EINA_PURE EINA_MALLOC EINA_ARG_NONNULL(1, 2);
-EAPI char *eina_module_environment_path_get(const char *env, const char *sub_dir) EINA_PURE EINA_MALLOC EINA_ARG_NONNULL(1, 2);
-
-EAPI Eina_Array * eina_module_arch_list_get(Eina_Array *array, const char *path, const char *arch);
-EAPI Eina_Array * eina_module_list_get(Eina_Array *array, const char *path, unsigned int recursive, Eina_Module_Cb cb, void *data) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
-EAPI void eina_module_list_load(Eina_Array *list) EINA_ARG_NONNULL(1);
-EAPI void eina_module_list_unload(Eina_Array *list) EINA_ARG_NONNULL(1);
-EAPI void eina_module_list_free(Eina_Array *list) EINA_ARG_NONNULL(1);
-EAPI Eina_Module * eina_module_find(const Eina_Array *array, const char *module) EINA_ARG_NONNULL(1, 2);
+EAPI Eina_Module *
+eina_module_new(const char *file) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
+EAPI Eina_Bool
+eina_module_free(Eina_Module *m) EINA_ARG_NONNULL(1);
+EAPI Eina_Bool
+eina_module_load(Eina_Module *module) EINA_ARG_NONNULL(1);
+EAPI Eina_Bool
+eina_module_unload(Eina_Module *m) EINA_ARG_NONNULL(1);
+EAPI void *
+eina_module_symbol_get(const Eina_Module *module, const char *symbol) EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
+EAPI const char *
+eina_module_file_get(const Eina_Module *m) EINA_PURE EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
+
+EAPI char *
+eina_module_symbol_path_get(const void *symbol, const char *sub_dir) EINA_PURE EINA_MALLOC EINA_ARG_NONNULL(1, 2);
+EAPI char *
+eina_module_environment_path_get(const char *env, const char *sub_dir) EINA_PURE EINA_MALLOC EINA_ARG_NONNULL(1, 2);
+
+EAPI Eina_Array *
+eina_module_arch_list_get(Eina_Array *array, const char *path, const char *arch);
+EAPI Eina_Array *
+eina_module_list_get(Eina_Array *array, const char *path, unsigned int recursive, Eina_Module_Cb cb, void *data) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+EAPI void
+eina_module_list_load(Eina_Array *list) EINA_ARG_NONNULL(1);
+EAPI void
+eina_module_list_unload(Eina_Array *list) EINA_ARG_NONNULL(1);
+EAPI void
+eina_module_list_free(Eina_Array *list) EINA_ARG_NONNULL(1);
+EAPI Eina_Module *
+eina_module_find(const Eina_Array *array, const char *module) EINA_ARG_NONNULL(1, 2);
 
 /**
  * @}
index 3a4f661..ad24c3e 100644 (file)
@@ -27,28 +27,27 @@ typedef struct _Eina_QuadTree Eina_QuadTree;
 typedef struct _Eina_QuadTree_Item Eina_QuadTree_Item;
 
 typedef enum {
-  EINA_QUAD_LEFT,
-  EINA_QUAD_RIGHT,
-  EINA_QUAD_BOTH
+   EINA_QUAD_LEFT,
+   EINA_QUAD_RIGHT,
+   EINA_QUAD_BOTH
 } Eina_Quad_Direction;
 
 typedef Eina_Quad_Direction (*Eina_Quad_Callback)(const void *object, size_t middle);
 
-EAPI Eina_QuadTree *eina_quadtree_new(size_t w, size_t h,
-                                     Eina_Quad_Callback vertical,
-                                     Eina_Quad_Callback horizontal);
-EAPI void eina_quadtree_free(Eina_QuadTree *q);
-EAPI void eina_quadtree_resize(Eina_QuadTree *q, size_t w, size_t h);
-EAPI void eina_quadtree_cycle(Eina_QuadTree *q);
+EAPI Eina_QuadTree *     eina_quadtree_new(size_t w, size_t h, Eina_Quad_Callback vertical, Eina_Quad_Callback horizontal);
+EAPI void                eina_quadtree_free(Eina_QuadTree *q);
+EAPI void                eina_quadtree_resize(Eina_QuadTree *q, size_t w, size_t h);
+
+EAPI void                eina_quadtree_cycle(Eina_QuadTree *q);
+EAPI void                eina_quadtree_increase(Eina_QuadTree_Item *object);
 
 EAPI Eina_QuadTree_Item *eina_quadtree_add(Eina_QuadTree *q, const void *object);
-EAPI Eina_Bool eina_quadtree_del(Eina_QuadTree_Item *object);
-EAPI Eina_Bool eina_quadtree_change(Eina_QuadTree_Item *object);
-EAPI Eina_Bool eina_quadtree_hide(Eina_QuadTree_Item *object);
-EAPI Eina_Bool eina_quadtree_show(Eina_QuadTree_Item *object);
-
-EAPI Eina_Inlist *eina_quadtree_collide(Eina_QuadTree *q,
-                                       int x, int y, int w, int h);
-EAPI void *eina_quadtree_object(Eina_Inlist *list);
+EAPI Eina_Bool           eina_quadtree_del(Eina_QuadTree_Item *object);
+EAPI Eina_Bool           eina_quadtree_change(Eina_QuadTree_Item *object);
+EAPI Eina_Bool           eina_quadtree_hide(Eina_QuadTree_Item *object);
+EAPI Eina_Bool           eina_quadtree_show(Eina_QuadTree_Item *object);
+
+EAPI Eina_Inlist *       eina_quadtree_collide(Eina_QuadTree *q, int x, int y, int w, int h);
+EAPI void *              eina_quadtree_object(Eina_Inlist *list);
 
 #endif
index 5a6a124..026db41 100644 (file)
@@ -48,8 +48,8 @@
  * node color.
  */
 typedef enum {
-  EINA_RBTREE_RED,
-  EINA_RBTREE_BLACK
+   EINA_RBTREE_RED,
+   EINA_RBTREE_BLACK
 } Eina_Rbtree_Color;
 
 /**
@@ -57,8 +57,8 @@ typedef enum {
  * walk direction.
  */
 typedef enum {
-  EINA_RBTREE_LEFT = 0,
-  EINA_RBTREE_RIGHT = 1
+   EINA_RBTREE_LEFT = 0,
+   EINA_RBTREE_RIGHT = 1
 } Eina_Rbtree_Direction;
 
 /**
@@ -68,9 +68,9 @@ typedef enum {
 typedef struct _Eina_Rbtree Eina_Rbtree;
 struct _Eina_Rbtree
 {
-   Eina_Rbtree       *son[2];
+   Eina_Rbtree *son[2];
 
-   Eina_Rbtree_Color  color : 1;
+   Eina_Rbtree_Color color : 1;
 };
 
 /**
@@ -93,7 +93,7 @@ struct _Eina_Rbtree
  * @def EINA_RBTREE_GET
  * access the inlined node if it was created with #EINA_RBTREE.
  */
-#define EINA_RBTREE_GET(Rbtree) &((Rbtree)->__rbtree)
+#define EINA_RBTREE_GET(Rbtree) & ((Rbtree)->__rbtree)
 
 /**
  * @typedef Eina_Rbtree_Cmp_Node_Cb
@@ -105,7 +105,7 @@ typedef Eina_Rbtree_Direction (*Eina_Rbtree_Cmp_Node_Cb)(const Eina_Rbtree *left
  * @def EINA_RBTREE_CMP_NODE_CB
  * Cast using #Eina_Rbtree_Cmp_Node_Cb
  */
-#define EINA_RBTREE_CMP_NODE_CB(Function) ((Eina_Rbtree_Cmp_Node_Cb) Function)
+#define EINA_RBTREE_CMP_NODE_CB(Function) ((Eina_Rbtree_Cmp_Node_Cb)Function)
 
 /**
  * @typedef Eina_Rbtree_Cmp_Key_Cb
@@ -116,7 +116,7 @@ typedef int (*Eina_Rbtree_Cmp_Key_Cb)(const Eina_Rbtree *node, const void *key,
  * @def EINA_RBTREE_CMP_KEY_CB
  * Cast using #Eina_Rbtree_Cmp_Key_Cb
  */
-#define EINA_RBTREE_CMP_KEY_CB(Function) ((Eina_Rbtree_Cmp_Key_Cb) Function)
+#define EINA_RBTREE_CMP_KEY_CB(Function) ((Eina_Rbtree_Cmp_Key_Cb)Function)
 
 /**
  * @typedef Eina_Rbtree_Free_Cb
@@ -127,17 +127,17 @@ typedef void (*Eina_Rbtree_Free_Cb)(Eina_Rbtree *node, void *data);
  * @def EINA_RBTREE_FREE_CB
  * Cast using #Eina_Rbtree_Free_Cb
  */
-#define EINA_RBTREE_FREE_CB(Function) ((Eina_Rbtree_Free_Cb) Function)
+#define EINA_RBTREE_FREE_CB(Function) ((Eina_Rbtree_Free_Cb)Function)
 
-EAPI Eina_Rbtree *eina_rbtree_inline_insert(Eina_Rbtree *root, Eina_Rbtree *node, Eina_Rbtree_Cmp_Node_Cb cmp, const void *data) EINA_ARG_NONNULL(2, 3) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Rbtree *eina_rbtree_inline_remove(Eina_Rbtree *root, Eina_Rbtree *node, Eina_Rbtree_Cmp_Node_Cb cmp, const void *data) EINA_ARG_NONNULL(2, 3) EINA_WARN_UNUSED_RESULT;
-EAPI void eina_rbtree_delete(Eina_Rbtree *root, Eina_Rbtree_Free_Cb func, void *data) EINA_ARG_NONNULL(2);
+EAPI Eina_Rbtree *              eina_rbtree_inline_insert(Eina_Rbtree *root,Eina_Rbtree *node,Eina_Rbtree_Cmp_Node_Cb cmp,const void *data) EINA_ARG_NONNULL(2, 3) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Rbtree *              eina_rbtree_inline_remove(Eina_Rbtree *root,Eina_Rbtree *node,Eina_Rbtree_Cmp_Node_Cb cmp,const void *data) EINA_ARG_NONNULL(2, 3) EINA_WARN_UNUSED_RESULT;
+EAPI void                       eina_rbtree_delete(Eina_Rbtree *root,Eina_Rbtree_Free_Cb func,void *data) EINA_ARG_NONNULL(2);
 
-static inline Eina_Rbtree *eina_rbtree_inline_lookup(const Eina_Rbtree *root, const void *key, int length, Eina_Rbtree_Cmp_Key_Cb cmp, const void *data) EINA_PURE EINA_ARG_NONNULL(2, 4) EINA_WARN_UNUSED_RESULT;
+static inline Eina_Rbtree *     eina_rbtree_inline_lookup(const Eina_Rbtree *root,const void *key,int length,Eina_Rbtree_Cmp_Key_Cb cmp,const void *data) EINA_PURE EINA_ARG_NONNULL(2, 4) EINA_WARN_UNUSED_RESULT;
 
-EAPI Eina_Iterator *eina_rbtree_iterator_prefix(const Eina_Rbtree *root) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Iterator *eina_rbtree_iterator_infix(const Eina_Rbtree *root) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Iterator *eina_rbtree_iterator_postfix(const Eina_Rbtree *root) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Iterator *            eina_rbtree_iterator_prefix(const Eina_Rbtree *root) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Iterator *            eina_rbtree_iterator_infix(const Eina_Rbtree *root) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Iterator *            eina_rbtree_iterator_postfix(const Eina_Rbtree *root) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
 
 #include "eina_inline_rbtree.x"
 
index 16d4c79..4ce3955 100644 (file)
@@ -6,7 +6,7 @@
  * 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,
+ * 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.
  */
 typedef struct _Eina_Rectangle
 {
-   int x; /**< top-left x co-ordinate of rectangle */
-   int y; /**< top-left y co-ordinate of rectangle */
-   int w; /**< width of rectangle */
-   int h; /**< height of rectangle */
+  int x; /**< top-left x co-ordinate of rectangle */
+  int y; /**< top-left y co-ordinate of rectangle */
+  int w; /**< width of rectangle */
+  int h; /**< height of rectangle */
 } Eina_Rectangle;
 
 typedef struct _Eina_Rectangle_Pool Eina_Rectangle_Pool;
@@ -58,14 +58,14 @@ static inline Eina_Bool eina_rectangle_intersection(Eina_Rectangle *dst, const E
 static inline void eina_rectangle_rescale_in(const Eina_Rectangle *out, const Eina_Rectangle *in, Eina_Rectangle *res) EINA_ARG_NONNULL(1, 2, 3);
 static inline void eina_rectangle_rescale_out(const Eina_Rectangle *out, const Eina_Rectangle *in, Eina_Rectangle *res) EINA_ARG_NONNULL(1, 2, 3);
 
-EAPI Eina_Rectangle_Pool *eina_rectangle_pool_new(int w, int h) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Rectangle_Pool *eina_rectangle_pool_get(Eina_Rectangle *rect) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
+EAPI Eina_Rectangle_Pool * eina_rectangle_pool_new(int w, int h) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Rectangle_Pool * eina_rectangle_pool_get(Eina_Rectangle *rect) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
 EAPI Eina_Bool eina_rectangle_pool_geometry_get(Eina_Rectangle_Pool *pool, int *w, int *h) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-EAPI void *eina_rectangle_pool_data_get(Eina_Rectangle_Pool *pool) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
+EAPI void * eina_rectangle_pool_data_get(Eina_Rectangle_Pool *pool) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
 EAPI void eina_rectangle_pool_data_set(Eina_Rectangle_Pool *pool, const void *data) EINA_ARG_NONNULL(1);
 EAPI void eina_rectangle_pool_free(Eina_Rectangle_Pool *pool) EINA_ARG_NONNULL(1);
 EAPI int eina_rectangle_pool_count(Eina_Rectangle_Pool *pool) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Rectangle *eina_rectangle_pool_request(Eina_Rectangle_Pool *pool, int w, int h) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
+EAPI Eina_Rectangle * eina_rectangle_pool_request(Eina_Rectangle_Pool *pool, int w, int h) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
 EAPI void eina_rectangle_pool_release(Eina_Rectangle *rect) EINA_ARG_NONNULL(1);
 
 /**
@@ -83,13 +83,13 @@ EAPI void eina_rectangle_pool_release(Eina_Rectangle *rect) EINA_ARG_NONNULL(1);
  * width and @p H is its height.
  */
 #define EINA_RECTANGLE_SET(Rectangle, X, Y, W, H) \
-  (Rectangle)->x = X;                            \
-  (Rectangle)->y = Y;                            \
-  (Rectangle)->w = W;                            \
-  (Rectangle)->h = H;
+                          (Rectangle)->x = X;     \
+                          (Rectangle)->y = Y;     \
+                          (Rectangle)->w = W;     \
+                          (Rectangle)->h = H;
 
 EAPI Eina_Rectangle *eina_rectangle_new(int x, int y, int w, int h) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
-EAPI void eina_rectangle_free(Eina_Rectangle *rect) EINA_ARG_NONNULL(1);
+EAPI void            eina_rectangle_free(Eina_Rectangle *rect) EINA_ARG_NONNULL(1);
 
 #include "eina_inline_rectangle.x"
 
index 1c0b4dd..79ebc54 100644 (file)
@@ -78,100 +78,112 @@ EAPI extern Eina_Error EINA_ERROR_SAFETY_FAILED;
 
 #include "eina_log.h"
 
-#define EINA_SAFETY_ON_NULL_RETURN(exp)                                        \
-  do                                                                   \
-    {                                                                  \
-       if (EINA_UNLIKELY((exp) == NULL))                               \
-        {                                                              \
-           eina_error_set(EINA_ERROR_SAFETY_FAILED);                   \
-           EINA_LOG_ERR("%s", "safety check failed: " #exp " == NULL"); \
-           return;                                                     \
-        }                                                              \
-    }                                                                  \
+#define EINA_SAFETY_ON_NULL_RETURN(exp)                                 \
+  do                                                                    \
+    {                                                                   \
+       if (EINA_UNLIKELY((exp) == NULL))                                \
+        {                                                              \
+           eina_error_set(EINA_ERROR_SAFETY_FAILED);                   \
+           EINA_LOG_ERR("%s", "safety check failed: " # exp " == NULL"); \
+           return;                                                     \
+        }                                                              \
+    }                                                                   \
   while (0)
 
-#define EINA_SAFETY_ON_NULL_RETURN_VAL(exp, val)                       \
-  do                                                                   \
-    {                                                                  \
-       if (EINA_UNLIKELY((exp) == NULL))                               \
-        {                                                              \
-           eina_error_set(EINA_ERROR_SAFETY_FAILED);                   \
-           EINA_LOG_ERR("%s", "safety check failed: " #exp " == NULL"); \
-           return (val);                                               \
-        }                                                              \
-    }                                                                  \
+#define EINA_SAFETY_ON_NULL_RETURN_VAL(exp, val)                        \
+  do                                                                    \
+    {                                                                   \
+       if (EINA_UNLIKELY((exp) == NULL))                                \
+        {                                                              \
+           eina_error_set(EINA_ERROR_SAFETY_FAILED);                   \
+           EINA_LOG_ERR("%s", "safety check failed: " # exp " == NULL"); \
+           return (val);                                               \
+        }                                                              \
+    }                                                                   \
   while (0)
 
-#define EINA_SAFETY_ON_TRUE_RETURN(exp)                                        \
-  do                                                                   \
-    {                                                                  \
-       if (EINA_UNLIKELY(exp))                                         \
-        {                                                              \
-           eina_error_set(EINA_ERROR_SAFETY_FAILED);                   \
-           EINA_LOG_ERR("%s", "safety check failed: " #exp " is true"); \
-           return;                                                     \
-        }                                                              \
-    }                                                                  \
+#define EINA_SAFETY_ON_NULL_GOTO(exp, label)                            \
+  do                                                                    \
+    {                                                                   \
+       if (EINA_UNLIKELY((exp) == NULL))                                \
+        {                                                              \
+           eina_error_set(EINA_ERROR_SAFETY_FAILED);                   \
+           EINA_LOG_ERR("%s", "safety check failed: " # exp " == NULL"); \
+           goto label;                                                 \
+        }                                                              \
+    }                                                                   \
   while (0)
 
-#define EINA_SAFETY_ON_TRUE_RETURN_VAL(exp, val)                       \
-  do                                                                   \
-    {                                                                  \
-       if (EINA_UNLIKELY(exp))                                         \
-        {                                                              \
-           eina_error_set(EINA_ERROR_SAFETY_FAILED);                   \
-           EINA_LOG_ERR("%s", "safety check failed: " #exp " is true"); \
-           return val;                                                 \
-        }                                                              \
-    }                                                                  \
+#define EINA_SAFETY_ON_TRUE_RETURN(exp)                                 \
+  do                                                                    \
+    {                                                                   \
+       if (EINA_UNLIKELY(exp))                                          \
+        {                                                              \
+           eina_error_set(EINA_ERROR_SAFETY_FAILED);                   \
+           EINA_LOG_ERR("%s", "safety check failed: " # exp " is true"); \
+           return;                                                     \
+        }                                                              \
+    }                                                                   \
   while (0)
 
-#define EINA_SAFETY_ON_TRUE_GOTO(exp, label)                           \
-  do                                                                   \
+#define EINA_SAFETY_ON_TRUE_RETURN_VAL(exp, val)                        \
+  do                                                                    \
     {                                                                  \
        if (EINA_UNLIKELY(exp))                                         \
-        {                                                              \
-           eina_error_set(EINA_ERROR_SAFETY_FAILED);                   \
-           EINA_LOG_ERR("%s", "safety check failed: " #exp " is true"); \
-           goto label;                                                 \
-        }                                                              \
-    }                                                                  \
+        {                                                              \
+           eina_error_set(EINA_ERROR_SAFETY_FAILED);                   \
+           EINA_LOG_ERR("%s", "safety check failed: " # exp " is true"); \
+           return val;                                                 \
+        }                                                              \
+    }                                                                   \
   while (0)
 
-#define EINA_SAFETY_ON_FALSE_RETURN(exp)                               \
-  do                                                                   \
-    {                                                                  \
-       if (EINA_UNLIKELY(!(exp)))                                      \
-        {                                                              \
-           eina_error_set(EINA_ERROR_SAFETY_FAILED);                   \
-           EINA_LOG_ERR("%s", "safety check failed: " #exp " is false"); \
-           return;                                                     \
-        }                                                              \
-    }                                                                  \
+#define EINA_SAFETY_ON_TRUE_GOTO(exp, label)                            \
+  do                                                                    \
+    {                                                                   \
+       if (EINA_UNLIKELY(exp))                                          \
+        {                                                              \
+           eina_error_set(EINA_ERROR_SAFETY_FAILED);                   \
+           EINA_LOG_ERR("%s", "safety check failed: " # exp " is true"); \
+           goto label;                                                 \
+        }                                                              \
+    }                                                                   \
   while (0)
 
-#define EINA_SAFETY_ON_FALSE_RETURN_VAL(exp, val)                      \
-  do                                                                   \
-    {                                                                  \
-       if (EINA_UNLIKELY(!(exp)))                                      \
-        {                                                              \
-           eina_error_set(EINA_ERROR_SAFETY_FAILED);                   \
-           EINA_LOG_ERR("%s", "safety check failed: " #exp " is false"); \
-           return val;                                                 \
-        }                                                              \
-    }                                                                  \
+#define EINA_SAFETY_ON_FALSE_RETURN(exp)                                \
+  do                                                                    \
+    {                                                                   \
+       if (EINA_UNLIKELY(!(exp)))                                       \
+        {                                                              \
+           eina_error_set(EINA_ERROR_SAFETY_FAILED);                   \
+           EINA_LOG_ERR("%s", "safety check failed: " # exp " is false"); \
+           return;                                                     \
+        }                                                              \
+    }                                                                   \
   while (0)
 
-#define EINA_SAFETY_ON_FALSE_GOTO(exp, label)                          \
-  do                                                                   \
-    {                                                                  \
-       if (EINA_UNLIKELY(!(exp)))                                      \
-        {                                                              \
-           eina_error_set(EINA_ERROR_SAFETY_FAILED);                   \
-           EINA_LOG_ERR("%s", "safety check failed: " #exp " is false"); \
-           goto label;                                                 \
-        }                                                              \
-    }                                                                  \
+#define EINA_SAFETY_ON_FALSE_RETURN_VAL(exp, val)                       \
+  do                                                                    \
+    {                                                                   \
+       if (EINA_UNLIKELY(!(exp)))                                       \
+        {                                                              \
+           eina_error_set(EINA_ERROR_SAFETY_FAILED);                   \
+           EINA_LOG_ERR("%s", "safety check failed: " # exp " is false"); \
+           return val;                                                 \
+        }                                                              \
+    }                                                                   \
+  while (0)
+
+#define EINA_SAFETY_ON_FALSE_GOTO(exp, label)                           \
+  do                                                                    \
+    {                                                                   \
+       if (EINA_UNLIKELY(!(exp)))                                       \
+        {                                                              \
+           eina_error_set(EINA_ERROR_SAFETY_FAILED);                   \
+           EINA_LOG_ERR("%s", "safety check failed: " # exp " is false"); \
+           goto label;                                                 \
+        }                                                              \
+    }                                                                   \
   while (0)
 
 #ifdef EINA_ARG_NONNULL
@@ -183,23 +195,32 @@ EAPI extern Eina_Error EINA_ERROR_SAFETY_FAILED;
 
 #else /* no safety checks */
 
-#define EINA_SAFETY_ON_NULL_RETURN(exp)                                        \
+#define EINA_SAFETY_ON_NULL_RETURN(exp)                \
   do { (void)((exp) == NULL); } while (0)
 
-#define EINA_SAFETY_ON_NULL_RETURN_VAL(exp, val)                       \
-  do { if (0 && (exp) == NULL) (void)val; } while (0)
+#define EINA_SAFETY_ON_NULL_RETURN_VAL(exp, val)               \
+  do { if (0 && (exp) == NULL) { (void)val; } } while (0)
 
-#define EINA_SAFETY_ON_TRUE_RETURN(exp)                                        \
+#define EINA_SAFETY_ON_NULL_GOTO(exp, label)                   \
+  do { if (0 && (exp) == NULL) { goto label; } } while (0)
+
+#define EINA_SAFETY_ON_TRUE_RETURN(exp)                \
   do { (void)(exp); } while (0)
 
-#define EINA_SAFETY_ON_TRUE_RETURN_VAL(exp, val)                       \
-  do { if (0 && (exp)) (void)val; } while (0)
+#define EINA_SAFETY_ON_TRUE_RETURN_VAL(exp, val)       \
+  do { if (0 && (exp)) { (void)val; } } while (0)
+
+#define EINA_SAFETY_ON_TRUE_GOTO(exp, label)           \
+  do { if (0 && (exp)) { goto label; } } while (0)
 
-#define EINA_SAFETY_ON_FALSE_RETURN(exp)                               \
+#define EINA_SAFETY_ON_FALSE_RETURN(exp)       \
   do { (void)(!(exp)); } while (0)
 
-#define EINA_SAFETY_ON_FALSE_RETURN_VAL(exp, val)                      \
-  do { if (0 && !(exp)) (void)val; } while (0)
+#define EINA_SAFETY_ON_FALSE_RETURN_VAL(exp, val)      \
+  do { if (0 && !(exp)) { (void)val; } } while (0)
+
+#define EINA_SAFETY_ON_FALSE_GOTO(exp, label)          \
+  do { if (0 && !(exp)) { goto label; } } while (0)
 
 #endif /* safety checks macros */
 #endif /* EINA_SAFETY_CHECKS_H_ */
index 5df9a6c..1d12615 100644 (file)
  */
 
 /* strlcpy implementation for libc's lacking it */
-EAPI size_t eina_strlcpy(char *dst, const char *src, size_t siz) EINA_ARG_NONNULL(1, 2);
-EAPI size_t eina_strlcat(char *dst, const char *src, size_t siz) EINA_ARG_NONNULL(1, 2);
+EAPI size_t      eina_strlcpy(char *dst, const char *src, size_t siz) EINA_ARG_NONNULL(1, 2);
+EAPI size_t      eina_strlcat(char *dst, const char *src, size_t siz) EINA_ARG_NONNULL(1, 2);
 
-EAPI Eina_Bool eina_str_has_prefix(const char *str, const char *prefix) EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Bool eina_str_has_suffix(const char *str, const char *suffix) EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
-EAPI Eina_Bool eina_str_has_extension(const char *str, const char *ext) EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Bool   eina_str_has_prefix(const char *str, const char *prefix) EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Bool   eina_str_has_suffix(const char *str, const char *suffix) EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
+EAPI Eina_Bool   eina_str_has_extension(const char *str, const char *ext) EINA_PURE    EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
 
-EAPI char **eina_str_split(const char *string, const char *delimiter, int max_tokens) EINA_ARG_NONNULL(1, 2) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
-EAPI char **eina_str_split_full(const char *string, const char *delimiter, int max_tokens, unsigned int *elements) EINA_ARG_NONNULL(1, 2, 4) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+EAPI char **     eina_str_split(const char *string, const char *delimiter, int max_tokens) EINA_ARG_NONNULL(1, 2) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+EAPI char **     eina_str_split_full(const char *string, const char *delimiter, int max_tokens, unsigned int *elements) EINA_ARG_NONNULL(1, 2, 4) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
 
-EAPI size_t eina_str_join_len(char *dst, size_t size, char sep, const char *a, size_t a_len, const char *b, size_t b_len) EINA_ARG_NONNULL(1, 4, 6);
+EAPI size_t      eina_str_join_len(char *dst, size_t size, char sep, const char *a, size_t a_len, const char *b, size_t b_len) EINA_ARG_NONNULL(1, 4, 6);
 
-EAPI char *eina_str_convert(const char *enc_from, const char *enc_to, const char *text) EINA_WARN_UNUSED_RESULT EINA_MALLOC EINA_ARG_NONNULL(1, 2, 3);
+EAPI char *      eina_str_convert(const char *enc_from, const char *enc_to, const char *text) EINA_WARN_UNUSED_RESULT EINA_MALLOC EINA_ARG_NONNULL(1, 2, 3);
 
-EAPI char *eina_str_escape(const char *str) EINA_WARN_UNUSED_RESULT EINA_MALLOC EINA_ARG_NONNULL(1);
+EAPI char *      eina_str_escape(const char *str) EINA_WARN_UNUSED_RESULT EINA_MALLOC EINA_ARG_NONNULL(1);
 
+EAPI void        eina_str_tolower(char **str);
+EAPI void        eina_str_toupper(char **str);
 
 static inline size_t eina_str_join(char *dst, size_t size, char sep, const char *a, const char *b) EINA_ARG_NONNULL(1, 4, 5);
 
 /**
- * @brief Join two strings of known length.
- *
- * @param dst The buffer to store the result.
- * @param size Size (in byte) of the buffer.
- * @param sep The separator character to use.
- * @param a First string to use, before @p sep.
- * @param b Second string to use, after @p sep.
- * @return The number of characters printed.
- *
- * This function is similar to eina_str_join_len(), but will compute
- * the length of @p a  and @p b using strlen().
- *
- * @see eina_str_join_len()
- * @see eina_str_join_static()
- */
-static inline size_t eina_str_join(char *dst, size_t size, char sep, const char *a, const char *b)
-{
-   return eina_str_join_len(dst, size, sep, a, strlen(a), b, strlen(b));
-}
-
-/**
  * @def eina_str_join_static(dst, sep, a, b)
  * @brief Join two static strings and store the result in a static buffer.
  *
index a6f3282..5f498dc 100644 (file)
@@ -2,6 +2,7 @@
 #define EINA_STRBUF_H
 
 #include <stddef.h>
+#include <stdarg.h>
 
 #include "eina_types.h"
 
  */
 typedef struct _Eina_Strbuf Eina_Strbuf;
 
+/**
+ * @brief Create a new string buffer.
+ *
+ * @return Newly allocated string buffer instance.
+ *
+ * This function creates a new string buffer. On error, @c NULL is
+ * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To
+ * free the resources, use eina_strbuf_free().
+ *
+ * @see eina_strbuf_free()
+ * @see eina_strbuf_append()
+ * @see eina_strbuf_string_get()
+ */
 EAPI Eina_Strbuf *eina_strbuf_new(void) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
-EAPI void eina_strbuf_free(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
-EAPI void eina_strbuf_reset(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
-
-EAPI Eina_Bool eina_strbuf_append(Eina_Strbuf *buf, const char *str) EINA_ARG_NONNULL(1, 2);
-EAPI Eina_Bool eina_strbuf_append_escaped(Eina_Strbuf *buf, const char *str) EINA_ARG_NONNULL(1, 2);
-EAPI Eina_Bool eina_strbuf_append_n(Eina_Strbuf *buf, const char *str, size_t maxlen) EINA_ARG_NONNULL(1, 2);
-EAPI Eina_Bool eina_strbuf_append_length(Eina_Strbuf *buf, const char *str, size_t length) EINA_ARG_NONNULL(1, 2);
-EAPI Eina_Bool eina_strbuf_append_char(Eina_Strbuf *buf, char c) EINA_ARG_NONNULL(1);
-EAPI Eina_Bool eina_strbuf_append_printf(Eina_Strbuf *buf, const char *fmt, ...) EINA_ARG_NONNULL(1, 2) EINA_PRINTF(2, 3);
-EAPI Eina_Bool eina_strbuf_append_vprintf(Eina_Strbuf *buf, const char *fmt, va_list args) EINA_ARG_NONNULL(1, 2);
-
-EAPI Eina_Bool eina_strbuf_insert(Eina_Strbuf *buf, const char *str, size_t pos) EINA_ARG_NONNULL(1, 2);
-EAPI Eina_Bool eina_strbuf_insert_escaped(Eina_Strbuf *buf, const char *str, size_t pos) EINA_ARG_NONNULL(1, 2);
-EAPI Eina_Bool eina_strbuf_insert_n(Eina_Strbuf *buf, const char *str, size_t maxlen, size_t pos) EINA_ARG_NONNULL(1, 2);
-EAPI Eina_Bool eina_strbuf_insert_length(Eina_Strbuf *buf, const char *str, size_t length, size_t pos) EINA_ARG_NONNULL(1, 2);
-EAPI Eina_Bool eina_strbuf_insert_char(Eina_Strbuf *buf, char c, size_t pos) EINA_ARG_NONNULL(1);
-EAPI Eina_Bool eina_strbuf_insert_printf(Eina_Strbuf *buf, const char *fmt, size_t pos, ...) EINA_ARG_NONNULL(1, 2) EINA_PRINTF(2, 4);
-EAPI Eina_Bool eina_strbuf_insert_vprintf(Eina_Strbuf *buf, const char *fmt, size_t pos, va_list args) EINA_ARG_NONNULL(1, 2);
+
+/**
+ * @brief Free a string buffer.
+ *
+ * @param buf The string buffer to free.
+ *
+ * This function frees the memory of @p buf. @p buf must have been
+ * created by eina_strbuf_new().
+ */
+EAPI void         eina_strbuf_free(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
+
+/**
+ * @brief Reset a string buffer.
+ *
+ * @param buf The string buffer to reset.
+ *
+ * This function reset @p buf: the buffer len is set to 0, and the
+ * string is set to '\\0'. No memory is free'd.
+ */
+EAPI void         eina_strbuf_reset(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
+
+/**
+ * @brief Append a string to a buffer, reallocating as necessary.
+ *
+ * @param buf The string buffer to append to.
+ * @param str The string to append.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function appends @p str to @p buf. It computes the length of
+ * @p str, so is slightly slower than eina_strbuf_append_length(). If
+ * the length is known beforehand, consider using that variant. If
+ * @p buf can't append it, #EINA_FALSE is returned, otherwise
+ * #EINA_TRUE is returned.
+ *
+ * @see eina_strbuf_append()
+ * @see eina_strbuf_append_length()
+ */
+EAPI Eina_Bool    eina_strbuf_append(Eina_Strbuf *buf, const char *str) EINA_ARG_NONNULL(1, 2);
+
+/**
+ * @brief Append an escaped string to a buffer, reallocating as necessary.
+ *
+ * @param buf The string buffer to append to.
+ * @param str The string to append.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function appends the escaped string @p str to @p buf. If @p
+ * str can not be appended, #EINA_FALSE is returned, otherwise,
+ * #EINA_TRUE is returned.
+ */
+EAPI Eina_Bool    eina_strbuf_append_escaped(Eina_Strbuf *buf, const char *str) EINA_ARG_NONNULL(1, 2);
+
+/**
+ * @brief Append a string to a buffer, reallocating as necessary,
+ * limited by the given length.
+ *
+ * @param buf The string buffer to append to.
+ * @param str The string to append.
+ * @param maxlen The maximum number of characters to append.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function appends at most @p maxlen characters of @p str to
+ * @p buf. It can't appends more than the length of @p str. It
+ * computes the length of @p str, so is slightly slower than
+ * eina_strbuf_append_length(). If the length is known beforehand,
+ * consider using that variant (@p maxlen should then be checked so
+ * that it is greater than the size of @p str). If @p str can not be
+ * appended, #EINA_FALSE is returned, otherwise, #EINA_TRUE is
+ * returned.
+ *
+ * @see eina_strbuf_append()
+ * @see eina_strbuf_append_length()
+ */
+EAPI Eina_Bool    eina_strbuf_append_n(Eina_Strbuf *buf, const char *str, size_t maxlen) EINA_ARG_NONNULL(1, 2);
+
+/**
+ * @brief Append a string of exact length to a buffer, reallocating as necessary.
+ *
+ * @param buf The string buffer to append to.
+ * @param str The string to append.
+ * @param length The exact length to use.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function appends @p str to @p buf. @p str must be of size at
+ * most @p length. It is slightly faster than eina_strbuf_append() as
+ * it does not compute the size of @p str. It is useful when dealing
+ * with strings of known size, such as eina_strngshare. If @p buf
+ * can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
+ * returned.
+ *
+ * @see eina_stringshare_length()
+ * @see eina_strbuf_append()
+ * @see eina_strbuf_append_n()
+ */
+EAPI Eina_Bool    eina_strbuf_append_length(Eina_Strbuf *buf, const char *str, size_t length) EINA_ARG_NONNULL(1, 2);
+
+/**
+ * @brief Append a character to a string buffer, reallocating as
+ * necessary.
+ *
+ * @param buf The string buffer to append to.
+ * @param c The char to append.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function inserts @p c to @p buf. If it can not insert it,
+ * #EINA_FALSE is returned, otherwise #EINA_TRUE is returned.
+ */
+EAPI Eina_Bool    eina_strbuf_append_char(Eina_Strbuf *buf, char c) EINA_ARG_NONNULL(1);
+
+/**
+ * @brief Append a string to a buffer, reallocating as necessary.
+ *
+ * @param buf The string buffer to append to.
+ * @param fmt The string to append.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * @see eina_strbuf_append()
+ */
+EAPI Eina_Bool    eina_strbuf_append_printf(Eina_Strbuf *buf, const char *fmt, ...) EINA_ARG_NONNULL(1, 2) EINA_PRINTF(2, 3);
+
+/**
+ * @brief Append a string to a buffer, reallocating as necessary.
+ *
+ * @param buf The string buffer to append to.
+ * @param fmt The string to append.
+ * @param args The variable arguments.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * @see eina_strbuf_append()
+ */
+EAPI Eina_Bool    eina_strbuf_append_vprintf(Eina_Strbuf *buf, const char *fmt, va_list args) EINA_ARG_NONNULL(1, 2);
+
+/**
+ * @brief Insert a string to a buffer, reallocating as necessary.
+ *
+ * @param buf The string buffer to insert.
+ * @param str The string to insert.
+ * @param pos The position to insert the string.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function inserts @p str to @p buf at position @p pos. It
+ * computes the length of @p str, so is slightly slower than
+ * eina_strbuf_insert_length(). If  the length is known beforehand,
+ * consider using that variant. If @p buf can't insert it, #EINA_FALSE
+ * is returned, otherwise #EINA_TRUE is returned.
+ */
+EAPI Eina_Bool    eina_strbuf_insert(Eina_Strbuf *buf, const char *str, size_t pos) EINA_ARG_NONNULL(1, 2);
+
+/**
+ * @brief Insert an escaped string to a buffer, reallocating as
+ * necessary.
+ *
+ * @param buf The string buffer to insert to.
+ * @param str The string to insert.
+ * @param pos The position to insert the string.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function inserts the escaped string @p str to @p buf at
+ * position @p pos. If @p buf can't insert @p str, #EINA_FALSE is
+ * returned, otherwise #EINA_TRUE is returned.
+ */
+EAPI Eina_Bool    eina_strbuf_insert_escaped(Eina_Strbuf *buf, const char *str, size_t pos) EINA_ARG_NONNULL(1, 2);
+
+/**
+ * @brief Insert a string to a buffer, reallocating as necessary. Limited by maxlen.
+ *
+ * @param buf The string buffer to insert to.
+ * @param str The string to insert.
+ * @param maxlen The maximum number of chars to insert.
+ * @param pos The position to insert the string.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function inserts @p str ot @p buf at position @p pos, with at
+ * most @p maxlen bytes. The number of inserted characters can not be
+ * greater than the length of @p str. It computes the length of
+ * @p str, so is slightly slower than eina_strbuf_insert_length(). If the
+ * length is known beforehand, consider using that variant (@p maxlen
+ * should then be checked so that it is greater than the size of
+ * @p str). If @p str can not be inserted, #EINA_FALSE is returned,
+ * otherwise, #EINA_TRUE is returned.
+ */
+EAPI Eina_Bool    eina_strbuf_insert_n(Eina_Strbuf *buf, const char *str, size_t maxlen, size_t pos) EINA_ARG_NONNULL(1, 2);
+
+/**
+ * @brief Insert a string of exact length to a buffer, reallocating as necessary.
+ *
+ * @param buf The string buffer to insert to.
+ * @param str The string to insert.
+ * @param length The exact length to use.
+ * @param pos The position to insert the string.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function inserts @p str to @p buf. @p str must be of size at
+ * most @p length. It is slightly faster than eina_strbuf_insert() as
+ * it does not compute the size of @p str. It is useful when dealing
+ * with strings of known size, such as eina_strngshare. If @p buf
+ * can't insert it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
+ * returned.
+ *
+ * @see eina_stringshare_length()
+ * @see eina_strbuf_insert()
+ * @see eina_strbuf_insert_n()
+ */
+EAPI Eina_Bool    eina_strbuf_insert_length(Eina_Strbuf *buf, const char *str, size_t length, size_t pos) EINA_ARG_NONNULL(1, 2);
+
+/**
+ * @brief Insert a character to a string buffer, reallocating as
+ * necessary.
+ *
+ * @param buf The string buffer to insert to.
+ * @param c The char to insert.
+ * @param pos The position to insert the char.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function inserts @p c to @p buf at position @p pos. If @p buf
+ * can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
+ * returned.
+ */
+EAPI Eina_Bool    eina_strbuf_insert_char(Eina_Strbuf *buf, char c, size_t pos) EINA_ARG_NONNULL(1);
+
+/**
+ * @brief Insert a string to a buffer, reallocating as necessary.
+ *
+ * @param buf The string buffer to insert.
+ * @param fmt The string to insert.
+ * @param pos The position to insert the string.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ */
+EAPI Eina_Bool    eina_strbuf_insert_printf(Eina_Strbuf *buf, const char *fmt, size_t pos, ...) EINA_ARG_NONNULL(1, 2) EINA_PRINTF(2, 4);
+
+/**
+ * @brief Insert a string to a buffer, reallocating as necessary.
+ *
+ * @param buf The string buffer to insert.
+ * @param fmt The string to insert.
+ * @param pos The position to insert the string.
+ * @param args The variable arguments.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ */
+EAPI Eina_Bool    eina_strbuf_insert_vprintf(Eina_Strbuf *buf, const char *fmt, size_t pos, va_list args) EINA_ARG_NONNULL(1, 2);
 
 /**
  * @def eina_strbuf_prepend(buf, str)
@@ -99,7 +335,7 @@ EAPI Eina_Bool eina_strbuf_insert_vprintf(Eina_Strbuf *buf, const char *fmt, siz
  * @p buf can't prepend it, #EINA_FALSE is returned, otherwise
  * #EINA_TRUE is returned.
  */
-#define eina_strbuf_prepend_length(buf, str, length) eina_strbuf_insert_length(buf, str, length, 0)
+#define eina_strbuf_prepend_length(buf, str, length) eina_strbuf_insert_length( buf, str, length, 0)
 
 /**
  * @def eina_strbuf_prepend_char(buf, str)
@@ -120,14 +356,14 @@ EAPI Eina_Bool eina_strbuf_insert_vprintf(Eina_Strbuf *buf, const char *fmt, siz
  * @brief Prepend the given string to the given buffer
  *
  * @param buf The string buffer to prepend to.
- * @param str The string to prepend.
+ * @param fmt The string to prepend.
  * @return #EINA_TRUE on success, #EINA_FALSE on failure.
  *
  * This macro is calling eina_strbuf_insert_printf() at position 0.If @p buf
  * can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
  * returned.
  */
-#define eina_strbuf_prepend_printf(buf, fmt, ...) eina_strbuf_insert_printf(buf, fmt, 0, ##__VA_ARGS__)
+#define eina_strbuf_prepend_printf(buf, fmt, ...) eina_strbuf_insert_printf(buf, fmt, 0, ## __VA_ARGS__)
 
 /**
  * @def eina_strbuf_prepend_vprintf(buf, fmt, args)
@@ -135,6 +371,7 @@ EAPI Eina_Bool eina_strbuf_insert_vprintf(Eina_Strbuf *buf, const char *fmt, siz
  *
  * @param buf The string buffer to prepend to.
  * @param fmt The string to prepend.
+ * @param args The variable arguments.
  * @return #EINA_TRUE on success, #EINA_FALSE on failure.
  *
  * This macro is calling eina_strbuf_insert_vprintf() at position 0.If @p buf
@@ -143,11 +380,73 @@ EAPI Eina_Bool eina_strbuf_insert_vprintf(Eina_Strbuf *buf, const char *fmt, siz
  */
 #define eina_strbuf_prepend_vprintf(buf, fmt, args) eina_strbuf_insert_vprintf(buf, fmt, 0, args)
 
+/**
+ * @brief Remove a slice of the given string buffer.
+ *
+ * @param buf The string buffer to remove a slice.
+ * @param start The initial (inclusive) slice position to start
+ *        removing, in bytes.
+ * @param end The final (non-inclusive) slice position to finish
+ *        removing, in bytes.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function removes a slice of @p buf, starting at @p start
+ * (inclusive) and ending at @p end (non-inclusive). Both values are
+ * in bytes. It returns #EINA_FALSE on failure, #EINA_TRUE otherwise.
+ */
 
 EAPI Eina_Bool eina_strbuf_remove(Eina_Strbuf *buf, size_t start, size_t end) EINA_ARG_NONNULL(1);
-EAPI const char *eina_strbuf_string_get(const Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
+
+/**
+ * @brief Retrieve a pointer to the contents of a string buffer
+ *
+ * @param buf The string buffer.
+ * @return The current string in the string buffer.
+ *
+ * This function returns the string contained in @p buf. The returned
+ * value must not be modified and will no longer be valid if @p buf is
+ * modified. In other words, any eina_strbuf_append() or similar will
+ * make that pointer invalid.
+ *
+ * @see eina_strbuf_string_steal()
+ */
+EAPI const char *eina_strbuf_string_get(const Eina_Strbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+
+/**
+ * @brief Steal the contents of a string buffer.
+ *
+ * @param buf The string buffer to steal.
+ * @return The current string in the string buffer.
+ *
+ * This function returns the string contained in @p buf. @p buf is
+ * then initialized and does not own the returned string anymore. The
+ * caller must release the memory of the returned string by calling
+ * free().
+ *
+ * @see eina_strbuf_string_get()
+ */
 EAPI char *eina_strbuf_string_steal(Eina_Strbuf *buf) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
-EAPI size_t eina_strbuf_length_get(const Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
+
+/**
+ * @brief Free the contents of a string buffer but not the buffer.
+ *
+ * @param buf The string buffer to free the string of.
+ *
+ * This function frees the string contained in @p buf without freeing
+ * @p buf.
+ */
+EAPI void eina_strbuf_string_free(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
+
+/**
+ * @brief Retrieve the length of the string buffer content.
+ *
+ * @param buf The string buffer.
+ * @return The current length of the string, in bytes.
+ *
+ * This function returns the length of @p buf.
+ */
+EAPI size_t eina_strbuf_length_get(const Eina_Strbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+
 EAPI Eina_Bool eina_strbuf_replace(Eina_Strbuf *buf, const char *str, const char *with, unsigned int n) EINA_ARG_NONNULL(1, 2, 3);
 
 /**
index 94c61e6..4df5b40 100644 (file)
@@ -51,6 +51,8 @@
 #ifndef EINA_STRINGSHARE_H_
 #define EINA_STRINGSHARE_H_
 
+#include <stdarg.h>
+
 #include "eina_types.h"
 
 /**
  * @{
  */
 
-EAPI const char *eina_stringshare_add_length(const char *str, unsigned int slen) EINA_WARN_UNUSED_RESULT;
-EAPI const char *eina_stringshare_add(const char *str) EINA_WARN_UNUSED_RESULT;
-EAPI const char *eina_stringshare_ref(const char *str);
-EAPI void eina_stringshare_del(const char *str);
-EAPI int eina_stringshare_strlen(const char *str) EINA_CONST EINA_WARN_UNUSED_RESULT;
-EAPI void eina_stringshare_dump(void);
+EAPI const char *       eina_stringshare_add_length(const char *str, unsigned int slen) EINA_WARN_UNUSED_RESULT;
+EAPI const char *       eina_stringshare_add(const char *str) EINA_WARN_UNUSED_RESULT;
+EAPI const char *       eina_stringshare_printf(const char *fmt, ...) EINA_WARN_UNUSED_RESULT EINA_PRINTF(1, 2);
+EAPI const char *       eina_stringshare_vprintf(const char *fmt, va_list args) EINA_WARN_UNUSED_RESULT;
+EAPI const char *       eina_stringshare_nprintf(unsigned int len, const char *fmt, ...) EINA_WARN_UNUSED_RESULT EINA_PRINTF(2, 3);
+EAPI const char *       eina_stringshare_ref(const char *str);
+EAPI void               eina_stringshare_del(const char *str);
+EAPI int                eina_stringshare_strlen(const char *str) EINA_PURE EINA_WARN_UNUSED_RESULT;
+EAPI void               eina_stringshare_dump(void);
 
 static inline Eina_Bool eina_stringshare_replace(const char **p_str, const char *news) EINA_ARG_NONNULL(1);
+static inline Eina_Bool eina_stringshare_replace_length(const char **p_str, const char *news, unsigned int slen) EINA_ARG_NONNULL(1);
 
 #include "eina_inline_stringshare.x"
 
index f94c559..19762a5 100644 (file)
@@ -53,22 +53,22 @@ typedef struct Eina_Tile_Grid_Info Eina_Tile_Grid_Info;
  */
 struct Eina_Tile_Grid_Info
 {
-   unsigned long  col;  /**< column of the tiler grid */
-   unsigned long  row;  /**< row of the tiler grid*/
+   unsigned long col; /**< column of the tiler grid */
+   unsigned long row; /**< row of the tiler grid*/
    Eina_Rectangle rect; /**< rectangle of the tiler grid*/
-   Eina_Bool      full; /**< whether the grid is full or not */
+   Eina_Bool full; /**< whether the grid is full or not */
 };
 
 typedef struct _Eina_Tile_Grid_Slicer Eina_Tile_Grid_Slicer;
 
-EAPI Eina_Tiler *eina_tiler_new(int w, int h);
-EAPI void eina_tiler_free(Eina_Tiler *t);
-EAPI void eina_tiler_tile_size_set(Eina_Tiler *t, int w, int h);
-EAPI Eina_Bool eina_tiler_rect_add(Eina_Tiler *t, const Eina_Rectangle *r);
-EAPI void eina_tiler_rect_del(Eina_Tiler *t, const Eina_Rectangle *r);
-EAPI void eina_tiler_clear(Eina_Tiler *t);
-EAPI Eina_Iterator * eina_tiler_iterator_new(const Eina_Tiler *t);
-EAPI Eina_Iterator * eina_tile_grid_slicer_iterator_new(int x, int y, int w, int h, int tile_w, int tile_h);
+EAPI Eina_Tiler *   eina_tiler_new(int w, int h);
+EAPI void           eina_tiler_free(Eina_Tiler *t);
+EAPI void           eina_tiler_tile_size_set(Eina_Tiler *t, int w, int h);
+EAPI Eina_Bool      eina_tiler_rect_add(Eina_Tiler *t, const Eina_Rectangle *r);
+EAPI void           eina_tiler_rect_del(Eina_Tiler *t, const Eina_Rectangle *r);
+EAPI void           eina_tiler_clear(Eina_Tiler *t);
+EAPI Eina_Iterator *eina_tiler_iterator_new(const Eina_Tiler *t);
+EAPI Eina_Iterator *eina_tile_grid_slicer_iterator_new(int x, int y, int w, int h, int tile_w, int tile_h);
 static inline Eina_Bool eina_tile_grid_slicer_next(Eina_Tile_Grid_Slicer *slc, const Eina_Tile_Grid_Info **rect);
 static inline Eina_Bool eina_tile_grid_slicer_setup(Eina_Tile_Grid_Slicer *slc, int x, int y, int w, int h, int tile_w, int tile_h);
 
index f69efb8..83274f3 100644 (file)
@@ -52,8 +52,8 @@ struct _Eina_Trash
    Eina_Trash *next; /**< next item in trash. */
 };
 
-static inline void eina_trash_init(Eina_Trash **trash) EINA_ARG_NONNULL(1);
-static inline void eina_trash_push(Eina_Trash **trash, void *data) EINA_ARG_NONNULL(1);
+static inline void  eina_trash_init(Eina_Trash **trash) EINA_ARG_NONNULL(1);
+static inline void  eina_trash_push(Eina_Trash **trash, void *data) EINA_ARG_NONNULL(1);
 static inline void *eina_trash_pop(Eina_Trash **trash) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
 
 /**
index 16d8208..c94983f 100644 (file)
@@ -245,7 +245,7 @@ EAPI extern const unsigned int eina_prime_table[];
  * if it is 'greater', 1 must be returned, and if they are equal, 0
  * must be returned.
  */
-typedef int (*Eina_Compare_Cb) (const void *data1, const void *data2);
+typedef int (*Eina_Compare_Cb)(const void *data1, const void *data2);
 
 /**
  * @def EINA_COMPARE_CB
@@ -253,15 +253,13 @@ typedef int (*Eina_Compare_Cb) (const void *data1, const void *data2);
  */
 #define EINA_COMPARE_CB(function) ((Eina_Compare_Cb)function)
 
-typedef Eina_Bool (*Eina_Each)(const void *container,
-                              void *data,
-                              void *fdata);
+typedef Eina_Bool (*Eina_Each_Cb)(const void *container, void *data, void *fdata);
 
 /**
- * @def EINA_EACH
+ * @def EINA_EACH_CB
  * Macro to cast to Eina_Each.
  */
-#define EINA_EACH(Function) ((Eina_Each)Function)
+#define EINA_EACH_CB(Function) ((Eina_Each_Cb)Function)
 
 /**
  * @typedef Eina_Free_Cb
diff --git a/src/include/eina_unicode.h b/src/include/eina_unicode.h
new file mode 100644 (file)
index 0000000..06a2af1
--- /dev/null
@@ -0,0 +1,67 @@
+#ifndef EINA_UNICODE_H
+#define EINA_UNICODE_H
+
+#include <stdlib.h>
+
+#include "eina_config.h"
+#include "eina_types.h"
+
+/**
+ * @addtogroup Eina_Data_Types_Group Data Types
+ *
+ * @{
+ */
+/**
+ * @addtogroup Eina_Unicode_String Unicode String
+ *
+ * @brief These functions provide basic unicode string handling
+ *
+ * Eina_Unicode is a type that holds unicode codepoints.
+ *
+ * @{
+ */
+
+/**
+ * @typedef Eina_Unicode
+ * A type that holds Unicode codepoints.
+ */
+#if EINA_SIZEOF_WCHAR_T >= 4
+# include <wchar.h>
+typedef wchar_t Eina_Unicode;
+#elif defined(EINA_HAVE_INTTYPES_H)
+# include <inttypes.h>
+typedef uint32_t Eina_Unicode;
+#elif defined(EINA_HAVE_STDINT_H)
+# include <stdint.h>
+typedef uint32_t Eina_Unicode;
+#else
+/* Hope that int is big enough */
+typedef unsigned int Eina_Unicode;
+#endif
+
+EAPI extern const Eina_Unicode *EINA_UNICODE_EMPTY_STRING;
+
+EAPI size_t eina_unicode_strlen(const Eina_Unicode *ustr) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_PURE;
+EAPI size_t eina_unicode_strnlen(const Eina_Unicode *ustr, int n) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_PURE;
+
+
+EAPI Eina_Unicode *eina_unicode_strdup(const Eina_Unicode *text) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
+
+EAPI int           eina_unicode_strcmp(const Eina_Unicode *a, const Eina_Unicode *b) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2) EINA_PURE;
+
+EAPI Eina_Unicode *eina_unicode_strcpy(Eina_Unicode *dest, const Eina_Unicode *source) EINA_ARG_NONNULL(1, 2);
+
+EAPI Eina_Unicode *eina_unicode_strstr(const Eina_Unicode *haystack, const Eina_Unicode *needle) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2) EINA_PURE;
+
+EAPI Eina_Unicode *eina_unicode_strncpy(Eina_Unicode *dest, const Eina_Unicode *source, size_t n) EINA_ARG_NONNULL(1, 2);
+
+EAPI Eina_Unicode *eina_unicode_escape(const Eina_Unicode *str) EINA_ARG_NONNULL(1) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+
+/**
+ * @}
+ */
+/**
+ * @}
+ */
+
+#endif
diff --git a/src/include/eina_ustrbuf.h b/src/include/eina_ustrbuf.h
new file mode 100644 (file)
index 0000000..e042b5d
--- /dev/null
@@ -0,0 +1,418 @@
+#ifndef EINA_USTRBUF_H
+#define EINA_USTRBUF_H
+
+#include <stddef.h>
+
+#include "eina_types.h"
+#include "eina_unicode.h"
+
+/**
+ * @addtogroup Eina_Data_Types_Group Data Types
+ *
+ * @{
+ */
+
+/**
+ * @defgroup Eina_Unicode_String_Buffer_Group Unicode String Buffer
+ *
+ * @{
+ */
+
+/**
+ * @typedef Eina_UStrbuf
+ * Type for a string buffer.
+ */
+typedef struct _Eina_Strbuf Eina_UStrbuf;
+
+/**
+ * @brief Create a new string buffer.
+ *
+ * @return Newly allocated string buffer instance.
+ *
+ * This function creates a new string buffer. On error, @c NULL is
+ * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To
+ * free the resources, use eina_ustrbuf_free().
+ *
+ * @see eina_ustrbuf_free()
+ * @see eina_ustrbuf_append()
+ * @see eina_ustrbuf_string_get()
+ */
+EAPI Eina_UStrbuf *eina_ustrbuf_new(void) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
+
+/**
+ * @brief Free a string buffer.
+ *
+ * @param buf The string buffer to free.
+ *
+ * This function frees the memory of @p buf. @p buf must have been
+ * created by eina_ustrbuf_new().
+ */
+EAPI void          eina_ustrbuf_free(Eina_UStrbuf *buf) EINA_ARG_NONNULL(1);
+
+/**
+ * @brief Reset a string buffer.
+ *
+ * @param buf The string buffer to reset.
+ *
+ * This function reset @p buf: the buffer len is set to 0, and the
+ * string is set to '\\0'. No memory is free'd.
+ */
+EAPI void          eina_ustrbuf_reset(Eina_UStrbuf *buf) EINA_ARG_NONNULL(1);
+
+/**
+ * @brief Append a string to a buffer, reallocating as necessary.
+ *
+ * @param buf The string buffer to append to.
+ * @param str The string to append.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function appends @p str to @p buf. It computes the length of
+ * @p str, so is slightly slower than eina_ustrbuf_append_length(). If
+ * the length is known beforehand, consider using that variant. If
+ * @p buf can't append it, #EINA_FALSE is returned, otherwise
+ * #EINA_TRUE is returned.
+ *
+ * @see eina_ustrbuf_append()
+ * @see eina_ustrbuf_append_length()
+ */
+EAPI Eina_Bool     eina_ustrbuf_append(Eina_UStrbuf *buf, const Eina_Unicode *str) EINA_ARG_NONNULL(1, 2);
+
+/**
+ * @brief Append an escaped string to a buffer, reallocating as necessary.
+ *
+ * @param buf The string buffer to append to.
+ * @param str The string to append.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function appends the escaped string @p str to @p buf. If @p
+ * str can not be appended, #EINA_FALSE is returned, otherwise,
+ * #EINA_TRUE is returned.
+ */
+EAPI Eina_Bool     eina_ustrbuf_append_escaped(Eina_UStrbuf *buf, const Eina_Unicode *str) EINA_ARG_NONNULL(1, 2);
+
+/**
+ * @brief Append a string to a buffer, reallocating as necessary,
+ * limited by the given length.
+ *
+ * @param buf The string buffer to append to.
+ * @param str The string to append.
+ * @param maxlen The maximum number of characters to append.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function appends at most @p maxlen characters of @p str to
+ * @p buf. It can't appends more than the length of @p str. It
+ * computes the length of @p str, so is slightly slower than
+ * eina_ustrbuf_append_length(). If the length is known beforehand,
+ * consider using that variant (@p maxlen should then be checked so
+ * that it is greater than the size of @p str). If @p str can not be
+ * appended, #EINA_FALSE is returned, otherwise, #EINA_TRUE is
+ * returned.
+ *
+ * @see eina_ustrbuf_append()
+ * @see eina_ustrbuf_append_length()
+ */
+EAPI Eina_Bool     eina_ustrbuf_append_n(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t maxlen) EINA_ARG_NONNULL(1, 2);
+
+/**
+ * @brief Append a string of exact length to a buffer, reallocating as necessary.
+ *
+ * @param buf The string buffer to append to.
+ * @param str The string to append.
+ * @param length The exact length to use.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function appends @p str to @p buf. @p str must be of size at
+ * most @p length. It is slightly faster than eina_ustrbuf_append() as
+ * it does not compute the size of @p str. It is useful when dealing
+ * with strings of known size, such as eina_strngshare. If @p buf
+ * can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
+ * returned.
+ *
+ * @see eina_stringshare_length()
+ * @see eina_ustrbuf_append()
+ * @see eina_ustrbuf_append_n()
+ */
+EAPI Eina_Bool     eina_ustrbuf_append_length(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t length) EINA_ARG_NONNULL(1, 2);
+
+/**
+ * @brief Append a character to a string buffer, reallocating as
+ * necessary.
+ *
+ * @param buf The string buffer to append to.
+ * @param c The char to append.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function inserts @p c to @p buf. If it can not insert it,
+ * #EINA_FALSE is returned, otherwise #EINA_TRUE is returned.
+ */
+EAPI Eina_Bool     eina_ustrbuf_append_char(Eina_UStrbuf *buf, Eina_Unicode c) EINA_ARG_NONNULL(1);
+
+/**
+ * @brief Insert a string to a buffer, reallocating as necessary.
+ *
+ * @param buf The string buffer to insert.
+ * @param str The string to insert.
+ * @param pos The position to insert the string.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function inserts @p str to @p buf at position @p pos. It
+ * computes the length of @p str, so is slightly slower than
+ * eina_ustrbuf_insert_length(). If  the length is known beforehand,
+ * consider using that variant. If @p buf can't insert it, #EINA_FALSE
+ * is returned, otherwise #EINA_TRUE is returned.
+ */
+EAPI Eina_Bool     eina_ustrbuf_insert(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t pos) EINA_ARG_NONNULL(1, 2);
+
+/**
+ * @brief Insert an escaped string to a buffer, reallocating as
+ * necessary.
+ *
+ * @param buf The string buffer to insert to.
+ * @param str The string to insert.
+ * @param pos The position to insert the string.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function inserts the escaped string @p str to @p buf at
+ * position @p pos. If @p buf can't insert @p str, #EINA_FALSE is
+ * returned, otherwise #EINA_TRUE is returned.
+ */
+EAPI Eina_Bool     eina_ustrbuf_insert_escaped(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t pos) EINA_ARG_NONNULL(1, 2);
+
+/**
+ * @brief Insert a string to a buffer, reallocating as necessary. Limited by maxlen.
+ *
+ * @param buf The string buffer to insert to.
+ * @param str The string to insert.
+ * @param maxlen The maximum number of chars to insert.
+ * @param pos The position to insert the string.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function inserts @p str ot @p buf at position @p pos, with at
+ * most @p maxlen bytes. The number of inserted characters can not be
+ * greater than the length of @p str. It computes the length of
+ * @p str, so is slightly slower than eina_ustrbuf_insert_length(). If the
+ * length is known beforehand, consider using that variant (@p maxlen
+ * should then be checked so that it is greater than the size of
+ * @p str). If @p str can not be inserted, #EINA_FALSE is returned,
+ * otherwise, #EINA_TRUE is returned.
+ */
+EAPI Eina_Bool     eina_ustrbuf_insert_n(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t maxlen, size_t pos) EINA_ARG_NONNULL(1, 2);
+
+/**
+ * @brief Insert a string of exact length to a buffer, reallocating as necessary.
+ *
+ * @param buf The string buffer to insert to.
+ * @param str The string to insert.
+ * @param length The exact length to use.
+ * @param pos The position to insert the string.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function inserts @p str to @p buf. @p str must be of size at
+ * most @p length. It is slightly faster than eina_ustrbuf_insert() as
+ * it does not compute the size of @p str. It is useful when dealing
+ * with strings of known size, such as eina_strngshare. If @p buf
+ * can't insert it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
+ * returned.
+ *
+ * @see eina_stringshare_length()
+ * @see eina_ustrbuf_insert()
+ * @see eina_ustrbuf_insert_n()
+ */
+EAPI Eina_Bool     eina_ustrbuf_insert_length(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t length, size_t pos) EINA_ARG_NONNULL(1, 2);
+
+/**
+ * @brief Insert a character to a string buffer, reallocating as
+ * necessary.
+ *
+ * @param buf The string buffer to insert to.
+ * @param c The char to insert.
+ * @param pos The position to insert the char.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function inserts @p c to @p buf at position @p pos. If @p buf
+ * can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
+ * returned.
+ */
+EAPI Eina_Bool     eina_ustrbuf_insert_char(Eina_UStrbuf *buf, Eina_Unicode c, size_t pos) EINA_ARG_NONNULL(1);
+
+/**
+ * @def eina_ustrbuf_prepend(buf, str)
+ * @brief Prepend the given string to the given buffer
+ *
+ * @param buf The string buffer to prepend to.
+ * @param str The string to prepend.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This macro is calling eina_ustrbuf_insert() at position 0.If @p buf
+ * can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
+ * returned.
+ */
+#define eina_ustrbuf_prepend(buf, str) eina_ustrbuf_insert(buf, str, 0)
+
+/**
+ * @def eina_ustrbuf_prepend_escaped(buf, str)
+ * @brief Prepend the given escaped string to the given buffer
+ *
+ * @param buf The string buffer to prepend to.
+ * @param str The string to prepend.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This macro is calling eina_ustrbuf_insert_escaped() at position 0. If
+ * @p buf can't prepend it, #EINA_FALSE is returned, otherwise
+ * #EINA_TRUE is returned.
+ */
+#define eina_ustrbuf_prepend_escaped(buf, str) eina_ustrbuf_insert_escaped(buf, str, 0)
+
+/**
+ * @def eina_ustrbuf_prepend_n(buf, str)
+ * @brief Prepend the given escaped string to the given buffer
+ *
+ * @param buf The string buffer to prepend to.
+ * @param str The string to prepend.
+ * @param maxlen The maximum number of Eina_Unicode *s to prepend.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This macro is calling eina_ustrbuf_insert_n() at position 0. If
+ * @p buf can't prepend it, #EINA_FALSE is returned, otherwise
+ * #EINA_TRUE is returned.
+ */
+#define eina_ustrbuf_prepend_n(buf, str, maxlen) eina_ustrbuf_insert_n(buf, str, maxlen, 0)
+
+/**
+ * @def eina_ustrbuf_prepend_length(buf, str)
+ * @brief Prepend the given escaped string to the given buffer
+ *
+ * @param buf The string buffer to prepend to.
+ * @param str The string to prepend.
+ * @param length The exact length to use.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This macro is calling eina_ustrbuf_insert_length() at position 0. If
+ * @p buf can't prepend it, #EINA_FALSE is returned, otherwise
+ * #EINA_TRUE is returned.
+ */
+#define eina_ustrbuf_prepend_length(buf, str, length) eina_ustrbuf_insert_length(buf, str, length, 0)
+
+/**
+ * @def eina_ustrbuf_prepend_Eina_Unicode *(buf, str)
+ * @brief Prepend the given Eina_Unicode *acter to the given buffer
+ *
+ * @param buf The string buffer to prepend to.
+ * @param c The Eina_Unicode *acter to prepend.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This macro is calling eina_ustrbuf_insert_Eina_Unicode *() at position 0. If
+ * @p buf can't prepend it, #EINA_FALSE is returned, otherwise
+ * #EINA_TRUE is returned.
+ */
+#define eina_ustrbuf_prepend_Eina_Unicode *(buf, c)eina_ustrbuf_insert_Eina_Unicode * (buf, c, 0)
+
+/**
+ * @def eina_ustrbuf_prepend_printf(buf, fmt, ...)
+ * @brief Prepend the given string to the given buffer
+ *
+ * @param buf The string buffer to prepend to.
+ * @param fmt The string to prepend.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This macro is calling eina_ustrbuf_insert_printf() at position 0.If @p buf
+ * can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
+ * returned.
+ */
+#define eina_ustrbuf_prepend_printf(buf, fmt, ...) eina_ustrbuf_insert_printf(buf, fmt, 0, ## __VA_ARGS__)
+
+/**
+ * @def eina_ustrbuf_prepend_vprintf(buf, fmt, args)
+ * @brief Prepend the given string to the given buffer
+ *
+ * @param buf The string buffer to prepend to.
+ * @param fmt The string to prepend.
+ * @param args The variable arguments.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This macro is calling eina_ustrbuf_insert_vprintf() at position 0.If @p buf
+ * can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
+ * returned.
+ */
+#define eina_ustrbuf_prepend_vprintf(buf, fmt, args) eina_ustrbuf_insert_vprintf(buf, fmt, 0, args)
+
+/**
+ * @brief Remove a slice of the given string buffer.
+ *
+ * @param buf The string buffer to remove a slice.
+ * @param start The initial (inclusive) slice position to start
+ *        removing, in bytes.
+ * @param end The final (non-inclusive) slice position to finish
+ *        removing, in bytes.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function removes a slice of @p buf, starting at @p start
+ * (inclusive) and ending at @p end (non-inclusive). Both values are
+ * in bytes. It returns #EINA_FALSE on failure, #EINA_TRUE otherwise.
+ */
+EAPI Eina_Bool
+eina_ustrbuf_remove(Eina_UStrbuf *buf, size_t start, size_t end) EINA_ARG_NONNULL(1);
+
+/**
+ * @brief Retrieve a pointer to the contents of a string buffer
+ *
+ * @param buf The string buffer.
+ * @return The current string in the string buffer.
+ *
+ * This function returns the string contained in @p buf. The returned
+ * value must not be modified and will no longer be valid if @p buf is
+ * modified. In other words, any eina_ustrbuf_append() or similar will
+ * make that pointer invalid.
+ *
+ * @see eina_ustrbuf_string_steal()
+ */
+EAPI const Eina_Unicode *
+eina_ustrbuf_string_get(const Eina_UStrbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+
+/**
+ * @brief Steal the contents of a string buffer.
+ *
+ * @param buf The string buffer to steal.
+ * @return The current string in the string buffer.
+ *
+ * This function returns the string contained in @p buf. @p buf is
+ * then initialized and does not own the returned string anymore. The
+ * caller must release the memory of the returned string by calling
+ * free().
+ *
+ * @see eina_ustrbuf_string_get()
+ */
+EAPI Eina_Unicode *
+eina_ustrbuf_string_steal(Eina_UStrbuf *buf) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
+
+/**
+ * @brief Free the contents of a string buffer but not the buffer.
+ *
+ * @param buf The string buffer to free the string of.
+ *
+ * This function frees the string contained in @p buf without freeing
+ * @p buf.
+ */
+EAPI void
+eina_ustrbuf_string_free(Eina_UStrbuf *buf) EINA_ARG_NONNULL(1);
+
+/**
+ * @brief Retrieve the length of the string buffer content.
+ *
+ * @param buf The string buffer.
+ * @return The current length of the string, in bytes.
+ *
+ * This function returns the length of @p buf.
+ */
+EAPI size_t
+eina_ustrbuf_length_get(const Eina_UStrbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+#endif /* EINA_STRBUF_H */
diff --git a/src/include/eina_ustringshare.h b/src/include/eina_ustringshare.h
new file mode 100644 (file)
index 0000000..ac8c889
--- /dev/null
@@ -0,0 +1,89 @@
+/* EINA - EFL data type library
+ * Copyright (C) 2002-2008 Carsten Haitzler, Jorge Luis Zapata Muga, Cedric Bail
+ *
+ * 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/>.
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright (C) 2008 Peter Wehrfritz
+ *
+ *  Permission is hereby granted, free of charge, to any person obtaining a copy
+ *  of this software and associated documentation files (the "Software"), to
+ *  deal in the Software without restriction, including without limitation the
+ *  rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ *  sell copies of the Software, and to permit persons to whom the Software is
+ *  furnished to do so, subject to the following conditions:
+ *
+ *  The above copyright notice and this permission notice shall be included in
+ *  all copies of the Software and its Copyright notices. In addition publicly
+ *  documented acknowledgment must be given that this software has been used if no
+ *  source code of this software is made available publicly. This includes
+ *  acknowledgments in either Copyright notices, Manuals, Publicity and Marketing
+ *  documents or any documentation provided with any product containing this
+ *  software. This License does not apply to any software that links to the
+ *  libraries provided by this software (statically or dynamically), but only to
+ *  the software provided.
+ *
+ *  Please see the OLD-COPYING.PLAIN for a plain-english explanation of this notice
+ *  and it's intent.
+ *
+ *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ *  THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ *  IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ *  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef EINA_USTRINGSHARE_H_
+#define EINA_USTRINGSHARE_H_
+
+#include "eina_types.h"
+#include "eina_unicode.h"
+
+/**
+ * @addtogroup Eina_Data_Types_Group Data Types
+ *
+ * @{
+ */
+
+/**
+ * @defgroup Eina_UStringshare_Group Unicode Stringshare
+ *
+ * @{
+ */
+
+EAPI const Eina_Unicode *eina_ustringshare_add_length(const Eina_Unicode *str, unsigned int slen) EINA_WARN_UNUSED_RESULT;
+EAPI const Eina_Unicode *eina_ustringshare_add(const Eina_Unicode *str) EINA_WARN_UNUSED_RESULT;
+EAPI const Eina_Unicode *eina_ustringshare_ref(const Eina_Unicode *str);
+EAPI void                eina_ustringshare_del(const Eina_Unicode *str);
+EAPI int                 eina_ustringshare_strlen(const Eina_Unicode *str) EINA_PURE EINA_WARN_UNUSED_RESULT;
+EAPI void                eina_ustringshare_dump(void);
+
+static inline Eina_Bool  eina_ustringshare_replace(const Eina_Unicode **p_str, const Eina_Unicode *news) EINA_ARG_NONNULL(1);
+static inline Eina_Bool  eina_ustringshare_replace_length(const Eina_Unicode **p_str, const Eina_Unicode *news, unsigned int slen) EINA_ARG_NONNULL(1);
+
+#include "eina_inline_ustringshare.x"
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+#endif /* EINA_STRINGSHARE_H_ */
index e219cf8..7018549 100644 (file)
@@ -32,19 +32,37 @@ eina_fp.c \
 eina_rbtree.c \
 eina_benchmark.c \
 eina_rectangle.c \
+eina_share_common.c \
+eina_binshare.c \
 eina_stringshare.c \
+eina_ustringshare.c \
 eina_cpu.c \
 eina_tiler.c \
 eina_hamster.c \
 eina_safety_checks.c \
 eina_str.c \
 eina_strbuf.c \
+eina_strbuf_common.c \
+eina_ustrbuf.c \
+eina_unicode.c \
 eina_quadtree.c
 
+EXTRA_DIST = \
+       eina_share_common.h \
+       eina_private.h \
+       eina_strbuf_common.h \
+       eina_strbuf_template_c.x
+
+
+
 if EINA_STATIC_BUILD_CHAINED_POOL
 base_sources += $(top_srcdir)/src/modules/mp/chained_pool/eina_chained_mempool.c
 endif
 
+if EINA_STATIC_BUILD_ONE_BIG
+base_sources += $(top_srcdir)/src/modules/mp/one_big/eina_one_big.c
+endif
+
 if EINA_STATIC_BUILD_EMEMOA_FIXED
 base_sources += $(top_srcdir)/src/modules/mp/ememoa_fixed/eina_ememoa_fixed.c
 endif
@@ -112,6 +130,8 @@ eina_amalgamation.c: $(base_sources) Makefile
        @echo "#include \"eina_private.h\"" >> eina_amalgamation.c
        @echo "#include \"eina_safety_checks.h\"" >> eina_amalgamation.c
        @echo "#include \"Eina.h\"" >> eina_amalgamation.c
+       @echo "#include \"eina_strbuf_common.h\"" >> eina_amalgamation.c
+       @echo "#include \"eina_share_common.h\"" >> eina_amalgamation.c
 
        @for f in $(base_sources); do \
           if [ `echo $$f | sed -e 's/^...\(.\).*/\1/'` != '/' ]; then \
index 38fe129..b244057 100644 (file)
@@ -1,6 +1,3 @@
-/*
- * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
- */
 /* EINA - EFL data type library
  * Copyright (C) 2002-2008 Cedric Bail
  *
@@ -33,8 +30,8 @@
 #include "eina_accessor.h"
 
 /*============================================================================*
- *                                  Local                                     *
- *============================================================================*/
+*                                  Local                                     *
+*============================================================================*/
 
 /**
  * @cond LOCAL
 
 static const char EINA_MAGIC_ACCESSOR_STR[] = "Eina Accessor";
 
-#define EINA_MAGIC_CHECK_ACCESSOR(d)                           \
-  do {                                                         \
-    if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_ACCESSOR))             \
-      EINA_MAGIC_FAIL(d, EINA_MAGIC_ACCESSOR);                 \
-  } while(0)
+#define EINA_MAGIC_CHECK_ACCESSOR(d)                            \
+   do {                                                          \
+        if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_ACCESSOR)) {              \
+             EINA_MAGIC_FAIL(d, EINA_MAGIC_ACCESSOR); }                  \
+     } while(0)
 
 /**
  * @endcond
  */
 
 /*============================================================================*
- *                                 Global                                     *
- *============================================================================*/
+*                                 Global                                     *
+*============================================================================*/
 
 /**
  * @internal
@@ -91,8 +88,8 @@ eina_accessor_shutdown(void)
 }
 
 /*============================================================================*
- *                                   API                                      *
- *============================================================================*/
+*                                   API                                      *
+*============================================================================*/
 
 /**
  * @addtogroup Eina_Accessor_Group Accessor Functions
@@ -143,7 +140,7 @@ EAPI void *
 eina_accessor_container_get(Eina_Accessor *accessor)
 {
    EINA_MAGIC_CHECK_ACCESSOR(accessor);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(accessor, NULL);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(accessor,                NULL);
    EINA_SAFETY_ON_NULL_RETURN_VAL(accessor->get_container, NULL);
    return accessor->get_container(accessor);
 }
@@ -162,12 +159,14 @@ eina_accessor_container_get(Eina_Accessor *accessor)
  * #EINA_FALSE is returned, otherwise EINA_TRUE is returned.
  */
 EAPI Eina_Bool
-eina_accessor_data_get(Eina_Accessor *accessor, unsigned int position, void **data)
+eina_accessor_data_get(Eina_Accessor *accessor,
+                       unsigned int position,
+                       void **data)
 {
    EINA_MAGIC_CHECK_ACCESSOR(accessor);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(accessor, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(accessor,         EINA_FALSE);
    EINA_SAFETY_ON_NULL_RETURN_VAL(accessor->get_at, EINA_FALSE);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(data,             EINA_FALSE);
    return accessor->get_at(accessor, position, data);
 }
 
@@ -189,10 +188,10 @@ eina_accessor_data_get(Eina_Accessor *accessor, unsigned int position, void **da
  */
 EAPI void
 eina_accessor_over(Eina_Accessor *accessor,
-                  Eina_Each cb,
-                  unsigned int start,
-                  unsigned int end,
-                  const void *fdata)
+                   Eina_Each_Cb cb,
+                   unsigned int start,
+                   unsigned int end,
+                   const void *fdata)
 {
    const void *container;
    void *data;
@@ -205,9 +204,62 @@ eina_accessor_over(Eina_Accessor *accessor,
    EINA_SAFETY_ON_NULL_RETURN(cb);
    EINA_SAFETY_ON_FALSE_RETURN(start < end);
 
+   if (!eina_accessor_lock(accessor))
+      return ;
+
    container = accessor->get_container(accessor);
-   for (i = start; i < end && accessor->get_at(accessor, i, &data) == EINA_TRUE; ++i)
-      if (cb(container, data, (void*) fdata) != EINA_TRUE) return ;
+   for (i = start; i < end && accessor->get_at(accessor, i, &data) == EINA_TRUE;
+        ++i)
+      if (cb(container, data, (void *)fdata) != EINA_TRUE)
+        goto on_exit;
+
+ on_exit:
+   (void) eina_accessor_unlock(accessor);
+}
+
+/**
+ * @brief Lock the container of the accessor.
+ *
+ * @param accessor The accessor.
+ * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
+ *
+ * If the container of the @p accessor permit it, it will be locked.
+ * If @p accessor is @c NULL or if a problem occured, #EINA_FALSE is
+ * returned, otherwise #EINA_TRUE is returned. If the container
+ * is not lockable, it will return EINA_TRUE.
+ */
+EAPI Eina_Bool
+eina_accessor_lock(Eina_Accessor *accessor)
+{
+   EINA_MAGIC_CHECK_ACCESSOR(accessor);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(accessor, EINA_FALSE);
+
+   if (accessor->lock)
+      return accessor->lock(accessor);
+   return EINA_TRUE;
+}
+
+/**
+ * @brief Unlock the container of the accessor.
+ *
+ * @param accessor The accessor.
+ * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
+ *
+ * If the container of the @p accessor permit it and was previously
+ * locked, it will be unlocked. If @p accessor is @c NULL or if a
+ * problem occured, #EINA_FALSE is returned, otherwise #EINA_TRUE
+ * is returned. If the container is not lockable, it will return
+ * EINA_TRUE.
+ */
+EAPI Eina_Bool
+eina_accessor_unlock(Eina_Accessor *accessor)
+{
+   EINA_MAGIC_CHECK_ACCESSOR(accessor);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(accessor, EINA_FALSE);
+
+   if (accessor->unlock)
+      return accessor->unlock(accessor);
+   return EINA_TRUE;
 }
 
 /**
index c880826..5eff8b1 100644 (file)
@@ -1,6 +1,3 @@
-/*
- * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
- */
 /* EINA - EFL data type library
  * Copyright (C) 2008 Cedric Bail
  *
@@ -138,29 +135,29 @@ static const char EINA_MAGIC_ARRAY_STR[] = "Eina Array";
 static const char EINA_MAGIC_ARRAY_ITERATOR_STR[] = "Eina Array Iterator";
 static const char EINA_MAGIC_ARRAY_ACCESSOR_STR[] = "Eina Array Accessor";
 
-#define EINA_MAGIC_CHECK_ARRAY(d)                      \
-  do {                                                 \
-     if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_ARRAY))       \
-       EINA_MAGIC_FAIL(d, EINA_MAGIC_ARRAY);           \
-  } while (0)
-
-#define EINA_MAGIC_CHECK_ARRAY_ITERATOR(d, ...)                        \
-  do {                                                         \
-     if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_ARRAY_ITERATOR))      \
-       {                                                       \
-          EINA_MAGIC_FAIL(d, EINA_MAGIC_ARRAY_ITERATOR);       \
-          return __VA_ARGS__;                                  \
-       }                                                       \
-  } while (0)
-
-#define EINA_MAGIC_CHECK_ARRAY_ACCESSOR(d, ...)                        \
-  do {                                                         \
-     if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_ARRAY_ACCESSOR))      \
-       {                                                       \
-          EINA_MAGIC_FAIL(d, EINA_MAGIC_ACCESSOR);             \
-          return __VA_ARGS__;                                  \
-       }                                                       \
-  } while (0)
+#define EINA_MAGIC_CHECK_ARRAY(d)                       \
+   do {                                                  \
+        if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_ARRAY)) {        \
+             EINA_MAGIC_FAIL(d, EINA_MAGIC_ARRAY); }            \
+     } while (0)
+
+#define EINA_MAGIC_CHECK_ARRAY_ITERATOR(d, ...)                 \
+   do {                                                          \
+        if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_ARRAY_ITERATOR))       \
+          {                                                        \
+             EINA_MAGIC_FAIL(d, EINA_MAGIC_ARRAY_ITERATOR);        \
+             return __VA_ARGS__;                                   \
+          }                                                        \
+     } while (0)
+
+#define EINA_MAGIC_CHECK_ARRAY_ACCESSOR(d, ...)                 \
+   do {                                                          \
+        if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_ARRAY_ACCESSOR))       \
+          {                                                        \
+             EINA_MAGIC_FAIL(d, EINA_MAGIC_ACCESSOR);              \
+             return __VA_ARGS__;                                   \
+          }                                                        \
+     } while (0)
 
 
 typedef struct _Eina_Iterator_Array Eina_Iterator_Array;
@@ -194,13 +191,16 @@ static int _eina_array_log_dom = -1;
 #endif
 #define DBG(...) EINA_LOG_DOM_DBG(_eina_array_log_dom, __VA_ARGS__)
 
-static void eina_array_iterator_free(Eina_Iterator_Array *it) EINA_ARG_NONNULL(1);
+static void        eina_array_iterator_free(Eina_Iterator_Array *it) EINA_ARG_NONNULL(1);
 static Eina_Array *eina_array_iterator_get_container(Eina_Iterator_Array *it) EINA_ARG_NONNULL(1);
-static Eina_Bool eina_array_iterator_next(Eina_Iterator_Array *it, void **data) EINA_ARG_NONNULL(1);
+static Eina_Bool   eina_array_iterator_next(Eina_Iterator_Array *it,
+                                            void **data) EINA_ARG_NONNULL(1);
 
-static Eina_Bool eina_array_accessor_get_at(Eina_Accessor_Array *it, unsigned int idx, void **data) EINA_ARG_NONNULL(1);
+static Eina_Bool   eina_array_accessor_get_at(Eina_Accessor_Array *it,
+                                              unsigned int idx,
+                                              void **data) EINA_ARG_NONNULL(1);
 static Eina_Array *eina_array_accessor_get_container(Eina_Accessor_Array *it) EINA_ARG_NONNULL(1);
-static void eina_array_accessor_free(Eina_Accessor_Array *it) EINA_ARG_NONNULL(1);
+static void        eina_array_accessor_free(Eina_Accessor_Array *it) EINA_ARG_NONNULL(1);
 
 static Eina_Bool
 eina_array_iterator_next(Eina_Iterator_Array *it, void **data)
@@ -208,9 +208,11 @@ eina_array_iterator_next(Eina_Iterator_Array *it, void **data)
    EINA_MAGIC_CHECK_ARRAY_ITERATOR(it, EINA_FALSE);
 
    if (!(it->index < eina_array_count_get(it->array)))
-     return EINA_FALSE;
+      return EINA_FALSE;
+
    if (data)
-     *data = eina_array_data_get(it->array, it->index);
+      *data = eina_array_data_get(it->array, it->index);
+
    it->index++;
    return EINA_TRUE;
 }
@@ -219,7 +221,7 @@ static Eina_Array *
 eina_array_iterator_get_container(Eina_Iterator_Array *it)
 {
    EINA_MAGIC_CHECK_ARRAY_ITERATOR(it, NULL);
-   return (Eina_Array *) it->array;
+   return (Eina_Array *)it->array;
 }
 
 static void
@@ -230,14 +232,18 @@ eina_array_iterator_free(Eina_Iterator_Array *it)
 }
 
 static Eina_Bool
-eina_array_accessor_get_at(Eina_Accessor_Array *it, unsigned int idx, void **data)
+eina_array_accessor_get_at(Eina_Accessor_Array *it,
+                           unsigned int idx,
+                           void **data)
 {
    EINA_MAGIC_CHECK_ARRAY_ACCESSOR(it, EINA_FALSE);
 
    if (!(idx < eina_array_count_get(it->array)))
-     return EINA_FALSE;
+      return EINA_FALSE;
+
    if (data)
-     *data = eina_array_data_get(it->array, idx);
+      *data = eina_array_data_get(it->array, idx);
+
    return EINA_TRUE;
 }
 
@@ -245,7 +251,7 @@ static Eina_Array *
 eina_array_accessor_get_container(Eina_Accessor_Array *it)
 {
    EINA_MAGIC_CHECK_ARRAY_ACCESSOR(it, NULL);
-   return (Eina_Array *) it->array;
+   return (Eina_Array *)it->array;
 }
 
 static void
@@ -261,16 +267,18 @@ eina_array_grow(Eina_Array *array)
    void **tmp;
    unsigned int total;
 
-   EINA_MAGIC_CHECK_ARRAY(array);
    EINA_SAFETY_ON_NULL_RETURN_VAL(array, EINA_FALSE);
 
+   EINA_MAGIC_CHECK_ARRAY(array);
+
    total = array->total + array->step;
-   eina_error_set(0);
-   tmp = realloc(array->data, sizeof (void*) * total);
-   if (EINA_UNLIKELY(!tmp)) {
-      eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
-      return 0;
-   }
+        eina_error_set(0);
+   tmp = realloc(array->data, sizeof (void *) * total);
+   if (EINA_UNLIKELY(!tmp))
+     {
+        eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+        return 0;
+     }
 
    array->total = total;
    array->data = tmp;
@@ -301,14 +309,15 @@ eina_array_grow(Eina_Array *array)
 Eina_Bool
 eina_array_init(void)
 {
-   _eina_array_log_dom = eina_log_domain_register("eina_array", EINA_LOG_COLOR_DEFAULT);
+   _eina_array_log_dom = eina_log_domain_register("eina_array",
+                                                  EINA_LOG_COLOR_DEFAULT);
    if (_eina_array_log_dom < 0)
      {
-       EINA_LOG_ERR("Could not register log domain: eina_array");
-       return EINA_FALSE;
+        EINA_LOG_ERR("Could not register log domain: eina_array");
+        return EINA_FALSE;
      }
 
-#define EMS(n) eina_magic_string_static_set(n, n##_STR)
+#define EMS(n) eina_magic_string_static_set(n, n ## _STR)
    EMS(EINA_MAGIC_ARRAY);
    EMS(EINA_MAGIC_ARRAY_ITERATOR);
    EMS(EINA_MAGIC_ARRAY_ACCESSOR);
@@ -398,20 +407,20 @@ eina_array_new(unsigned int step)
 
    eina_error_set(0);
    array = malloc(sizeof (Eina_Array));
-   if (!array) {
-      eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
-      return NULL;
-   }
+   if (!array)
+     {
+        eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+        return NULL;
+     }
 
    EINA_MAGIC_SET(array, EINA_MAGIC_ARRAY);
 
+   array->version = EINA_ARRAY_VERSION;
    array->data = NULL;
    array->total = 0;
    array->count = 0;
    array->step = step;
 
-   DBG("array=%p", array);
-
    return array;
 }
 
@@ -421,7 +430,7 @@ eina_array_new(unsigned int step)
  * @param array The array to free.
  *
  * This function frees @p array. It calls first eina_array_flush() then
- * free the memory of the pointeur. It does not free the memory
+ * free the memory of the pointer. It does not free the memory
  * allocated for the elements of @p array. To free them, use
  * #EINA_ARRAY_ITER_NEXT. For performance reasons, there is no check
  * of @p array.
@@ -431,9 +440,8 @@ eina_array_free(Eina_Array *array)
 {
    eina_array_flush(array);
 
-   EINA_MAGIC_CHECK_ARRAY(array);
    EINA_SAFETY_ON_NULL_RETURN(array);
-   DBG("array=%p", array);
+   EINA_MAGIC_CHECK_ARRAY(array);
    MAGIC_FREE(array);
 }
 
@@ -441,22 +449,37 @@ eina_array_free(Eina_Array *array)
  * @brief Set the step of an array.
  *
  * @param array The array.
+ * @param sizeof_array Should be the value returned by sizeof (Eina_Array).
  * @param step The count of pointers to add when increasing the array size.
  *
  * This function sets the step of @p array to @p step. For performance
  * reasons, there is no check of @p array. If it is @c NULL or
- * invalid, the program may crash.
+ * invalid, the program may crash. This function should be called when
+ * the array is not initialized.
  */
 EAPI void
-eina_array_step_set(Eina_Array *array, unsigned int step)
+eina_array_step_set(Eina_Array *array,
+                   unsigned int sizeof_eina_array,
+                   unsigned int step)
 {
-  EINA_SAFETY_ON_NULL_RETURN(array);
-  array->data = NULL;
-  array->total = 0;
-  array->count = 0;
-  array->step = step;
-  EINA_MAGIC_SET(array, EINA_MAGIC_ARRAY);
-  DBG("array=%p, step=%u", array, step);
+   EINA_SAFETY_ON_NULL_RETURN(array);
+
+   if (sizeof (Eina_Array) != sizeof_eina_array)
+     {
+       ERR("Unknow Eina_Array size ! Got %i, expected %i !\n",
+           sizeof_eina_array,
+           (int) sizeof (Eina_Array));
+       /* Force memory to zero to provide a small layer of security */
+       memset(array, 0, sizeof_eina_array);
+       return ;
+     }
+
+   array->version = EINA_ARRAY_VERSION;
+   array->data = NULL;
+   array->total = 0;
+   array->count = 0;
+   array->step = step;
+   EINA_MAGIC_SET(array, EINA_MAGIC_ARRAY);
 }
 
 /**
@@ -471,10 +494,10 @@ eina_array_step_set(Eina_Array *array, unsigned int step)
 EAPI void
 eina_array_clean(Eina_Array *array)
 {
-   EINA_MAGIC_CHECK_ARRAY(array);
    EINA_SAFETY_ON_NULL_RETURN(array);
+   EINA_MAGIC_CHECK_ARRAY(array);
+
    array->count = 0;
-   DBG("array=%p", array);
 }
 
 /**
@@ -490,13 +513,15 @@ eina_array_clean(Eina_Array *array)
 EAPI void
 eina_array_flush(Eina_Array *array)
 {
-   EINA_MAGIC_CHECK_ARRAY(array);
    EINA_SAFETY_ON_NULL_RETURN(array);
-   DBG("array=%p", array);
+   EINA_MAGIC_CHECK_ARRAY(array);
+
    array->count = 0;
    array->total = 0;
 
-   if (!array->data) return;
+   if (!array->data)
+      return;
+
    free(array->data);
    array->data = NULL;
 }
@@ -519,7 +544,9 @@ eina_array_flush(Eina_Array *array)
  * and the error is set to #EINA_ERROR_OUT_OF_MEMORY.
  */
 EAPI Eina_Bool
-eina_array_remove(Eina_Array *array, Eina_Bool (*keep)(void *data, void *gdata), void *gdata)
+eina_array_remove(Eina_Array *array, Eina_Bool (*keep)(void *data,
+                                                       void *gdata),
+                  void *gdata)
 {
    void **tmp;
    /* WARNING:
@@ -531,68 +558,72 @@ eina_array_remove(Eina_Array *array, Eina_Bool (*keep)(void *data, void *gdata),
    unsigned int limit;
    unsigned int i;
 
-   EINA_MAGIC_CHECK_ARRAY(array);
    EINA_SAFETY_ON_NULL_RETURN_VAL(array, EINA_FALSE);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(keep, EINA_FALSE);
-
-   DBG("array=%p, keep=%p, gdata=%p", array, keep, gdata);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(keep,  EINA_FALSE);
+   EINA_MAGIC_CHECK_ARRAY(array);
 
-   if (array->total == 0) return EINA_TRUE;
+   if (array->total == 0)
+      return EINA_TRUE;
 
    for (i = 0; i < array->count; ++i)
      {
-       data = eina_array_data_get(array, i);
+        data = eina_array_data_get(array, i);
 
-       if (keep(data, gdata) == EINA_FALSE) break;
+        if (keep(data, gdata) == EINA_FALSE)
+           break;
      }
    limit = i;
-   if (i < array->count) ++i;
+   if (i < array->count)
+      ++i;
+
    for (; i < array->count; ++i)
      {
-       data = eina_array_data_get(array, i);
+        data = eina_array_data_get(array, i);
 
-       if (keep(data, gdata) == EINA_TRUE) break;
+        if (keep(data, gdata) == EINA_TRUE)
+           break;
      }
    /* Special case all objects that need to stay are at the beginning of the array. */
    if (i == array->count)
      {
-       array->count = limit;
-       if (array->count == 0)
-         {
-            free(array->data);
-            array->total = 0;
-            array->data = NULL;
-         }
-
-       return EINA_TRUE;
+        array->count = limit;
+        if (array->count == 0)
+          {
+             free(array->data);
+             array->total = 0;
+             array->data = NULL;
+          }
+
+        return EINA_TRUE;
      }
 
-   eina_error_set(0);
-   tmp = malloc(sizeof (void*) * array->total);
-   if (!tmp) {
-      eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
-      return EINA_FALSE;
-   }
+        eina_error_set(0);
+   tmp = malloc(sizeof (void *) * array->total);
+   if (!tmp)
+     {
+        eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+        return EINA_FALSE;
+     }
 
-   memcpy(tmp, array->data, limit * sizeof(void*));
+   memcpy(tmp, array->data, limit * sizeof(void *));
    total = limit;
 
    if (i < array->count)
      {
-       tmp[total] = data;
-       total++;
-       ++i;
+        tmp[total] = data;
+        total++;
+        ++i;
      }
 
    for (; i < array->count; ++i)
      {
-       data = eina_array_data_get(array, i);
+        data = eina_array_data_get(array, i);
 
-       if (keep(data, gdata))
-         {
-            tmp[total] = data;
-            total++;
-         }
+        if (keep(data, gdata))
+          {
+             tmp[total] = data;
+             total++;
+          }
      }
 
    free(array->data);
@@ -603,7 +634,6 @@ eina_array_remove(Eina_Array *array, Eina_Bool (*keep)(void *data, void *gdata),
 
    array->data = tmp;
    array->count = total;
-
    return EINA_TRUE;
 }
 
@@ -624,27 +654,28 @@ eina_array_iterator_new(const Eina_Array *array)
 {
    Eina_Iterator_Array *it;
 
-   EINA_MAGIC_CHECK_ARRAY(array);
    EINA_SAFETY_ON_NULL_RETURN_VAL(array, NULL);
+   EINA_MAGIC_CHECK_ARRAY(array);
 
    eina_error_set(0);
    it = calloc(1, sizeof (Eina_Iterator_Array));
-   if (!it) {
-      eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
-      return NULL;
-   }
+   if (!it)
+     {
+        eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+        return NULL;
+     }
 
-   EINA_MAGIC_SET(it, EINA_MAGIC_ARRAY_ITERATOR);
+   EINA_MAGIC_SET(it,            EINA_MAGIC_ARRAY_ITERATOR);
    EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
 
    it->array = array;
 
+   it->iterator.version = EINA_ITERATOR_VERSION;
    it->iterator.next = FUNC_ITERATOR_NEXT(eina_array_iterator_next);
-   it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(eina_array_iterator_get_container);
+   it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
+         eina_array_iterator_get_container);
    it->iterator.free = FUNC_ITERATOR_FREE(eina_array_iterator_free);
 
-   DBG("array=%p, iterator=%p", array, it);
-
    return &it->iterator;
 }
 
@@ -665,27 +696,28 @@ eina_array_accessor_new(const Eina_Array *array)
 {
    Eina_Accessor_Array *it;
 
-   EINA_MAGIC_CHECK_ARRAY(array);
    EINA_SAFETY_ON_NULL_RETURN_VAL(array, NULL);
+   EINA_MAGIC_CHECK_ARRAY(array);
 
    eina_error_set(0);
    it = calloc(1, sizeof (Eina_Accessor_Array));
-   if (!it) {
-      eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
-      return NULL;
-   }
+   if (!it)
+     {
+        eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+        return NULL;
+     }
 
-   EINA_MAGIC_SET(it, EINA_MAGIC_ARRAY_ACCESSOR);
+   EINA_MAGIC_SET(it,            EINA_MAGIC_ARRAY_ACCESSOR);
    EINA_MAGIC_SET(&it->accessor, EINA_MAGIC_ACCESSOR);
 
    it->array = array;
 
+   it->accessor.version = EINA_ACCESSOR_VERSION;
    it->accessor.get_at = FUNC_ACCESSOR_GET_AT(eina_array_accessor_get_at);
-   it->accessor.get_container = FUNC_ACCESSOR_GET_CONTAINER(eina_array_accessor_get_container);
+   it->accessor.get_container = FUNC_ACCESSOR_GET_CONTAINER(
+         eina_array_accessor_get_container);
    it->accessor.free = FUNC_ACCESSOR_FREE(eina_array_accessor_free);
 
-   DBG("array=%p, accessor=%p", array, it);
-
    return &it->accessor;
 }
 
index 30f4884..949798d 100644 (file)
@@ -32,7 +32,7 @@
  *
  * @li Create a new bechmark
  * @li Write the functions that wraps the the functions you want to
- * bechmark. 
+ * bechmark.
  * @li Register these wrappers functions.
  * @li Run the benchmark.
  * @li Free the memory.
@@ -79,7 +79,7 @@
  *   eina_shutdown();
  *
  *   return EXIT_SUCCESS;
- * 
+ *
  *  shutdown_eina:
  *   eina_shutdown();
  *
  *       test = eina_benchmark_new(benchmarks[i].bench_case, "Benchmark example");
  *       if (!test)
  *         continue;
- * 
+ *
  *       benchmarks[i].build(test);
  *
  *       ea = eina_benchmark_run(test);
@@ -325,8 +325,8 @@ void *alloca (size_t);
 #include "eina_counter.h"
 
 /*============================================================================*
- *                                  Local                                     *
- *============================================================================*/
+*                                  Local                                     *
+*============================================================================*/
 
 /**
  * @cond LOCAL
@@ -373,8 +373,8 @@ static int _eina_benchmark_log_dom = -1;
  */
 
 /*============================================================================*
- *                                 Global                                     *
- *============================================================================*/
+*                                 Global                                     *
+*============================================================================*/
 
 /**
  * @internal
@@ -390,11 +390,12 @@ static int _eina_benchmark_log_dom = -1;
 Eina_Bool
 eina_benchmark_init(void)
 {
-   _eina_benchmark_log_dom = eina_log_domain_register("eina_benchmark", EINA_LOG_COLOR_DEFAULT);
+   _eina_benchmark_log_dom = eina_log_domain_register("eina_benchmark",
+                                                      EINA_LOG_COLOR_DEFAULT);
    if (_eina_benchmark_log_dom < 0)
      {
-       EINA_LOG_ERR("Could not register log domain: eina_benchmark");
-       return EINA_FALSE;
+        EINA_LOG_ERR("Could not register log domain: eina_benchmark");
+        return EINA_FALSE;
      }
 
    return EINA_TRUE;
@@ -420,8 +421,8 @@ eina_benchmark_shutdown(void)
 }
 
 /*============================================================================*
- *                                   API                                      *
- *============================================================================*/
+*                                   API                                      *
+*============================================================================*/
 
 /**
  * @addtogroup Eina_Benchmark_Group Benchmark
@@ -472,12 +473,12 @@ eina_benchmark_new(const char *name, const char *run)
 {
    Eina_Benchmark *new;
 
-   eina_error_set(0);
+        eina_error_set(0);
    new = calloc(1, sizeof (Eina_Benchmark));
    if (!new)
      {
-       eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
-       return NULL;
+        eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+        return NULL;
      }
 
    new->name = name;
@@ -500,27 +501,28 @@ eina_benchmark_free(Eina_Benchmark *bench)
 {
    Eina_Array *names;
 
-   if (!bench) return ;
+   if (!bench)
+      return;
 
    while (bench->runs)
      {
-       Eina_Run *run = (Eina_Run *) bench->runs;
+        Eina_Run *run = (Eina_Run *)bench->runs;
 
-       bench->runs = eina_inlist_remove(bench->runs, bench->runs);
-       free(run);
+        bench->runs = eina_inlist_remove(bench->runs, bench->runs);
+        free(run);
      }
 
    EINA_LIST_FREE(bench->names, names)
-     {
-       Eina_Array_Iterator it;
-       char *tmp;
-       unsigned int i;
+   {
+      Eina_Array_Iterator it;
+      char *tmp;
+      unsigned int i;
 
-       EINA_ARRAY_ITER_NEXT(names, i, tmp, it)
-         free(tmp);
+      EINA_ARRAY_ITER_NEXT(names, i, tmp, it)
+       free(tmp);
 
-       eina_array_free(names);
-     }
+      eina_array_free(names);
+   }
 
    free(bench);
 }
@@ -547,20 +549,27 @@ eina_benchmark_free(Eina_Benchmark *bench)
  * to #EINA_ERROR_OUT_OF_MEMORY.
  */
 EAPI Eina_Bool
-eina_benchmark_register(Eina_Benchmark *bench, const char *name, Eina_Benchmark_Specimens bench_cb,
-                       int count_start, int count_end, int count_step)
+eina_benchmark_register(Eina_Benchmark *bench,
+                        const char *name,
+                        Eina_Benchmark_Specimens bench_cb,
+                        int count_start,
+                        int count_end,
+                        int count_step)
 {
    Eina_Run *run;
 
-   if (!bench) return EINA_FALSE;
-   if (count_step == 0) return EINA_FALSE;
+   if (!bench)
+      return EINA_FALSE;
 
-   eina_error_set(0);
+   if (count_step == 0)
+      return EINA_FALSE;
+
+        eina_error_set(0);
    run = calloc(1, sizeof (Eina_Run));
    if (!run)
      {
-       eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
-       return EINA_FALSE;
+        eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+        return EINA_FALSE;
      }
 
    run->cb = bench_cb;
@@ -610,96 +619,118 @@ eina_benchmark_run(Eina_Benchmark *bench)
    Eina_Bool first = EINA_FALSE;
    size_t length;
 
-   if (!bench) return NULL;
+   if (!bench)
+      return NULL;
 
-   length = strlen(EINA_BENCHMARK_FILENAME_MASK) + strlen(bench->name) + strlen(bench->run);
+   length = strlen(EINA_BENCHMARK_FILENAME_MASK) + strlen(bench->name) + strlen(
+         bench->run);
 
    buffer = alloca(sizeof (char) * length);
-   if (!buffer) return NULL;
+   if (!buffer)
+      return NULL;
 
-   snprintf(buffer, length, EINA_BENCHMARK_FILENAME_MASK, bench->name, bench->run);
+   snprintf(buffer,
+            length,
+            EINA_BENCHMARK_FILENAME_MASK,
+            bench->name,
+            bench->run);
 
    main_script = fopen(buffer, "w");
-   if (!main_script) return NULL;
+   if (!main_script)
+      return NULL;
 
    ea = eina_array_new(16);
    if (!ea)
      {
-       fclose(main_script);
-       return NULL;
+        fclose(main_script);
+        return NULL;
      }
 
    eina_array_push(ea, strdup(buffer));
 
-   fprintf(main_script,
-          "set   autoscale                        # scale axes automatically\n"
-          "unset log                              # remove any log-scaling\n"
-          "unset label                            # remove any previous labels\n"
-          "set xtic auto                          # set xtics automatically\n"
-          "set ytic auto                          # set ytics automatically\n"
-/*        "set logscale y\n" */
-          "set terminal png size 1024,768\n"
-          "set output \"output_%s_%s.png\"\n"
-          "set title \"%s %s\n"
-          "set xlabel \"tests\"\n"
-          "set ylabel \"time\"\n"
-          "plot ", bench->name, bench->run, bench->name, bench->run);
+   fprintf(
+      main_script,
+      "set   autoscale                        # scale axes automatically\n"
+      "unset log                              # remove any log-scaling\n"
+      "unset label                            # remove any previous labels\n"
+      "set xtic auto                          # set xtics automatically\n"
+      "set ytic auto                          # set ytics automatically\n"
+/*     "set logscale y\n" */
+      "set terminal png size 1024,768\n"
+      "set output \"output_%s_%s.png\"\n"
+      "set title \"%s %s\n"
+      "set xlabel \"tests\"\n"
+      "set ylabel \"time\"\n"
+      "plot ",
+      bench->name,
+      bench->run,
+      bench->name,
+      bench->run);
 
    EINA_INLIST_FOREACH(bench->runs, run)
-     {
-       Eina_Counter *counter;
-       char *result;
-       size_t tmp;
-       int i;
+   {
+      Eina_Counter *counter;
+      char *result;
+      size_t tmp;
+      int i;
 
-       tmp = strlen(EINA_BENCHMARK_DATA_MASK) + strlen(bench->name) + strlen(bench->run) + strlen(run->name);
-       if (tmp > length)
-         {
-            buffer = alloca(sizeof (char) * tmp);
-            length = tmp;
-         }
+      tmp = strlen(EINA_BENCHMARK_DATA_MASK) + strlen(bench->name) + strlen(
+            bench->run) + strlen(run->name);
+      if (tmp > length)
+        {
+           buffer = alloca(sizeof (char) * tmp);
+           length = tmp;
+        }
 
-       snprintf(buffer, length, EINA_BENCHMARK_DATA_MASK, bench->name, bench->run, run->name);
+      snprintf(buffer,
+               length,
+               EINA_BENCHMARK_DATA_MASK,
+               bench->name,
+               bench->run,
+               run->name);
 
-       current_data = fopen(buffer, "w");
-       if (!current_data) continue ;
+      current_data = fopen(buffer, "w");
+      if (!current_data)
+         continue;
 
-       eina_array_push(ea, strdup(buffer));
+      eina_array_push(ea, strdup(buffer));
 
-       counter = eina_counter_new(run->name);
+      counter = eina_counter_new(run->name);
 
-       for (i = run->start; i < run->end; i += run->step)
-         {
-            fprintf(stderr, "Run %s: %i\n", run->name, i);
-            eina_counter_start(counter);
+      for (i = run->start; i < run->end; i += run->step)
+        {
+           fprintf(stderr, "Run %s: %i\n", run->name, i);
+           eina_counter_start(counter);
 
-            run->cb(i);
+           run->cb(i);
 
-            eina_counter_stop(counter, i);
-         }
+           eina_counter_stop(counter, i);
+        }
 
-       result = eina_counter_dump(counter);
-       if (result)
-         {
-            fprintf(current_data, "%s", result);
-            free(result);
-         }
+      result = eina_counter_dump(counter);
+      if (result)
+        {
+           fprintf(current_data, "%s", result);
+           free(result);
+        }
 
-       eina_counter_free(counter);
+      eina_counter_free(counter);
 
-       fclose(current_data);
+      fclose(current_data);
 
-       if (first == EINA_FALSE) first = EINA_TRUE;
-       else fprintf(main_script, ", \\\n");
+      if (first == EINA_FALSE)
+         first = EINA_TRUE;
+      else
+         fprintf(main_script, ", \\\n");
 
-       fprintf(main_script,
-               "\"%s\" using 1:2 title \'%s\' with line",
-               buffer, run->name);
-     }
+         fprintf(main_script,
+              "\"%s\" using 1:2 title \'%s\' with line",
+              buffer, run->name);
+   }
 
-   fprintf(main_script, "\n");
+         fprintf(main_script, "\n");
 
-   fclose(main_script);
+         fclose(main_script);
 
    bench->names = eina_list_append(bench->names, ea);
 
diff --git a/src/lib/eina_binshare.c b/src/lib/eina_binshare.c
new file mode 100644 (file)
index 0000000..e93c315
--- /dev/null
@@ -0,0 +1,202 @@
+/* EINA - EFL data type library
+ * Copyright (C) 2002-2008 Carsten Haitzler,
+ *                         Jorge Luis Zapata Muga,
+ *                         Cedric Bail,
+ *                         Gustavo Sverzut Barbieri
+ *                         Tom Hacohen
+ *
+ * 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/>.
+
+ */
+/**
+ * @page tutorial_binshare_page Binary Share Tutorial
+ *
+ * Should call eina_binshare_init() before usage and eina_binshare_shutdown() after.
+ * to be written...
+ *
+ */
+
+#include "eina_share_common.h"
+#include "eina_unicode.h"
+#include "eina_private.h"
+#include "eina_binshare.h"
+
+/* The actual share */
+static Eina_Share *binshare_share;
+static const char EINA_MAGIC_BINSHARE_NODE_STR[] = "Eina Binshare Node";
+
+/*============================================================================*
+*                                 Global                                     *
+*============================================================================*/
+
+/**
+ * @internal
+ * @brief Initialize the share_common module.
+ *
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function sets up the share_common module of Eina. It is called by
+ * eina_init().
+ *
+ * @see eina_init()
+ */
+EAPI Eina_Bool
+eina_binshare_init(void)
+{
+   return eina_share_common_init(&binshare_share,
+                                 EINA_MAGIC_BINSHARE_NODE,
+                                 EINA_MAGIC_BINSHARE_NODE_STR);
+}
+
+/**
+ * @internal
+ * @brief Shut down the share_common module.
+ *
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function shuts down the share_common module set up by
+ * eina_share_common_init(). It is called by eina_shutdown().
+ *
+ * @see eina_shutdown()
+ */
+EAPI Eina_Bool
+eina_binshare_shutdown(void)
+{
+   Eina_Bool ret;
+   ret = eina_share_common_shutdown(&binshare_share);
+   return ret;
+}
+
+/*============================================================================*
+*                                   API                                      *
+*============================================================================*/
+/**
+ * @addtogroup Eina_Binshare_Group Binary Share
+ *
+ * These functions allow you to store one copy of an object, and use it
+ * throughout your program.
+ *
+ * This is a method to reduce the number of duplicated objects kept in
+ * memory.
+ *
+ * For more information, you can look at the @ref tutorial_binshare_page.
+ *
+ * @{
+ */
+
+/**
+ * @brief Note that the given object has lost an instance.
+ *
+ * @param obj object The given object.
+ *
+ * This function decreases the reference counter associated to @p obj
+ * if it exists. If that counter reaches 0, the memory associated to
+ * @p obj is freed. If @p obj is NULL, the function returns
+ * immediatly.
+ *
+ * Note that if the given pointer is not shared or NULL, bad things
+ * will happen, likely a segmentation fault.
+ */
+EAPI void
+eina_binshare_del(const void *obj)
+{
+   if (!obj)
+      return;
+
+   eina_share_common_del(binshare_share, obj);
+}
+
+/**
+ * @brief Retrieve an instance of an object for use in a program.
+ *
+ * @param   obj The binary object to retrieve an instance of.
+ * @param   olen The byte size
+ * @return  A pointer to an instance of the object on success.
+ *          @c NULL on failure.
+ *
+ * This function retrieves an instance of @p obj. If @p obj is
+ * @c NULL, then @c NULL is returned. If @p obj is already stored, it
+ * is just returned and its reference counter is increased. Otherwise
+ * it is added to the objects to be searched and a duplicated object
+ * of @p obj is returned.
+ *
+ * This function does not check object size, but uses the
+ * exact given size. This can be used to share part of a larger
+ * object or subobject.
+ *
+ * @see eina_binshare_add()
+ */
+EAPI const void *
+eina_binshare_add_length(const void *obj, unsigned int olen)
+{
+   return eina_share_common_add_length(binshare_share,
+                                                     obj,
+                                                     (olen) * sizeof(char),
+                                                     0);
+}
+
+/**
+ * Increment references of the given shared object.
+ *
+ * @param obj The shared object.
+ * @return    A pointer to an instance of the object on success.
+ *            @c NULL on failure.
+ *
+ * This is similar to eina_share_common_add(), but it's faster since it will
+ * avoid lookups if possible, but on the down side it requires the parameter
+ * to be shared before, in other words, it must be the return of a previous
+ * eina_binshare_add().
+ *
+ * There is no unref since this is the work of eina_binshare_del().
+ */
+EAPI const void *
+eina_binshare_ref(const void *obj)
+{
+   return eina_share_common_ref(binshare_share, obj);
+}
+
+/**
+ * @brief Note that the given object @b must be shared.
+ *
+ * @param obj the shared object to know the length. It is safe to
+ *        give NULL, in that case -1 is returned.
+ *
+ * This function is a cheap way to known the length of a shared
+ * object. Note that if the given pointer is not shared, bad
+ * things will happen, likely a segmentation fault. If in doubt, try
+ * strlen().
+ */
+EAPI int
+eina_binshare_length(const void *obj)
+{
+   return eina_share_common_length(binshare_share, obj);
+}
+
+/**
+ * @brief Dump the contents of the share_common.
+ *
+ * This function dumps all objects in the share_common to stdout with a
+ * DDD: prefix per line and a memory usage summary.
+ */
+EAPI void
+eina_binshare_dump(void)
+{
+   eina_share_common_dump(binshare_share, NULL, 0);
+}
+
+/**
+ * @}
+ */
+
index 581bb0f..1db4a92 100644 (file)
 #include "eina_fp.h"
 
 /*============================================================================*
- *                                  Local                                     *
- *============================================================================*/
+*                                  Local                                     *
+*============================================================================*/
 
 /**
  * @cond LOCAL
  */
 
 static const char look_up_table[] = {'0', '1', '2', '3', '4',
-                                    '5', '6', '7', '8', '9',
-                                    'a', 'b', 'c', 'd', 'e', 'f'};
+                                     '5', '6', '7', '8', '9',
+                                     'a', 'b', 'c', 'd', 'e', 'f'};
 static int _eina_convert_log_dom = -1;
 
 #ifdef ERR
@@ -70,9 +70,9 @@ static inline void reverse(char s[], int length)
 
    for (i = 0, j = length - 1; i < j; i++, j--)
      {
-       c = s[i];
-       s[i] = s[j];
-       s[j] = c;
+        c = s[i];
+        s[i] = s[j];
+        s[j] = c;
      }
 }
 
@@ -81,8 +81,8 @@ static inline void reverse(char s[], int length)
  */
 
 /*============================================================================*
- *                                 Global                                     *
- *============================================================================*/
+*                                 Global                                     *
+*============================================================================*/
 
 /**
  * @cond LOCAL
@@ -92,9 +92,12 @@ EAPI Eina_Error EINA_ERROR_CONVERT_P_NOT_FOUND = 0;
 EAPI Eina_Error EINA_ERROR_CONVERT_0X_NOT_FOUND = 0;
 EAPI Eina_Error EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH = 0;
 
-static const char EINA_ERROR_CONVERT_0X_NOT_FOUND_STR[] = "Error during string convertion to float, First '0x' was not found.";
-static const char EINA_ERROR_CONVERT_P_NOT_FOUND_STR[] = "Error during string convertion to float, First 'p' was not found.";
-static const char EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH_STR[] = "Error outrun string limit during convertion string convertion to float.";
+static const char EINA_ERROR_CONVERT_0X_NOT_FOUND_STR[] =
+   "Error during string convertion to float, First '0x' was not found.";
+static const char EINA_ERROR_CONVERT_P_NOT_FOUND_STR[] =
+   "Error during string convertion to float, First 'p' was not found.";
+static const char EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH_STR[] =
+   "Error outrun string limit during convertion string convertion to float.";
 
 /**
  * @endcond
@@ -119,14 +122,15 @@ static const char EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH_STR[] = "Error outrun
 Eina_Bool
 eina_convert_init(void)
 {
-   _eina_convert_log_dom = eina_log_domain_register("eina_convert", EINA_LOG_COLOR_DEFAULT);
+   _eina_convert_log_dom = eina_log_domain_register("eina_convert",
+                                                    EINA_LOG_COLOR_DEFAULT);
    if (_eina_convert_log_dom < 0)
      {
-       EINA_LOG_ERR("Could not register log domain: eina_convert");
-       return EINA_FALSE;
+        EINA_LOG_ERR("Could not register log domain: eina_convert");
+        return EINA_FALSE;
      }
 
-#define EEMR(n) n = eina_error_msg_static_register(n##_STR)
+#define EEMR(n) n = eina_error_msg_static_register(n ## _STR)
    EEMR(EINA_ERROR_CONVERT_0X_NOT_FOUND);
    EEMR(EINA_ERROR_CONVERT_P_NOT_FOUND);
    EEMR(EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH);
@@ -155,8 +159,8 @@ eina_convert_shutdown(void)
 }
 
 /*============================================================================*
- *                                   API                                      *
- *============================================================================*/
+*                                   API                                      *
+*============================================================================*/
 
 /**
  * @addtogroup Eina_Convert_Group Convert
@@ -180,11 +184,11 @@ eina_convert_shutdown(void)
  * #include <stdlib.h>
  * #include <stdio.h>
  *
- * #include <eina_convert.h>
+ * #include <Eina.h>
  *
  * int main(void)
  * {
- *    char *tmp[128];
+ *    char tmp[128];
  *
  *    if (!eina_init())
  *    {
@@ -204,7 +208,7 @@ eina_convert_shutdown(void)
  * }
  * @endcode
  *
- * Compile this code with the following commant:
+ * Compile this code with the following command:
  *
  * @code
  * gcc -Wall -o test_eina_convert test_eina.c `pkg-config --cflags --libs eina`
@@ -242,15 +246,16 @@ eina_convert_shutdown(void)
  * @code
  * #include <stdlib.h>
  * #include <stdio.h>
+ * #include <math.h>
  *
- * #include <eina_convert.h>
+ * #include <Eina.h>
  *
  * int main(void)
  * {
- *    char     *tmp[128];
+ *    char      tmp[128];
  *    long long int m = 0;
  *    long int  e = 0;
- *    doule     r;
+ *    double    r;
  *
  *    if (!eina_init())
  *    {
@@ -258,12 +263,13 @@ eina_convert_shutdown(void)
  *        return EXIT_FAILURE;
  *    }
  *
+ *    printf("initial value : 40.56\n");
  *    eina_convert_dtoa(40.56, tmp);
- *    printf("value: %s\n", tmp);
+ *    printf("result dtoa   : %s\n", tmp);
 
  *    eina_convert_atod(tmp, 128, &m, &e);
  *    r = ldexp((double)m, e);
- *    printf("value: %s\n", tmp);
+ *    printf("result atod   : %f\n", r);
  *
  *    eina_shutdown();
  *
@@ -271,7 +277,11 @@ eina_convert_shutdown(void)
  * }
  * @endcode
  *
- * Compile this code with the same command as above.
+ * Compile this code with the following command:
+ *
+ * @code
+ * gcc -Wall -o test_eina_convert test_eina.c `pkg-config --cflags --libs eina` -lm
+ * @endcode
  *
  * @{
  */
@@ -305,14 +315,14 @@ eina_convert_itoa(int n, char *s)
 
    if (n < 0)
      {
-       n = -n;
-       *s++ = '-';
-       r = 1;
+        n = -n;
+        *s++ = '-';
+        r = 1;
      }
 
    do {
-      s[i++] = n % 10 + '0';
-   } while ((n /= 10) > 0);
+        s[i++] = n % 10 + '0';
+     } while ((n /= 10) > 0);
 
    s[i] = '\0';
 
@@ -346,8 +356,8 @@ eina_convert_xtoa(unsigned int n, char *s)
 
    i = 0;
    do {
-      s[i++] = look_up_table[n & 0xF];
-   } while ((n >>= 4) > 0);
+        s[i++] = look_up_table[n & 0xF];
+     } while ((n >>= 4) > 0);
 
    s[i] = '\0';
 
@@ -402,31 +412,33 @@ EAPI Eina_Bool
 eina_convert_atod(const char *src, int length, long long *m, long *e)
 {
    const char *str = src;
-   long long   mantisse;
-   long        exponent;
-   int         nbr_decimals = 0;
-   int         sign = 1;
+   long long mantisse;
+   long exponent;
+   int nbr_decimals = 0;
+   int sign = 1;
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(src, EINA_FALSE);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(m, EINA_FALSE);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(e, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(m,   EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(e,   EINA_FALSE);
 
-   if (length <= 0) goto on_length_error;
+   if (length <= 0)
+      goto on_length_error;
 
    /* Compute the mantisse. */
    if (*str == '-')
      {
         sign = -1;
         str++;
-       length--;
+        length--;
      }
 
-   if (length <= 2) goto on_length_error;
+   if (length <= 2)
+      goto on_length_error;
 
    if (strncmp(str, "0x", 2))
      {
-       eina_error_set(EINA_ERROR_CONVERT_0X_NOT_FOUND);
-       DBG("'0x' not found in '%s'", src);
+        eina_error_set(EINA_ERROR_CONVERT_0X_NOT_FOUND);
+        DBG("'0x' not found in '%s'", src);
         return EINA_FALSE;
      }
 
@@ -436,35 +448,38 @@ eina_convert_atod(const char *src, int length, long long *m, long *e)
    mantisse = HEXA_TO_INT(*str);
 
    str++;
-   length--; if (length <= 0) goto on_length_error;
+   length--; if (length <= 0)
+      goto on_length_error;
 
    if (*str == '.')
-     {
-       for (str++, length--;
-            length > 0 && *str != 'p';
-            ++str, --length, ++nbr_decimals)
-          {
-             mantisse <<= 4;
-             mantisse += HEXA_TO_INT(*str);
-          }
-     }
-   if (sign < 0) mantisse = -mantisse;
+      for (str++, length--;
+           length > 0 && *str != 'p';
+           ++str, --length, ++nbr_decimals)
+        {
+           mantisse <<= 4;
+           mantisse += HEXA_TO_INT(*str);
+        }
+
+   if (sign < 0)
+      mantisse = -mantisse;
 
    /* Compute the exponent. */
    if (*str != 'p')
      {
-       eina_error_set(EINA_ERROR_CONVERT_P_NOT_FOUND);
-       DBG("'p' not found in '%s'", src);
+        eina_error_set(EINA_ERROR_CONVERT_P_NOT_FOUND);
+        DBG("'p' not found in '%s'", src);
         return EINA_FALSE;
      }
+
    sign = +1;
 
    str++;
-   length--; if (length <= 0) goto on_length_error;
+   length--; if (length <= 0)
+      goto on_length_error;
 
    if (strchr("-+", *str))
      {
-       sign = (*str == '-') ? -1 : +1;
+        sign = (*str == '-') ? -1 : +1;
 
         str++; length--;
      }
@@ -475,17 +490,18 @@ eina_convert_atod(const char *src, int length, long long *m, long *e)
         exponent += *str - '0';
      }
 
-   if (length < 0) goto on_length_error;
+   if (length < 0)
+      goto on_length_error;
 
    if (sign < 0)
-     exponent = -exponent;
+      exponent = -exponent;
 
    *m = mantisse;
    *e = exponent - (nbr_decimals << 2);
 
    return EINA_TRUE;
 
- on_length_error:
+on_length_error:
    eina_error_set(EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH);
    return EINA_FALSE;
 }
@@ -525,7 +541,7 @@ eina_convert_dtoa(double d, char *des)
      {
         *(des++) = '-';
         d = -d;
-       length++;
+        length++;
      }
 
    d = frexp(d, &p);
@@ -551,14 +567,14 @@ eina_convert_dtoa(double d, char *des)
 
    while (*(des - 1) == '0')
      {
-       des--;
-       length--;
+        des--;
+        length--;
      }
 
    if (*(des - 1) == '.')
      {
-       des--;
-       length--;
+        des--;
+        length--;
      }
 
    *(des++) = 'p';
@@ -568,7 +584,8 @@ eina_convert_dtoa(double d, char *des)
         p = -p;
      }
    else
-     *(des++) = '+';
+      *(des++) = '+';
+
    length += 2;
 
    return length + eina_convert_itoa(p, des);
@@ -612,42 +629,37 @@ eina_convert_fptoa(Eina_F32p32 fp, char *des)
 
    if (fp == 0)
      {
-       memcpy(des, "0x0p+0", 7);
-       return 7;
+        memcpy(des, "0x0p+0", 7);
+        return 7;
      }
 
    if (fp < 0)
      {
         *(des++) = '-';
         fp = -fp;
-       length++;
+        length++;
      }
 
    /* fp >= 1 */
    if (fp >= 0x0000000100000000LL)
-     {
-        while (fp >= 0x0000000100000000LL)
-          {
-            p++;
-            /* fp /= 2 */
-            fp >>= 1;
-          }
-     }
-   /* fp < 0.5 */
+      while (fp >= 0x0000000100000000LL)
+        {
+           p++;
+           /* fp /= 2 */
+           fp >>= 1;
+        } /* fp < 0.5 */
    else if (fp < 0x80000000)
-     {
-        while (fp < 0x80000000)
-          {
-             p--;
-             /* fp *= 2 */
-             fp <<= 1;
-          }
-     }
+      while (fp < 0x80000000)
+        {
+           p--;
+           /* fp *= 2 */
+           fp <<= 1;
+        }
 
    if (p)
      {
         p--;
-       /* fp *= 2 */
+        /* fp *= 2 */
         fp <<= 1;
      }
 
@@ -666,14 +678,14 @@ eina_convert_fptoa(Eina_F32p32 fp, char *des)
 
    while (*(des - 1) == '0')
      {
-       des--;
-       length--;
+        des--;
+        length--;
      }
 
    if (*(des - 1) == '.')
      {
-       des--;
-       length--;
+        des--;
+        length--;
      }
 
    *(des++) = 'p';
@@ -683,7 +695,8 @@ eina_convert_fptoa(Eina_F32p32 fp, char *des)
         p = -p;
      }
    else
-     *(des++) = '+';
+      *(des++) = '+';
+
    length += 2;
 
    return length + eina_convert_itoa(p, des);
@@ -740,14 +753,17 @@ eina_convert_atofp(const char *src, int length, Eina_F32p32 *fp)
    long e;
 
    if (!eina_convert_atod(src, length, &m, &e))
-     return EINA_FALSE;
+      return EINA_FALSE;
 
-   if (!fp) return EINA_TRUE;
+   if (!fp)
+      return EINA_TRUE;
 
    e += 32;
 
-   if (e > 0) *fp = m << e;
-   else *fp = m >> -e;
+   if (e > 0)
+      *fp = m << e;
+   else
+      *fp = m >> -e;
 
    return EINA_TRUE;
 }
index bdb2abb..8bbe0c2 100644 (file)
@@ -42,8 +42,8 @@
 #include "eina_counter.h"
 
 /*============================================================================*
- *                                  Local                                     *
- *============================================================================*/
+*                                  Local                                     *
+*============================================================================*/
 
 /**
  * @cond LOCAL
@@ -91,7 +91,8 @@ _eina_counter_time_get(Eina_Nano_Time *tp)
 # endif
 }
 #else
-static const char EINA_ERROR_COUNTER_WINDOWS_STR[] = "Change your OS, you moron !";
+static const char EINA_ERROR_COUNTER_WINDOWS_STR[] =
+   "Change your OS, you moron !";
 static int EINA_ERROR_COUNTER_WINDOWS = 0;
 static LARGE_INTEGER _eina_counter_frequency;
 
@@ -111,28 +112,34 @@ _eina_counter_asiprintf(char *base, int *position, const char *format, ...)
    va_list ap;
 
    tmp = realloc(base, sizeof (char) * (*position + size));
-   if (!tmp) return base;
+   if (!tmp)
+      return base;
+
    result = tmp;
 
    while (1)
      {
-       va_start(ap, format);
-       n = vsnprintf(result + *position, size, format, ap);
-       va_end(ap);
-
-       if (n > -1 && n < size)
-         {
-            /* If we always have glibc > 2.2, we could just return *position += n. */
-            *position += strlen(result + *position);
-            return result;
-         }
-
-       if (n > -1) size = n + 1;
-       else size <<= 1;
-
-       tmp = realloc(result, sizeof (char) * (*position + size));
-       if (!tmp) return result;
-       result = tmp;
+        va_start(ap, format);
+        n = vsnprintf(result + *position, size, format, ap);
+        va_end(ap);
+
+        if (n > -1 && n < size)
+          {
+             /* If we always have glibc > 2.2, we could just return *position += n. */
+             *position += strlen(result + *position);
+             return result;
+          }
+
+        if (n > -1)
+           size = n + 1;
+        else
+           size <<= 1;
+
+        tmp = realloc(result, sizeof (char) * (*position + size));
+        if (!tmp)
+           return result;
+
+        result = tmp;
      }
 }
 
@@ -141,8 +148,8 @@ _eina_counter_asiprintf(char *base, int *position, const char *format, ...)
  */
 
 /*============================================================================*
- *                                 Global                                     *
- *============================================================================*/
+*                                 Global                                     *
+*============================================================================*/
 
 /**
  * @internal
@@ -165,12 +172,14 @@ Eina_Bool
 eina_counter_init(void)
 {
 #ifdef _WIN32
-   EINA_ERROR_COUNTER_WINDOWS = eina_error_msg_static_register(EINA_ERROR_COUNTER_WINDOWS_STR);
+   EINA_ERROR_COUNTER_WINDOWS = eina_error_msg_static_register(
+         EINA_ERROR_COUNTER_WINDOWS_STR);
    if (!QueryPerformanceFrequency(&_eina_counter_frequency))
      {
-       eina_error_set(EINA_ERROR_COUNTER_WINDOWS);
-       return EINA_FALSE;
+        eina_error_set(EINA_ERROR_COUNTER_WINDOWS);
+        return EINA_FALSE;
      }
+
 #endif /* _WIN2 */
    return EINA_TRUE;
 }
@@ -193,8 +202,8 @@ eina_counter_shutdown(void)
 }
 
 /*============================================================================*
- *                                   API                                      *
- *============================================================================*/
+*                                   API                                      *
+*============================================================================*/
 
 /**
  * @addtogroup Eina_Counter_Group Counter
@@ -302,16 +311,16 @@ eina_counter_new(const char *name)
 
    length = strlen(name) + 1;
 
-   eina_error_set(0);
+        eina_error_set(0);
    counter = calloc(1, sizeof (Eina_Counter) + length);
    if (!counter)
      {
-       eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
-       return NULL;
+        eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+        return NULL;
      }
 
-   counter->name = (char*) (counter + 1);
-   memcpy((char*) counter->name, name, length);
+   counter->name = (char *)(counter + 1);
+   memcpy((char *)counter->name, name, length);
 
    return counter;
 }
@@ -333,13 +342,13 @@ eina_counter_free(Eina_Counter *counter)
 
    while (counter->clocks)
      {
-       Eina_Clock *clk = (Eina_Clock *) counter->clocks;
+        Eina_Clock *clk = (Eina_Clock *)counter->clocks;
 
-       counter->clocks = eina_inlist_remove(counter->clocks, counter->clocks);
-       free(clk);
+        counter->clocks = eina_inlist_remove(counter->clocks, counter->clocks);
+        free(clk);
      }
 
-   free(counter);
+        free(counter);
 }
 
 /**
@@ -365,14 +374,15 @@ eina_counter_start(Eina_Counter *counter)
    Eina_Nano_Time tp;
 
    EINA_SAFETY_ON_NULL_RETURN(counter);
-   if (_eina_counter_time_get(&tp) != 0) return;
+   if (_eina_counter_time_get(&tp) != 0)
+      return;
 
-   eina_error_set(0);
+        eina_error_set(0);
    clk = calloc(1, sizeof (Eina_Clock));
    if (!clk)
      {
-       eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
-       return;
+        eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+        return;
      }
 
    counter->clocks = eina_inlist_prepend(counter->clocks, EINA_INLIST_GET(clk));
@@ -400,11 +410,13 @@ eina_counter_stop(Eina_Counter *counter, int specimen)
    Eina_Nano_Time tp;
 
    EINA_SAFETY_ON_NULL_RETURN(counter);
-   if (_eina_counter_time_get(&tp) != 0) return;
+   if (_eina_counter_time_get(&tp) != 0)
+      return;
 
-   clk = (Eina_Clock *) counter->clocks;
+   clk = (Eina_Clock *)counter->clocks;
 
-   if (!clk || clk->valid == EINA_TRUE) return;
+   if (!clk || clk->valid == EINA_TRUE)
+      return;
 
    clk->end = tp;
    clk->specimen = specimen;
@@ -428,7 +440,7 @@ eina_counter_stop(Eina_Counter *counter, int specimen)
  * @endverbatim
  *
  * The unit of time is the nanosecond.
-*/
+ */
 EAPI char *
 eina_counter_dump(Eina_Counter *counter)
 {
@@ -438,34 +450,52 @@ eina_counter_dump(Eina_Counter *counter)
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(counter, NULL);
 
-   result = _eina_counter_asiprintf(result, &position, "# specimen\texperiment time\tstarting time\tending time\n");
-   if (!result) return NULL;
+   result = _eina_counter_asiprintf(
+         result,
+         &position,
+         "# specimen\texperiment time\tstarting time\tending time\n");
+   if (!result)
+      return NULL;
 
    EINA_INLIST_REVERSE_FOREACH(counter->clocks, clk)
-     {
-        long int start;
-        long int end;
-        long int diff;
+   {
+      long int start;
+      long int end;
+      long int diff;
 
-       if (clk->valid == EINA_FALSE) continue;
+      if (clk->valid == EINA_FALSE)
+         continue;
 
 #ifndef _WIN32
-        start = clk->start.tv_sec * 1000000000 + clk->start.tv_nsec;
-        end = clk->end.tv_sec * 1000000000 + clk->end.tv_nsec;
-        diff = (clk->end.tv_sec - clk->start.tv_sec) * 1000000000 + clk->end.tv_nsec - clk->start.tv_nsec;
+      start = clk->start.tv_sec * 1000000000 + clk->start.tv_nsec;
+      end = clk->end.tv_sec * 1000000000 + clk->end.tv_nsec;
+      diff =
+         (clk->end.tv_sec -
+          clk->start.tv_sec) * 1000000000 + clk->end.tv_nsec -
+         clk->start.tv_nsec;
 #else
-        start = (long int)(((long long int)clk->start.QuadPart * 1000000000ll) / (long long int)_eina_counter_frequency.QuadPart);
-        end = (long int)(((long long int)clk->end.QuadPart * 1000000000LL) / (long long int)_eina_counter_frequency.QuadPart);
-        diff = (long int)(((long long int)(clk->end.QuadPart - clk->start.QuadPart) * 1000000000LL) / (long long int)_eina_counter_frequency.QuadPart);
+      start =
+         (long int)(((long long int)clk->start.QuadPart *
+                     1000000000ll) /
+                    (long long int)_eina_counter_frequency.QuadPart);
+      end =
+         (long int)(((long long int)clk->end.QuadPart *
+                     1000000000LL) /
+                    (long long int)_eina_counter_frequency.QuadPart);
+      diff =
+         (long int)(((long long int)(clk->end.QuadPart -
+                                     clk->start.QuadPart) *
+                     1000000000LL) /
+                    (long long int)_eina_counter_frequency.QuadPart);
 #endif /* _WIN2 */
 
-       result = _eina_counter_asiprintf(result, &position,
-                                        "%i\t%li\t%li\t%li\n",
-                                        clk->specimen,
-                                        diff,
-                                        start,
-                                        end);
-     }
+      result = _eina_counter_asiprintf(result, &position,
+                                       "%i\t%li\t%li\t%li\n",
+                                       clk->specimen,
+                                       diff,
+                                       start,
+                                       end);
+   }
 
    return result;
 }
index 8ddbd0a..1ee411f 100644 (file)
 # include "config.h"
 #endif
 
-#ifdef EFL_HAVE_PTHREAD
+#ifdef EFL_HAVE_THREADS
 # ifdef _WIN32
 #  define WIN32_LEAN_AND_MEAN
 #  include <windows.h>
 # elif defined (__SUNPRO_C) || defined(__GNU__)
 #  include <unistd.h>
-# elif defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) || defined (__DragonFly__) || defined (__MacOSX__) || ( defined (__MACH__) && defined (__APPLE__))
+# elif defined (__FreeBSD__) || defined (__OpenBSD__) || \
+   defined (__NetBSD__) || defined (__DragonFly__) || defined (__MacOSX__) || \
+   (defined (__MACH__) && defined (__APPLE__))
 #  include <unistd.h>
 #  include <sys/param.h>
 #  include <sys/sysctl.h>
@@ -34,7 +36,9 @@
 #  define _GNU_SOURCE
 #  include <sched.h>
 # endif
-# include <pthread.h>
+# ifdef EFL_HAVE_POSIX_THREADS
+#  include <pthread.h>
+# endif
 
 # define TH_MAX 8
 #endif
 #include "eina_cpu.h"
 
 /*============================================================================*
- *                                  Local                                     *
- *============================================================================*/
+*                                  Local                                     *
+*============================================================================*/
 
 /* FIXME this ifdefs should be replaced */
 #if defined(__i386__) || defined(__x86_64__)
 /* We save ebx and restore it to be PIC compatible */
 static inline void _x86_cpuid(int op, int *a, int *b, int *c, int *d)
 {
-       asm volatile(
+   asm volatile (
 #if defined(__x86_64__)
-               "pushq %%rbx      \n\t" /* save %ebx */
+      "pushq %%rbx      \n\t" /* save %ebx */
 #else
-               "pushl %%ebx      \n\t" /* save %ebx */
+      "pushl %%ebx      \n\t" /* save %ebx */
 #endif
-               "cpuid            \n\t"
-               "movl %%ebx, %1   \n\t" /* save what cpuid just put in %ebx */
+      "cpuid            \n\t"
+      "movl %%ebx, %1   \n\t" /* save what cpuid just put in %ebx */
 #if defined(__x86_64__)
-               "popq %%rbx       \n\t" /* restore the old %ebx */
+      "popq %%rbx       \n\t" /* restore the old %ebx */
 #else
-               "popl %%ebx       \n\t" /* restore the old %ebx */
+      "popl %%ebx       \n\t" /* restore the old %ebx */
 #endif
-               : "=a"(*a), "=r"(*b), "=c"(*c), "=d"(*d)
-               : "a"(op)
-               : "cc");
+      : "=a" (*a), "=r" (*b), "=c" (*c), "=d" (*d)
+      : "a" (op)
+      : "cc");
 }
 
 static
 void _x86_simd(Eina_Cpu_Features *features)
 {
-       int a, b, c, d;
-
-       _x86_cpuid(1, &a, &b, &c, &d);
-       /*
-        * edx
-        * 18 = PN (Processor Number)
-        * 19 = CLFlush (Cache Line Flush)
-        * 23 = MMX
-        * 25 = SSE
-        * 26 = SSE2
-        * 28 = HTT (Hyper Threading)
-        * ecx
-        * 0 = SSE3
-        */
-       if ((d >> 23) & 1)
-               *features |= EINA_CPU_MMX;
-       if ((d >> 25) & 1)
-               *features |= EINA_CPU_SSE;
-       if ((d >> 26) & 1)
-               *features |= EINA_CPU_SSE2;
-       if (c & 1)
-               *features |= EINA_CPU_SSE3;
+   int a, b, c, d;
+
+   _x86_cpuid(1, &a, &b, &c, &d);
+   /*
+    * edx
+    * 18 = PN (Processor Number)
+    * 19 = CLFlush (Cache Line Flush)
+    * 23 = MMX
+    * 25 = SSE
+    * 26 = SSE2
+    * 28 = HTT (Hyper Threading)
+    * ecx
+    * 0 = SSE3
+    */
+   if ((d >> 23) & 1)
+      *features |= EINA_CPU_MMX;
+
+   if ((d >> 25) & 1)
+      *features |= EINA_CPU_SSE;
+
+   if ((d >> 26) & 1)
+      *features |= EINA_CPU_SSE2;
+
+   if (c & 1)
+      *features |= EINA_CPU_SSE3;
 }
 #endif
 
 /*============================================================================*
- *                                 Global                                     *
- *============================================================================*/
+*                                 Global                                     *
+*============================================================================*/
 
 /*============================================================================*
- *                                   API                                      *
- *============================================================================*/
+*                                   API                                      *
+*============================================================================*/
 
 /* FIXME the features checks should be called when this function is called?
  * or make it static by doing eina_cpu_init() and return a local var
@@ -117,16 +124,16 @@ void _x86_simd(Eina_Cpu_Features *features)
  */
 EAPI Eina_Cpu_Features eina_cpu_features_get(void)
 {
-       Eina_Cpu_Features ecf = 0;
+   Eina_Cpu_Features ecf = 0;
 #if defined(__i386__) || defined(__x86_64__)
-       _x86_simd(&ecf);
+   _x86_simd(&ecf);
 #endif
-       return ecf;
+   return ecf;
 }
 
 EAPI int eina_cpu_count(void)
 {
-#ifdef EFL_HAVE_PTHREAD
+#ifdef EFL_HAVE_THREADS
 
 # if   defined (_WIN32)
    SYSTEM_INFO sysinfo;
@@ -147,10 +154,12 @@ EAPI int eina_cpu_count(void)
     */
    return sysconf(_SC_NPROCESSORS_ONLN);
 
-# elif defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__NetBSD__) || defined (__DragonFly__) || defined (__MacOSX__) || ( defined (__MACH__) && defined (__APPLE__))
+# elif defined (__FreeBSD__) || defined (__OpenBSD__) || \
+   defined (__NetBSD__) || defined (__DragonFly__) || defined (__MacOSX__) || \
+   (defined (__MACH__) && defined (__APPLE__))
 
-   int    mib[4];
-   int    cpus;
+   int mib[4];
+   int cpus;
    size_t len = sizeof(cpus);
 
    mib[0] = CTL_HW;
@@ -161,7 +170,7 @@ EAPI int eina_cpu_count(void)
 #endif
    sysctl(mib, 2, &cpus, &len, NULL, 0);
    if (cpus < 1)
-     cpus = 1;
+      cpus = 1;
 
    return cpus;
 
@@ -170,18 +179,23 @@ EAPI int eina_cpu_count(void)
    int i;
    static int cpus = 0;
 
-   if (cpus != 0) return cpus;
+   if (cpus != 0)
+      return cpus;
 
    CPU_ZERO(&cpu);
    if (sched_getaffinity(0, sizeof(cpu), &cpu) != 0)
      {
-       fprintf(stderr, "[Eina] could not get cpu affinity: %s\n", strerror(errno));
-       return 1;
+        fprintf(stderr, "[Eina] could not get cpu affinity: %s\n",
+                strerror(errno));
+        return 1;
      }
+
    for (i = 0; i < TH_MAX; i++)
      {
-       if (CPU_ISSET(i, &cpu)) cpus = i + 1;
-       else break;
+        if (CPU_ISSET(i, &cpu))
+           cpus = i + 1;
+        else
+           break;
      }
    return cpus;
 
index 219cbc0..f273ca5 100644 (file)
  */
 
 /*============================================================================*
- *                                  Local                                     *
- *============================================================================*/
+*                                  Local                                     *
+*============================================================================*/
 
 /**
  * @cond LOCAL
@@ -184,19 +184,20 @@ _eina_error_msg_alloc(void)
 
    if (_eina_errors_count == _eina_errors_allocated)
      {
-       void *tmp;
-       size_t size;
-
-       if (EINA_UNLIKELY(_eina_errors_allocated == 0))
-         size = 24;
-       else
-         size = _eina_errors_allocated + 8;
-
-       tmp = realloc(_eina_errors, sizeof(Eina_Error_Message) * size);
-       if (!tmp)
-         return NULL;
-       _eina_errors = tmp;
-       _eina_errors_allocated = size;
+        void *tmp;
+        size_t size;
+
+        if (EINA_UNLIKELY(_eina_errors_allocated == 0))
+           size = 24;
+        else
+           size = _eina_errors_allocated + 8;
+
+        tmp = realloc(_eina_errors, sizeof(Eina_Error_Message) * size);
+        if (!tmp)
+           return NULL;
+
+        _eina_errors = tmp;
+        _eina_errors_allocated = size;
      }
 
    idx = _eina_errors_count;
@@ -210,8 +211,8 @@ _eina_error_msg_alloc(void)
 
 
 /*============================================================================*
- *                                 Global                                     *
- *============================================================================*/
+*                                 Global                                     *
+*============================================================================*/
 
 /**
  * @cond LOCAL
@@ -242,7 +243,8 @@ Eina_Bool
 eina_error_init(void)
 {
    /* TODO register the eina's basic errors */
-   EINA_ERROR_OUT_OF_MEMORY = eina_error_msg_static_register(EINA_ERROR_OUT_OF_MEMORY_STR);
+   EINA_ERROR_OUT_OF_MEMORY = eina_error_msg_static_register(
+         EINA_ERROR_OUT_OF_MEMORY_STR);
    return EINA_TRUE;
 }
 
@@ -266,10 +268,10 @@ eina_error_shutdown(void)
    eem_end = eem + _eina_errors_count;
 
    for (; eem < eem_end; eem++)
-     if (eem->string_allocated)
-       free((char *)eem->string);
+      if (eem->string_allocated)
+         free((char *)eem->string);
 
-   free(_eina_errors);
+         free(_eina_errors);
    _eina_errors = NULL;
    _eina_errors_count = 0;
    _eina_errors_allocated = 0;
@@ -278,8 +280,8 @@ eina_error_shutdown(void)
 }
 
 /*============================================================================*
- *                                   API                                      *
- *============================================================================*/
+*                                   API                                      *
+*============================================================================*/
 
 /**
  * @addtogroup Eina_Error_Group Error
@@ -320,14 +322,14 @@ eina_error_msg_register(const char *msg)
 
    eem = _eina_error_msg_alloc();
    if (!eem)
-     return 0;
+      return 0;
 
    eem->string_allocated = EINA_TRUE;
    eem->string = strdup(msg);
    if (!eem->string)
      {
-       _eina_errors_count--;
-       return 0;
+        _eina_errors_count--;
+        return 0;
      }
 
    return _eina_errors_count; /* identifier = index + 1 (== _count). */
@@ -357,7 +359,7 @@ eina_error_msg_static_register(const char *msg)
 
    eem = _eina_error_msg_alloc();
    if (!eem)
-     return 0;
+      return 0;
 
    eem->string_allocated = EINA_FALSE;
    eem->string = msg;
@@ -365,6 +367,48 @@ eina_error_msg_static_register(const char *msg)
 }
 
 /**
+ * @brief Change the message of an already registered message
+ *
+ * @param error The Eina_Error to change the message of
+ * @param msg The description of the error. This string will be
+ * duplicated only if the error was registered with @ref eina_error_msg_register
+ * otherwise it must remain intact for the duration
+ * @return EINA_TRUE if successful, EINA_FALSE on error
+ *
+ * This function modifies the message associated with @p error and changes
+ * it to @p msg.  If the error was previously registered by @ref eina_error_msg_static_register
+ * then the string will not be duplicated, otherwise the previous message
+ * will be freed and @p msg copied.
+ *
+ * @see eina_error_msg_register()
+ */
+EAPI Eina_Bool
+eina_error_msg_modify(Eina_Error error, const char *msg)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(msg, EINA_FALSE);
+   if (error < 1)
+      return EINA_FALSE;
+
+   if ((size_t)error > _eina_errors_count)
+      return EINA_FALSE;
+
+   if (_eina_errors[error - 1].string_allocated)
+     {
+        const char *tmp;
+
+        if (!(tmp = strdup(msg)))
+           return EINA_FALSE;
+
+        free((void *)_eina_errors[error - 1].string);
+        _eina_errors[error - 1].string = tmp;
+        return EINA_TRUE;
+     }
+
+   _eina_errors[error - 1].string = msg;
+   return EINA_TRUE;
+}
+
+/**
  * @brief Return the description of the given an error number.
  *
  * @param error The error number.
@@ -378,9 +422,11 @@ EAPI const char *
 eina_error_msg_get(Eina_Error error)
 {
    if (error < 1)
-     return NULL;
+      return NULL;
+
    if ((size_t)error > _eina_errors_count)
-     return NULL;
+      return NULL;
+
    return _eina_errors[error - 1].string;
 }
 
index f826c8b..0e3a3df 100644 (file)
@@ -42,16 +42,13 @@ void *alloca (size_t);
 #endif
 
 #include <string.h>
+#include <dirent.h>
 
 #ifndef _WIN32
 # include <sys/types.h>
 # include <sys/stat.h>
 # include <unistd.h>
-# include <dirent.h>
 #else
-# define WIN32_LEAN_AND_MEAN
-# include <windows.h>
-# undef WIN32_LEAN_AND_MEAN
 # include <Evil.h>
 #endif /* _WIN2 */
 
@@ -59,6 +56,7 @@ void *alloca (size_t);
 # define PATH_DELIM '/'
 #else
 # define PATH_DELIM '\\'
+# define NAME_MAX MAX_PATH
 #endif
 
 #include "eina_config.h"
@@ -67,14 +65,127 @@ void *alloca (size_t);
 /* undefs EINA_ARG_NONULL() so NULL checks are not compiled out! */
 #include "eina_safety_checks.h"
 #include "eina_file.h"
+#include "eina_stringshare.h"
+
+typedef struct _Eina_File_Iterator Eina_File_Iterator;
+struct _Eina_File_Iterator
+{
+   Eina_Iterator iterator;
+
+   DIR *dirp;
+   int length;
+
+   char dir[1];
+};
+
+static Eina_Bool
+_eina_file_ls_iterator_next(Eina_File_Iterator *it, void **data)
+{
+   struct dirent *dp;
+   char *name;
+   size_t length;
+
+   do
+     {
+        dp = readdir(it->dirp);
+        if (!dp)
+           return EINA_FALSE;
+     }
+   while ((dp->d_name[0] == '.') &&
+          ((dp->d_name[1] == '\0') ||
+           ((dp->d_name[1] == '.') && (dp->d_name[2] == '\0'))));
+
+   length = strlen(dp->d_name);
+   name = alloca(length + 2 + it->length);
+
+   memcpy(name,                  it->dir,    it->length);
+   memcpy(name + it->length,     "/",        1);
+   memcpy(name + it->length + 1, dp->d_name, length + 1);
+
+   *data = (char *)eina_stringshare_add(name);
+   return EINA_TRUE;
+}
+
+static char *
+_eina_file_ls_iterator_container(Eina_File_Iterator *it)
+{
+   return it->dir;
+}
+
+static void
+_eina_file_ls_iterator_free(Eina_File_Iterator *it)
+{
+   closedir(it->dirp);
+
+   EINA_MAGIC_SET(&it->iterator, 0);
+   free(it);
+}
+
+typedef struct _Eina_File_Direct_Iterator Eina_File_Direct_Iterator;
+struct _Eina_File_Direct_Iterator
+{
+   Eina_Iterator iterator;
+
+   DIR *dirp;
+   int length;
+
+   Eina_File_Direct_Info info;
+
+   char dir[1];
+};
+
+static Eina_Bool
+_eina_file_direct_ls_iterator_next(Eina_File_Direct_Iterator *it, void **data)
+{
+   struct dirent *dp;
+   size_t length;
+
+   do
+     {
+        dp = readdir(it->dirp);
+        if (!dp)
+           return EINA_FALSE;
+
+        length = strlen(dp->d_name);
+        if (it->info.name_start + length + 1 >= PATH_MAX)
+           continue;
+     }
+   while ((dp->d_name[0] == '.') &&
+          ((dp->d_name[1] == '\0') ||
+           ((dp->d_name[1] == '.') && (dp->d_name[2] == '\0'))));
+
+   memcpy(it->info.path + it->info.name_start, dp->d_name, length);
+   it->info.name_length = length;
+   it->info.path_length = it->info.name_start + length;
+   it->info.path[it->info.path_length] = '\0';
+   it->info.dirent = dp;
+
+   *data = &it->info;
+   return EINA_TRUE;
+}
+
+static char *
+_eina_file_direct_ls_iterator_container(Eina_File_Direct_Iterator *it)
+{
+   return it->dir;
+}
+
+static void
+_eina_file_direct_ls_iterator_free(Eina_File_Direct_Iterator *it)
+{
+   closedir(it->dirp);
+
+   EINA_MAGIC_SET(&it->iterator, 0);
+   free(it);
+}
 
 /*============================================================================*
- *                                 Global                                     *
- *============================================================================*/
+*                                 Global                                     *
+*============================================================================*/
 
 /*============================================================================*
- *                                   API                                      *
- *============================================================================*/
+*                                   API                                      *
+*============================================================================*/
 
 /**
  * @addtogroup Eina_File_Group File
@@ -109,121 +220,133 @@ void *alloca (size_t);
  * immediatly. otherwise, it returns #EINA_TRUE.
  */
 EAPI Eina_Bool
-eina_file_dir_list(const char *dir, Eina_Bool recursive, Eina_File_Dir_List_Cb cb, void *data)
+eina_file_dir_list(const char *dir,
+                   Eina_Bool recursive,
+                   Eina_File_Dir_List_Cb cb,
+                   void *data)
 {
 #ifndef _WIN32
-       struct dirent *de;
-       DIR *d;
+   struct dirent *de;
+   DIR *d;
 
-       EINA_SAFETY_ON_NULL_RETURN_VAL(cb, EINA_FALSE);
-       EINA_SAFETY_ON_NULL_RETURN_VAL(dir, EINA_FALSE);
-       EINA_SAFETY_ON_TRUE_RETURN_VAL(dir[0] == '\0', EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(cb,  EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(dir, EINA_FALSE);
+   EINA_SAFETY_ON_TRUE_RETURN_VAL(dir[0] == '\0', EINA_FALSE);
 
-       d = opendir(dir);
-       if (!d) return EINA_FALSE;
+   d = opendir(dir);
+   if (!d)
+      return EINA_FALSE;
 
-       while ((de = readdir(d)))
-       {
-               if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, ".."))
-                       continue;
+   while ((de = readdir(d)))
+     {
+        if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, ".."))
+           continue;
 
-               cb(de->d_name, dir, data);
-               /* d_type is only available on linux and bsd (_BSD_SOURCE) */
+        cb(de->d_name, dir, data);
+        /* d_type is only available on linux and bsd (_BSD_SOURCE) */
 
-               if (recursive == EINA_TRUE) {
-                       char *path;
+        if (recursive == EINA_TRUE)
+          {
+             char *path;
 
-                       path = alloca(strlen(dir) + strlen(de->d_name) + 2);
-                       strcpy(path, dir);
-                       strcat(path, "/");
-                       strcat(path, de->d_name);
+             path = alloca(strlen(dir) + strlen(de->d_name) + 2);
+             strcpy(path, dir);
+             strcat(path, "/");
+             strcat(path, de->d_name);
 #ifndef sun
-                       if (de->d_type == DT_UNKNOWN) {
+             if (de->d_type == DT_UNKNOWN)
+               {
 #endif
-                               struct stat st;
+             struct stat st;
 
-                               if (stat(path, &st))
-                                       continue ;
+             if (stat(path, &st))
+                continue;
+
+             if (!S_ISDIR(st.st_mode))
+                continue;
 
-                               if (!S_ISDIR(st.st_mode))
-                                       continue ;
 #ifndef sun
-                       } else if (de->d_type != DT_DIR) {
-                               continue ;
-                       }
+          }
+        else if (de->d_type != DT_DIR)
+           continue;
+
 #endif
 
-                       eina_file_dir_list(path, recursive, cb, data);
-               }
-       }
+             eina_file_dir_list(path, recursive, cb, data);
+          }
+     }
 
-       closedir(d);
+   closedir(d);
 #else
-       WIN32_FIND_DATA file;
-       HANDLE          hSearch;
-       char           *new_dir;
-       TCHAR          *tdir;
-       size_t          length_dir;
+   WIN32_FIND_DATA file;
+   HANDLE hSearch;
+   char *new_dir;
+   TCHAR *tdir;
+   size_t length_dir;
 
-       EINA_SAFETY_ON_NULL_RETURN_VAL(cb, EINA_FALSE);
-       EINA_SAFETY_ON_NULL_RETURN_VAL(dir, EINA_FALSE);
-       EINA_SAFETY_ON_TRUE_RETURN_VAL(dir[0] == '\0', EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(cb,  EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(dir, EINA_FALSE);
+   EINA_SAFETY_ON_TRUE_RETURN_VAL(dir[0] == '\0', EINA_FALSE);
 
-       length_dir = strlen(dir);
-       new_dir = (char *)alloca(length_dir + 5);
-       if (!new_dir) return EINA_FALSE;
+   length_dir = strlen(dir);
+   new_dir = (char *)alloca(length_dir + 5);
+   if (!new_dir)
+      return EINA_FALSE;
 
-       memcpy(new_dir, dir, length_dir);
-       memcpy(new_dir + length_dir, "/*.*", 5);
+   memcpy(new_dir,              dir,    length_dir);
+   memcpy(new_dir + length_dir, "/*.*", 5);
 
 #ifdef UNICODE
-       tdir =  evil_char_to_wchar(new_dir);
+   tdir = evil_char_to_wchar(new_dir);
 #else
-       tdir = new_dir;
+   tdir = new_dir;
 #endif /* ! UNICODE */
-       hSearch = FindFirstFile(tdir, &file);
+   hSearch = FindFirstFile(tdir, &file);
 #ifdef UNICODE
-       free(tdir);
+   free(tdir);
 #endif /* UNICODE */
 
-       if (hSearch == INVALID_HANDLE_VALUE) return EINA_FALSE;
+   if (hSearch == INVALID_HANDLE_VALUE)
+      return EINA_FALSE;
 
-       do
-       {
-               char *filename;
+   do
+     {
+        char *filename;
 
 #ifdef UNICODE
-               filename = evil_wchar_to_char(file.cFileName);
+        filename = evil_wchar_to_char(file.cFileName);
 #else
-               filename = file.cFileName;
+        filename = file.cFileName;
 #endif /* ! UNICODE */
-               if (!strcmp(filename, ".") || !strcmp(filename, ".."))
-                       continue;
+        if (!strcmp(filename, ".") || !strcmp(filename, ".."))
+           continue;
 
-               cb(filename, dir, data);
+        cb(filename, dir, data);
 
-               if (recursive == EINA_TRUE) {
-                       char *path;
+        if (recursive == EINA_TRUE)
+          {
+             char *path;
 
-                       path = alloca(strlen(dir) + strlen(filename) + 2);
-                       strcpy(path, dir);
-                       strcat(path, "/");
-                       strcat(path, filename);
+             path = alloca(strlen(dir) + strlen(filename) + 2);
+             strcpy(path, dir);
+             strcat(path, "/");
+             strcat(path, filename);
 
-                       if (!(file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
-                               continue ;
+             if (!(file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
+                continue;
+
+             eina_file_dir_list(path, recursive, cb, data);
+          }
 
-                       eina_file_dir_list(path, recursive, cb, data);
-               }
 #ifdef UNICODE
-               free(filename);
+        free(filename);
 #endif /* UNICODE */
 
-       } while (FindNextFile(hSearch, &file));
-       FindClose(hSearch);
+     } while (FindNextFile(hSearch, &file));
+   FindClose(hSearch);
 #endif /* _WIN32 */
 
-       return EINA_TRUE;
+   return EINA_TRUE;
 }
 
 /**
@@ -240,32 +363,174 @@ eina_file_dir_list(const char *dir, Eina_Bool recursive, Eina_File_Dir_List_Cb c
 EAPI Eina_Array *
 eina_file_split(char *path)
 {
-       Eina_Array *ea;
-       char *current;
-       size_t length;
+   Eina_Array *ea;
+   char *current;
+   size_t length;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
 
-       EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
+   ea = eina_array_new(16);
 
-       ea = eina_array_new(16);
+   if (!ea)
+      return NULL;
 
-       if (!ea) return NULL;
+   for (current = strchr(path, PATH_DELIM);
+        current != NULL;
+        path = current + 1, current = strchr(path, PATH_DELIM))
+     {
+        length = current - path;
 
-       for (current = strchr(path, PATH_DELIM);
-            current != NULL;
-            path = current + 1, current = strchr(path, PATH_DELIM))
-       {
-               length = current - path;
+        if (length <= 0)
+           continue;
 
-               if (length <= 0) continue ;
+        eina_array_push(ea, path);
+        *current = '\0';
+     }
 
-               eina_array_push(ea, path);
-               *current = '\0';
-       }
+   if (*path != '\0')
+        eina_array_push(ea, path);
 
-       if (*path != '\0')
-               eina_array_push(ea, path);
+   return ea;
+}
+
+/**
+ * Get an iterator to list the content of a directory.
+ *
+ * Iterators are cheap to be created and allow interruption at any
+ * iteration. At each iteration, only the next directory entry is read
+ * from the filesystem with readdir().
+ *
+ * The iterator will handle the user a stringshared value with the
+ * full path. One must call eina_stringshare_del() on it after usage
+ * to not leak!
+ *
+ * The eina_file_direct_ls() function will provide a possibly faster
+ * alternative if you need to filter the results somehow, like
+ * checking extension.
+ *
+ * The iterator will walk over '.' and '..' without returning them.
+ *
+ * @param  dir The name of the directory to list
+ * @return Return an Eina_Iterator that will walk over the files and
+ *         directory in the pointed directory. On failure it will
+ *         return NULL. The iterator emits stringshared value with the
+ *         full path and must be freed with eina_stringshare_del().
+ *
+ * @see eina_file_direct_ls()
+ */
+EAPI Eina_Iterator *
+eina_file_ls(const char *dir)
+{
+   Eina_File_Iterator *it;
+   size_t length;
+
+   if (!dir)
+      return NULL;
+
+   length = strlen(dir);
+   if (length < 1)
+      return NULL;
+
+   it = calloc(1, sizeof (Eina_File_Iterator) + length);
+   if (!it)
+      return NULL;
+
+   EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
+
+   it->dirp = opendir(dir);
+   if (!it->dirp)
+     {
+        free(it);
+        return NULL;
+     }
+
+   memcpy(it->dir, dir, length + 1);
+   if (dir[length - 1] != '/')
+      it->length = length;
+   else
+      it->length = length - 1;
+
+   it->iterator.version = EINA_ITERATOR_VERSION;
+   it->iterator.next = FUNC_ITERATOR_NEXT(_eina_file_ls_iterator_next);
+   it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
+         _eina_file_ls_iterator_container);
+   it->iterator.free = FUNC_ITERATOR_FREE(_eina_file_ls_iterator_free);
+
+   return &it->iterator;
+}
 
-       return ea;
+/**
+ * Get an iterator to list the content of a directory, with direct information.
+ *
+ * Iterators are cheap to be created and allow interruption at any
+ * iteration. At each iteration, only the next directory entry is read
+ * from the filesystem with readdir().
+ *
+ * The iterator returns the direct pointer to couple of useful information in
+ * #Eina_File_Direct_Info and that pointer should not be modified anyhow!
+ *
+ * The iterator will walk over '.' and '..' without returning them.
+ *
+ * @param  dir The name of the directory to list
+
+ * @return Return an Eina_Iterator that will walk over the files and
+ *         directory in the pointed directory. On failure it will
+ *         return NULL. The iterator emits #Eina_File_Direct_Info
+ *         pointers that could be used but not modified. The lifetime
+ *         of the returned pointer is until the next iteration and
+ *         while the iterator is live, deleting the iterator
+ *         invalidates the pointer.
+ *
+ * @see eina_file_ls()
+ */
+EAPI Eina_Iterator *
+eina_file_direct_ls(const char *dir)
+{
+   Eina_File_Direct_Iterator *it;
+   size_t length;
+
+   if (!dir)
+      return NULL;
+
+   length = strlen(dir);
+   if (length < 1)
+      return NULL;
+
+   if (length + NAME_MAX + 2 >= PATH_MAX)
+      return NULL;
+
+   it = calloc(1, sizeof(Eina_File_Direct_Iterator) + length);
+   if (!it)
+      return NULL;
+
+   EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
+
+   it->dirp = opendir(dir);
+   if (!it->dirp)
+     {
+        free(it);
+        return NULL;
+     }
+
+   memcpy(it->dir,       dir, length + 1);
+   it->length = length;
+
+   memcpy(it->info.path, dir, length);
+   if (dir[length - 1] == '/')
+      it->info.name_start = length;
+   else
+     {
+        it->info.path[length] = '/';
+        it->info.name_start = length + 1;
+     }
+
+   it->iterator.version = EINA_ITERATOR_VERSION;
+   it->iterator.next = FUNC_ITERATOR_NEXT(_eina_file_direct_ls_iterator_next);
+   it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
+         _eina_file_direct_ls_iterator_container);
+   it->iterator.free = FUNC_ITERATOR_FREE(_eina_file_direct_ls_iterator_free);
+
+   return &it->iterator;
 }
 
 /**
index 1ade0b8..73a2df0 100644 (file)
 
 #define MAX_PREC 1025
 static const Eina_F32p32 eina_trigo[MAX_PREC] =
-  {
-    0x0000000100000000, 0x00000000ffffec43, 0x00000000ffffb10b, 0x00000000ffff4e5a, 0x00000000fffec42e, 0x00000000fffe1287, 0x00000000fffd3967, 0x00000000fffc38cd, 0x00000000fffb10b9, 0x00000000fff9c12c,
-    0x00000000fff84a25, 0x00000000fff6aba5, 0x00000000fff4e5ac, 0x00000000fff2f83b, 0x00000000fff0e351, 0x00000000ffeea6ef, 0x00000000ffec4316, 0x00000000ffe9b7c5, 0x00000000ffe704fe, 0x00000000ffe42ac0,
-    0x00000000ffe1290b, 0x00000000ffddffe2, 0x00000000ffdaaf43, 0x00000000ffd7372f, 0x00000000ffd397a8, 0x00000000ffcfd0ad, 0x00000000ffcbe23f, 0x00000000ffc7cc5f, 0x00000000ffc38f0d, 0x00000000ffbf2a4b,
-    0x00000000ffba9e17, 0x00000000ffb5ea75, 0x00000000ffb10f63, 0x00000000ffac0ce3, 0x00000000ffa6e2f6, 0x00000000ffa1919c, 0x00000000ff9c18d6, 0x00000000ff9678a6, 0x00000000ff90b10b, 0x00000000ff8ac208,
-    0x00000000ff84ab9c, 0x00000000ff7e6dc8, 0x00000000ff78088f, 0x00000000ff717bf0, 0x00000000ff6ac7ec, 0x00000000ff63ec85, 0x00000000ff5ce9bc, 0x00000000ff55bf92, 0x00000000ff4e6e08, 0x00000000ff46f51f,
-    0x00000000ff3f54d8, 0x00000000ff378d34, 0x00000000ff2f9e35, 0x00000000ff2787dc, 0x00000000ff1f4a2a, 0x00000000ff16e520, 0x00000000ff0e58c0, 0x00000000ff05a50a, 0x00000000fefcca01, 0x00000000fef3c7a6,
-    0x00000000feea9df9, 0x00000000fee14cfe, 0x00000000fed7d4b3, 0x00000000fece351d, 0x00000000fec46e3b, 0x00000000feba800f, 0x00000000feb06a9c, 0x00000000fea62de1, 0x00000000fe9bc9e2, 0x00000000fe913e9f,
-    0x00000000fe868c1b, 0x00000000fe7bb256, 0x00000000fe70b153, 0x00000000fe658913, 0x00000000fe5a3998, 0x00000000fe4ec2e4, 0x00000000fe4324f9, 0x00000000fe375fd7, 0x00000000fe2b7382, 0x00000000fe1f5ffa,
-    0x00000000fe132543, 0x00000000fe06c35d, 0x00000000fdfa3a4b, 0x00000000fded8a0e, 0x00000000fde0b2a8, 0x00000000fdd3b41c, 0x00000000fdc68e6c, 0x00000000fdb94199, 0x00000000fdabcda5, 0x00000000fd9e3294,
-    0x00000000fd907065, 0x00000000fd82871d, 0x00000000fd7476bd, 0x00000000fd663f46, 0x00000000fd57e0bd, 0x00000000fd495b21, 0x00000000fd3aae77, 0x00000000fd2bdabf, 0x00000000fd1cdffd, 0x00000000fd0dbe32,
-    0x00000000fcfe7562, 0x00000000fcef058e, 0x00000000fcdf6eb8, 0x00000000fccfb0e4, 0x00000000fcbfcc13, 0x00000000fcafc048, 0x00000000fc9f8d86, 0x00000000fc8f33ce, 0x00000000fc7eb325, 0x00000000fc6e0b8b,
-    0x00000000fc5d3d03, 0x00000000fc4c4791, 0x00000000fc3b2b37, 0x00000000fc29e7f7, 0x00000000fc187dd5, 0x00000000fc06ecd2, 0x00000000fbf534f2, 0x00000000fbe35637, 0x00000000fbd150a3, 0x00000000fbbf243b,
-    0x00000000fbacd100, 0x00000000fb9a56f6, 0x00000000fb87b61f, 0x00000000fb74ee7e, 0x00000000fb620016, 0x00000000fb4eeaea, 0x00000000fb3baefd, 0x00000000fb284c52, 0x00000000fb14c2eb, 0x00000000fb0112cd,
-    0x00000000faed3bf9, 0x00000000fad93e73, 0x00000000fac51a3f, 0x00000000fab0cf5e, 0x00000000fa9c5dd5, 0x00000000fa87c5a6, 0x00000000fa7306d5, 0x00000000fa5e2164, 0x00000000fa491558, 0x00000000fa33e2b3,
-    0x00000000fa1e8978, 0x00000000fa0909ab, 0x00000000f9f36350, 0x00000000f9dd9668, 0x00000000f9c7a2f9, 0x00000000f9b18905, 0x00000000f99b488f, 0x00000000f984e19c, 0x00000000f96e542e, 0x00000000f957a049,
-    0x00000000f940c5f1, 0x00000000f929c528, 0x00000000f9129df3, 0x00000000f8fb5056, 0x00000000f8e3dc53, 0x00000000f8cc41ee, 0x00000000f8b4812b, 0x00000000f89c9a0e, 0x00000000f8848c9b, 0x00000000f86c58d4,
-    0x00000000f853febe, 0x00000000f83b7e5d, 0x00000000f822d7b4, 0x00000000f80a0ac7, 0x00000000f7f1179a, 0x00000000f7d7fe31, 0x00000000f7bebe90, 0x00000000f7a558ba, 0x00000000f78bccb3, 0x00000000f7721a80,
-    0x00000000f7584225, 0x00000000f73e43a5, 0x00000000f7241f04, 0x00000000f709d446, 0x00000000f6ef6370, 0x00000000f6d4cc85, 0x00000000f6ba0f8a, 0x00000000f69f2c83, 0x00000000f6842374, 0x00000000f668f461,
-    0x00000000f64d9f4e, 0x00000000f632243f, 0x00000000f616833a, 0x00000000f5fabc41, 0x00000000f5decf59, 0x00000000f5c2bc87, 0x00000000f5a683cf, 0x00000000f58a2535, 0x00000000f56da0be, 0x00000000f550f66e,
-    0x00000000f5342649, 0x00000000f5173054, 0x00000000f4fa1494, 0x00000000f4dcd30c, 0x00000000f4bf6bc2, 0x00000000f4a1deb9, 0x00000000f4842bf7, 0x00000000f4665380, 0x00000000f4485559, 0x00000000f42a3186,
-    0x00000000f40be80c, 0x00000000f3ed78ef, 0x00000000f3cee434, 0x00000000f3b029e1, 0x00000000f39149f9, 0x00000000f3724482, 0x00000000f3531980, 0x00000000f333c8f8, 0x00000000f31452ef, 0x00000000f2f4b76a,
-    0x00000000f2d4f66d, 0x00000000f2b50ffe, 0x00000000f2950421, 0x00000000f274d2dc, 0x00000000f2547c33, 0x00000000f234002b, 0x00000000f2135eca, 0x00000000f1f29814, 0x00000000f1d1ac0e, 0x00000000f1b09abe,
-    0x00000000f18f6429, 0x00000000f16e0853, 0x00000000f14c8742, 0x00000000f12ae0fb, 0x00000000f1091583, 0x00000000f0e724e0, 0x00000000f0c50f17, 0x00000000f0a2d42c, 0x00000000f0807426, 0x00000000f05def09,
-    0x00000000f03b44db, 0x00000000f01875a1, 0x00000000eff58161, 0x00000000efd2681f, 0x00000000efaf29e2, 0x00000000ef8bc6af, 0x00000000ef683e8b, 0x00000000ef44917b, 0x00000000ef20bf86, 0x00000000eefcc8b1,
-    0x00000000eed8ad01, 0x00000000eeb46c7b, 0x00000000ee900727, 0x00000000ee6b7d08, 0x00000000ee46ce25, 0x00000000ee21fa83, 0x00000000edfd0228, 0x00000000edd7e51a, 0x00000000edb2a35f, 0x00000000ed8d3cfc,
-    0x00000000ed67b1f6, 0x00000000ed420255, 0x00000000ed1c2e1d, 0x00000000ecf63554, 0x00000000ecd01801, 0x00000000eca9d628, 0x00000000ec836fd1, 0x00000000ec5ce501, 0x00000000ec3635bd, 0x00000000ec0f620d,
-    0x00000000ebe869f5, 0x00000000ebc14d7d, 0x00000000eb9a0ca9, 0x00000000eb72a780, 0x00000000eb4b1e08, 0x00000000eb237047, 0x00000000eafb9e43, 0x00000000ead3a803, 0x00000000eaab8d8d, 0x00000000ea834ee6,
-    0x00000000ea5aec15, 0x00000000ea326520, 0x00000000ea09ba0d, 0x00000000e9e0eae4, 0x00000000e9b7f7a9, 0x00000000e98ee063, 0x00000000e965a51a, 0x00000000e93c45d2, 0x00000000e912c292, 0x00000000e8e91b61,
-    0x00000000e8bf5046, 0x00000000e8956146, 0x00000000e86b4e68, 0x00000000e84117b3, 0x00000000e816bd2d, 0x00000000e7ec3edc, 0x00000000e7c19cc8, 0x00000000e796d6f6, 0x00000000e76bed6e, 0x00000000e740e036,
-    0x00000000e715af54, 0x00000000e6ea5ad0, 0x00000000e6bee2af, 0x00000000e69346f9, 0x00000000e66787b5, 0x00000000e63ba4e9, 0x00000000e60f9e9b, 0x00000000e5e374d4, 0x00000000e5b72798, 0x00000000e58ab6f1,
-    0x00000000e55e22e3, 0x00000000e5316b76, 0x00000000e50490b1, 0x00000000e4d7929c, 0x00000000e4aa713c, 0x00000000e47d2c98, 0x00000000e44fc4b9, 0x00000000e42239a4, 0x00000000e3f48b61, 0x00000000e3c6b9f7,
-    0x00000000e398c56c, 0x00000000e36aadc9, 0x00000000e33c7314, 0x00000000e30e1554, 0x00000000e2df9490, 0x00000000e2b0f0d0, 0x00000000e2822a1a, 0x00000000e2534077, 0x00000000e22433ec, 0x00000000e1f50482,
-    0x00000000e1c5b240, 0x00000000e1963d2d, 0x00000000e166a550, 0x00000000e136eab0, 0x00000000e1070d56, 0x00000000e0d70d48, 0x00000000e0a6ea8e, 0x00000000e076a52f, 0x00000000e0463d33, 0x00000000e015b2a1,
-    0x00000000dfe50580, 0x00000000dfb435d9, 0x00000000df8343b2, 0x00000000df522f13, 0x00000000df20f804, 0x00000000deef9e8d, 0x00000000debe22b5, 0x00000000de8c8483, 0x00000000de5ac3ff, 0x00000000de28e131,
-    0x00000000ddf6dc21, 0x00000000ddc4b4d6, 0x00000000dd926b59, 0x00000000dd5fffb0, 0x00000000dd2d71e3, 0x00000000dcfac1fb, 0x00000000dcc7f000, 0x00000000dc94fbf8, 0x00000000dc61e5ec, 0x00000000dc2eade4,
-    0x00000000dbfb53e8, 0x00000000dbc7d7ff, 0x00000000db943a31, 0x00000000db607a88, 0x00000000db2c9909, 0x00000000daf895bf, 0x00000000dac470af, 0x00000000da9029e3, 0x00000000da5bc163, 0x00000000da273737,
-    0x00000000d9f28b66, 0x00000000d9bdbdf9, 0x00000000d988cef8, 0x00000000d953be6b, 0x00000000d91e8c5b, 0x00000000d8e938d0, 0x00000000d8b3c3d1, 0x00000000d87e2d67, 0x00000000d848759b, 0x00000000d8129c74,
-    0x00000000d7dca1fb, 0x00000000d7a68638, 0x00000000d7704934, 0x00000000d739eaf7, 0x00000000d7036b89, 0x00000000d6cccaf3, 0x00000000d696093d, 0x00000000d65f266f, 0x00000000d6282293, 0x00000000d5f0fdb0,
-    0x00000000d5b9b7d0, 0x00000000d58250fa, 0x00000000d54ac937, 0x00000000d513208f, 0x00000000d4db570c, 0x00000000d4a36cb6, 0x00000000d46b6195, 0x00000000d43335b3, 0x00000000d3fae917, 0x00000000d3c27bcb,
-    0x00000000d389edd7, 0x00000000d3513f43, 0x00000000d318701a, 0x00000000d2df8063, 0x00000000d2a67027, 0x00000000d26d3f6f, 0x00000000d233ee43, 0x00000000d1fa7cae, 0x00000000d1c0eab7, 0x00000000d1873867,
-    0x00000000d14d65c8, 0x00000000d11372e1, 0x00000000d0d95fbd, 0x00000000d09f2c64, 0x00000000d064d8df, 0x00000000d02a6537, 0x00000000cfefd176, 0x00000000cfb51da3, 0x00000000cf7a49c8, 0x00000000cf3f55ef,
-    0x00000000cf044220, 0x00000000cec90e64, 0x00000000ce8dbac5, 0x00000000ce52474c, 0x00000000ce16b401, 0x00000000cddb00ef, 0x00000000cd9f2e1e, 0x00000000cd633b97, 0x00000000cd272964, 0x00000000cceaf78e,
-    0x00000000ccaea61e, 0x00000000cc72351e, 0x00000000cc35a497, 0x00000000cbf8f492, 0x00000000cbbc2519, 0x00000000cb7f3634, 0x00000000cb4227ee, 0x00000000cb04fa50, 0x00000000cac7ad63, 0x00000000ca8a4131,
-    0x00000000ca4cb5c3, 0x00000000ca0f0b22, 0x00000000c9d14159, 0x00000000c9935870, 0x00000000c9555072, 0x00000000c9172967, 0x00000000c8d8e35a, 0x00000000c89a7e53, 0x00000000c85bfa5e, 0x00000000c81d5782,
-    0x00000000c7de95cb, 0x00000000c79fb541, 0x00000000c760b5ee, 0x00000000c72197dc, 0x00000000c6e25b15, 0x00000000c6a2ffa3, 0x00000000c663858f, 0x00000000c623ece2, 0x00000000c5e435a8, 0x00000000c5a45fe9,
-    0x00000000c5646bb0, 0x00000000c5245906, 0x00000000c4e427f6, 0x00000000c4a3d888, 0x00000000c4636ac8, 0x00000000c422debf, 0x00000000c3e23476, 0x00000000c3a16bf9, 0x00000000c3608550, 0x00000000c31f8087,
-    0x00000000c2de5da6, 0x00000000c29d1cb8, 0x00000000c25bbdc8, 0x00000000c21a40de, 0x00000000c1d8a606, 0x00000000c196ed49, 0x00000000c15516b2, 0x00000000c113224a, 0x00000000c0d1101d, 0x00000000c08ee033,
-    0x00000000c04c9297, 0x00000000c00a2754, 0x00000000bfc79e73, 0x00000000bf84f800, 0x00000000bf423404, 0x00000000beff5289, 0x00000000bebc539a, 0x00000000be793741, 0x00000000be35fd89, 0x00000000bdf2a67b,
-    0x00000000bdaf3223, 0x00000000bd6ba08b, 0x00000000bd27f1bc, 0x00000000bce425c2, 0x00000000bca03ca7, 0x00000000bc5c3676, 0x00000000bc181338, 0x00000000bbd3d2f9, 0x00000000bb8f75c3, 0x00000000bb4afba1,
-    0x00000000bb06649c, 0x00000000bac1b0c0, 0x00000000ba7ce018, 0x00000000ba37f2ad, 0x00000000b9f2e88b, 0x00000000b9adc1bc, 0x00000000b9687e4a, 0x00000000b9231e41, 0x00000000b8dda1ac, 0x00000000b8980894,
-    0x00000000b8525305, 0x00000000b80c8109, 0x00000000b7c692ac, 0x00000000b78087f7, 0x00000000b73a60f6, 0x00000000b6f41db4, 0x00000000b6adbe3a, 0x00000000b6674296, 0x00000000b620aad0, 0x00000000b5d9f6f4,
-    0x00000000b593270e, 0x00000000b54c3b27, 0x00000000b505334a, 0x00000000b4be0f84, 0x00000000b476cfde, 0x00000000b42f7464, 0x00000000b3e7fd20, 0x00000000b3a06a1e, 0x00000000b358bb69, 0x00000000b310f10c,
-    0x00000000b2c90b11, 0x00000000b2810985, 0x00000000b238ec71, 0x00000000b1f0b3e2, 0x00000000b1a85fe2, 0x00000000b15ff07c, 0x00000000b11765bc, 0x00000000b0cebfad, 0x00000000b085fe5a, 0x00000000b03d21ce,
-    0x00000000aff42a15, 0x00000000afab1739, 0x00000000af61e946, 0x00000000af18a048, 0x00000000aecf3c49, 0x00000000ae85bd55, 0x00000000ae3c2377, 0x00000000adf26ebb, 0x00000000ada89f2c, 0x00000000ad5eb4d5,
-    0x00000000ad14afc2, 0x00000000acca8ffd, 0x00000000ac805594, 0x00000000ac360090, 0x00000000abeb90fe, 0x00000000aba106e9, 0x00000000ab56625d, 0x00000000ab0ba364, 0x00000000aac0ca0b, 0x00000000aa75d65d,
-    0x00000000aa2ac865, 0x00000000a9dfa030, 0x00000000a9945dc9, 0x00000000a949013a, 0x00000000a8fd8a91, 0x00000000a8b1f9d8, 0x00000000a8664f1c, 0x00000000a81a8a68, 0x00000000a7ceabc7, 0x00000000a782b345,
-    0x00000000a736a0ef, 0x00000000a6ea74cf, 0x00000000a69e2ef2, 0x00000000a651cf63, 0x00000000a605562f, 0x00000000a5b8c360, 0x00000000a56c1702, 0x00000000a51f5123, 0x00000000a4d271cc, 0x00000000a485790b,
-    0x00000000a43866eb, 0x00000000a3eb3b77, 0x00000000a39df6bd, 0x00000000a35098c7, 0x00000000a30321a2, 0x00000000a2b5915a, 0x00000000a267e7fa, 0x00000000a21a258e, 0x00000000a1cc4a24, 0x00000000a17e55c5,
-    0x00000000a1304880, 0x00000000a0e2225f, 0x00000000a093e36f, 0x00000000a0458bbb, 0x000000009ff71b50, 0x000000009fa8923a, 0x000000009f59f086, 0x000000009f0b363e, 0x000000009ebc6370, 0x000000009e6d7827,
-    0x000000009e1e746f, 0x000000009dcf5856, 0x000000009d8023e6, 0x000000009d30d72d, 0x000000009ce17236, 0x000000009c91f50e, 0x000000009c425fc1, 0x000000009bf2b25b, 0x000000009ba2ece8, 0x000000009b530f76,
-    0x000000009b031a0f, 0x000000009ab30cc1, 0x000000009a62e797, 0x000000009a12aa9f, 0x0000000099c255e5, 0x000000009971e974, 0x000000009921655a, 0x0000000098d0c9a2, 0x0000000098801659, 0x00000000982f4b8d,
-    0x0000000097de6948, 0x00000000978d6f97, 0x00000000973c5e88, 0x0000000096eb3626, 0x000000009699f67f, 0x0000000096489f9e, 0x0000000095f73190, 0x0000000095a5ac61, 0x000000009554101f, 0x0000000095025cd6,
-    0x0000000094b09292, 0x00000000945eb161, 0x00000000940cb94e, 0x0000000093baaa66, 0x00000000936884b6, 0x000000009316484b, 0x0000000092c3f531, 0x0000000092718b75, 0x00000000921f0b24, 0x0000000091cc744b,
-    0x000000009179c6f5, 0x0000000091270331, 0x0000000090d4290a, 0x000000009081388e, 0x00000000902e31c8, 0x000000008fdb14c7, 0x000000008f87e197, 0x000000008f349845, 0x000000008ee138dd, 0x000000008e8dc36c,
-    0x000000008e3a3800, 0x000000008de696a5, 0x000000008d92df68, 0x000000008d3f1256, 0x000000008ceb2f7c, 0x000000008c9736e7, 0x000000008c4328a3, 0x000000008bef04bf, 0x000000008b9acb46, 0x000000008b467c45,
-    0x000000008af217cb, 0x000000008a9d9de3, 0x000000008a490e9b, 0x0000000089f469ff, 0x00000000899fb01e, 0x00000000894ae103, 0x0000000088f5fcbc, 0x0000000088a10357, 0x00000000884bf4df, 0x0000000087f6d163,
-    0x0000000087a198f0, 0x00000000874c4b92, 0x0000000086f6e956, 0x0000000086a1724b, 0x00000000864be67c, 0x0000000085f645f8, 0x0000000085a090cc, 0x00000000854ac704, 0x0000000084f4e8ad, 0x00000000849ef5d7,
-    0x000000008448ee8c, 0x0000000083f2d2db, 0x00000000839ca2d1, 0x0000000083465e7c, 0x0000000082f005e8, 0x0000000082999922, 0x0000000082431839, 0x0000000081ec833a, 0x000000008195da31, 0x00000000813f1d2d,
-    0x0000000080e84c3a, 0x0000000080916766, 0x00000000803a6ebf, 0x000000007fe36251, 0x000000007f8c422b, 0x000000007f350e59, 0x000000007eddc6ea, 0x000000007e866bea, 0x000000007e2efd67, 0x000000007dd77b6f,
-    0x000000007d7fe60f, 0x000000007d283d54, 0x000000007cd0814c, 0x000000007c78b205, 0x000000007c20cf8c, 0x000000007bc8d9ef, 0x000000007b70d13b, 0x000000007b18b57e, 0x000000007ac086c5, 0x000000007a68451f,
-    0x000000007a0ff098, 0x0000000079b7893e, 0x00000000795f0f1f, 0x0000000079068248, 0x0000000078ade2c8, 0x00000000785530ab, 0x0000000077fc6c01, 0x0000000077a394d5, 0x00000000774aab36, 0x0000000076f1af32,
-    0x000000007698a0d6, 0x00000000763f8030, 0x0000000075e64d4e, 0x00000000758d083e, 0x000000007533b10d, 0x0000000074da47c9, 0x000000007480cc80, 0x0000000074273f3f, 0x0000000073cda016, 0x000000007373ef10,
-    0x00000000731a2c3d, 0x0000000072c057aa, 0x0000000072667164, 0x00000000720c797a, 0x0000000071b26ffa, 0x00000000715854f2, 0x0000000070fe286e, 0x0000000070a3ea7e, 0x0000000070499b30, 0x000000006fef3a90,
-    0x000000006f94c8ae, 0x000000006f3a4596, 0x000000006edfb157, 0x000000006e850c00, 0x000000006e2a559d, 0x000000006dcf8e3d, 0x000000006d74b5ee, 0x000000006d19ccbe, 0x000000006cbed2bb, 0x000000006c63c7f3,
-    0x000000006c08ac74, 0x000000006bad804c, 0x000000006b524389, 0x000000006af6f639, 0x000000006a9b986b, 0x000000006a402a2c, 0x0000000069e4ab8a, 0x0000000069891c94, 0x00000000692d7d57, 0x0000000068d1cde3,
-    0x0000000068760e44, 0x00000000681a3e89, 0x0000000067be5ec1, 0x0000000067626ef9, 0x0000000067066f40, 0x0000000066aa5fa3, 0x00000000664e4032, 0x0000000065f210f9, 0x000000006595d209, 0x000000006539836d,
-    0x0000000064dd2536, 0x000000006480b770, 0x0000000064243a2b, 0x0000000063c7ad75, 0x00000000636b115c, 0x00000000630e65ed, 0x0000000062b1ab39, 0x000000006254e14c, 0x0000000061f80835, 0x00000000619b2002,
-    0x00000000613e28c2, 0x0000000060e12283, 0x0000000060840d54, 0x000000006026e943, 0x000000005fc9b65d, 0x000000005f6c74b2, 0x000000005f0f2450, 0x000000005eb1c545, 0x000000005e5457a0, 0x000000005df6db6f,
-    0x000000005d9950c0, 0x000000005d3bb7a3, 0x000000005cde1024, 0x000000005c805a54, 0x000000005c22963f, 0x000000005bc4c3f6, 0x000000005b66e385, 0x000000005b08f4fd, 0x000000005aaaf86a, 0x000000005a4ceddc,
-    0x0000000059eed561, 0x000000005990af08, 0x0000000059327adf, 0x0000000058d438f4, 0x000000005875e957, 0x0000000058178c16, 0x0000000057b9213f, 0x00000000575aa8e0, 0x0000000056fc230a, 0x00000000569d8fc9,
-    0x00000000563eef2d, 0x0000000055e04144, 0x000000005581861d, 0x000000005522bdc6, 0x0000000054c3e84e, 0x00000000546505c4, 0x0000000054061636, 0x0000000053a719b3, 0x000000005348104a, 0x0000000052e8fa09,
-    0x000000005289d6ff, 0x00000000522aa73a, 0x0000000051cb6aca, 0x00000000516c21bc, 0x00000000510ccc20, 0x0000000050ad6a05, 0x00000000504dfb78, 0x000000004fee808a, 0x000000004f8ef947, 0x000000004f2f65c0,
-    0x000000004ecfc603, 0x000000004e701a1f, 0x000000004e106222, 0x000000004db09e1b, 0x000000004d50ce19, 0x000000004cf0f22b, 0x000000004c910a5f, 0x000000004c3116c5, 0x000000004bd1176b, 0x000000004b710c5f,
-    0x000000004b10f5b2, 0x000000004ab0d371, 0x000000004a50a5ab, 0x0000000049f06c70, 0x00000000499027cd, 0x00000000492fd7d3, 0x0000000048cf7c8f, 0x00000000486f1611, 0x00000000480ea467, 0x0000000047ae27a1,
-    0x00000000474d9fcd, 0x0000000046ed0cfa, 0x00000000468c6f37, 0x00000000462bc693, 0x0000000045cb131c, 0x00000000456a54e3, 0x0000000045098bf5, 0x0000000044a8b861, 0x000000004447da37, 0x0000000043e6f186,
-    0x000000004385fe5c, 0x00000000432500c8, 0x0000000042c3f8d9, 0x000000004262e69f, 0x000000004201ca28, 0x0000000041a0a383, 0x00000000413f72bf, 0x0000000040de37eb, 0x00000000407cf317, 0x00000000401ba450,
-    0x000000003fba4ba7, 0x000000003f58e92a, 0x000000003ef77ce8, 0x000000003e9606f1, 0x000000003e348752, 0x000000003dd2fe1c, 0x000000003d716b5e, 0x000000003d0fcf25, 0x000000003cae2982, 0x000000003c4c7a83,
-    0x000000003beac238, 0x000000003b8900b0, 0x000000003b2735f9, 0x000000003ac56223, 0x000000003a63853d, 0x000000003a019f56, 0x00000000399fb07d, 0x00000000393db8c1, 0x0000000038dbb831, 0x000000003879aedd,
-    0x0000000038179cd3, 0x0000000037b58222, 0x0000000037535edb, 0x0000000036f1330b, 0x00000000368efec2, 0x00000000362cc20f, 0x0000000035ca7d02, 0x0000000035682fa9, 0x000000003505da14, 0x0000000034a37c51,
-    0x0000000034411671, 0x0000000033dea881, 0x00000000337c3292, 0x000000003319b4b3, 0x0000000032b72ef2, 0x000000003254a15e, 0x0000000031f20c08, 0x00000000318f6efe, 0x00000000312cca50, 0x0000000030ca1e0c,
-    0x0000000030676a43, 0x000000003004af02, 0x000000002fa1ec5a, 0x000000002f3f2259, 0x000000002edc510f, 0x000000002e79788b, 0x000000002e1698dc, 0x000000002db3b212, 0x000000002d50c43c, 0x000000002cedcf68,
-    0x000000002c8ad3a7, 0x000000002c27d108, 0x000000002bc4c799, 0x000000002b61b76b, 0x000000002afea08c, 0x000000002a9b830b, 0x000000002a385ef9, 0x0000000029d53464, 0x000000002972035b, 0x00000000290ecbee,
-    0x0000000028ab8e2c, 0x0000000028484a25, 0x0000000027e4ffe7, 0x000000002781af83, 0x00000000271e5906, 0x0000000026bafc82, 0x0000000026579a04, 0x0000000025f4319d, 0x000000002590c35c, 0x00000000252d4f4f,
-    0x0000000024c9d587, 0x0000000024665613, 0x000000002402d101, 0x00000000239f4662, 0x00000000233bb644, 0x0000000022d820b8, 0x00000000227485cc, 0x000000002210e590, 0x0000000021ad4013, 0x0000000021499565,
-    0x0000000020e5e594, 0x00000000208230b1, 0x00000000201e76ca, 0x000000001fbab7ef, 0x000000001f56f430, 0x000000001ef32b9b, 0x000000001e8f5e41, 0x000000001e2b8c30, 0x000000001dc7b578, 0x000000001d63da29,
-    0x000000001cfffa51, 0x000000001c9c1600, 0x000000001c382d46, 0x000000001bd44032, 0x000000001b704ed3, 0x000000001b0c5939, 0x000000001aa85f74, 0x000000001a446191, 0x0000000019e05fa2, 0x00000000197c59b5,
-    0x0000000019184fdb, 0x0000000018b44221, 0x0000000018503098, 0x0000000017ec1b50, 0x0000000017880257, 0x000000001723e5bd, 0x0000000016bfc591, 0x00000000165ba1e4, 0x0000000015f77ac3, 0x0000000015935040,
-    0x00000000152f2269, 0x0000000014caf14d, 0x000000001466bcfd, 0x0000000014028587, 0x00000000139e4afb, 0x00000000133a0d69, 0x0000000012d5cce0, 0x000000001271896f, 0x00000000120d4326, 0x0000000011a8fa15,
-    0x000000001144ae4a, 0x0000000010e05fd6, 0x00000000107c0ec7, 0x000000001017bb2d, 0x000000000fb36519, 0x000000000f4f0c98, 0x000000000eeab1bb, 0x000000000e865491, 0x000000000e21f52a, 0x000000000dbd9395,
-    0x000000000d592fe1, 0x000000000cf4ca1f, 0x000000000c90625c, 0x000000000c2bf8aa, 0x000000000bc78d18, 0x000000000b631fb4, 0x000000000afeb08f, 0x000000000a9a3fb8, 0x000000000a35cd3e, 0x0000000009d15931,
-    0x00000000096ce3a1, 0x0000000009086c9c, 0x0000000008a3f433, 0x00000000083f7a75, 0x0000000007daff71, 0x0000000007768337, 0x00000000071205d6, 0x0000000006ad875f, 0x00000000064907df, 0x0000000005e48768,
-    0x0000000005800608, 0x00000000051b83cf, 0x0000000004b700cc, 0x0000000004527d0f, 0x0000000003edf8a7, 0x00000000038973a4, 0x000000000324ee16, 0x0000000002c0680b, 0x00000000025be194, 0x0000000001f75ac0,
-    0x000000000192d39e, 0x00000000012e4c3e, 0x0000000000c9c4af, 0x0000000000653d02, 0x0000000000000000
-  };
+{
+   0x0000000100000000, 0x00000000ffffec43, 0x00000000ffffb10b,
+   0x00000000ffff4e5a, 0x00000000fffec42e, 0x00000000fffe1287,
+   0x00000000fffd3967, 0x00000000fffc38cd, 0x00000000fffb10b9,
+   0x00000000fff9c12c,
+   0x00000000fff84a25, 0x00000000fff6aba5, 0x00000000fff4e5ac,
+   0x00000000fff2f83b, 0x00000000fff0e351, 0x00000000ffeea6ef,
+   0x00000000ffec4316, 0x00000000ffe9b7c5, 0x00000000ffe704fe,
+   0x00000000ffe42ac0,
+   0x00000000ffe1290b, 0x00000000ffddffe2, 0x00000000ffdaaf43,
+   0x00000000ffd7372f, 0x00000000ffd397a8, 0x00000000ffcfd0ad,
+   0x00000000ffcbe23f, 0x00000000ffc7cc5f, 0x00000000ffc38f0d,
+   0x00000000ffbf2a4b,
+   0x00000000ffba9e17, 0x00000000ffb5ea75, 0x00000000ffb10f63,
+   0x00000000ffac0ce3, 0x00000000ffa6e2f6, 0x00000000ffa1919c,
+   0x00000000ff9c18d6, 0x00000000ff9678a6, 0x00000000ff90b10b,
+   0x00000000ff8ac208,
+   0x00000000ff84ab9c, 0x00000000ff7e6dc8, 0x00000000ff78088f,
+   0x00000000ff717bf0, 0x00000000ff6ac7ec, 0x00000000ff63ec85,
+   0x00000000ff5ce9bc, 0x00000000ff55bf92, 0x00000000ff4e6e08,
+   0x00000000ff46f51f,
+   0x00000000ff3f54d8, 0x00000000ff378d34, 0x00000000ff2f9e35,
+   0x00000000ff2787dc, 0x00000000ff1f4a2a, 0x00000000ff16e520,
+   0x00000000ff0e58c0, 0x00000000ff05a50a, 0x00000000fefcca01,
+   0x00000000fef3c7a6,
+   0x00000000feea9df9, 0x00000000fee14cfe, 0x00000000fed7d4b3,
+   0x00000000fece351d, 0x00000000fec46e3b, 0x00000000feba800f,
+   0x00000000feb06a9c, 0x00000000fea62de1, 0x00000000fe9bc9e2,
+   0x00000000fe913e9f,
+   0x00000000fe868c1b, 0x00000000fe7bb256, 0x00000000fe70b153,
+   0x00000000fe658913, 0x00000000fe5a3998, 0x00000000fe4ec2e4,
+   0x00000000fe4324f9, 0x00000000fe375fd7, 0x00000000fe2b7382,
+   0x00000000fe1f5ffa,
+   0x00000000fe132543, 0x00000000fe06c35d, 0x00000000fdfa3a4b,
+   0x00000000fded8a0e, 0x00000000fde0b2a8, 0x00000000fdd3b41c,
+   0x00000000fdc68e6c, 0x00000000fdb94199, 0x00000000fdabcda5,
+   0x00000000fd9e3294,
+   0x00000000fd907065, 0x00000000fd82871d, 0x00000000fd7476bd,
+   0x00000000fd663f46, 0x00000000fd57e0bd, 0x00000000fd495b21,
+   0x00000000fd3aae77, 0x00000000fd2bdabf, 0x00000000fd1cdffd,
+   0x00000000fd0dbe32,
+   0x00000000fcfe7562, 0x00000000fcef058e, 0x00000000fcdf6eb8,
+   0x00000000fccfb0e4, 0x00000000fcbfcc13, 0x00000000fcafc048,
+   0x00000000fc9f8d86, 0x00000000fc8f33ce, 0x00000000fc7eb325,
+   0x00000000fc6e0b8b,
+   0x00000000fc5d3d03, 0x00000000fc4c4791, 0x00000000fc3b2b37,
+   0x00000000fc29e7f7, 0x00000000fc187dd5, 0x00000000fc06ecd2,
+   0x00000000fbf534f2, 0x00000000fbe35637, 0x00000000fbd150a3,
+   0x00000000fbbf243b,
+   0x00000000fbacd100, 0x00000000fb9a56f6, 0x00000000fb87b61f,
+   0x00000000fb74ee7e, 0x00000000fb620016, 0x00000000fb4eeaea,
+   0x00000000fb3baefd, 0x00000000fb284c52, 0x00000000fb14c2eb,
+   0x00000000fb0112cd,
+   0x00000000faed3bf9, 0x00000000fad93e73, 0x00000000fac51a3f,
+   0x00000000fab0cf5e, 0x00000000fa9c5dd5, 0x00000000fa87c5a6,
+   0x00000000fa7306d5, 0x00000000fa5e2164, 0x00000000fa491558,
+   0x00000000fa33e2b3,
+   0x00000000fa1e8978, 0x00000000fa0909ab, 0x00000000f9f36350,
+   0x00000000f9dd9668, 0x00000000f9c7a2f9, 0x00000000f9b18905,
+   0x00000000f99b488f, 0x00000000f984e19c, 0x00000000f96e542e,
+   0x00000000f957a049,
+   0x00000000f940c5f1, 0x00000000f929c528, 0x00000000f9129df3,
+   0x00000000f8fb5056, 0x00000000f8e3dc53, 0x00000000f8cc41ee,
+   0x00000000f8b4812b, 0x00000000f89c9a0e, 0x00000000f8848c9b,
+   0x00000000f86c58d4,
+   0x00000000f853febe, 0x00000000f83b7e5d, 0x00000000f822d7b4,
+   0x00000000f80a0ac7, 0x00000000f7f1179a, 0x00000000f7d7fe31,
+   0x00000000f7bebe90, 0x00000000f7a558ba, 0x00000000f78bccb3,
+   0x00000000f7721a80,
+   0x00000000f7584225, 0x00000000f73e43a5, 0x00000000f7241f04,
+   0x00000000f709d446, 0x00000000f6ef6370, 0x00000000f6d4cc85,
+   0x00000000f6ba0f8a, 0x00000000f69f2c83, 0x00000000f6842374,
+   0x00000000f668f461,
+   0x00000000f64d9f4e, 0x00000000f632243f, 0x00000000f616833a,
+   0x00000000f5fabc41, 0x00000000f5decf59, 0x00000000f5c2bc87,
+   0x00000000f5a683cf, 0x00000000f58a2535, 0x00000000f56da0be,
+   0x00000000f550f66e,
+   0x00000000f5342649, 0x00000000f5173054, 0x00000000f4fa1494,
+   0x00000000f4dcd30c, 0x00000000f4bf6bc2, 0x00000000f4a1deb9,
+   0x00000000f4842bf7, 0x00000000f4665380, 0x00000000f4485559,
+   0x00000000f42a3186,
+   0x00000000f40be80c, 0x00000000f3ed78ef, 0x00000000f3cee434,
+   0x00000000f3b029e1, 0x00000000f39149f9, 0x00000000f3724482,
+   0x00000000f3531980, 0x00000000f333c8f8, 0x00000000f31452ef,
+   0x00000000f2f4b76a,
+   0x00000000f2d4f66d, 0x00000000f2b50ffe, 0x00000000f2950421,
+   0x00000000f274d2dc, 0x00000000f2547c33, 0x00000000f234002b,
+   0x00000000f2135eca, 0x00000000f1f29814, 0x00000000f1d1ac0e,
+   0x00000000f1b09abe,
+   0x00000000f18f6429, 0x00000000f16e0853, 0x00000000f14c8742,
+   0x00000000f12ae0fb, 0x00000000f1091583, 0x00000000f0e724e0,
+   0x00000000f0c50f17, 0x00000000f0a2d42c, 0x00000000f0807426,
+   0x00000000f05def09,
+   0x00000000f03b44db, 0x00000000f01875a1, 0x00000000eff58161,
+   0x00000000efd2681f, 0x00000000efaf29e2, 0x00000000ef8bc6af,
+   0x00000000ef683e8b, 0x00000000ef44917b, 0x00000000ef20bf86,
+   0x00000000eefcc8b1,
+   0x00000000eed8ad01, 0x00000000eeb46c7b, 0x00000000ee900727,
+   0x00000000ee6b7d08, 0x00000000ee46ce25, 0x00000000ee21fa83,
+   0x00000000edfd0228, 0x00000000edd7e51a, 0x00000000edb2a35f,
+   0x00000000ed8d3cfc,
+   0x00000000ed67b1f6, 0x00000000ed420255, 0x00000000ed1c2e1d,
+   0x00000000ecf63554, 0x00000000ecd01801, 0x00000000eca9d628,
+   0x00000000ec836fd1, 0x00000000ec5ce501, 0x00000000ec3635bd,
+   0x00000000ec0f620d,
+   0x00000000ebe869f5, 0x00000000ebc14d7d, 0x00000000eb9a0ca9,
+   0x00000000eb72a780, 0x00000000eb4b1e08, 0x00000000eb237047,
+   0x00000000eafb9e43, 0x00000000ead3a803, 0x00000000eaab8d8d,
+   0x00000000ea834ee6,
+   0x00000000ea5aec15, 0x00000000ea326520, 0x00000000ea09ba0d,
+   0x00000000e9e0eae4, 0x00000000e9b7f7a9, 0x00000000e98ee063,
+   0x00000000e965a51a, 0x00000000e93c45d2, 0x00000000e912c292,
+   0x00000000e8e91b61,
+   0x00000000e8bf5046, 0x00000000e8956146, 0x00000000e86b4e68,
+   0x00000000e84117b3, 0x00000000e816bd2d, 0x00000000e7ec3edc,
+   0x00000000e7c19cc8, 0x00000000e796d6f6, 0x00000000e76bed6e,
+   0x00000000e740e036,
+   0x00000000e715af54, 0x00000000e6ea5ad0, 0x00000000e6bee2af,
+   0x00000000e69346f9, 0x00000000e66787b5, 0x00000000e63ba4e9,
+   0x00000000e60f9e9b, 0x00000000e5e374d4, 0x00000000e5b72798,
+   0x00000000e58ab6f1,
+   0x00000000e55e22e3, 0x00000000e5316b76, 0x00000000e50490b1,
+   0x00000000e4d7929c, 0x00000000e4aa713c, 0x00000000e47d2c98,
+   0x00000000e44fc4b9, 0x00000000e42239a4, 0x00000000e3f48b61,
+   0x00000000e3c6b9f7,
+   0x00000000e398c56c, 0x00000000e36aadc9, 0x00000000e33c7314,
+   0x00000000e30e1554, 0x00000000e2df9490, 0x00000000e2b0f0d0,
+   0x00000000e2822a1a, 0x00000000e2534077, 0x00000000e22433ec,
+   0x00000000e1f50482,
+   0x00000000e1c5b240, 0x00000000e1963d2d, 0x00000000e166a550,
+   0x00000000e136eab0, 0x00000000e1070d56, 0x00000000e0d70d48,
+   0x00000000e0a6ea8e, 0x00000000e076a52f, 0x00000000e0463d33,
+   0x00000000e015b2a1,
+   0x00000000dfe50580, 0x00000000dfb435d9, 0x00000000df8343b2,
+   0x00000000df522f13, 0x00000000df20f804, 0x00000000deef9e8d,
+   0x00000000debe22b5, 0x00000000de8c8483, 0x00000000de5ac3ff,
+   0x00000000de28e131,
+   0x00000000ddf6dc21, 0x00000000ddc4b4d6, 0x00000000dd926b59,
+   0x00000000dd5fffb0, 0x00000000dd2d71e3, 0x00000000dcfac1fb,
+   0x00000000dcc7f000, 0x00000000dc94fbf8, 0x00000000dc61e5ec,
+   0x00000000dc2eade4,
+   0x00000000dbfb53e8, 0x00000000dbc7d7ff, 0x00000000db943a31,
+   0x00000000db607a88, 0x00000000db2c9909, 0x00000000daf895bf,
+   0x00000000dac470af, 0x00000000da9029e3, 0x00000000da5bc163,
+   0x00000000da273737,
+   0x00000000d9f28b66, 0x00000000d9bdbdf9, 0x00000000d988cef8,
+   0x00000000d953be6b, 0x00000000d91e8c5b, 0x00000000d8e938d0,
+   0x00000000d8b3c3d1, 0x00000000d87e2d67, 0x00000000d848759b,
+   0x00000000d8129c74,
+   0x00000000d7dca1fb, 0x00000000d7a68638, 0x00000000d7704934,
+   0x00000000d739eaf7, 0x00000000d7036b89, 0x00000000d6cccaf3,
+   0x00000000d696093d, 0x00000000d65f266f, 0x00000000d6282293,
+   0x00000000d5f0fdb0,
+   0x00000000d5b9b7d0, 0x00000000d58250fa, 0x00000000d54ac937,
+   0x00000000d513208f, 0x00000000d4db570c, 0x00000000d4a36cb6,
+   0x00000000d46b6195, 0x00000000d43335b3, 0x00000000d3fae917,
+   0x00000000d3c27bcb,
+   0x00000000d389edd7, 0x00000000d3513f43, 0x00000000d318701a,
+   0x00000000d2df8063, 0x00000000d2a67027, 0x00000000d26d3f6f,
+   0x00000000d233ee43, 0x00000000d1fa7cae, 0x00000000d1c0eab7,
+   0x00000000d1873867,
+   0x00000000d14d65c8, 0x00000000d11372e1, 0x00000000d0d95fbd,
+   0x00000000d09f2c64, 0x00000000d064d8df, 0x00000000d02a6537,
+   0x00000000cfefd176, 0x00000000cfb51da3, 0x00000000cf7a49c8,
+   0x00000000cf3f55ef,
+   0x00000000cf044220, 0x00000000cec90e64, 0x00000000ce8dbac5,
+   0x00000000ce52474c, 0x00000000ce16b401, 0x00000000cddb00ef,
+   0x00000000cd9f2e1e, 0x00000000cd633b97, 0x00000000cd272964,
+   0x00000000cceaf78e,
+   0x00000000ccaea61e, 0x00000000cc72351e, 0x00000000cc35a497,
+   0x00000000cbf8f492, 0x00000000cbbc2519, 0x00000000cb7f3634,
+   0x00000000cb4227ee, 0x00000000cb04fa50, 0x00000000cac7ad63,
+   0x00000000ca8a4131,
+   0x00000000ca4cb5c3, 0x00000000ca0f0b22, 0x00000000c9d14159,
+   0x00000000c9935870, 0x00000000c9555072, 0x00000000c9172967,
+   0x00000000c8d8e35a, 0x00000000c89a7e53, 0x00000000c85bfa5e,
+   0x00000000c81d5782,
+   0x00000000c7de95cb, 0x00000000c79fb541, 0x00000000c760b5ee,
+   0x00000000c72197dc, 0x00000000c6e25b15, 0x00000000c6a2ffa3,
+   0x00000000c663858f, 0x00000000c623ece2, 0x00000000c5e435a8,
+   0x00000000c5a45fe9,
+   0x00000000c5646bb0, 0x00000000c5245906, 0x00000000c4e427f6,
+   0x00000000c4a3d888, 0x00000000c4636ac8, 0x00000000c422debf,
+   0x00000000c3e23476, 0x00000000c3a16bf9, 0x00000000c3608550,
+   0x00000000c31f8087,
+   0x00000000c2de5da6, 0x00000000c29d1cb8, 0x00000000c25bbdc8,
+   0x00000000c21a40de, 0x00000000c1d8a606, 0x00000000c196ed49,
+   0x00000000c15516b2, 0x00000000c113224a, 0x00000000c0d1101d,
+   0x00000000c08ee033,
+   0x00000000c04c9297, 0x00000000c00a2754, 0x00000000bfc79e73,
+   0x00000000bf84f800, 0x00000000bf423404, 0x00000000beff5289,
+   0x00000000bebc539a, 0x00000000be793741, 0x00000000be35fd89,
+   0x00000000bdf2a67b,
+   0x00000000bdaf3223, 0x00000000bd6ba08b, 0x00000000bd27f1bc,
+   0x00000000bce425c2, 0x00000000bca03ca7, 0x00000000bc5c3676,
+   0x00000000bc181338, 0x00000000bbd3d2f9, 0x00000000bb8f75c3,
+   0x00000000bb4afba1,
+   0x00000000bb06649c, 0x00000000bac1b0c0, 0x00000000ba7ce018,
+   0x00000000ba37f2ad, 0x00000000b9f2e88b, 0x00000000b9adc1bc,
+   0x00000000b9687e4a, 0x00000000b9231e41, 0x00000000b8dda1ac,
+   0x00000000b8980894,
+   0x00000000b8525305, 0x00000000b80c8109, 0x00000000b7c692ac,
+   0x00000000b78087f7, 0x00000000b73a60f6, 0x00000000b6f41db4,
+   0x00000000b6adbe3a, 0x00000000b6674296, 0x00000000b620aad0,
+   0x00000000b5d9f6f4,
+   0x00000000b593270e, 0x00000000b54c3b27, 0x00000000b505334a,
+   0x00000000b4be0f84, 0x00000000b476cfde, 0x00000000b42f7464,
+   0x00000000b3e7fd20, 0x00000000b3a06a1e, 0x00000000b358bb69,
+   0x00000000b310f10c,
+   0x00000000b2c90b11, 0x00000000b2810985, 0x00000000b238ec71,
+   0x00000000b1f0b3e2, 0x00000000b1a85fe2, 0x00000000b15ff07c,
+   0x00000000b11765bc, 0x00000000b0cebfad, 0x00000000b085fe5a,
+   0x00000000b03d21ce,
+   0x00000000aff42a15, 0x00000000afab1739, 0x00000000af61e946,
+   0x00000000af18a048, 0x00000000aecf3c49, 0x00000000ae85bd55,
+   0x00000000ae3c2377, 0x00000000adf26ebb, 0x00000000ada89f2c,
+   0x00000000ad5eb4d5,
+   0x00000000ad14afc2, 0x00000000acca8ffd, 0x00000000ac805594,
+   0x00000000ac360090, 0x00000000abeb90fe, 0x00000000aba106e9,
+   0x00000000ab56625d, 0x00000000ab0ba364, 0x00000000aac0ca0b,
+   0x00000000aa75d65d,
+   0x00000000aa2ac865, 0x00000000a9dfa030, 0x00000000a9945dc9,
+   0x00000000a949013a, 0x00000000a8fd8a91, 0x00000000a8b1f9d8,
+   0x00000000a8664f1c, 0x00000000a81a8a68, 0x00000000a7ceabc7,
+   0x00000000a782b345,
+   0x00000000a736a0ef, 0x00000000a6ea74cf, 0x00000000a69e2ef2,
+   0x00000000a651cf63, 0x00000000a605562f, 0x00000000a5b8c360,
+   0x00000000a56c1702, 0x00000000a51f5123, 0x00000000a4d271cc,
+   0x00000000a485790b,
+   0x00000000a43866eb, 0x00000000a3eb3b77, 0x00000000a39df6bd,
+   0x00000000a35098c7, 0x00000000a30321a2, 0x00000000a2b5915a,
+   0x00000000a267e7fa, 0x00000000a21a258e, 0x00000000a1cc4a24,
+   0x00000000a17e55c5,
+   0x00000000a1304880, 0x00000000a0e2225f, 0x00000000a093e36f,
+   0x00000000a0458bbb, 0x000000009ff71b50, 0x000000009fa8923a,
+   0x000000009f59f086, 0x000000009f0b363e, 0x000000009ebc6370,
+   0x000000009e6d7827,
+   0x000000009e1e746f, 0x000000009dcf5856, 0x000000009d8023e6,
+   0x000000009d30d72d, 0x000000009ce17236, 0x000000009c91f50e,
+   0x000000009c425fc1, 0x000000009bf2b25b, 0x000000009ba2ece8,
+   0x000000009b530f76,
+   0x000000009b031a0f, 0x000000009ab30cc1, 0x000000009a62e797,
+   0x000000009a12aa9f, 0x0000000099c255e5, 0x000000009971e974,
+   0x000000009921655a, 0x0000000098d0c9a2, 0x0000000098801659,
+   0x00000000982f4b8d,
+   0x0000000097de6948, 0x00000000978d6f97, 0x00000000973c5e88,
+   0x0000000096eb3626, 0x000000009699f67f, 0x0000000096489f9e,
+   0x0000000095f73190, 0x0000000095a5ac61, 0x000000009554101f,
+   0x0000000095025cd6,
+   0x0000000094b09292, 0x00000000945eb161, 0x00000000940cb94e,
+   0x0000000093baaa66, 0x00000000936884b6, 0x000000009316484b,
+   0x0000000092c3f531, 0x0000000092718b75, 0x00000000921f0b24,
+   0x0000000091cc744b,
+   0x000000009179c6f5, 0x0000000091270331, 0x0000000090d4290a,
+   0x000000009081388e, 0x00000000902e31c8, 0x000000008fdb14c7,
+   0x000000008f87e197, 0x000000008f349845, 0x000000008ee138dd,
+   0x000000008e8dc36c,
+   0x000000008e3a3800, 0x000000008de696a5, 0x000000008d92df68,
+   0x000000008d3f1256, 0x000000008ceb2f7c, 0x000000008c9736e7,
+   0x000000008c4328a3, 0x000000008bef04bf, 0x000000008b9acb46,
+   0x000000008b467c45,
+   0x000000008af217cb, 0x000000008a9d9de3, 0x000000008a490e9b,
+   0x0000000089f469ff, 0x00000000899fb01e, 0x00000000894ae103,
+   0x0000000088f5fcbc, 0x0000000088a10357, 0x00000000884bf4df,
+   0x0000000087f6d163,
+   0x0000000087a198f0, 0x00000000874c4b92, 0x0000000086f6e956,
+   0x0000000086a1724b, 0x00000000864be67c, 0x0000000085f645f8,
+   0x0000000085a090cc, 0x00000000854ac704, 0x0000000084f4e8ad,
+   0x00000000849ef5d7,
+   0x000000008448ee8c, 0x0000000083f2d2db, 0x00000000839ca2d1,
+   0x0000000083465e7c, 0x0000000082f005e8, 0x0000000082999922,
+   0x0000000082431839, 0x0000000081ec833a, 0x000000008195da31,
+   0x00000000813f1d2d,
+   0x0000000080e84c3a, 0x0000000080916766, 0x00000000803a6ebf,
+   0x000000007fe36251, 0x000000007f8c422b, 0x000000007f350e59,
+   0x000000007eddc6ea, 0x000000007e866bea, 0x000000007e2efd67,
+   0x000000007dd77b6f,
+   0x000000007d7fe60f, 0x000000007d283d54, 0x000000007cd0814c,
+   0x000000007c78b205, 0x000000007c20cf8c, 0x000000007bc8d9ef,
+   0x000000007b70d13b, 0x000000007b18b57e, 0x000000007ac086c5,
+   0x000000007a68451f,
+   0x000000007a0ff098, 0x0000000079b7893e, 0x00000000795f0f1f,
+   0x0000000079068248, 0x0000000078ade2c8, 0x00000000785530ab,
+   0x0000000077fc6c01, 0x0000000077a394d5, 0x00000000774aab36,
+   0x0000000076f1af32,
+   0x000000007698a0d6, 0x00000000763f8030, 0x0000000075e64d4e,
+   0x00000000758d083e, 0x000000007533b10d, 0x0000000074da47c9,
+   0x000000007480cc80, 0x0000000074273f3f, 0x0000000073cda016,
+   0x000000007373ef10,
+   0x00000000731a2c3d, 0x0000000072c057aa, 0x0000000072667164,
+   0x00000000720c797a, 0x0000000071b26ffa, 0x00000000715854f2,
+   0x0000000070fe286e, 0x0000000070a3ea7e, 0x0000000070499b30,
+   0x000000006fef3a90,
+   0x000000006f94c8ae, 0x000000006f3a4596, 0x000000006edfb157,
+   0x000000006e850c00, 0x000000006e2a559d, 0x000000006dcf8e3d,
+   0x000000006d74b5ee, 0x000000006d19ccbe, 0x000000006cbed2bb,
+   0x000000006c63c7f3,
+   0x000000006c08ac74, 0x000000006bad804c, 0x000000006b524389,
+   0x000000006af6f639, 0x000000006a9b986b, 0x000000006a402a2c,
+   0x0000000069e4ab8a, 0x0000000069891c94, 0x00000000692d7d57,
+   0x0000000068d1cde3,
+   0x0000000068760e44, 0x00000000681a3e89, 0x0000000067be5ec1,
+   0x0000000067626ef9, 0x0000000067066f40, 0x0000000066aa5fa3,
+   0x00000000664e4032, 0x0000000065f210f9, 0x000000006595d209,
+   0x000000006539836d,
+   0x0000000064dd2536, 0x000000006480b770, 0x0000000064243a2b,
+   0x0000000063c7ad75, 0x00000000636b115c, 0x00000000630e65ed,
+   0x0000000062b1ab39, 0x000000006254e14c, 0x0000000061f80835,
+   0x00000000619b2002,
+   0x00000000613e28c2, 0x0000000060e12283, 0x0000000060840d54,
+   0x000000006026e943, 0x000000005fc9b65d, 0x000000005f6c74b2,
+   0x000000005f0f2450, 0x000000005eb1c545, 0x000000005e5457a0,
+   0x000000005df6db6f,
+   0x000000005d9950c0, 0x000000005d3bb7a3, 0x000000005cde1024,
+   0x000000005c805a54, 0x000000005c22963f, 0x000000005bc4c3f6,
+   0x000000005b66e385, 0x000000005b08f4fd, 0x000000005aaaf86a,
+   0x000000005a4ceddc,
+   0x0000000059eed561, 0x000000005990af08, 0x0000000059327adf,
+   0x0000000058d438f4, 0x000000005875e957, 0x0000000058178c16,
+   0x0000000057b9213f, 0x00000000575aa8e0, 0x0000000056fc230a,
+   0x00000000569d8fc9,
+   0x00000000563eef2d, 0x0000000055e04144, 0x000000005581861d,
+   0x000000005522bdc6, 0x0000000054c3e84e, 0x00000000546505c4,
+   0x0000000054061636, 0x0000000053a719b3, 0x000000005348104a,
+   0x0000000052e8fa09,
+   0x000000005289d6ff, 0x00000000522aa73a, 0x0000000051cb6aca,
+   0x00000000516c21bc, 0x00000000510ccc20, 0x0000000050ad6a05,
+   0x00000000504dfb78, 0x000000004fee808a, 0x000000004f8ef947,
+   0x000000004f2f65c0,
+   0x000000004ecfc603, 0x000000004e701a1f, 0x000000004e106222,
+   0x000000004db09e1b, 0x000000004d50ce19, 0x000000004cf0f22b,
+   0x000000004c910a5f, 0x000000004c3116c5, 0x000000004bd1176b,
+   0x000000004b710c5f,
+   0x000000004b10f5b2, 0x000000004ab0d371, 0x000000004a50a5ab,
+   0x0000000049f06c70, 0x00000000499027cd, 0x00000000492fd7d3,
+   0x0000000048cf7c8f, 0x00000000486f1611, 0x00000000480ea467,
+   0x0000000047ae27a1,
+   0x00000000474d9fcd, 0x0000000046ed0cfa, 0x00000000468c6f37,
+   0x00000000462bc693, 0x0000000045cb131c, 0x00000000456a54e3,
+   0x0000000045098bf5, 0x0000000044a8b861, 0x000000004447da37,
+   0x0000000043e6f186,
+   0x000000004385fe5c, 0x00000000432500c8, 0x0000000042c3f8d9,
+   0x000000004262e69f, 0x000000004201ca28, 0x0000000041a0a383,
+   0x00000000413f72bf, 0x0000000040de37eb, 0x00000000407cf317,
+   0x00000000401ba450,
+   0x000000003fba4ba7, 0x000000003f58e92a, 0x000000003ef77ce8,
+   0x000000003e9606f1, 0x000000003e348752, 0x000000003dd2fe1c,
+   0x000000003d716b5e, 0x000000003d0fcf25, 0x000000003cae2982,
+   0x000000003c4c7a83,
+   0x000000003beac238, 0x000000003b8900b0, 0x000000003b2735f9,
+   0x000000003ac56223, 0x000000003a63853d, 0x000000003a019f56,
+   0x00000000399fb07d, 0x00000000393db8c1, 0x0000000038dbb831,
+   0x000000003879aedd,
+   0x0000000038179cd3, 0x0000000037b58222, 0x0000000037535edb,
+   0x0000000036f1330b, 0x00000000368efec2, 0x00000000362cc20f,
+   0x0000000035ca7d02, 0x0000000035682fa9, 0x000000003505da14,
+   0x0000000034a37c51,
+   0x0000000034411671, 0x0000000033dea881, 0x00000000337c3292,
+   0x000000003319b4b3, 0x0000000032b72ef2, 0x000000003254a15e,
+   0x0000000031f20c08, 0x00000000318f6efe, 0x00000000312cca50,
+   0x0000000030ca1e0c,
+   0x0000000030676a43, 0x000000003004af02, 0x000000002fa1ec5a,
+   0x000000002f3f2259, 0x000000002edc510f, 0x000000002e79788b,
+   0x000000002e1698dc, 0x000000002db3b212, 0x000000002d50c43c,
+   0x000000002cedcf68,
+   0x000000002c8ad3a7, 0x000000002c27d108, 0x000000002bc4c799,
+   0x000000002b61b76b, 0x000000002afea08c, 0x000000002a9b830b,
+   0x000000002a385ef9, 0x0000000029d53464, 0x000000002972035b,
+   0x00000000290ecbee,
+   0x0000000028ab8e2c, 0x0000000028484a25, 0x0000000027e4ffe7,
+   0x000000002781af83, 0x00000000271e5906, 0x0000000026bafc82,
+   0x0000000026579a04, 0x0000000025f4319d, 0x000000002590c35c,
+   0x00000000252d4f4f,
+   0x0000000024c9d587, 0x0000000024665613, 0x000000002402d101,
+   0x00000000239f4662, 0x00000000233bb644, 0x0000000022d820b8,
+   0x00000000227485cc, 0x000000002210e590, 0x0000000021ad4013,
+   0x0000000021499565,
+   0x0000000020e5e594, 0x00000000208230b1, 0x00000000201e76ca,
+   0x000000001fbab7ef, 0x000000001f56f430, 0x000000001ef32b9b,
+   0x000000001e8f5e41, 0x000000001e2b8c30, 0x000000001dc7b578,
+   0x000000001d63da29,
+   0x000000001cfffa51, 0x000000001c9c1600, 0x000000001c382d46,
+   0x000000001bd44032, 0x000000001b704ed3, 0x000000001b0c5939,
+   0x000000001aa85f74, 0x000000001a446191, 0x0000000019e05fa2,
+   0x00000000197c59b5,
+   0x0000000019184fdb, 0x0000000018b44221, 0x0000000018503098,
+   0x0000000017ec1b50, 0x0000000017880257, 0x000000001723e5bd,
+   0x0000000016bfc591, 0x00000000165ba1e4, 0x0000000015f77ac3,
+   0x0000000015935040,
+   0x00000000152f2269, 0x0000000014caf14d, 0x000000001466bcfd,
+   0x0000000014028587, 0x00000000139e4afb, 0x00000000133a0d69,
+   0x0000000012d5cce0, 0x000000001271896f, 0x00000000120d4326,
+   0x0000000011a8fa15,
+   0x000000001144ae4a, 0x0000000010e05fd6, 0x00000000107c0ec7,
+   0x000000001017bb2d, 0x000000000fb36519, 0x000000000f4f0c98,
+   0x000000000eeab1bb, 0x000000000e865491, 0x000000000e21f52a,
+   0x000000000dbd9395,
+   0x000000000d592fe1, 0x000000000cf4ca1f, 0x000000000c90625c,
+   0x000000000c2bf8aa, 0x000000000bc78d18, 0x000000000b631fb4,
+   0x000000000afeb08f, 0x000000000a9a3fb8, 0x000000000a35cd3e,
+   0x0000000009d15931,
+   0x00000000096ce3a1, 0x0000000009086c9c, 0x0000000008a3f433,
+   0x00000000083f7a75, 0x0000000007daff71, 0x0000000007768337,
+   0x00000000071205d6, 0x0000000006ad875f, 0x00000000064907df,
+   0x0000000005e48768,
+   0x0000000005800608, 0x00000000051b83cf, 0x0000000004b700cc,
+   0x0000000004527d0f, 0x0000000003edf8a7, 0x00000000038973a4,
+   0x000000000324ee16, 0x0000000002c0680b, 0x00000000025be194,
+   0x0000000001f75ac0,
+   0x000000000192d39e, 0x00000000012e4c3e, 0x0000000000c9c4af,
+   0x0000000000653d02, 0x0000000000000000
+};
 
 EAPI Eina_F32p32
 eina_f32p32_cos(Eina_F32p32 a)
@@ -143,28 +450,29 @@ eina_f32p32_cos(Eina_F32p32 a)
    remainder_2PI = a - (a / F32P32_2PI) * F32P32_2PI;
 
    interpol = eina_f32p32_div(eina_f32p32_scale(remainder_PI, MAX_PREC * 2),
-                             EINA_F32P32_PI);
+                              EINA_F32P32_PI);
    idx = eina_f32p32_int_to(interpol);
    if (idx >= MAX_PREC)
-     idx = 2 * MAX_PREC - (idx - 1);
+      idx = 2 * MAX_PREC - (idx - 1);
 
    index2 = idx + 1;
    if (index2 == MAX_PREC)
-     index2 = idx - 1;
+      index2 = idx - 1;
 
    result = eina_f32p32_add(eina_trigo[idx],
-                           eina_f32p32_mul(eina_f32p32_sub(eina_trigo[idx],
-                                                           eina_trigo[index2]),
-                                           (Eina_F32p32) eina_f32p32_fracc_get(interpol)));
+                            eina_f32p32_mul(eina_f32p32_sub(eina_trigo[idx],
+                                                            eina_trigo[index2]),
+                                            (Eina_F32p32)eina_f32p32_fracc_get(
+                                               interpol)));
 
    if (0 <= remainder_2PI && remainder_2PI < F32P32_PI2)
-     return result;
+      return result;
    else if (F32P32_PI2 <= remainder_2PI && remainder_2PI < EINA_F32P32_PI)
-     return -result;
+      return -result;
    else if (EINA_F32P32_PI <= remainder_2PI && remainder_2PI < F32P32_3PI2)
-     return -result;
-   else/*  if (F32P32_3PI2 <= remainder_2PI) */
-     return result;
+      return -result;
+   else /*  if (F32P32_3PI2 <= remainder_2PI) */
+      return result;
 }
 
 EAPI Eina_F32p32
@@ -197,27 +505,28 @@ eina_f32p32_sin(Eina_F32p32 a)
    remainder_2PI = a - (a / F32P32_2PI) * F32P32_2PI;
 
    interpol = eina_f32p32_div(eina_f32p32_scale(remainder_PI, MAX_PREC * 2),
-                             EINA_F32P32_PI);
+                              EINA_F32P32_PI);
    idx = eina_f32p32_int_to(interpol);
    if (idx >= MAX_PREC)
-     idx = 2 * MAX_PREC - (idx + 1);
+      idx = 2 * MAX_PREC - (idx + 1);
 
    index2 = idx + 1;
    if (index2 == MAX_PREC)
-     index2 = idx - 1;
+      index2 = idx - 1;
 
    result = eina_f32p32_add(eina_trigo[idx],
-                           eina_f32p32_mul(eina_f32p32_sub(eina_trigo[idx],
-                                                           eina_trigo[index2]),
-                                           (Eina_F32p32) eina_f32p32_fracc_get(interpol)));
+                            eina_f32p32_mul(eina_f32p32_sub(eina_trigo[idx],
+                                                            eina_trigo[index2]),
+                                            (Eina_F32p32)eina_f32p32_fracc_get(
+                                               interpol)));
 
    if (0 <= remainder_2PI && remainder_2PI < F32P32_PI2)
-     return result;
+      return result;
    else if (F32P32_PI2 <= remainder_2PI && remainder_2PI < EINA_F32P32_PI)
-     return -result;
+      return -result;
    else if (EINA_F32P32_PI <= remainder_2PI && remainder_2PI < F32P32_3PI2)
-     return -result;
+      return -result;
    else /* if (F32P32_3PI2 <= remainder_2PI) */
-     return result;
+      return result;
 }
 
index 843dbc6..2f68777 100644 (file)
@@ -28,8 +28,8 @@
 #include "eina_hamster.h"
 
 /*============================================================================*
- *                                  Local                                     *
- *============================================================================*/
+*                                  Local                                     *
+*============================================================================*/
 
 /**
  * @cond LOCAL
@@ -44,12 +44,12 @@ static int _eina_hamsters = -1;
  */
 
 /*============================================================================*
- *                                 Global                                     *
- *============================================================================*/
+*                                 Global                                     *
+*============================================================================*/
 
 /*============================================================================*
- *                                   API                                      *
- *============================================================================*/
+*                                   API                                      *
+*============================================================================*/
 
 /**
  * @addtogroup Eina_Hamster_Group Hamster
@@ -75,7 +75,7 @@ eina_hamster_count(void)
         char mon[8] = "";
         int monnum = 0, day = 0, year = 0;
         int fields;
-        
+
         fields = sscanf(_eina_hamster_time, "%02i:%02i:%02i", &hrs, &min, &sec);
         if (fields == 3)
           {
@@ -85,21 +85,21 @@ eina_hamster_count(void)
                {
                   int i;
                   const char *mons[] =
-                    {
-                       "Jan",
-                       "Feb",
-                       "Mar",
-                       "Apr",
-                       "May",
-                       "Jun",
-                       "Jul",
-                       "Aug",
-                       "Sep",
-                       "Oct",
-                       "Nov",
-                       "Dec"
-                    };
-                  
+                  {
+                     "Jan",
+                     "Feb",
+                     "Mar",
+                     "Apr",
+                     "May",
+                     "Jun",
+                     "Jul",
+                     "Aug",
+                     "Sep",
+                     "Oct",
+                     "Nov",
+                     "Dec"
+                  };
+
                   for (i = 0; i < 12; i++)
                     {
                        if (!strcmp(mon, mons[i]))
@@ -113,11 +113,12 @@ eina_hamster_count(void)
                   // use year as-is, for 31 bits (signed) this gives us up to
                   // 3584 years, which is good enough imho. - 1500 years from
                   // now or so. :)
-                  _eina_hamsters += 
-                    (day + (monnum * 32) + (13 * 32 * year)) * (24 * 60);
+                  _eina_hamsters +=
+                     (day + (monnum * 32) + (13 * 32 * year)) * (24 * 60);
                }
           }
      }
+
    // format: [rest - year][0-12 - month][0-31 - day][0-23 - hrs][0-59 - sec]
    return _eina_hamsters;
 }
index 67c7f28..076a407 100644 (file)
 #include "eina_hash.h"
 
 /*============================================================================*
- *                                  Local                                     *
- *============================================================================*/
+*                                  Local                                     *
+*============================================================================*/
 
 /**
  * @cond LOCAL
  */
 
-#define EINA_MAGIC_CHECK_HASH(d)                                       \
-  do {                                                                 \
-     if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_HASH))                                \
-       EINA_MAGIC_FAIL(d, EINA_MAGIC_HASH);                            \
-  } while(0)
-
-#define EINA_MAGIC_CHECK_HASH_ITERATOR(d, ...)                         \
-  do {                                                                 \
-     if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_HASH_ITERATOR))               \
-     {                                                                 \
-          EINA_MAGIC_FAIL(d, EINA_MAGIC_HASH_ITERATOR);                        \
-          return __VA_ARGS__;                                                  \
-     }                                                                 \
-  } while(0)
+#define EINA_MAGIC_CHECK_HASH(d)                                        \
+   do {                                                                  \
+        if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_HASH)) {                         \
+             EINA_MAGIC_FAIL(d, EINA_MAGIC_HASH); }                             \
+     } while(0)
+
+#define EINA_MAGIC_CHECK_HASH_ITERATOR(d, ...)                          \
+   do {                                                                  \
+        if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_HASH_ITERATOR))                \
+          {                                                                  \
+             EINA_MAGIC_FAIL(d, EINA_MAGIC_HASH_ITERATOR);                 \
+             return __VA_ARGS__;                                                   \
+          }                                                                  \
+     } while(0)
 
 #define EINA_HASH_BUCKET_SIZE 8
 #define EINA_HASH_SMALL_BUCKET_SIZE 5
@@ -68,7 +68,7 @@
 #define EINA_HASH_RBTREE_MASK 0xFFF
 
 typedef struct _Eina_Hash_Head Eina_Hash_Head;
-typedef struct _Eina_Hash_El Eina_Hash_El;
+typedef struct _Eina_Hash_Element Eina_Hash_Element;
 typedef struct _Eina_Hash_Foreach_Data Eina_Hash_Foreach_Data;
 typedef struct _Eina_Iterator_Hash Eina_Iterator_Hash;
 typedef struct _Eina_Hash_Each Eina_Hash_Each;
@@ -97,7 +97,7 @@ struct _Eina_Hash_Head
    Eina_Rbtree *head;
 };
 
-struct _Eina_Hash_El
+struct _Eina_Hash_Element
 {
    EINA_RBTREE;
    Eina_Hash_Tuple tuple;
@@ -122,8 +122,8 @@ struct _Eina_Iterator_Hash
 
    Eina_Iterator *current;
    Eina_Iterator *list;
-   Eina_Hash_Head *eh;
-   Eina_Hash_El *el;
+   Eina_Hash_Head *hash_head;
+   Eina_Hash_Element *hash_element;
    int bucket;
 
    int index;
@@ -133,76 +133,93 @@ struct _Eina_Iterator_Hash
 
 struct _Eina_Hash_Each
 {
-   Eina_Hash_Head *eh;
-   const Eina_Hash_El *el;
+   Eina_Hash_Head *hash_head;
+   const Eina_Hash_Element *hash_element;
    const void *data;
 };
 
 #undef get16bits
 #if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) \
-  || defined(_MSC_VER) || defined (__BORLANDC__) || defined (__TURBOC__)
-# define get16bits(d) (*((const uint16_t *) (d)))
+   || defined(_MSC_VER) || defined (__BORLANDC__) || defined (__TURBOC__)
+# define get16bits(d) (*((const uint16_t *)(d)))
 #endif
 
 #if !defined (get16bits)
-# define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8)\
-                        +(uint32_t)(((const uint8_t *)(d))[0]) )
+# define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8) \
+                       + (uint32_t)(((const uint8_t *)(d))[0]))
 #endif
 
 static inline int
-_eina_hash_hash_rbtree_cmp_hash(const Eina_Hash_Head *eh, const int *hash, __UNUSED__ int key_length, __UNUSED__ void *data)
+_eina_hash_hash_rbtree_cmp_hash(const Eina_Hash_Head *hash_head,
+                                const int *hash,
+                                __UNUSED__ int key_length,
+                                __UNUSED__ void *data)
 {
-   return eh->hash - *hash;
+   return hash_head->hash - *hash;
 }
 
 static Eina_Rbtree_Direction
-_eina_hash_hash_rbtree_cmp_node(const Eina_Hash_Head *left, const Eina_Hash_Head *right, __UNUSED__ void *data)
+_eina_hash_hash_rbtree_cmp_node(const Eina_Hash_Head *left,
+                                const Eina_Hash_Head *right,
+                                __UNUSED__ void *data)
 {
    if (left->hash - right->hash < 0)
-     return EINA_RBTREE_LEFT;
+      return EINA_RBTREE_LEFT;
+
    return EINA_RBTREE_RIGHT;
 }
 
 static inline int
-_eina_hash_key_rbtree_cmp_key_data(const Eina_Hash_El *el, const Eina_Hash_Tuple *tuple, __UNUSED__ unsigned int key_length, Eina_Key_Cmp cmp)
+_eina_hash_key_rbtree_cmp_key_data(const Eina_Hash_Element *hash_element,
+                                   const Eina_Hash_Tuple *tuple,
+                                   __UNUSED__ unsigned int key_length,
+                                   Eina_Key_Cmp cmp)
 {
    int result;
 
-   result = cmp(el->tuple.key, el->tuple.key_length, tuple->key, tuple->key_length);
+   result = cmp(hash_element->tuple.key,
+                hash_element->tuple.key_length,
+                tuple->key,
+                tuple->key_length);
+
+   if (result == 0 && tuple->data && tuple->data != hash_element->tuple.data)
+      return 1;
 
-   if (result == 0 && tuple->data && tuple->data != el->tuple.data)
-     return 1;
    return result;
 }
 
 static Eina_Rbtree_Direction
-_eina_hash_key_rbtree_cmp_node(const Eina_Hash_El *left, const Eina_Hash_El *right, Eina_Key_Cmp cmp)
+_eina_hash_key_rbtree_cmp_node(const Eina_Hash_Element *left,
+                               const Eina_Hash_Element *right,
+                               Eina_Key_Cmp cmp)
 {
    int result;
 
    result = cmp(left->tuple.key, left->tuple.key_length,
-               right->tuple.key, right->tuple.key_length);
+                right->tuple.key, right->tuple.key_length);
 
    if (result < 0)
-     return EINA_RBTREE_LEFT;
+      return EINA_RBTREE_LEFT;
+
    return EINA_RBTREE_RIGHT;
 }
 
 static inline Eina_Bool
 eina_hash_add_alloc_by_hash(Eina_Hash *hash,
-                           const void *key, int key_length, int alloc_length,
-                           int key_hash,
-                           const void *data)
+                            const void *key, int key_length, int alloc_length,
+                            int key_hash,
+                            const void *data)
 {
-   Eina_Hash_El *el = NULL;
-   Eina_Hash_Head *eh;
+   Eina_Hash_Element *new_hash_element = NULL;
+   Eina_Hash_Head *hash_head;
    Eina_Error error = 0;
    int hash_num;
 
-   EINA_MAGIC_CHECK_HASH(hash);
    EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(key,  EINA_FALSE);
    EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
+   EINA_MAGIC_CHECK_HASH(hash);
+
    error = EINA_ERROR_OUT_OF_MEMORY;
 
    /* Apply eina mask to hash. */
@@ -211,204 +228,245 @@ eina_hash_add_alloc_by_hash(Eina_Hash *hash,
 
    if (!hash->buckets)
      {
-       hash->buckets = malloc(sizeof (Eina_Rbtree*) * hash->size);
-       memset(hash->buckets, 0, sizeof (Eina_Rbtree*) * hash->size);
+        hash->buckets = calloc(sizeof (Eina_Rbtree *), hash->size);
+        if (!hash->buckets) goto on_error;
 
-       eh = NULL;
+        hash_head = NULL;
      }
    else
-     {
-       /* Look up for head node. */
-       eh = (Eina_Hash_Head*) eina_rbtree_inline_lookup(hash->buckets[hash_num],
-                                                        &key_hash, 0,
-                                                        EINA_RBTREE_CMP_KEY_CB(_eina_hash_hash_rbtree_cmp_hash), NULL);
-     }
+      /* Look up for head node. */
+      hash_head = (Eina_Hash_Head *)eina_rbtree_inline_lookup(hash->buckets[hash_num],
+                                                              &key_hash, 0,
+                                                              EINA_RBTREE_CMP_KEY_CB(_eina_hash_hash_rbtree_cmp_hash),
+                                                              NULL);
 
-   if (!eh)
+   if (!hash_head)
      {
-       /* If not found allocate it and a element. */
-       eh = malloc(sizeof (Eina_Hash_Head) + sizeof (Eina_Hash_El) + alloc_length);
-       if (!eh) goto on_error;
-       eh->hash = key_hash;
-       eh->head = NULL;
+        /* If not found allocate it and an element. */
+        hash_head = malloc(sizeof(Eina_Hash_Head) + sizeof(Eina_Hash_Element) + alloc_length);
+        if (!hash_head)
+           goto on_error;
+
+        hash_head->hash = key_hash;
+        hash_head->head = NULL;
 
-       hash->buckets[hash_num] = eina_rbtree_inline_insert(hash->buckets[hash_num], EINA_RBTREE_GET(eh),
-                                                           EINA_RBTREE_CMP_NODE_CB(_eina_hash_hash_rbtree_cmp_node), NULL);
+        hash->buckets[hash_num] =
+           eina_rbtree_inline_insert(hash->buckets[hash_num], EINA_RBTREE_GET(hash_head),
+                                     EINA_RBTREE_CMP_NODE_CB(
+                                        _eina_hash_hash_rbtree_cmp_node), NULL);
 
-       el = (Eina_Hash_El*) (eh + 1);
-       el->begin = EINA_TRUE;
+        new_hash_element = (Eina_Hash_Element *)(hash_head + 1);
+        new_hash_element->begin = EINA_TRUE;
      }
 
-   if (!el)
+   if (!new_hash_element)
      {
-       /*
-         Alloc every needed things
-         (No more lookup as we expect to support more than one item for one key).
-       */
-       el = malloc(sizeof (Eina_Hash_El) + alloc_length);
-       if (!el) goto on_error;
-       el->begin = EINA_FALSE;
+        /*
+           Alloc a new element
+           (No more lookup as we expect to support more than one item for one key).
+         */
+        new_hash_element = malloc(sizeof (Eina_Hash_Element) + alloc_length);
+        if (!new_hash_element)
+           goto on_error;
+
+        new_hash_element->begin = EINA_FALSE;
      }
 
    /* Setup the element */
-   el->tuple.key_length = key_length;
-   el->tuple.data = (void *) data;
+   new_hash_element->tuple.key_length = key_length;
+   new_hash_element->tuple.data = (void *)data;
    if (alloc_length > 0)
      {
-       el->tuple.key = (char *) (el + 1);
-       memcpy((char *) el->tuple.key, key, alloc_length);
+        new_hash_element->tuple.key = (char *)(new_hash_element + 1);
+        memcpy((char *)new_hash_element->tuple.key, key, alloc_length);
      }
    else
-     {
-       el->tuple.key = key;
-     }
+      new_hash_element->tuple.key = key;
 
    /* add the new element to the hash. */
-   eh->head = eina_rbtree_inline_insert(eh->head, EINA_RBTREE_GET(el),
-                                       EINA_RBTREE_CMP_NODE_CB(_eina_hash_key_rbtree_cmp_node), (const void *)hash->key_cmp_cb);
+   hash_head->head = eina_rbtree_inline_insert(hash_head->head, EINA_RBTREE_GET(new_hash_element),
+                                        EINA_RBTREE_CMP_NODE_CB(
+                                           _eina_hash_key_rbtree_cmp_node),
+                                        (const void *)hash->key_cmp_cb);
    hash->population++;
    return EINA_TRUE;
 
- on_error:
+on_error:
    eina_error_set(error);
    return EINA_FALSE;
 }
 
 static Eina_Bool
-_eina_hash_rbtree_each(__UNUSED__ const Eina_Rbtree *container, const Eina_Hash_Head *eh, Eina_Hash_Each *data)
+_eina_hash_rbtree_each(__UNUSED__ const Eina_Rbtree *container,
+                       const Eina_Hash_Head *hash_head,
+                       Eina_Hash_Each *data)
 {
    Eina_Iterator *it;
-   Eina_Hash_El *el;
+   Eina_Hash_Element *hash_element;
    Eina_Bool found = EINA_TRUE;
 
-   it = eina_rbtree_iterator_prefix(eh->head);
-   EINA_ITERATOR_FOREACH(it, el)
-     {
-       if (el->tuple.data == data->data)
-         {
-            data->el = el;
-            data->eh = (Eina_Hash_Head*) eh;
-            found = EINA_FALSE;
-            break ;
-         }
-     }
+   it = eina_rbtree_iterator_prefix(hash_head->head);
+   EINA_ITERATOR_FOREACH(it, hash_element)
+   {
+      if (hash_element->tuple.data == data->data)
+        {
+           data->hash_element = hash_element;
+           data->hash_head = (Eina_Hash_Head *)hash_head;
+           found = EINA_FALSE;
+           break;
+        }
+   }
 
    eina_iterator_free(it);
    return found;
 }
 
-static inline Eina_Hash_El *
-_eina_hash_find_by_hash(const Eina_Hash *hash, Eina_Hash_Tuple *tuple, int key_hash, Eina_Hash_Head **eh)
+static inline Eina_Hash_Element *
+_eina_hash_find_by_hash(const Eina_Hash *hash,
+                        Eina_Hash_Tuple *tuple,
+                        int key_hash,
+                        Eina_Hash_Head **hash_head)
 {
-   Eina_Hash_El *el;
+   Eina_Hash_Element *hash_element;
    int rb_hash = key_hash & EINA_HASH_RBTREE_MASK;
 
    key_hash &= hash->mask;
 
-   if (!hash->buckets) return NULL;
+   if (!hash->buckets)
+      return NULL;
 
-   *eh = (Eina_Hash_Head*) eina_rbtree_inline_lookup(hash->buckets[key_hash],
-                                                   &rb_hash, 0,
-                                                   EINA_RBTREE_CMP_KEY_CB(_eina_hash_hash_rbtree_cmp_hash), NULL);
-   if (!*eh) return NULL;
+   *hash_head = (Eina_Hash_Head *)eina_rbtree_inline_lookup(hash->buckets[key_hash],
+                                                     &rb_hash, 0,
+                                                     EINA_RBTREE_CMP_KEY_CB(
+                                                        _eina_hash_hash_rbtree_cmp_hash),
+                                                     NULL);
+   if (!*hash_head)
+      return NULL;
 
-   el = (Eina_Hash_El*) eina_rbtree_inline_lookup((*eh)->head,
-                                                 tuple, 0,
-                                                 EINA_RBTREE_CMP_KEY_CB(_eina_hash_key_rbtree_cmp_key_data), (const void *)hash->key_cmp_cb);
+   hash_element = (Eina_Hash_Element *)eina_rbtree_inline_lookup((*hash_head)->head,
+                                                  tuple, 0,
+                                                     EINA_RBTREE_CMP_KEY_CB(
+                                                     _eina_hash_key_rbtree_cmp_key_data),
+                                                  (const void *)hash->
+                                                  key_cmp_cb);
 
-   return el;
+   return hash_element;
 }
 
-static inline Eina_Hash_El *
-_eina_hash_find_by_data(const Eina_Hash *hash, const void *data, int *key_hash, Eina_Hash_Head **eh)
+static inline Eina_Hash_Element *
+_eina_hash_find_by_data(const Eina_Hash *hash,
+                        const void *data,
+                        int *key_hash,
+                        Eina_Hash_Head **hash_head)
 {
    Eina_Hash_Each each;
    Eina_Iterator *it;
    int hash_num;
 
-   if (!hash->buckets) return NULL;
+   if (!hash->buckets)
+      return NULL;
 
-   each.el = NULL;
+   each.hash_element = NULL;
    each.data = data;
 
    for (hash_num = 0; hash_num < hash->size; hash_num++)
      {
-       if (!hash->buckets[hash_num])
-         continue;
-       it = eina_rbtree_iterator_prefix(hash->buckets[hash_num]);
-       eina_iterator_foreach(it, EINA_EACH(_eina_hash_rbtree_each), &each);
-       eina_iterator_free(it);
-
-       if (each.el)
-         {
-           *key_hash = hash_num;
-           *eh = each.eh;
-           return (Eina_Hash_El*) each.el;
-         }
+        if (!hash->buckets[hash_num])
+           continue;
+
+        it = eina_rbtree_iterator_prefix(hash->buckets[hash_num]);
+        eina_iterator_foreach(it, EINA_EACH_CB(_eina_hash_rbtree_each), &each);
+        eina_iterator_free(it);
+
+        if (each.hash_element)
+          {
+             *key_hash = hash_num;
+             *hash_head = each.hash_head;
+             return (Eina_Hash_Element *)each.hash_element;
+          }
      }
 
    return NULL;
 }
 
 static void
-_eina_hash_el_free(Eina_Hash_El *el, Eina_Hash *hash)
+_eina_hash_el_free(Eina_Hash_Element *hash_element, Eina_Hash *hash)
 {
    if (hash->data_free_cb)
-     hash->data_free_cb(el->tuple.data);
-   if (el->begin == EINA_FALSE) free(el);
+      hash->data_free_cb(hash_element->tuple.data);
+
+   if (hash_element->begin == EINA_FALSE)
+      free(hash_element);
 }
 
 static void
-_eina_hash_head_free(Eina_Hash_Head *eh, Eina_Hash *hash)
+_eina_hash_head_free(Eina_Hash_Head *hash_head, Eina_Hash *hash)
 {
-   eina_rbtree_delete(eh->head, EINA_RBTREE_FREE_CB(_eina_hash_el_free), hash);
-   free(eh);
+   eina_rbtree_delete(hash_head->head, EINA_RBTREE_FREE_CB(_eina_hash_el_free), hash);
+   free(hash_head);
 }
 
 static Eina_Bool
-_eina_hash_del_by_hash_el(Eina_Hash *hash, Eina_Hash_El *el, Eina_Hash_Head *eh, int key_hash)
+_eina_hash_del_by_hash_el(Eina_Hash *hash,
+                          Eina_Hash_Element *hash_element,
+                          Eina_Hash_Head *hash_head,
+                          int key_hash)
 {
-  eh->head = eina_rbtree_inline_remove(eh->head, EINA_RBTREE_GET(el), EINA_RBTREE_CMP_NODE_CB(_eina_hash_key_rbtree_cmp_node), (const void *)hash->key_cmp_cb);
-   _eina_hash_el_free(el, hash);
+   hash_head->head = eina_rbtree_inline_remove(hash_head->head, EINA_RBTREE_GET(
+                                           hash_element), EINA_RBTREE_CMP_NODE_CB(
+                                           _eina_hash_key_rbtree_cmp_node),
+                                        (const void *)hash->key_cmp_cb);
+   _eina_hash_el_free(hash_element, hash);
 
-   if (!eh->head)
+   if (!hash_head->head)
      {
-       key_hash &= hash->mask;
-
-       hash->buckets[key_hash] = eina_rbtree_inline_remove(hash->buckets[key_hash], EINA_RBTREE_GET(eh), EINA_RBTREE_CMP_NODE_CB(_eina_hash_hash_rbtree_cmp_node), NULL);
-       free(eh);
+        key_hash &= hash->mask;
+
+        hash->buckets[key_hash] =
+           eina_rbtree_inline_remove(hash->buckets[key_hash], EINA_RBTREE_GET(
+                                        hash_head),
+                                     EINA_RBTREE_CMP_NODE_CB(
+                                        _eina_hash_hash_rbtree_cmp_node), NULL);
+        free(hash_head);
      }
 
    hash->population--;
    if (hash->population == 0)
      {
-       free(hash->buckets);
-       hash->buckets = NULL;
+        free(hash->buckets);
+        hash->buckets = NULL;
      }
 
    return EINA_TRUE;
 }
 
 static Eina_Bool
-_eina_hash_del_by_key_hash(Eina_Hash *hash, const void *key, int key_length, int key_hash, const void *data)
+_eina_hash_del_by_key_hash(Eina_Hash *hash,
+                           const void *key,
+                           int key_length,
+                           int key_hash,
+                           const void *data)
 {
-   Eina_Hash_El *el;
-   Eina_Hash_Head *eh;
+   Eina_Hash_Element *hash_element;
+   Eina_Hash_Head *hash_head;
    Eina_Hash_Tuple tuple;
 
-   EINA_MAGIC_CHECK_HASH(hash);
    EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(key,  EINA_FALSE);
+   EINA_MAGIC_CHECK_HASH(hash);
 
-   if (!hash->buckets) return EINA_FALSE;
+   if (!hash->buckets)
+      return EINA_FALSE;
 
-   tuple.key = (void *) key;
+   tuple.key = (void *)key;
    tuple.key_length = key_length;
-   tuple.data = (void *) data;
+   tuple.data = (void *)data;
 
-   el = _eina_hash_find_by_hash(hash, &tuple, key_hash, &eh);
-   if (!el) return EINA_FALSE;
-   return _eina_hash_del_by_hash_el(hash, el, eh, key_hash);
+   hash_element = _eina_hash_find_by_hash(hash, &tuple, key_hash, &hash_head);
+   if (!hash_element)
+      return EINA_FALSE;
+
+   return _eina_hash_del_by_hash_el(hash, hash_element, hash_head, key_hash);
 }
 
 static Eina_Bool
@@ -417,9 +475,14 @@ _eina_hash_del_by_key(Eina_Hash *hash, const void *key, const void *data)
    int key_length, key_hash;
 
    EINA_MAGIC_CHECK_HASH(hash);
-   if (!hash) return EINA_FALSE;
-   if (!key) return EINA_FALSE;
-   if (!hash->buckets) return EINA_FALSE;
+   if (!hash)
+      return EINA_FALSE;
+
+   if (!key)
+      return EINA_FALSE;
+
+   if (!hash->buckets)
+      return EINA_FALSE;
 
    key_length = hash->key_length_cb ? hash->key_length_cb(key) : 0;
    key_hash = hash->key_hash_cb(key, key_length);
@@ -429,20 +492,22 @@ _eina_hash_del_by_key(Eina_Hash *hash, const void *key, const void *data)
 static unsigned int
 _eina_string_key_length(const char *key)
 {
-   if (!key) return 0;
+   if (!key)
+      return 0;
+
    return (int)strlen(key) + 1;
 }
 
 static int
 _eina_string_key_cmp(const char *key1, __UNUSED__ int key1_length,
-                    const char *key2, __UNUSED__ int key2_length)
+                     const char *key2, __UNUSED__ int key2_length)
 {
    return strcmp(key1, key2);
 }
 
 static int
 _eina_stringshared_key_cmp(const char *key1, __UNUSED__ int key1_length,
-                          const char *key2, __UNUSED__ int key2_length)
+                           const char *key2, __UNUSED__ int key2_length)
 {
    return key1 - key2;
 }
@@ -450,12 +515,12 @@ _eina_stringshared_key_cmp(const char *key1, __UNUSED__ int key1_length,
 static unsigned int
 _eina_int32_key_length(__UNUSED__ const uint32_t *key)
 {
-  return 4;
+   return 4;
 }
 
 static int
 _eina_int32_key_cmp(const uint32_t *key1, __UNUSED__ int key1_length,
-                   const uint32_t *key2, __UNUSED__ int key2_length)
+                    const uint32_t *key2, __UNUSED__ int key2_length)
 {
    return *key1 - *key2;
 }
@@ -463,58 +528,69 @@ _eina_int32_key_cmp(const uint32_t *key1, __UNUSED__ int key1_length,
 static unsigned int
 _eina_int64_key_length(__UNUSED__ const uint32_t *key)
 {
-  return 8;
+   return 8;
 }
 
 static int
 _eina_int64_key_cmp(const uint64_t *key1, __UNUSED__ int key1_length,
-                   const uint64_t *key2, __UNUSED__ int key2_length)
+                    const uint64_t *key2, __UNUSED__ int key2_length)
 {
    return *key1 - *key2;
 }
 
 static Eina_Bool
-_eina_foreach_cb(const Eina_Hash *hash, Eina_Hash_Tuple *data, Eina_Hash_Foreach_Data *fdata)
+_eina_foreach_cb(const Eina_Hash *hash,
+                 Eina_Hash_Tuple *data,
+                 Eina_Hash_Foreach_Data *fdata)
 {
-   return fdata->cb((Eina_Hash *) hash, data->key, data->data, (void*) fdata->fdata);
+   return fdata->cb((Eina_Hash *)hash,
+                    data->key,
+                    data->data,
+                    (void *)fdata->fdata);
 }
 
 static void *
 _eina_hash_iterator_data_get_content(Eina_Iterator_Hash *it)
 {
-   Eina_Hash_El *stuff;
+   Eina_Hash_Element *stuff;
 
    EINA_MAGIC_CHECK_HASH_ITERATOR(it, NULL);
 
-   stuff = it->el;
+   stuff = it->hash_element;
+
+   if (!stuff)
+      return NULL;
 
-   if (!stuff) return NULL;
    return stuff->tuple.data;
 }
 
 static void *
 _eina_hash_iterator_key_get_content(Eina_Iterator_Hash *it)
 {
-   Eina_Hash_El *stuff;
+   Eina_Hash_Element *stuff;
 
    EINA_MAGIC_CHECK_HASH_ITERATOR(it, NULL);
 
-   stuff = it->el;
+   stuff = it->hash_element;
+
+   if (!stuff)
+      return NULL;
 
-   if (!stuff) return NULL;
-   return (void *) stuff->tuple.key;
+   return (void *)stuff->tuple.key;
 }
 
 static Eina_Hash_Tuple *
 _eina_hash_iterator_tuple_get_content(Eina_Iterator_Hash *it)
 {
-   Eina_Hash_El *stuff;
+   Eina_Hash_Element *stuff;
 
    EINA_MAGIC_CHECK_HASH_ITERATOR(it, NULL);
 
-   stuff = it->el;
+   stuff = it->hash_element;
+
+   if (!stuff)
+      return NULL;
 
-   if (!stuff) return NULL;
    return &stuff->tuple;
 }
 
@@ -524,63 +600,72 @@ _eina_hash_iterator_next(Eina_Iterator_Hash *it, void **data)
    Eina_Bool ok;
    int bucket;
 
-   if (!(it->index < it->hash->population)) return EINA_FALSE;
+   if (!(it->index < it->hash->population))
+      return EINA_FALSE;
+
    if (it->current == NULL)
      {
-       ok = EINA_FALSE;
-       bucket = 0;
-       it->index = -1;
+        ok = EINA_FALSE;
+        bucket = 0;
+        it->index = -1;
      }
    else
      {
-       ok = eina_iterator_next(it->list, (void**) &it->el);
-       if (!ok)
-         {
-            eina_iterator_free(it->list);
-            it->list = NULL;
-
-            ok = eina_iterator_next(it->current, (void**) &it->eh);
-            if (!ok)
-              {
-                 eina_iterator_free(it->current);
-                 it->current = NULL;
-                 it->bucket++;
-              }
-            else
-              {
-                 it->list = eina_rbtree_iterator_prefix(it->eh->head);
-                 ok = eina_iterator_next(it->list, (void**) &it->el);
-              }
-         }
-
-       bucket = it->bucket;
+        ok = eina_iterator_next(it->list, (void **)&it->hash_element);
+        if (!ok)
+          {
+                  eina_iterator_free(it->list);
+             it->list = NULL;
+
+             ok = eina_iterator_next(it->current, (void **)&it->hash_head);
+             if (!ok)
+               {
+                  eina_iterator_free(it->current);
+                  it->current = NULL;
+                  it->bucket++;
+               }
+             else
+               {
+                  it->list = eina_rbtree_iterator_prefix(it->hash_head->head);
+                  ok = eina_iterator_next(it->list, (void **)&it->hash_element);
+               }
+          }
+
+        bucket = it->bucket;
      }
 
    if (ok == EINA_FALSE)
      {
-       while (bucket < it->hash->size)
-         {
-            if (it->hash->buckets[bucket] != NULL)
-              {
-                 it->current = eina_rbtree_iterator_prefix(it->hash->buckets[bucket]);
-                 ok = eina_iterator_next(it->current, (void**) &it->eh);
-                 if (ok) break ;
-                 eina_iterator_free(it->current);
-                 it->current = NULL;
-              }
-            ++bucket;
-         }
-       if (it->list) eina_iterator_free(it->list);
-       it->list = eina_rbtree_iterator_prefix(it->eh->head);
-       ok = eina_iterator_next(it->list, (void**) &it->el);
-       if (bucket == it->hash->size) ok = EINA_FALSE;
+        while (bucket < it->hash->size)
+          {
+             if (it->hash->buckets[bucket] != NULL)
+               {
+                  it->current =
+                     eina_rbtree_iterator_prefix(it->hash->buckets[bucket]);
+                  ok = eina_iterator_next(it->current, (void **)&it->hash_head);
+                  if (ok)
+                     break;
+
+                  eina_iterator_free(it->current);
+                  it->current = NULL;
+               }
+
+             ++bucket;
+          }
+        if (it->list)
+                  eina_iterator_free(it->list);
+
+        it->list = eina_rbtree_iterator_prefix(it->hash_head->head);
+        ok = eina_iterator_next(it->list, (void **)&it->hash_element);
+        if (bucket == it->hash->size)
+           ok = EINA_FALSE;
      }
 
    it->index++;
    it->bucket = bucket;
 
    if (ok)
-     *data = it->get_content(it);
+      *data = it->get_content(it);
 
    return ok;
 }
@@ -588,17 +673,21 @@ _eina_hash_iterator_next(Eina_Iterator_Hash *it, void **data)
 static void *
 _eina_hash_iterator_get_container(Eina_Iterator_Hash *it)
 {
-   EINA_MAGIC_CHECK_HASH_ITERATOR(it, NULL);
-   return (void *) it->hash;
+      EINA_MAGIC_CHECK_HASH_ITERATOR(it, NULL);
+   return (void *)it->hash;
 }
 
 static void
 _eina_hash_iterator_free(Eina_Iterator_Hash *it)
 {
-   EINA_MAGIC_CHECK_HASH_ITERATOR(it);
-   if (it->current) eina_iterator_free(it->current);
-   if (it->list) eina_iterator_free(it->list);
-   free(it);
+      EINA_MAGIC_CHECK_HASH_ITERATOR(it);
+   if (it->current)
+      eina_iterator_free(it->current);
+
+   if (it->list)
+      eina_iterator_free(it->list);
+
+      free(it);
 }
 
 /**
@@ -606,12 +695,12 @@ _eina_hash_iterator_free(Eina_Iterator_Hash *it)
  */
 
 /*============================================================================*
- *                                 Global                                     *
- *============================================================================*/
+*                                 Global                                     *
+*============================================================================*/
 
 /*============================================================================*
- *                                   API                                      *
- *============================================================================*/
+*                                   API                                      *
+*============================================================================*/
 
 /**
  * @addtogroup Eina_Hash_Group Hash Table
@@ -640,22 +729,23 @@ _eina_hash_iterator_free(Eina_Iterator_Hash *it)
 
 EAPI Eina_Hash *
 eina_hash_new(Eina_Key_Length key_length_cb,
-             Eina_Key_Cmp key_cmp_cb,
-             Eina_Key_Hash key_hash_cb,
-             Eina_Free_Cb data_free_cb,
-             int buckets_power_size)
+              Eina_Key_Cmp key_cmp_cb,
+              Eina_Key_Hash key_hash_cb,
+              Eina_Free_Cb data_free_cb,
+              int buckets_power_size)
 {
    /* FIXME: Use mempool. */
    Eina_Hash *new;
 
    eina_error_set(0);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(key_cmp_cb, NULL);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(key_cmp_cb,  NULL);
    EINA_SAFETY_ON_NULL_RETURN_VAL(key_hash_cb, NULL);
-   EINA_SAFETY_ON_TRUE_RETURN_VAL(buckets_power_size < 3, NULL);
+   EINA_SAFETY_ON_TRUE_RETURN_VAL(buckets_power_size < 3,  NULL);
    EINA_SAFETY_ON_TRUE_RETURN_VAL(buckets_power_size > 16, NULL);
 
    new = malloc(sizeof (Eina_Hash));
-   if (!new) goto on_error;
+   if (!new)
+      goto on_error;
 
    new->key_length_cb = key_length_cb;
    new->key_cmp_cb = key_cmp_cb;
@@ -671,113 +761,189 @@ eina_hash_new(Eina_Key_Length key_length_cb,
 
    return new;
 
- on_error:
+on_error:
    eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
    return NULL;
 }
 
+/**
+ * @brief Create a new hash using the djb2 algorithm.
+ * @param data_free_cb The function to call on values when the hash table is freed
+ * @return The @ref Eina_Hash object, or @c NULL on error
+ * Use to create a new hash using the djb2 algorithm for table management and strcmp to compare keys.
+ * NOTE: If your hash is created by this, you CAN look up values with pointers other
+ * than the original key pointer that was used to add a value.
+ */
 EAPI Eina_Hash *
 eina_hash_string_djb2_new(Eina_Free_Cb data_free_cb)
 {
    return eina_hash_new(EINA_KEY_LENGTH(_eina_string_key_length),
-                       EINA_KEY_CMP(_eina_string_key_cmp),
-                       EINA_KEY_HASH(eina_hash_djb2),
-                       data_free_cb,
-                       EINA_HASH_BUCKET_SIZE);
+                        EINA_KEY_CMP(_eina_string_key_cmp),
+                        EINA_KEY_HASH(eina_hash_djb2),
+                        data_free_cb,
+                        EINA_HASH_BUCKET_SIZE);
 }
 
+/**
+ * @brief Create a new hash for use with strings.
+ * @param data_free_cb The function to call on values when the hash table is freed
+ * @return The @ref Eina_Hash object, or @c NULL on error
+ * Use to create a new hash using the superfast algorithm for table management and strcmp to compare keys.
+ * NOTE: If your hash is created by this, you CAN look up values with pointers other
+ * than the original key pointer that was used to add a value.
+ */
 EAPI Eina_Hash *
 eina_hash_string_superfast_new(Eina_Free_Cb data_free_cb)
 {
    return eina_hash_new(EINA_KEY_LENGTH(_eina_string_key_length),
-                       EINA_KEY_CMP(_eina_string_key_cmp),
-                       EINA_KEY_HASH(eina_hash_superfast),
-                       data_free_cb,
-                       EINA_HASH_BUCKET_SIZE);
+                        EINA_KEY_CMP(_eina_string_key_cmp),
+                        EINA_KEY_HASH(eina_hash_superfast),
+                        data_free_cb,
+                        EINA_HASH_BUCKET_SIZE);
 }
 
+/**
+ * @brief Create a new hash for use with strings. If you are unsure of which hash creation
+ * function to use, use this one.
+ * @param data_free_cb The function to call on values when the hash table is freed
+ * @return The @ref Eina_Hash object, or @c NULL on error
+ * Use to create a new hash using the superfast algorithm for table management and strcmp to compare keys.
+ * This method also uses a reduced bucket size which will minimize the memory used by the table.
+ * If you are unsure of which hash creation function to use, you should probably use this one.
+ * NOTE: If your hash is created by this, you CAN look up values with pointers other
+ * than the original key pointer that was used to add a value.
+ */
 EAPI Eina_Hash *
 eina_hash_string_small_new(Eina_Free_Cb data_free_cb)
 {
    return eina_hash_new(EINA_KEY_LENGTH(_eina_string_key_length),
-                       EINA_KEY_CMP(_eina_string_key_cmp),
-                       EINA_KEY_HASH(eina_hash_superfast),
-                       data_free_cb,
-                       EINA_HASH_SMALL_BUCKET_SIZE);
+                        EINA_KEY_CMP(_eina_string_key_cmp),
+                        EINA_KEY_HASH(eina_hash_superfast),
+                        data_free_cb,
+                        EINA_HASH_SMALL_BUCKET_SIZE);
 }
 
+/**
+ * @brief Create a new hash for use with 32bit ints
+ * @param data_free_cb The function to call on values when the hash table is freed
+ * @return The @ref Eina_Hash object, or @c NULL on error
+ * Use to create a new hash using the int32 algorithm for table management and dereferenced
+ * pointers to compare keys.
+ * NOTE: If your hash is created by this, you CAN look up values with pointers other
+ * than the original key pointer that was used to add a value. Also note that while this method may
+ * appear to be able to match string keys, it is really only matching the first character.
+ */
 EAPI Eina_Hash *
 eina_hash_int32_new(Eina_Free_Cb data_free_cb)
 {
    return eina_hash_new(EINA_KEY_LENGTH(_eina_int32_key_length),
-                       EINA_KEY_CMP(_eina_int32_key_cmp),
-                       EINA_KEY_HASH(eina_hash_int32),
-                       data_free_cb,
-                       EINA_HASH_BUCKET_SIZE);
+                        EINA_KEY_CMP(_eina_int32_key_cmp),
+                        EINA_KEY_HASH(eina_hash_int32),
+                        data_free_cb,
+                        EINA_HASH_BUCKET_SIZE);
 }
 
+/**
+ * @brief Create a new hash for use with 64bit ints
+ * @param data_free_cb The function to call on values when the hash table is freed
+ * @return The @ref Eina_Hash object, or @c NULL on error
+ * Use to create a new hash using the int64 algorithm for table management and dereferenced
+ * pointers to compare keys.
+ * NOTE: If your hash is created by this, you CAN look up values with pointers other
+ * than the original key pointer that was used to add a value. Also note that while this method may
+ * appear to be able to match string keys, it is really only matching the first character.
+ */
 EAPI Eina_Hash *
 eina_hash_int64_new(Eina_Free_Cb data_free_cb)
 {
    return eina_hash_new(EINA_KEY_LENGTH(_eina_int64_key_length),
-                       EINA_KEY_CMP(_eina_int64_key_cmp),
-                       EINA_KEY_HASH(eina_hash_int64),
-                       data_free_cb,
-                       EINA_HASH_BUCKET_SIZE);
+                        EINA_KEY_CMP(_eina_int64_key_cmp),
+                        EINA_KEY_HASH(eina_hash_int64),
+                        data_free_cb,
+                        EINA_HASH_BUCKET_SIZE);
 }
 
+/**
+ * @brief Create a new hash for use with pointers
+ * @param data_free_cb The function to call on values when the hash table is freed
+ * @return The @ref Eina_Hash object, or @c NULL on error
+ * Use to create a new hash using the int64 algorithm for table management and dereferenced
+ * pointers to compare keys.
+ * NOTE: If your hash is created by this, you CAN look up values with pointers other
+ * than the original key pointer that was used to add a value. Also note that while this method may
+ * appear to be able to match string keys, it is really only matching the first character.
+ */
 EAPI Eina_Hash *
 eina_hash_pointer_new(Eina_Free_Cb data_free_cb)
 {
 #ifdef __LP64__
    return eina_hash_new(EINA_KEY_LENGTH(_eina_int64_key_length),
-                       EINA_KEY_CMP(_eina_int64_key_cmp),
-                       EINA_KEY_HASH(eina_hash_int64),
-                       data_free_cb,
-                       EINA_HASH_BUCKET_SIZE);
+                        EINA_KEY_CMP(_eina_int64_key_cmp),
+                        EINA_KEY_HASH(eina_hash_int64),
+                        data_free_cb,
+                        EINA_HASH_BUCKET_SIZE);
 #else
    return eina_hash_new(EINA_KEY_LENGTH(_eina_int32_key_length),
-                       EINA_KEY_CMP(_eina_int32_key_cmp),
-                       EINA_KEY_HASH(eina_hash_int32),
-                       data_free_cb,
-                       EINA_HASH_BUCKET_SIZE);
+                        EINA_KEY_CMP(_eina_int32_key_cmp),
+                        EINA_KEY_HASH(eina_hash_int32),
+                        data_free_cb,
+                        EINA_HASH_BUCKET_SIZE);
 #endif
 }
-
+/**
+ * @brief Create a new hash optimized for stringshared values.
+ * @param data_free_cb The function to call on values when the hash table is freed
+ * @return The @ref Eina_Hash object, or @c NULL on error
+ * Use to create a new hash optimized for stringshared values.
+ * NOTE: If your hash is created by this, you CANNOT look up values with pointers not
+ * equal to the original key pointer that was used to add a value.
+ * The following code will NOT work with this type of hash:
+ * @code
+ * extern Eina_Hash *hash;
+ * extern const char *value;
+ * const char *a = eina_stringshare_add("key");
+ *
+ * eina_hash_add(hash, a, value);
+ * eina_hash_find(hash, "key")
+ * @endcode
+ */
 EAPI Eina_Hash *
 eina_hash_stringshared_new(Eina_Free_Cb data_free_cb)
 {
    return eina_hash_new(NULL,
-                       EINA_KEY_CMP(_eina_stringshared_key_cmp),
-                       EINA_KEY_HASH(eina_hash_superfast),
-                       data_free_cb,
-                       EINA_HASH_BUCKET_SIZE);
+                        EINA_KEY_CMP(_eina_stringshared_key_cmp),
+                        EINA_KEY_HASH(eina_hash_superfast),
+                        data_free_cb,
+                        EINA_HASH_BUCKET_SIZE);
 }
 
 /**
- * Retrieves the number of buckets available in the given hash table.
+ * @brief Returns the number of entires in the hash table.
  * @param hash The given hash table.
- * @return @c 256 if @p hash is not @c NULL.  @c 0 otherwise.
+ * @return The number of entries in the hash table, @c 0 on error
+ * Returns the number of entires in the hash table.
  */
 EAPI int
 eina_hash_population(const Eina_Hash *hash)
 {
-   if (!hash) return 0;
+   if (!hash)
+      return 0;
 
    EINA_MAGIC_CHECK_HASH(hash);
    return hash->population;
 }
 
 /**
- * Free an entire hash table
+ * Calls @ref Eina_Free_Cb (if one was specified at time of creation) on all hash table
+ * buckets, frees the buckets, then frees the hash table
  * @param hash The hash table to be freed
  *
  * This function frees up all the memory allocated to storing the specified
- * hash tale pointed to by @p hash. If no data_free_cb has been passed to the
+ * hash table pointed to by @p hash. If no data_free_cb has been passed to the
  * hash at creation time, any entries in the table that the program
  * has no more pointers for elsewhere may now be lost, so this should only be
- * called if the program has lready freed any allocated data in the hash table
- * or has the pointers for data in teh table stored elswehere as well.
+ * called if the program has already freed any allocated data in the hash table
+ * or has the pointers for data in the table stored elsewhere as well.
  *
  * Example:
  * @code
@@ -797,14 +963,42 @@ eina_hash_free(Eina_Hash *hash)
 
    if (hash->buckets)
      {
-       for (i = 0; i < hash->size; i++)
-         eina_rbtree_delete(hash->buckets[i], EINA_RBTREE_FREE_CB(_eina_hash_head_free), hash);
-       free(hash->buckets);
+        for (i = 0; i < hash->size; i++)
+           eina_rbtree_delete(hash->buckets[i], EINA_RBTREE_FREE_CB(_eina_hash_head_free), hash);
+        free(hash->buckets);
      }
    free(hash);
 }
 
 /**
+ * Calls @ref Eina_Free_Cb (if one was specified at time of creation) on all hash table buckets,
+ * then frees the buckets.
+ * @param hash The hash table to free buckets on
+ *
+ * Frees all memory allocated for hash table buckets.  Note that the bucket value is not freed
+ * unless an @ref Eina_Free_Cb was specified at creation time.
+ * @see Noooo they be stealin' my bucket!
+ */
+EAPI void
+eina_hash_free_buckets(Eina_Hash *hash)
+{
+   int i;
+
+   EINA_MAGIC_CHECK_HASH(hash);
+   EINA_SAFETY_ON_NULL_RETURN(hash);
+
+   if (hash->buckets)
+     {
+        for (i = 0; i < hash->size; i++)
+           eina_rbtree_delete(hash->buckets[i],
+                              EINA_RBTREE_FREE_CB(_eina_hash_head_free), hash);
+        free(hash->buckets);
+        hash->buckets = NULL;
+        hash->population = 0;
+     }
+}
+
+/**
  * Adds an entry to the given hash table.
  *
  * @p key is expected to be a unique string within the hash table.
@@ -830,10 +1024,15 @@ eina_hash_free(Eina_Hash *hash)
  */
 EAPI Eina_Bool
 eina_hash_add_by_hash(Eina_Hash *hash,
-                     const void *key, int key_length, int key_hash,
-                     const void *data)
+                      const void *key, int key_length, int key_hash,
+                      const void *data)
 {
-   return eina_hash_add_alloc_by_hash(hash, key, key_length, key_length, key_hash, data);
+   return eina_hash_add_alloc_by_hash(hash,
+                                     key,
+                                      key_length,
+                                      key_length,
+                                      key_hash,
+                                      data);
 }
 
 /**
@@ -863,8 +1062,8 @@ eina_hash_add_by_hash(Eina_Hash *hash,
  */
 EAPI Eina_Bool
 eina_hash_direct_add_by_hash(Eina_Hash *hash,
-                            const void *key, int key_length, int key_hash,
-                            const void *data)
+                             const void *key, int key_length, int key_hash,
+                             const void *data)
 {
    return eina_hash_add_alloc_by_hash(hash, key, key_length, 0, key_hash, data);
 }
@@ -872,10 +1071,12 @@ eina_hash_direct_add_by_hash(Eina_Hash *hash,
 /**
  * Adds an entry to the given hash table.
  *
- * @p key is expected to be a unique string within the hash table.
- * Otherwise, you cannot be sure which inserted data pointer will be
- * accessed with @ref eina_hash_find , and removed with
- * @ref eina_hash_del .
+ * @p key is expected to be unique within the hash table.  Key uniqueness varies depending
+ * on the type of @p hash: a stringshared @ref Eina_Hash need only have unique pointers for
+ * keys, but the strings in the pointers may be identical.  All other hash types require
+ * the strings themselves to be unique.  Failure to use sufficient uniqueness will result in
+ * unexpected results when inserting data pointers accessed with @ref eina_hash_find ,
+ * and removed with @ref eina_hash_del .
  *
  * Key strings are case sensitive.
  *
@@ -895,25 +1096,28 @@ eina_hash_add(Eina_Hash *hash, const void *key, const void *data)
    int key_hash;
 
    EINA_MAGIC_CHECK_HASH(hash);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(hash,              EINA_FALSE);
    EINA_SAFETY_ON_NULL_RETURN_VAL(hash->key_hash_cb, EINA_FALSE);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(key,               EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(data,              EINA_FALSE);
 
    key_length = hash->key_length_cb ? hash->key_length_cb(key) : 0;
    key_hash = hash->key_hash_cb(key, key_length);
 
-   return eina_hash_add_by_hash(hash, key, key_length, key_hash, data);
+   return eina_hash_add_alloc_by_hash(hash, key, key_length, key_length, key_hash, data);
 }
 
 /**
- * Adds an entry to the given hash table and does not duplicate the string key.
+ * Adds an entry to the given hash table but does not duplicate the string key.
  *
- * @p key is expected to be a unique string within the hash table.
- * Otherwise, you cannot be sure which inserted data pointer will be
- * accessed with @ref eina_hash_find , and removed with
- * @ref eina_hash_del . This call does not make a copy of the key so it must
- * be a string constant or stored elsewhere (in the object being added) etc.
+ * @p key is expected to be unique within the hash table.  Key uniqueness varies depending
+ * on the type of @p hash: a stringshared @ref Eina_Hash need only have unique pointers for
+ * keys, but the strings in the pointers may be identical.  All other hash types require
+ * the strings themselves to be unique.  Failure to use sufficient uniqueness will result in
+ * unexpected results when inserting data pointers accessed with @ref eina_hash_find ,
+ * and removed with @ref eina_hash_del . This call does not make a copy
+ * of the key so it must be a string constant or stored elsewhere (in the object
+ * being added) etc.
  *
  * Key strings are case sensitive.
  *
@@ -932,21 +1136,23 @@ eina_hash_direct_add(Eina_Hash *hash, const void *key, const void *data)
    int key_length;
    int key_hash;
 
-   EINA_MAGIC_CHECK_HASH(hash);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(hash,              EINA_FALSE);
    EINA_SAFETY_ON_NULL_RETURN_VAL(hash->key_hash_cb, EINA_FALSE);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(key,               EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(data,              EINA_FALSE);
+   EINA_MAGIC_CHECK_HASH(hash);
 
    key_length = hash->key_length_cb ? hash->key_length_cb(key) : 0;
    key_hash = hash->key_hash_cb(key, key_length);
 
-   return eina_hash_direct_add_by_hash(hash, key, key_length, key_hash, data);
+   return eina_hash_add_alloc_by_hash(hash, key, key_length, 0, key_hash, data);
 }
 
 /**
  * Removes the entry identified by @p key and @p key_hash from the given
  * hash table.
+ * If a free function was given to the callback on creation, it will be
+ * called for the data being deleted.
  *
  * @param   hash The given hash table.
  * @param   key  The key.  Cannot be @c NULL.
@@ -959,15 +1165,21 @@ eina_hash_direct_add(Eina_Hash *hash, const void *key, const void *data)
  * @note if you don't have the key, use eina_hash_del_by_data() instead.
  */
 EAPI Eina_Bool
-eina_hash_del_by_key_hash(Eina_Hash *hash, const void *key, int key_length, int key_hash)
+eina_hash_del_by_key_hash(Eina_Hash *hash,
+                          const void *key,
+                          int key_length,
+                          int key_hash)
 {
    EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(key,  EINA_FALSE);
+
    return _eina_hash_del_by_key_hash(hash, key, key_length, key_hash, NULL);
 }
 
 /**
  * Removes the entry identified by @p key from the given hash table.
+ * If a free function was given to the callback on creation, it will be
+ * called for the data being deleted.
  *
  * This version will calculate key length and hash by using functions
  * provided to hash creation function.
@@ -984,12 +1196,15 @@ EAPI Eina_Bool
 eina_hash_del_by_key(Eina_Hash *hash, const void *key)
 {
    EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(key,  EINA_FALSE);
+
    return _eina_hash_del_by_key(hash, key, NULL);
 }
 
 /**
  * Removes the entry identified by @p data from the given hash table.
+ * If a free function was given to the callback on creation, it will be
+ * called for the data being deleted.
  *
  * This version is slow since there is no quick access to nodes based on data.
  *
@@ -1003,23 +1218,32 @@ eina_hash_del_by_key(Eina_Hash *hash, const void *key)
 EAPI Eina_Bool
 eina_hash_del_by_data(Eina_Hash *hash, const void *data)
 {
-   Eina_Hash_El *el;
-   Eina_Hash_Head *eh;
+   Eina_Hash_Element *hash_element;
+   Eina_Hash_Head *hash_head;
    int key_hash;
 
-   EINA_MAGIC_CHECK_HASH(hash);
    EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
    EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
+   EINA_MAGIC_CHECK_HASH(hash);
 
-   el = _eina_hash_find_by_data(hash, data, &key_hash, &eh);
-   if (!el) return EINA_FALSE;
-   if (el->tuple.data != data) return EINA_FALSE;
-   return _eina_hash_del_by_hash_el(hash, el, eh, key_hash);
+   hash_element = _eina_hash_find_by_data(hash, data, &key_hash, &hash_head);
+   if (!hash_element)
+      goto error;
+
+   if (hash_element->tuple.data != data)
+      goto error;
+
+   return _eina_hash_del_by_hash_el(hash, hash_element, hash_head, key_hash);
+
+error:
+   return EINA_FALSE;
 }
 
 /**
  * Removes the entry identified by @p key and @p key_hash or @p data from the given
  * hash table.
+ * If a free function was given to the callback on creation, it will be
+ * called for the data being deleted.
  *
  * If @p key is @c NULL, then @p data is used to find a match to
  * remove.
@@ -1038,17 +1262,30 @@ eina_hash_del_by_data(Eina_Hash *hash, const void *data)
  *       directly.
  */
 EAPI Eina_Bool
-eina_hash_del_by_hash(Eina_Hash *hash, const void *key, int key_length, int key_hash, const void *data)
+eina_hash_del_by_hash(Eina_Hash *hash,
+                      const void *key,
+                      int key_length,
+                      int key_hash,
+                      const void *data)
 {
-   EINA_MAGIC_CHECK_HASH(hash);
+   Eina_Bool ret;
+
    EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
-   if (key) return _eina_hash_del_by_key_hash(hash, key, key_length, key_hash, data);
-   else return eina_hash_del_by_data(hash, data);
+   EINA_MAGIC_CHECK_HASH(hash);
+
+   if (key)
+      ret = _eina_hash_del_by_key_hash(hash, key, key_length, key_hash, data);
+   else
+      ret = eina_hash_del_by_data(hash, data);
+
+   return ret;
 }
 
 /**
  * Removes the entry identified by @p key or @p data from the given
  * hash table.
+ * If a free function was given to the callback on creation, it will be
+ * called for the data being deleted.
  *
  * If @p key is @c NULL, then @p data is used to find a match to
  * remove.
@@ -1068,10 +1305,13 @@ eina_hash_del_by_hash(Eina_Hash *hash, const void *key, int key_length, int key_
 EAPI Eina_Bool
 eina_hash_del(Eina_Hash *hash, const void *key, const void *data)
 {
-   EINA_MAGIC_CHECK_HASH(hash);
    EINA_SAFETY_ON_NULL_RETURN_VAL(hash, EINA_FALSE);
-   if (key) return _eina_hash_del_by_key(hash, key, data);
-   else return eina_hash_del_by_data(hash, data);
+   EINA_MAGIC_CHECK_HASH(hash);
+
+   if (!key)
+     return eina_hash_del_by_data(hash, data);
+
+   return _eina_hash_del_by_key(hash, key, data);
 }
 
 /**
@@ -1084,23 +1324,29 @@ eina_hash_del(Eina_Hash *hash, const void *key, const void *data)
  *          found.
  */
 EAPI void *
-eina_hash_find_by_hash(const Eina_Hash *hash, const void *key, int key_length, int key_hash)
+eina_hash_find_by_hash(const Eina_Hash *hash,
+                       const void *key,
+                       int key_length,
+                       int key_hash)
 {
-   Eina_Hash_Head *eh;
-   Eina_Hash_El *el;
+   Eina_Hash_Head *hash_head;
+   Eina_Hash_Element *hash_element;
    Eina_Hash_Tuple tuple;
 
-   if (!hash) return NULL;
+   if (!hash)
+      return NULL;
 
-   EINA_MAGIC_CHECK_HASH(hash);
    EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
+   EINA_MAGIC_CHECK_HASH(hash);
 
    tuple.key = key;
    tuple.key_length = key_length;
    tuple.data = NULL;
 
-   el = _eina_hash_find_by_hash(hash, &tuple, key_hash, &eh);
-   if (el) return el->tuple.data;
+   hash_element = _eina_hash_find_by_hash(hash, &tuple, key_hash, &hash_head);
+   if (hash_element)
+      return hash_element->tuple.data;
+
    return NULL;
 }
 
@@ -1117,11 +1363,12 @@ eina_hash_find(const Eina_Hash *hash, const void *key)
    int key_length;
    int hash_num;
 
-   if (!hash) return NULL;
+   if (!hash)
+      return NULL;
 
-   EINA_MAGIC_CHECK_HASH(hash);
    EINA_SAFETY_ON_NULL_RETURN_VAL(hash->key_hash_cb, NULL);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(key,               NULL);
+   EINA_MAGIC_CHECK_HASH(hash);
 
    key_length = hash->key_length_cb ? hash->key_length_cb(key) : 0;
    hash_num = hash->key_hash_cb(key, key_length);
@@ -1141,33 +1388,89 @@ eina_hash_find(const Eina_Hash *hash, const void *key)
  *          hash.
  */
 EAPI void *
-eina_hash_modify_by_hash(Eina_Hash *hash, const void *key, int key_length, int key_hash, const void *data)
+eina_hash_modify_by_hash(Eina_Hash *hash,
+                         const void *key,
+                         int key_length,
+                         int key_hash,
+                         const void *data)
 {
-   Eina_Hash_Head *eh;
-   Eina_Hash_El *el;
+   Eina_Hash_Head *hash_head;
+   Eina_Hash_Element *hash_element;
    void *old_data = NULL;
    Eina_Hash_Tuple tuple;
 
-   EINA_MAGIC_CHECK_HASH(hash);
    EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(key,  NULL);
    EINA_SAFETY_ON_NULL_RETURN_VAL(data, NULL);
+   EINA_MAGIC_CHECK_HASH(hash);
 
    tuple.key = key;
    tuple.key_length = key_length;
    tuple.data = NULL;
 
-   el = _eina_hash_find_by_hash(hash, &tuple, key_hash, &eh);
-   if (el)
+   hash_element = _eina_hash_find_by_hash(hash, &tuple, key_hash, &hash_head);
+   if (hash_element)
      {
-       old_data = el->tuple.data;
-       el->tuple.data = (void *) data;
+        old_data = hash_element->tuple.data;
+        hash_element->tuple.data = (void *)data;
      }
 
    return old_data;
 }
 
 /**
+ * Modifies the entry pointer at the specified key and returns the old entry or
+ * adds the entry if not found
+ * @param   hash The given hash table.
+ * @param   key  The key of the entry to modify.
+ * @param   data The data to replace the old entry
+ * @return  The data pointer for the old stored entry, or @c NULL if not
+ *          found. If an existing entry is not found, the entry is added to the hash.
+ *
+ * This function adds the specified data to the table at with the key regardless
+ * of whether it is there.  To check for errors, use @ref eina_error_get
+ */
+EAPI void *
+eina_hash_set(Eina_Hash *hash, const void *key, const void *data)
+{
+   Eina_Hash_Tuple tuple;
+   Eina_Hash_Head *hash_head;
+   Eina_Hash_Element *hash_element;
+   int key_length;
+   int key_hash;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(hash,              NULL);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(hash->key_hash_cb, NULL);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(key,               NULL);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(data,              NULL);
+   EINA_MAGIC_CHECK_HASH(hash);
+
+   key_length = hash->key_length_cb ? hash->key_length_cb(key) : 0;
+   key_hash = hash->key_hash_cb(key, key_length);
+
+   tuple.key = key;
+   tuple.key_length = key_length;
+   tuple.data = NULL;
+
+   hash_element = _eina_hash_find_by_hash(hash, &tuple, key_hash, &hash_head);
+   if (hash_element)
+     {
+        void *old_data = NULL;
+
+        old_data = hash_element->tuple.data;
+        hash_element->tuple.data = (void *)data;
+        return old_data;
+     }
+
+   eina_hash_add_alloc_by_hash(hash,
+                               key,
+                               key_length,
+                               key_length,
+                               key_hash,
+                               data);
+   return NULL;
+}
+/**
  * Modifies the entry pointer at the specified key and returns the old entry
  * @param   hash The given hash table.
  * @param   key  The key of the entry to modify.
@@ -1182,11 +1485,11 @@ eina_hash_modify(Eina_Hash *hash, const void *key, const void *data)
    int key_length;
    int hash_num;
 
-   EINA_MAGIC_CHECK_HASH(hash);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(hash,              NULL);
    EINA_SAFETY_ON_NULL_RETURN_VAL(hash->key_hash_cb, NULL);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(data, NULL);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(key,               NULL);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(data,              NULL);
+   EINA_MAGIC_CHECK_HASH(hash);
 
    key_length = hash->key_length_cb ? hash->key_length_cb(key) : 0;
    hash_num = hash->key_hash_cb(key, key_length);
@@ -1194,9 +1497,47 @@ eina_hash_modify(Eina_Hash *hash, const void *key, const void *data)
    return eina_hash_modify_by_hash(hash, key, key_length, hash_num, data);
 }
 
+/**
+ * @brief Change the key associated with a data without triggering the free callback.
+ * @param hash    The given hash table.
+ * @param old_key The current key associated with the data
+ * @param new_key The new key to associate data with
+ * @return EINA_FALSE in any case but success, EINA_TRUE on success.
+ * This function allows for the move of data from one key to another,
+ * but does not call the Eina_Free_Cb associated with the hash table
+ * when destroying the old key.
+ */
+EAPI Eina_Bool
+eina_hash_move(Eina_Hash *hash, const void *old_key, const void *new_key)
+{
+   Eina_Free_Cb hash_free_cb;
+   const void *data;
+   Eina_Bool result = EINA_FALSE;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(hash,              EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(hash->key_hash_cb, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(old_key,           EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(new_key,           EINA_FALSE);
+   EINA_MAGIC_CHECK_HASH(hash);
+
+   data = eina_hash_find(hash, old_key);
+   if (!data) goto error;
+
+   hash_free_cb = hash->data_free_cb;
+   hash->data_free_cb = NULL;
+
+   eina_hash_del(hash, old_key, data);
+   result = eina_hash_add(hash, new_key, data);
+
+   hash->data_free_cb = hash_free_cb;
+
+error:
+   return result;
+}
+
 /*============================================================================*
- *                                Iterator                                    *
- *============================================================================*/
+*                                Iterator                                    *
+*============================================================================*/
 
 /**
  * Call a function on every member stored in the hash table
@@ -1232,8 +1573,8 @@ eina_hash_modify(Eina_Hash *hash, const void *key, const void *data)
  */
 EAPI void
 eina_hash_foreach(const Eina_Hash *hash,
-                 Eina_Hash_Foreach func,
-                 const void *fdata)
+                  Eina_Hash_Foreach func,
+                  const void *fdata)
 {
    Eina_Iterator *it;
    Eina_Hash_Foreach_Data foreach;
@@ -1246,9 +1587,10 @@ eina_hash_foreach(const Eina_Hash *hash,
    foreach.fdata = fdata;
 
    it = eina_hash_iterator_tuple_new(hash);
-   if (!it) return;
+   if (!it)
+      return;
+   eina_iterator_foreach(it, EINA_EACH_CB(_eina_foreach_cb), &foreach);
 
-   eina_iterator_foreach(it, EINA_EACH(_eina_foreach_cb), &foreach);
    eina_iterator_free(it);
 }
 
@@ -1276,25 +1618,28 @@ eina_hash_iterator_data_new(const Eina_Hash *hash)
 {
    Eina_Iterator_Hash *it;
 
-   EINA_MAGIC_CHECK_HASH(hash);
    EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
+   EINA_MAGIC_CHECK_HASH(hash);
 
    eina_error_set(0);
    it = calloc(1, sizeof (Eina_Iterator_Hash));
-   if (!it) {
-      eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
-      return NULL;
-   }
+   if (!it)
+     {
+        eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+        return NULL;
+     }
 
    it->hash = hash;
    it->get_content = FUNC_ITERATOR_GET_CONTENT(_eina_hash_iterator_data_get_content);
 
+   it->iterator.version = EINA_ITERATOR_VERSION;
    it->iterator.next = FUNC_ITERATOR_NEXT(_eina_hash_iterator_next);
-   it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(_eina_hash_iterator_get_container);
+   it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
+         _eina_hash_iterator_get_container);
    it->iterator.free = FUNC_ITERATOR_FREE(_eina_hash_iterator_free);
 
    EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
-   EINA_MAGIC_SET(it, EINA_MAGIC_HASH_ITERATOR);
+   EINA_MAGIC_SET(it,            EINA_MAGIC_HASH_ITERATOR);
 
    return &it->iterator;
 }
@@ -1323,25 +1668,29 @@ eina_hash_iterator_key_new(const Eina_Hash *hash)
 {
    Eina_Iterator_Hash *it;
 
-   EINA_MAGIC_CHECK_HASH(hash);
    EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
+   EINA_MAGIC_CHECK_HASH(hash);
 
    eina_error_set(0);
    it = calloc(1, sizeof (Eina_Iterator_Hash));
-   if (!it) {
-      eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
-      return NULL;
-   }
+   if (!it)
+     {
+        eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+        return NULL;
+     }
 
    it->hash = hash;
-   it->get_content = FUNC_ITERATOR_GET_CONTENT(_eina_hash_iterator_key_get_content);
+   it->get_content = FUNC_ITERATOR_GET_CONTENT(
+         _eina_hash_iterator_key_get_content);
 
+   it->iterator.version = EINA_ITERATOR_VERSION;
    it->iterator.next = FUNC_ITERATOR_NEXT(_eina_hash_iterator_next);
-   it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(_eina_hash_iterator_get_container);
+   it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
+         _eina_hash_iterator_get_container);
    it->iterator.free = FUNC_ITERATOR_FREE(_eina_hash_iterator_free);
 
    EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
-   EINA_MAGIC_SET(it, EINA_MAGIC_HASH_ITERATOR);
+   EINA_MAGIC_SET(it,            EINA_MAGIC_HASH_ITERATOR);
 
    return &it->iterator;
 }
@@ -1373,25 +1722,29 @@ eina_hash_iterator_tuple_new(const Eina_Hash *hash)
 {
    Eina_Iterator_Hash *it;
 
-   EINA_MAGIC_CHECK_HASH(hash);
    EINA_SAFETY_ON_NULL_RETURN_VAL(hash, NULL);
+   EINA_MAGIC_CHECK_HASH(hash);
 
    eina_error_set(0);
    it = calloc(1, sizeof (Eina_Iterator_Hash));
-   if (!it) {
-      eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
-      return NULL;
-   }
+   if (!it)
+     {
+        eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+        return NULL;
+     }
 
    it->hash = hash;
-   it->get_content = FUNC_ITERATOR_GET_CONTENT(_eina_hash_iterator_tuple_get_content);
+   it->get_content = FUNC_ITERATOR_GET_CONTENT(
+         _eina_hash_iterator_tuple_get_content);
 
+   it->iterator.version = EINA_ITERATOR_VERSION;
    it->iterator.next = FUNC_ITERATOR_NEXT(_eina_hash_iterator_next);
-   it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(_eina_hash_iterator_get_container);
+   it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
+         _eina_hash_iterator_get_container);
    it->iterator.free = FUNC_ITERATOR_FREE(_eina_hash_iterator_free);
 
    EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
-   EINA_MAGIC_SET(it, EINA_MAGIC_HASH_ITERATOR);
+   EINA_MAGIC_SET(it,            EINA_MAGIC_HASH_ITERATOR);
 
    return &it->iterator;
 }
@@ -1410,33 +1763,35 @@ eina_hash_superfast(const char *key, int len)
    len >>= 2;
 
    /* Main loop */
-   for ( ;len > 0; len--)
+   for (len > 0; len--)
      {
-       hash += get16bits(key);
-       tmp = (get16bits(key + 2) << 11) ^ hash;
-       hash = (hash << 16) ^ tmp;
-       key += 2 * sizeof (uint16_t);
-       hash += hash >> 11;
+        hash += get16bits(key);
+        tmp = (get16bits(key + 2) << 11) ^ hash;
+        hash = (hash << 16) ^ tmp;
+        key += 2 * sizeof (uint16_t);
+        hash += hash >> 11;
      }
 
    /* Handle end cases */
    switch (rem)
      {
       case 3:
-        hash += get16bits(key);
-        hash ^= hash << 16;
-        hash ^= key[sizeof (uint16_t)] << 18;
-        hash += hash >> 11;
-        break;
+         hash += get16bits(key);
+         hash ^= hash << 16;
+         hash ^= key[sizeof (uint16_t)] << 18;
+         hash += hash >> 11;
+         break;
+
       case 2:
-        hash += get16bits(key);
-        hash ^= hash << 11;
-        hash += hash >> 17;
-        break;
+         hash += get16bits(key);
+         hash ^= hash << 11;
+         hash += hash >> 17;
+         break;
+
       case 1:
-        hash += *key;
-        hash ^= hash << 10;
-        hash += hash >> 1;
+         hash += *key;
+         hash ^= hash << 10;
+         hash += hash >> 1;
      }
 
    /* Force "avalanching" of final 127 bits */
@@ -1452,4 +1807,5 @@ eina_hash_superfast(const char *key, int len)
 
 /**
  * @}
+ * @}
  */
index 9b118cf..82873b7 100644 (file)
@@ -34,8 +34,8 @@
 /* FIXME: TODO please, refactor this :) */
 
 /*============================================================================*
- *                                  Local                                     *
- *============================================================================*/
+*                                  Local                                     *
+*============================================================================*/
 
 /**
  * @cond LOCAL
@@ -46,91 +46,98 @@ typedef struct _Eina_Accessor_Inlist Eina_Accessor_Inlist;
 
 struct _Eina_Iterator_Inlist
 {
-       Eina_Iterator iterator;
-       const Eina_Inlist *head;
-       const Eina_Inlist *current;
+   Eina_Iterator iterator;
+   const Eina_Inlist *head;
+   const Eina_Inlist *current;
 };
 
 struct _Eina_Accessor_Inlist
 {
-       Eina_Accessor accessor;
+   Eina_Accessor accessor;
 
-       const Eina_Inlist *head;
-       const Eina_Inlist *current;
+   const Eina_Inlist *head;
+   const Eina_Inlist *current;
 
-       unsigned int index;
+   unsigned int index;
 };
 
 static Eina_Bool
 eina_inlist_iterator_next(Eina_Iterator_Inlist *it, void **data) {
-       if (it->current == NULL) return EINA_FALSE;
-       if (data) *data = (void*) it->current;
+   if (it->current == NULL)
+      return EINA_FALSE;
 
-       it->current = it->current->next;
+   if (data)
+      *data = (void *)it->current;
 
-       return EINA_TRUE;
+   it->current = it->current->next;
+
+   return EINA_TRUE;
 }
 
 static Eina_Inlist *
 eina_inlist_iterator_get_container(Eina_Iterator_Inlist *it) {
-       return (Eina_Inlist*) it->head;
+   return (Eina_Inlist *)it->head;
 }
 
 static void
 eina_inlist_iterator_free(Eina_Iterator_Inlist *it) {
-       free(it);
+   free(it);
 }
 
 static Eina_Bool
-eina_inlist_accessor_get_at(Eina_Accessor_Inlist *it, unsigned int idx, void **data) {
-       const Eina_Inlist *over;
-       unsigned int middle;
-       unsigned int i;
-
-       if (it->index == idx) {
-               over = it->current;
-       } else if (idx > it->index) {
-               /* Looking after current. */
-               for (i = it->index, over = it->current;
-                    i < idx && over != NULL;
-                    ++i, over = over->next)
-                       ;
-
-       } else {
-               middle = it->index >> 1;
-
-               if (idx > middle) {
-                       /* Looking backward from current. */
-                       for (i = it->index, over = it->current;
-                            i > idx && over != NULL;
-                            --i, over = over->prev)
-                               ;
-               } else {
-                       /* Looking from the start. */
-                       for (i = 0, over = it->head;
-                            i < idx && over != NULL;
-                            ++i, over = over->next)
-                               ;
-               }
-       }
-
-       if (over == NULL) return EINA_FALSE;
-
-       it->current = over;
-       it->index = idx;
-
-       if (data) *data = (void*) over;
-       return EINA_TRUE;
+eina_inlist_accessor_get_at(Eina_Accessor_Inlist *it,
+                            unsigned int idx,
+                            void **data) {
+   const Eina_Inlist *over;
+   unsigned int middle;
+   unsigned int i;
+
+   if (it->index == idx)
+      over = it->current;
+   else if (idx > it->index)
+      /* Looking after current. */
+      for (i = it->index, over = it->current;
+           i < idx && over != NULL;
+           ++i, over = over->next)
+         ;
+   else
+     {
+        middle = it->index >> 1;
+
+        if (idx > middle)
+           /* Looking backward from current. */
+           for (i = it->index, over = it->current;
+                i > idx && over != NULL;
+                --i, over = over->prev)
+              ;
+        else
+           /* Looking from the start. */
+           for (i = 0, over = it->head;
+                i < idx && over != NULL;
+                ++i, over = over->next)
+              ;
+     }
+
+   if (over == NULL)
+      return EINA_FALSE;
+
+   it->current = over;
+   it->index = idx;
+
+   if (data)
+      *data = (void *)over;
+
+   return EINA_TRUE;
 }
 
 static Eina_Inlist *
 eina_inlist_accessor_get_container(Eina_Accessor_Inlist *it) {
-       return (Eina_Inlist *) it->head;
+   return (Eina_Inlist *)it->head;
 }
 
 static void
 eina_inlist_accessor_free(Eina_Accessor_Inlist *it) {
-       free(it);
+   free(it);
 }
 
 /**
@@ -139,12 +146,12 @@ eina_inlist_accessor_free(Eina_Accessor_Inlist *it) {
 
 
 /*============================================================================*
- *                                 Global                                     *
- *============================================================================*/
+*                                 Global                                     *
+*============================================================================*/
 
 /*============================================================================*
- *                                   API                                      *
- *============================================================================*/
+*                                   API                                      *
+*============================================================================*/
 
 /**
  * @addtogroup Eina_Inline_List_Group Inline List
@@ -200,15 +207,15 @@ eina_inlist_accessor_free(Eina_Accessor_Inlist *it) {
  *    printf("list=%p\n", list);
  *    for (itr = list; itr != NULL; itr = itr->next)
  *      {
- *     cur = EINA_INLIST_CONTAINER_GET(itr, struct my_struct);
- *     printf("\ta=%d, b=%d\n", cur->a, cur->b);
+ *  cur = EINA_INLIST_CONTAINER_GET(itr, struct my_struct);
+ *  printf("\ta=%d, b=%d\n", cur->a, cur->b);
  *      }
  *
  *    while (list)
  *      {
- *     Eina_Inlist *aux = list;
- *     list = eina_inlist_remove(list, list);
- *     free(aux);
+ *  Eina_Inlist *aux = list;
+ *  list = eina_inlist_remove(list, list);
+ *  free(aux);
  *      }
  *
  *    eina_shutdown();
@@ -244,16 +251,19 @@ eina_inlist_append(Eina_Inlist *list, Eina_Inlist *new_l)
    EINA_SAFETY_ON_NULL_RETURN_VAL(new_l, list);
 
    new_l->next = NULL;
-   if (!list) {
-      new_l->prev = NULL;
-      new_l->last = new_l;
-      return new_l;
-   }
+   if (!list)
+     {
+        new_l->prev = NULL;
+        new_l->last = new_l;
+        return new_l;
+     }
+
    if (list->last)
-     l = list->last;
+      l = list->last;
    else
-     for (l = list; (l) && (l->next); l = l->next)
-       ;
+      for (l = list; (l) && (l->next); l = l->next)
+         ;
+
    l->next = new_l;
    new_l->prev = l;
    list->last = new_l;
@@ -282,11 +292,13 @@ eina_inlist_prepend(Eina_Inlist *list, Eina_Inlist *new_l)
    EINA_SAFETY_ON_NULL_RETURN_VAL(new_l, list);
 
    new_l->prev = NULL;
-   if (!list) {
-      new_l->next = NULL;
-      new_l->last = new_l;
-      return new_l;
-   }
+   if (!list)
+     {
+        new_l->next = NULL;
+        new_l->last = new_l;
+        return new_l;
+     }
+
    new_l->next = list;
    list->prev = new_l;
    new_l->last = list->last;
@@ -318,23 +330,29 @@ eina_inlist_prepend(Eina_Inlist *list, Eina_Inlist *new_l)
  */
 EAPI Eina_Inlist *
 eina_inlist_append_relative(Eina_Inlist *list,
-                           Eina_Inlist *new_l,
-                           Eina_Inlist *relative)
+                            Eina_Inlist *new_l,
+                            Eina_Inlist *relative)
 {
    EINA_SAFETY_ON_NULL_RETURN_VAL(new_l, list);
 
-   if (relative) {
-      if (relative->next) {
-        new_l->next = relative->next;
-        relative->next->prev = new_l;
-      } else
-       new_l->next = NULL;
-      relative->next = new_l;
-      new_l->prev = relative;
-      if (!new_l->next)
-       list->last = new_l;
-      return list;
-   }
+   if (relative)
+     {
+        if (relative->next)
+          {
+             new_l->next = relative->next;
+             relative->next->prev = new_l;
+          }
+        else
+           new_l->next = NULL;
+
+        relative->next = new_l;
+        new_l->prev = relative;
+        if (!new_l->next)
+           list->last = new_l;
+
+        return list;
+     }
+
    return eina_inlist_append(list, new_l);
 }
 
@@ -362,29 +380,34 @@ eina_inlist_append_relative(Eina_Inlist *list,
  */
 EAPI Eina_Inlist *
 eina_inlist_prepend_relative(Eina_Inlist *list,
-                            Eina_Inlist *new_l,
-                            Eina_Inlist *relative)
+                             Eina_Inlist *new_l,
+                             Eina_Inlist *relative)
 {
    EINA_SAFETY_ON_NULL_RETURN_VAL(new_l, list);
 
-   if (relative) {
-      new_l->prev = relative->prev;
-      new_l->next = relative;
-      relative->prev = new_l;
-      if (new_l->prev) {
-        new_l->prev->next = new_l;
-        /* new_l->next could not be NULL, as it was set to 'relative' */
-        assert(new_l->next);
-        return list;
-      } else {
-        /* new_l->next could not be NULL, as it was set to 'relative' */
-        assert(new_l->next);
-
-        new_l->last = list->last;
-        list->last = NULL;
-        return new_l;
-      }
-   }
+   if (relative)
+     {
+        new_l->prev = relative->prev;
+        new_l->next = relative;
+        relative->prev = new_l;
+        if (new_l->prev)
+          {
+             new_l->prev->next = new_l;
+             /* new_l->next could not be NULL, as it was set to 'relative' */
+             assert(new_l->next);
+             return list;
+          }
+        else
+          {
+             /* new_l->next could not be NULL, as it was set to 'relative' */
+             assert(new_l->next);
+
+             new_l->last = list->last;
+             list->last = NULL;
+             return new_l;
+          }
+     }
+
    return eina_inlist_prepend(list, new_l);
 }
 
@@ -414,21 +437,26 @@ eina_inlist_remove(Eina_Inlist *list, Eina_Inlist *item)
    EINA_SAFETY_ON_NULL_RETURN_VAL(list, NULL);
    EINA_SAFETY_ON_NULL_RETURN_VAL(item, list);
    EINA_SAFETY_ON_TRUE_RETURN_VAL
-     ((item != list) && (item->prev == NULL) && (item->next == NULL), list);
+      ((item != list) && (item->prev == NULL) && (item->next == NULL), list);
 
    if (item->next)
-     item->next->prev = item->prev;
+      item->next->prev = item->prev;
+
+   if (item->prev)
+     {
+        item->prev->next = item->next;
+        return_l = list;
+     }
+   else
+     {
+        return_l = item->next;
+        if (return_l)
+           return_l->last = list->last;
+     }
 
-   if (item->prev) {
-      item->prev->next = item->next;
-      return_l = list;
-   } else {
-      return_l = item->next;
-      if (return_l)
-       return_l->last = list->last;
-   }
    if (item == list->last)
-     list->last = item->prev;
+      list->last = item->prev;
+
    item->next = NULL;
    item->prev = NULL;
    return return_l;
@@ -455,14 +483,16 @@ eina_inlist_promote(Eina_Inlist *list, Eina_Inlist *item)
    EINA_SAFETY_ON_NULL_RETURN_VAL(list, NULL);
    EINA_SAFETY_ON_NULL_RETURN_VAL(item, list);
 
-   if (item == list) return list;
+   if (item == list)
+      return list;
 
    if (item->next)
-     item->next->prev = item->prev;
+      item->next->prev = item->prev;
+
    item->prev->next = item->next;
 
    if (list->last == item)
-     list->last = item->prev;
+      list->last = item->prev;
 
    item->next = list;
    item->prev = NULL;
@@ -497,20 +527,22 @@ eina_inlist_demote(Eina_Inlist *list, Eina_Inlist *item)
    EINA_SAFETY_ON_NULL_RETURN_VAL(list, NULL);
    EINA_SAFETY_ON_NULL_RETURN_VAL(item, list);
 
-   if (list->last == item) return list;
+   if (list->last == item)
+      return list;
 
    if (!list->last)
      {
-       for (l = list; l->next; l = l->next)
-         ;
-       list->last = l;
+        for (l = list; l->next; l = l->next)
+           ;
+        list->last = l;
      }
 
    l = list;
    if (item->prev)
-     item->prev->next = item->next;
+      item->prev->next = item->next;
    else
-     l = item->next;
+      l = item->next;
+
    item->next->prev = item->prev;
 
    list->last->next = item;
@@ -538,9 +570,9 @@ eina_inlist_find(Eina_Inlist *list, Eina_Inlist *item)
    Eina_Inlist *l;
 
    for (l = list; l; l = l->next) {
-      if (l == item)
-       return item;
-   }
+        if (l == item)
+           return item;
+     }
    return NULL;
 }
 
@@ -564,7 +596,7 @@ eina_inlist_count(const Eina_Inlist *list)
    unsigned int i = 0;
 
    for (l = list; l; l = l->next)
-     i++;
+      i++;
 
    return i;
 }
@@ -596,16 +628,19 @@ eina_inlist_iterator_new(const Eina_Inlist *list)
 
    eina_error_set(0);
    it = calloc(1, sizeof (Eina_Iterator_Inlist));
-   if (!it) {
-      eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
-      return NULL;
-   }
+   if (!it)
+     {
+        eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+        return NULL;
+     }
 
    it->head = list;
    it->current = list;
 
+   it->iterator.version = EINA_ITERATOR_VERSION;
    it->iterator.next = FUNC_ITERATOR_NEXT(eina_inlist_iterator_next);
-   it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(eina_inlist_iterator_get_container);
+   it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
+         eina_inlist_iterator_get_container);
    it->iterator.free = FUNC_ITERATOR_FREE(eina_inlist_iterator_free);
 
    EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
@@ -630,19 +665,22 @@ eina_inlist_accessor_new(const Eina_Inlist *list)
 {
    Eina_Accessor_Inlist *it;
 
-   eina_error_set(0);
+        eina_error_set(0);
    it = calloc(1, sizeof (Eina_Accessor_Inlist));
-   if (!it) {
-      eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
-      return NULL;
-   }
+   if (!it)
+     {
+        eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+        return NULL;
+     }
 
    it->head = list;
    it->current = list;
    it->index = 0;
 
+   it->accessor.version = EINA_ACCESSOR_VERSION;
    it->accessor.get_at = FUNC_ACCESSOR_GET_AT(eina_inlist_accessor_get_at);
-   it->accessor.get_container = FUNC_ACCESSOR_GET_CONTAINER(eina_inlist_accessor_get_container);
+   it->accessor.get_container = FUNC_ACCESSOR_GET_CONTAINER(
+         eina_inlist_accessor_get_container);
    it->accessor.free = FUNC_ACCESSOR_FREE(eina_inlist_accessor_free);
 
    EINA_MAGIC_SET(&it->accessor, EINA_MAGIC_ACCESSOR);
index c93aedf..b340292 100644 (file)
@@ -1,6 +1,3 @@
-/*
- * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
- */
 /* EINA - EFL data type library
  * Copyright (C) 2002-2008 Cedric Bail
  *
@@ -33,8 +30,8 @@
 #include "eina_iterator.h"
 
 /*============================================================================*
- *                                  Local                                     *
- *============================================================================*/
+*                                  Local                                     *
+*============================================================================*/
 
 /**
  * @cond LOCAL
 
 static const char EINA_MAGIC_ITERATOR_STR[] = "Eina Iterator";
 
-#define EINA_MAGIC_CHECK_ITERATOR(d)                           \
-  do {                                                         \
-    if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_ITERATOR))             \
-      EINA_MAGIC_FAIL(d, EINA_MAGIC_ITERATOR);                 \
-  } while(0)
+#define EINA_MAGIC_CHECK_ITERATOR(d)                            \
+   do {                                                          \
+        if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_ITERATOR)) {              \
+             EINA_MAGIC_FAIL(d, EINA_MAGIC_ITERATOR); }                  \
+     } while(0)
 
 /**
  * @endcond
@@ -54,8 +51,8 @@ static const char EINA_MAGIC_ITERATOR_STR[] = "Eina Iterator";
 
 
 /*============================================================================*
- *                                 Global                                     *
- *============================================================================*/
+*                                 Global                                     *
+*============================================================================*/
 
 /**
  * @internal
@@ -92,8 +89,8 @@ eina_iterator_shutdown(void)
 }
 
 /*============================================================================*
- *                                   API                                      *
- *============================================================================*/
+*                                   API                                      *
+*============================================================================*/
 
 /**
  * @addtogroup Eina_Iterator_Group Iterator Functions
@@ -144,7 +141,7 @@ EAPI void *
 eina_iterator_container_get(Eina_Iterator *iterator)
 {
    EINA_MAGIC_CHECK_ITERATOR(iterator);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(iterator, NULL);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(iterator,                NULL);
    EINA_SAFETY_ON_NULL_RETURN_VAL(iterator->get_container, NULL);
    return iterator->get_container(iterator);
 }
@@ -164,11 +161,13 @@ eina_iterator_container_get(Eina_Iterator *iterator)
 EAPI Eina_Bool
 eina_iterator_next(Eina_Iterator *iterator, void **data)
 {
-   if (!iterator) return EINA_FALSE;
+   if (!iterator)
+      return EINA_FALSE;
+
    EINA_MAGIC_CHECK_ITERATOR(iterator);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(iterator, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(iterator,       EINA_FALSE);
    EINA_SAFETY_ON_NULL_RETURN_VAL(iterator->next, EINA_FALSE);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(data,           EINA_FALSE);
    return iterator->next(iterator, data);
 }
 
@@ -181,13 +180,14 @@ eina_iterator_next(Eina_Iterator *iterator, void **data)
  *
  * This function iterates over the elements pointed by @p iterator,
  * beginning from the current element. For Each element, the callback
- * @p cb is called with the data @p fdata.If @p iterator is @c NULL,
- * the function returns immediatly.
+ * @p cb is called with the data @p fdata. If @p iterator is @c NULL,
+ * the function returns immediatly. Also, if @p cb returns @c
+ * EINA_FALSE, the iteration stops at that point.
  */
 EAPI void
 eina_iterator_foreach(Eina_Iterator *iterator,
-                     Eina_Each cb,
-                     const void *fdata)
+                      Eina_Each_Cb cb,
+                      const void *fdata)
 {
    const void *container;
    void *data;
@@ -198,10 +198,61 @@ eina_iterator_foreach(Eina_Iterator *iterator,
    EINA_SAFETY_ON_NULL_RETURN(iterator->next);
    EINA_SAFETY_ON_NULL_RETURN(cb);
 
+   if (!eina_iterator_lock(iterator)) return ;
+
    container = iterator->get_container(iterator);
    while (iterator->next(iterator, &data) == EINA_TRUE) {
-      if (cb(container, data, (void*) fdata) != EINA_TRUE) return ;
-   }
+        if (cb(container, data, (void *)fdata) != EINA_TRUE)
+          goto on_exit;
+     }
+
+ on_exit:
+   (void) eina_iterator_unlock(iterator);
+}
+
+/**
+ * @brief Lock the container of the iterator.
+ *
+ * @param iterator The iterator.
+ * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
+ *
+ * If the container of the @p iterator permit it, it will be locked.
+ * If @p iterator is @c NULL or if a problem occured, #EINA_FALSE is
+ * returned, otherwise #EINA_TRUE is returned. If the container
+ * is not lockable, it will return EINA_TRUE.
+ */
+EAPI Eina_Bool
+eina_iterator_lock(Eina_Iterator *iterator)
+{
+   EINA_MAGIC_CHECK_ITERATOR(iterator);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(iterator, EINA_FALSE);
+
+   if (iterator->lock)
+      return iterator->lock(iterator);
+   return EINA_TRUE;
+}
+
+/**
+ * @brief Unlock the container of the iterator.
+ *
+ * @param iterator The iterator.
+ * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
+ *
+ * If the container of the @p iterator permit it and was previously
+ * locked, it will be unlocked. If @p iterator is @c NULL or if a
+ * problem occured, #EINA_FALSE is returned, otherwise #EINA_TRUE
+ * is returned. If the container is not lockable, it will return
+ * EINA_TRUE.
+ */
+EAPI Eina_Bool
+eina_iterator_unlock(Eina_Iterator *iterator)
+{
+   EINA_MAGIC_CHECK_ITERATOR(iterator);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(iterator, EINA_FALSE);
+
+   if (iterator->unlock)
+      return iterator->unlock(iterator);
+   return EINA_TRUE;
 }
 
 /**
index a93594c..b1e62b7 100644 (file)
@@ -30,8 +30,8 @@
 #include "eina_lalloc.h"
 
 /*============================================================================*
- *                                  Local                                     *
- *============================================================================*/
+*                                  Local                                     *
+*============================================================================*/
 
 /**
  * @cond LOCAL
 
 struct _Eina_Lalloc
 {
-       void    *data;
-       int     num_allocated;
-       int     num_elements;
-       int     acc;
-       Eina_Lalloc_Alloc alloc_cb;
-       Eina_Lalloc_Free free_cb;
+   void *data;
+   int num_allocated;
+   int num_elements;
+   int acc;
+   Eina_Lalloc_Alloc alloc_cb;
+   Eina_Lalloc_Free free_cb;
 };
 
 /**
@@ -52,12 +52,12 @@ struct _Eina_Lalloc
  */
 
 /*============================================================================*
- *                                 Global                                     *
- *============================================================================*/
+*                                 Global                                     *
+*============================================================================*/
 
 /*============================================================================*
- *                                   API                                      *
- *============================================================================*/
+*                                   API                                      *
+*============================================================================*/
 
 /**
  * @addtogroup Eina_Lalloc_Group Lazy allocator
@@ -65,86 +65,92 @@ struct _Eina_Lalloc
  * @{
  */
 
-EAPI Eina_Lalloc * eina_lalloc_new(void *data, Eina_Lalloc_Alloc alloc_cb, Eina_Lalloc_Free free_cb, int num_init)
+EAPI Eina_Lalloc *eina_lalloc_new(void *data,
+                                  Eina_Lalloc_Alloc alloc_cb,
+                                  Eina_Lalloc_Free free_cb,
+                                  int num_init)
 {
-       Eina_Lalloc *a;
-
-       EINA_SAFETY_ON_NULL_RETURN_VAL(alloc_cb, NULL);
-       EINA_SAFETY_ON_NULL_RETURN_VAL(free_cb, NULL);
-
-       a = calloc(1, sizeof(Eina_Lalloc));
-       a->data = data;
-       a->alloc_cb = alloc_cb;
-       a->free_cb = free_cb;
-       if (num_init > 0)
-       {
-               a->num_allocated = num_init;
-               a->alloc_cb(a->data, a->num_allocated);
-       }
-       return a;
+   Eina_Lalloc *a;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(alloc_cb, NULL);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(free_cb,  NULL);
+
+   a = calloc(1, sizeof(Eina_Lalloc));
+   a->data = data;
+   a->alloc_cb = alloc_cb;
+   a->free_cb = free_cb;
+   if (num_init > 0)
+     {
+        a->num_allocated = num_init;
+        a->alloc_cb(a->data, a->num_allocated);
+     }
+
+   return a;
 }
 
 EAPI void eina_lalloc_free(Eina_Lalloc *a)
 {
-       EINA_SAFETY_ON_NULL_RETURN(a);
-       EINA_SAFETY_ON_NULL_RETURN(a->free_cb);
-       a->free_cb(a->data);
-       free(a);
+   EINA_SAFETY_ON_NULL_RETURN(a);
+   EINA_SAFETY_ON_NULL_RETURN(a->free_cb);
+   a->free_cb(a->data);
+   free(a);
 }
 
 EAPI Eina_Bool eina_lalloc_element_add(Eina_Lalloc *a)
 {
-       EINA_SAFETY_ON_NULL_RETURN_VAL(a, EINA_FALSE);
-       EINA_SAFETY_ON_NULL_RETURN_VAL(a->alloc_cb, EINA_FALSE);
-
-       if (a->num_elements == a->num_allocated)
-       {
-               if (a->alloc_cb(a->data, (1 << a->acc)) == EINA_TRUE)
-               {
-                       a->num_allocated = (1 << a->acc);
-                       a->acc++;
-               } else {
-                       return EINA_FALSE;
-               }
-       }
-       a->num_elements++;
-
-       return EINA_TRUE;
+   EINA_SAFETY_ON_NULL_RETURN_VAL(a,           EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(a->alloc_cb, EINA_FALSE);
+
+   if (a->num_elements == a->num_allocated)
+     {
+        if (a->alloc_cb(a->data, (1 << a->acc)) == EINA_TRUE)
+          {
+             a->num_allocated = (1 << a->acc);
+             a->acc++;
+          }
+        else
+           return EINA_FALSE;
+     }
+
+   a->num_elements++;
+
+   return EINA_TRUE;
 }
 
 EAPI Eina_Bool eina_lalloc_elements_add(Eina_Lalloc *a, int num)
 {
-       int tmp;
-
-       EINA_SAFETY_ON_NULL_RETURN_VAL(a, EINA_FALSE);
-       EINA_SAFETY_ON_NULL_RETURN_VAL(a->alloc_cb, EINA_FALSE);
-
-       tmp = a->num_elements + num;
-       if (tmp > a->num_allocated)
-       {
-               int allocated;
-               int acc;
-
-               allocated = a->num_allocated;
-               acc = a->acc;
-
-               while (tmp > allocated)
-               {
-                       allocated = (1 << acc);
-                       acc++;
-               }
-
-               if (a->alloc_cb(a->data, allocated) == EINA_TRUE)
-               {
-                       a->num_allocated = allocated;
-                       a->acc = acc;
-               } else {
-                       return EINA_FALSE;
-               }
-       }
-       a->num_elements += num;
-
-       return EINA_TRUE;
+   int tmp;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(a,           EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(a->alloc_cb, EINA_FALSE);
+
+   tmp = a->num_elements + num;
+   if (tmp > a->num_allocated)
+     {
+        int allocated;
+        int acc;
+
+        allocated = a->num_allocated;
+        acc = a->acc;
+
+        while (tmp > allocated)
+          {
+             allocated = (1 << acc);
+             acc++;
+          }
+
+        if (a->alloc_cb(a->data, allocated) == EINA_TRUE)
+          {
+             a->num_allocated = allocated;
+             a->acc = acc;
+          }
+        else
+           return EINA_FALSE;
+     }
+
+   a->num_elements += num;
+
+   return EINA_TRUE;
 }
 
 /**
index 3d5d047..2b140d2 100644 (file)
@@ -1,5 +1,3 @@
-// vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
-
 /* EINA - EFL data type library
  * Copyright (C) 2002-2008 Carsten Haitzler, Gustavo Sverzut Barbieri, Tilman Sauerbeck,
  *                         Vincent Torri, Cedric Bail, Jorge Luis Zapata Muga,
@@ -85,8 +83,8 @@
 
 
 /*============================================================================*
- *                                  Local                                     *
- *============================================================================*/
+*                                  Local                                     *
+*============================================================================*/
 
 /**
  * @cond LOCAL
@@ -98,41 +96,41 @@ static const char EINA_MAGIC_LIST_ACCESSOR_STR[] = "Eina List Accessor";
 static const char EINA_MAGIC_LIST_ACCOUNTING_STR[] = "Eina List Accounting";
 
 
-#define EINA_MAGIC_CHECK_LIST(d, ...)                          \
-  do {                                                         \
-    if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_LIST))                 \
-    {                                                          \
-        EINA_MAGIC_FAIL(d, EINA_MAGIC_LIST);                   \
-        return __VA_ARGS__;                                    \
-    }                                                          \
-  } while(0)
-
-#define EINA_MAGIC_CHECK_LIST_ITERATOR(d, ...)                 \
-  do {                                                         \
-    if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_LIST_ITERATOR))                \
-    {                                                          \
-        EINA_MAGIC_FAIL(d, EINA_MAGIC_LIST_ITERATOR);          \
-        return __VA_ARGS__;                                    \
-    }                                                          \
-  } while(0)
-
-#define EINA_MAGIC_CHECK_LIST_ACCESSOR(d, ...)                 \
-  do {                                                         \
-    if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_LIST_ACCESSOR))                \
-    {                                                          \
-        EINA_MAGIC_FAIL(d, EINA_MAGIC_LIST_ACCESSOR);          \
-        return __VA_ARGS__;                                    \
-    }                                                          \
-  } while(0)
-
-#define EINA_MAGIC_CHECK_LIST_ACCOUNTING(d)                    \
-  do {                                                         \
-    if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_LIST_ACCOUNTING))      \
-    {                                                          \
-        EINA_MAGIC_FAIL(d, EINA_MAGIC_LIST_ACCOUNTING);                \
-        return;                                                        \
-    }                                                          \
-  } while(0)
+#define EINA_MAGIC_CHECK_LIST(d, ...)                           \
+   do {                                                          \
+        if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_LIST))                  \
+          {                                                           \
+             EINA_MAGIC_FAIL(d, EINA_MAGIC_LIST);                    \
+             return __VA_ARGS__;                                     \
+          }                                                           \
+     } while(0)
+
+#define EINA_MAGIC_CHECK_LIST_ITERATOR(d, ...)                  \
+   do {                                                          \
+        if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_LIST_ITERATOR))         \
+          {                                                           \
+             EINA_MAGIC_FAIL(d, EINA_MAGIC_LIST_ITERATOR);           \
+             return __VA_ARGS__;                                     \
+          }                                                           \
+     } while(0)
+
+#define EINA_MAGIC_CHECK_LIST_ACCESSOR(d, ...)                  \
+   do {                                                          \
+        if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_LIST_ACCESSOR))         \
+          {                                                           \
+             EINA_MAGIC_FAIL(d, EINA_MAGIC_LIST_ACCESSOR);           \
+             return __VA_ARGS__;                                     \
+          }                                                           \
+     } while(0)
+
+#define EINA_MAGIC_CHECK_LIST_ACCOUNTING(d)                     \
+   do {                                                          \
+        if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_LIST_ACCOUNTING))       \
+          {                                                           \
+             EINA_MAGIC_FAIL(d, EINA_MAGIC_LIST_ACCOUNTING);         \
+             return;                                                 \
+          }                                                           \
+     } while(0)
 
 #define EINA_LIST_SORT_STACK_SIZE 32
 
@@ -175,13 +173,16 @@ static int _eina_list_log_dom = -1;
 #endif
 #define DBG(...) EINA_LOG_DOM_DBG(_eina_list_log_dom, __VA_ARGS__)
 
-static inline Eina_List_Accounting*
+static inline Eina_List_Accounting *
 _eina_list_mempool_accounting_new(__UNUSED__ Eina_List *list)
 {
    Eina_List_Accounting *tmp;
 
-   tmp = eina_mempool_malloc(_eina_list_accounting_mp, sizeof (Eina_List_Accounting));
-   if (!tmp) return NULL;
+   tmp =
+      eina_mempool_malloc(_eina_list_accounting_mp,
+                          sizeof (Eina_List_Accounting));
+   if (!tmp)
+      return NULL;
 
    EINA_MAGIC_SET(tmp, EINA_MAGIC_LIST_ACCOUNTING);
 
@@ -196,13 +197,14 @@ _eina_list_mempool_accounting_free(Eina_List_Accounting *accounting)
    eina_mempool_free(_eina_list_accounting_mp, accounting);
 }
 
-static inline Eina_List*
+static inline Eina_List *
 _eina_list_mempool_list_new(__UNUSED__ Eina_List *list)
 {
    Eina_List *tmp;
 
    tmp = eina_mempool_malloc(_eina_list_mp, sizeof (Eina_List));
-   if (!tmp) return NULL;
+   if (!tmp)
+      return NULL;
 
    EINA_MAGIC_SET(tmp, EINA_MAGIC_LIST);
 
@@ -215,7 +217,7 @@ _eina_list_mempool_list_free(Eina_List *list)
 
    list->accounting->count--;
    if (list->accounting->count == 0)
-     _eina_list_mempool_accounting_free(list->accounting);
+      _eina_list_mempool_accounting_free(list->accounting);
 
    EINA_MAGIC_SET(list, EINA_MAGIC_NONE);
    eina_mempool_free(_eina_list_mp, list);
@@ -227,14 +229,15 @@ _eina_list_setup_accounting(Eina_List *list)
    EINA_MAGIC_CHECK_LIST(list, NULL);
 
    list->accounting = _eina_list_mempool_accounting_new(list);
-   if (!list->accounting) goto on_error;
+   if (!list->accounting)
+      goto on_error;
 
    list->accounting->last = list;
    list->accounting->count = 1;
 
    return list;
 
- on_error:
+on_error:
    _eina_list_mempool_list_free(list);
    return NULL;
 }
@@ -269,7 +272,9 @@ eina_list_iterator_next(Eina_Iterator_List *it, void **data)
 {
    EINA_MAGIC_CHECK_LIST_ITERATOR(it, EINA_FALSE);
 
-   if (it->current == NULL) return EINA_FALSE;
+   if (it->current == NULL)
+      return EINA_FALSE;
+
    *data = eina_list_data_get(it->current);
 
    it->current = eina_list_next(it->current);
@@ -282,7 +287,9 @@ eina_list_iterator_prev(Eina_Iterator_List *it, void **data)
 {
    EINA_MAGIC_CHECK_LIST_ITERATOR(it, EINA_FALSE);
 
-   if (it->current == NULL) return EINA_FALSE;
+   if (it->current == NULL)
+      return EINA_FALSE;
+
    *data = eina_list_data_get(it->current);
 
    it->current = eina_list_prev(it->current);
@@ -295,7 +302,7 @@ eina_list_iterator_get_container(Eina_Iterator_List *it)
 {
    EINA_MAGIC_CHECK_LIST_ITERATOR(it, NULL);
 
-   return (Eina_List *) it->head;
+   return (Eina_List *)it->head;
 }
 
 static void
@@ -315,58 +322,51 @@ eina_list_accessor_get_at(Eina_Accessor_List *it, unsigned int idx, void **data)
 
    EINA_MAGIC_CHECK_LIST_ACCESSOR(it, EINA_FALSE);
 
-   if (idx >= eina_list_count(it->head)) return EINA_FALSE;
+   if (idx >= eina_list_count(it->head))
+      return EINA_FALSE;
 
    if (it->index == idx)
-     {
-       over = it->current;
-     }
+      over = it->current;
    else if (idx > it->index)
      {
-       /* After current position. */
-       middle = ((eina_list_count(it->head) - it->index) >> 1) + it->index;
-
-       if (idx > middle)
-         {
-            /* Go backward from the end. */
-            for (i = eina_list_count(it->head) - 1, over = eina_list_last(it->head);
-                 i > idx && over != NULL;
-                 --i, over = eina_list_prev(over))
-              ;
-         }
-       else
-         {
-            /* Go forward from current. */
-            for (i = it->index, over = it->current;
-                 i < idx && over != NULL;
-                 ++i, over = eina_list_next(over))
-              ;
-         }
+        /* After current position. */
+        middle = ((eina_list_count(it->head) - it->index) >> 1) + it->index;
+
+        if (idx > middle)
+           /* Go backward from the end. */
+           for (i = eina_list_count(it->head) - 1,
+                over = eina_list_last(it->head);
+                i > idx && over != NULL;
+                --i, over = eina_list_prev(over))
+              ;
+        else
+           /* Go forward from current. */
+           for (i = it->index, over = it->current;
+                i < idx && over != NULL;
+                ++i, over = eina_list_next(over))
+              ;
      }
    else
      {
-       /* Before current position. */
-       middle = it->index >> 1;
-
-       if (idx > middle)
-         {
-            /* Go backward from current. */
-            for (i = it->index, over = it->current;
-                 i > idx && over != NULL;
-                 --i, over = eina_list_prev(over))
-              ;
-         }
-       else
-         {
-            /* Go forward from start. */
-            for (i = 0, over = it->head;
-                 i < idx && over != NULL;
-                 ++i, over = eina_list_next(over))
-              ;
-         }
+        /* Before current position. */
+        middle = it->index >> 1;
+
+        if (idx > middle)
+           /* Go backward from current. */
+           for (i = it->index, over = it->current;
+                i > idx && over != NULL;
+                --i, over = eina_list_prev(over))
+              ;
+        else
+           /* Go forward from start. */
+           for (i = 0, over = it->head;
+                i < idx && over != NULL;
+                ++i, over = eina_list_next(over))
+              ;
      }
 
-   if (over == NULL) return EINA_FALSE;
+   if (over == NULL)
+      return EINA_FALSE;
 
    it->current = over;
    it->index = idx;
@@ -380,7 +380,7 @@ eina_list_accessor_get_container(Eina_Accessor_List *it)
 {
    EINA_MAGIC_CHECK_LIST_ACCESSOR(it, NULL);
 
-   return (Eina_List *) it->head;
+   return (Eina_List *)it->head;
 }
 
 static void
@@ -400,8 +400,8 @@ eina_list_sort_rebuild_prev(Eina_List *list)
 
    for (; list; list = list->next)
      {
-       list->prev = prev;
-       prev = list;
+        list->prev = prev;
+        prev = list;
      }
 
    return prev;
@@ -413,15 +413,15 @@ eina_list_sort_merge(Eina_List *a, Eina_List *b, Eina_Compare_Cb func)
    Eina_List *first, *last;
 
    if (func(a->data, b->data) < 0)
-     a = (last = first = a)->next;
+      a = (last = first = a)->next;
    else
-     b = (last = first = b)->next;
+      b = (last = first = b)->next;
 
    while (a && b)
-     if (func(a->data, b->data) < 0)
-       a = (last = last->next = a)->next;
-     else
-       b = (last = last->next = b)->next;
+      if (func(a->data, b->data) < 0)
+         a = (last = last->next = a)->next;
+      else
+         b = (last = last->next = b)->next;
 
    last->next = a ? a : b;
 
@@ -433,8 +433,8 @@ eina_list_sort_merge(Eina_List *a, Eina_List *b, Eina_Compare_Cb func)
  */
 
 /*============================================================================*
- *                                 Global                                     *
- *============================================================================*/
+*                                 Global                                     *
+*============================================================================*/
 
 /**
  * @internal
@@ -456,11 +456,12 @@ eina_list_init(void)
 {
    const char *choice, *tmp;
 
-   _eina_list_log_dom = eina_log_domain_register("eina_list", EINA_LOG_COLOR_DEFAULT);
+   _eina_list_log_dom = eina_log_domain_register("eina_list",
+                                                 EINA_LOG_COLOR_DEFAULT);
    if (_eina_list_log_dom < 0)
      {
-       EINA_LOG_ERR("Could not register log domain: eina_list");
-       return EINA_FALSE;
+        EINA_LOG_ERR("Could not register log domain: eina_list");
+        return EINA_FALSE;
      }
 
 #ifdef EINA_DEFAULT_MEMPOOL
@@ -470,25 +471,27 @@ eina_list_init(void)
 #endif
    tmp = getenv("EINA_MEMPOOL");
    if (tmp && tmp[0])
-     choice = tmp;
+      choice = tmp;
 
    _eina_list_mp = eina_mempool_add
-     (choice, "list", NULL, sizeof(Eina_List), 320);
+         (choice, "list", NULL, sizeof(Eina_List), 320);
    if (!_eina_list_mp)
      {
-       ERR("ERROR: Mempool for list cannot be allocated in list init.");
-       goto on_init_fail;
+        ERR("ERROR: Mempool for list cannot be allocated in list init.");
+        goto on_init_fail;
      }
+
    _eina_list_accounting_mp = eina_mempool_add
-     (choice, "list_accounting", NULL, sizeof(Eina_List_Accounting), 80);
+         (choice, "list_accounting", NULL, sizeof(Eina_List_Accounting), 80);
    if (!_eina_list_accounting_mp)
      {
-       ERR("ERROR: Mempool for list accounting cannot be allocated in list init.");
-       eina_mempool_del(_eina_list_mp);
-       goto on_init_fail;
+        ERR(
+           "ERROR: Mempool for list accounting cannot be allocated in list init.");
+        eina_mempool_del(_eina_list_mp);
+        goto on_init_fail;
      }
 
-#define EMS(n) eina_magic_string_static_set(n, n##_STR)
+#define EMS(n) eina_magic_string_static_set(n, n ## _STR)
    EMS(EINA_MAGIC_LIST);
    EMS(EINA_MAGIC_LIST_ITERATOR);
    EMS(EINA_MAGIC_LIST_ACCESSOR);
@@ -497,7 +500,7 @@ eina_list_init(void)
 
    return EINA_TRUE;
 
- on_init_fail:
+on_init_fail:
    eina_log_domain_unregister(_eina_list_log_dom);
    _eina_list_log_dom = -1;
    return EINA_FALSE;
@@ -526,8 +529,8 @@ eina_list_shutdown(void)
 }
 
 /*============================================================================*
- *                                   API                                      *
- *============================================================================*/
+*                                   API                                      *
+*============================================================================*/
 
 /**
  * @addtogroup Eina_List_Group List
@@ -573,13 +576,15 @@ eina_list_append(Eina_List *list, const void *data)
 
    eina_error_set(0);
    new_l = _eina_list_mempool_list_new(list);
-   if (!new_l) return list;
+   if (!new_l)
+      return list;
+
    new_l->next = NULL;
    new_l->data = (void *)data;
    if (!list)
      {
-       new_l->prev = NULL;
-       return _eina_list_setup_accounting(new_l);
+        new_l->prev = NULL;
+        return _eina_list_setup_accounting(new_l);
      }
 
    EINA_MAGIC_CHECK_LIST(list, NULL);
@@ -629,13 +634,15 @@ eina_list_prepend(Eina_List *list, const void *data)
 
    eina_error_set(0);
    new_l = _eina_list_mempool_list_new(list);
-   if (!new_l) return list;
+   if (!new_l)
+      return list;
 
    new_l->prev = NULL;
    new_l->next = list;
    new_l->data = (void *)data;
 
-   if (!list) return _eina_list_setup_accounting(new_l);
+   if (!list)
+      return _eina_list_setup_accounting(new_l);
 
    EINA_MAGIC_CHECK_LIST(list, NULL);
 
@@ -685,18 +692,21 @@ eina_list_prepend(Eina_List *list, const void *data)
  * @endcode
  */
 EAPI Eina_List *
-eina_list_append_relative(Eina_List *list, const void *data, const void *relative)
+eina_list_append_relative(Eina_List *list,
+                          const void *data,
+                          const void *relative)
 {
    Eina_List *l;
    void *list_data;
 
-   if (list) EINA_MAGIC_CHECK_LIST(list, NULL);
+   if (list)
+      EINA_MAGIC_CHECK_LIST(list, NULL);
 
    EINA_LIST_FOREACH(list, l, list_data)
-     {
-         if (list_data == relative)
-             return eina_list_append_relative_list(list, data, l);
-     }
+   {
+      if (list_data == relative)
+         return eina_list_append_relative_list(list, data, l);
+   }
 
    return eina_list_append(list, data);
 }
@@ -719,21 +729,26 @@ eina_list_append_relative(Eina_List *list, const void *data, const void *relativ
  * old pointer is returned.
  */
 EAPI Eina_List *
-eina_list_append_relative_list(Eina_List *list, const void *data, Eina_List *relative)
+eina_list_append_relative_list(Eina_List *list,
+                               const void *data,
+                               Eina_List *relative)
 {
    Eina_List *new_l;
 
-   if ((!list) || (!relative)) return eina_list_append(list, data);
+   if ((!list) || (!relative))
+      return eina_list_append(list, data);
+
    eina_error_set(0);
    new_l = _eina_list_mempool_list_new(list);
-   if (!new_l) return list;
+   if (!new_l)
+      return list;
 
    EINA_MAGIC_CHECK_LIST(relative, NULL);
    new_l->next = relative->next;
    new_l->data = (void *)data;
 
    if (relative->next)
-     relative->next->prev = new_l;
+      relative->next->prev = new_l;
 
    relative->next = new_l;
    new_l->prev = relative;
@@ -741,7 +756,7 @@ eina_list_append_relative_list(Eina_List *list, const void *data, Eina_List *rel
    _eina_list_update_accounting(list, new_l);
 
    if (!new_l->next)
-     new_l->accounting->last = new_l;
+      new_l->accounting->last = new_l;
 
    return list;
 }
@@ -785,18 +800,21 @@ eina_list_append_relative_list(Eina_List *list, const void *data, Eina_List *rel
  * @endcode
  */
 EAPI Eina_List *
-eina_list_prepend_relative(Eina_List *list, const void *data, const void *relative)
+eina_list_prepend_relative(Eina_List *list,
+                           const void *data,
+                           const void *relative)
 {
    Eina_List *l;
    void *list_data;
 
-   if (list) EINA_MAGIC_CHECK_LIST(list, NULL);
+   if (list)
+      EINA_MAGIC_CHECK_LIST(list, NULL);
 
    EINA_LIST_FOREACH(list, l, list_data)
-     {
-         if (list_data == relative)
-             return eina_list_prepend_relative_list(list, data, l);
-     }
+   {
+      if (list_data == relative)
+         return eina_list_prepend_relative_list(list, data, l);
+   }
    return eina_list_prepend(list, data);
 }
 
@@ -818,14 +836,19 @@ eina_list_prepend_relative(Eina_List *list, const void *data, const void *relati
  * old pointer is returned.
  */
 EAPI Eina_List *
-eina_list_prepend_relative_list(Eina_List *list, const void *data, Eina_List *relative)
+eina_list_prepend_relative_list(Eina_List *list,
+                                const void *data,
+                                Eina_List *relative)
 {
    Eina_List *new_l;
 
-   if ((!list) || (!relative)) return eina_list_prepend(list, data);
+   if ((!list) || (!relative))
+      return eina_list_prepend(list, data);
+
    eina_error_set(0);
    new_l = _eina_list_mempool_list_new(list);
-   if (!new_l) return list;
+   if (!new_l)
+      return list;
 
    EINA_MAGIC_CHECK_LIST(relative, NULL);
 
@@ -833,13 +856,15 @@ eina_list_prepend_relative_list(Eina_List *list, const void *data, Eina_List *re
    new_l->next = relative;
    new_l->data = (void *)data;
 
-   if (relative->prev) relative->prev->next = new_l;
+   if (relative->prev)
+      relative->prev->next = new_l;
+
    relative->prev = new_l;
 
    _eina_list_update_accounting(list, new_l);
 
    if (new_l->prev)
-     return list;
+      return list;
 
    return new_l;
 }
@@ -871,13 +896,14 @@ eina_list_sorted_insert(Eina_List *list, Eina_Compare_Cb func, const void *data)
    Eina_List *lnear;
    int cmp;
 
-   if (!list) return eina_list_append(NULL, data);
+   if (!list)
+      return eina_list_append(NULL, data);
 
    lnear = eina_list_search_sorted_near_list(list, func, data, &cmp);
    if (cmp < 0)
-     return eina_list_append_relative_list(list, data, lnear);
+      return eina_list_append_relative_list(list, data, lnear);
    else
-     return eina_list_prepend_relative_list(list, data, lnear);
+      return eina_list_prepend_relative_list(list, data, lnear);
 }
 
 /**
@@ -899,7 +925,8 @@ eina_list_remove(Eina_List *list, const void *data)
 {
    Eina_List *l;
 
-   if (list) EINA_MAGIC_CHECK_LIST(list, NULL);
+   if (list)
+        EINA_MAGIC_CHECK_LIST(list, NULL);
 
    l = eina_list_data_find_list(list, data);
    return eina_list_remove_list(list, l);
@@ -943,24 +970,31 @@ eina_list_remove_list(Eina_List *list, Eina_List *remove_list)
 {
    Eina_List *return_l;
 
-   if (!list) return NULL;
-   if (!remove_list) return list;
+   if (!list)
+      return NULL;
+
+   if (!remove_list)
+      return list;
 
-   EINA_MAGIC_CHECK_LIST(remove_list, NULL);
+        EINA_MAGIC_CHECK_LIST(remove_list, NULL);
+
+   if (remove_list->next)
+      remove_list->next->prev = remove_list->prev;
 
-   if (remove_list->next) remove_list->next->prev = remove_list->prev;
    if (remove_list->prev)
      {
-       remove_list->prev->next = remove_list->next;
-       return_l = list;
+        remove_list->prev->next = remove_list->next;
+        return_l = list;
      }
    else
-     return_l = remove_list->next;
+      return_l = remove_list->next;
+
    if (remove_list == remove_list->accounting->last)
      {
-       EINA_MAGIC_CHECK_LIST(list, NULL);
-       list->accounting->last = remove_list->prev;
+        EINA_MAGIC_CHECK_LIST(list, NULL);
+        list->accounting->last = remove_list->prev;
      }
+
    _eina_list_mempool_list_free(remove_list);
    return return_l;
 }
@@ -979,16 +1013,17 @@ eina_list_free(Eina_List *list)
 {
    Eina_List *l, *free_l;
 
-   if (!list) return NULL;
+   if (!list)
+      return NULL;
 
    EINA_MAGIC_CHECK_LIST(list, NULL);
 
-   for (l = list; l;)
+   for (l = list; l; )
      {
-       free_l = l;
-       l = l->next;
+        free_l = l;
+        l = l->next;
 
-       _eina_list_mempool_list_free(free_l);
+        _eina_list_mempool_list_free(free_l);
      }
 
    return NULL;
@@ -1026,25 +1061,34 @@ eina_list_free(Eina_List *list)
 EAPI Eina_List *
 eina_list_promote_list(Eina_List *list, Eina_List *move_list)
 {
-   if (!list) return NULL;
-   if (!move_list) return list;
-   /* Promoting head to be head. */
-   if (move_list == list) return list;
-   if (move_list->next == list) return move_list;
+   if (!list)
+      return NULL;
 
-   EINA_MAGIC_CHECK_LIST(list, NULL);
-   EINA_MAGIC_CHECK_LIST(move_list, NULL);
+   if (!move_list)
+     {
+        return list; /* Promoting head to be head. */
+
+     }
+
+   if (move_list == list)
+      return list;
+
+   if (move_list->next == list)
+      return move_list;
+
+      EINA_MAGIC_CHECK_LIST(list,      NULL);
+      EINA_MAGIC_CHECK_LIST(move_list, NULL);
 
    /* Remove the promoted item from the list. */
    if (!move_list->prev)
       move_list->next->prev = NULL;
    else
      {
-       move_list->prev->next = move_list->next;
-       if (move_list == list->accounting->last)
-          list->accounting->last = move_list->prev;
-       else
-          move_list->next->prev = move_list->prev;
+        move_list->prev->next = move_list->next;
+        if (move_list == list->accounting->last)
+           list->accounting->last = move_list->prev;
+        else
+           move_list->next->prev = move_list->prev;
      }
 
    /* Add the promoted item in the list. */
@@ -1089,20 +1133,31 @@ eina_list_promote_list(Eina_List *list, Eina_List *move_list)
 EAPI Eina_List *
 eina_list_demote_list(Eina_List *list, Eina_List *move_list)
 {
-   if (!list) return NULL;
-   if (!move_list) return list;
-   /* Demoting tail to be tail. */
-   if (move_list == list->accounting->last) return list;
+   if (!list)
+      return NULL;
 
-   EINA_MAGIC_CHECK_LIST(list, NULL);
-   EINA_MAGIC_CHECK_LIST(move_list, NULL);
+   if (!move_list)
+     {
+        return list; /* Demoting tail to be tail. */
+
+     }
+
+   if (move_list == list->accounting->last)
+      return list;
+
+      EINA_MAGIC_CHECK_LIST(list,      NULL);
+      EINA_MAGIC_CHECK_LIST(move_list, NULL);
 
    /* Update pointer list if necessary. */
    if (list == move_list)
-      list = move_list->next;
-   /* Remove the demoted item from the list. */
+     {
+        list = move_list->next; /* Remove the demoted item from the list. */
+
+     }
+
    if (move_list->prev)
       move_list->prev->next = move_list->next;
+
    move_list->next->prev = move_list->prev;
    /* Add the demoted item in the list. */
    move_list->prev = list->accounting->last;
@@ -1138,7 +1193,9 @@ eina_list_demote_list(Eina_List *list, Eina_List *move_list)
 EAPI void *
 eina_list_data_find(const Eina_List *list, const void *data)
 {
-   if (eina_list_data_find_list(list, data)) return (void*) data;
+   if (eina_list_data_find_list(list, data))
+      return (void *)data;
+
    return NULL;
 }
 
@@ -1160,12 +1217,14 @@ eina_list_data_find_list(const Eina_List *list, const void *data)
    const Eina_List *l;
    void *list_data;
 
-   if (list) EINA_MAGIC_CHECK_LIST(list, NULL);
+   if (list)
+      EINA_MAGIC_CHECK_LIST(list, NULL);
 
-   EINA_LIST_FOREACH(list, l, list_data)
-     {
-       if (list_data == data) return (Eina_List *)l;
-     }
+      EINA_LIST_FOREACH(list, l, list_data)
+   {
+      if (list_data == data)
+         return (Eina_List *)l;
+   }
 
    return NULL;
 }
@@ -1211,32 +1270,32 @@ eina_list_nth_list(const Eina_List *list, unsigned int n)
    const Eina_List *l;
    unsigned int i;
 
-   if (list) EINA_MAGIC_CHECK_LIST(list, NULL);
+   if (list)
+      EINA_MAGIC_CHECK_LIST(list, NULL);
 
    /* check for non-existing nodes */
    if ((!list) || (n > (list->accounting->count - 1)))
-     return NULL;
+      return NULL;
 
    /* if the node is in the 2nd half of the list, search from the end
     * else, search from the beginning.
     */
    if (n > (list->accounting->count / 2))
-     {
-       for (i = list->accounting->count - 1,
-            l = list->accounting->last;
-            l;
-            l = l->prev, i--)
-         {
-            if (i == n) return (Eina_List *)l;
-         }
-     }
+      for (i = list->accounting->count - 1,
+           l = list->accounting->last;
+           l;
+           l = l->prev, i--)
+        {
+           if (i == n)
+              return (Eina_List *)l;
+        }
    else
-     {
-       for (i = 0, l = list; l; l = l->next, i++)
-         {
-            if (i == n) return (Eina_List *)l;
-         }
-     }
+      for (i = 0, l = list; l; l = l->next, i++)
+        {
+           if (i == n)
+              return (Eina_List *)l;
+        }
+
    abort();
 }
 
@@ -1261,7 +1320,8 @@ eina_list_reverse(Eina_List *list)
 {
    Eina_List *l1, *l2;
 
-   if (!list) return NULL;
+   if (!list)
+      return NULL;
 
    EINA_MAGIC_CHECK_LIST(list, NULL);
 
@@ -1269,14 +1329,16 @@ eina_list_reverse(Eina_List *list)
    l2 = list->accounting->last;
    while (l1 != l2)
      {
-       void *data;
-
-       data = l1->data;
-       l1->data = l2->data;
-       l2->data = data;
-       l1 = l1->next;
-       if (l1 == l2) break;
-       l2 = l2->prev;
+        void *data;
+
+        data = l1->data;
+        l1->data = l2->data;
+        l2->data = data;
+        l1 = l1->next;
+        if (l1 == l2)
+           break;
+
+        l2 = l2->prev;
      }
 
    return list;
@@ -1305,13 +1367,14 @@ eina_list_reverse_clone(const Eina_List *list)
    Eina_List *lclone;
    void *data;
 
-   if (!list) return NULL;
+   if (!list)
+      return NULL;
 
    EINA_MAGIC_CHECK_LIST(list, NULL);
 
    lclone = NULL;
    EINA_LIST_FOREACH(list, l, data)
-     lclone = eina_list_prepend(lclone, data);
+   lclone = eina_list_prepend(lclone, data);
 
    return lclone;
 }
@@ -1338,13 +1401,14 @@ eina_list_clone(const Eina_List *list)
    Eina_List *lclone;
    void *data;
 
-   if (!list) return NULL;
+   if (!list)
+      return NULL;
 
    EINA_MAGIC_CHECK_LIST(list, NULL);
 
    lclone = NULL;
    EINA_LIST_FOREACH(list, l, data)
-     lclone = eina_list_append(lclone, data);
+   lclone = eina_list_append(lclone, data);
 
    return lclone;
 }
@@ -1400,59 +1464,61 @@ eina_list_sort(Eina_List *list, unsigned int size, Eina_Compare_Cb func)
    Eina_List *stack[EINA_LIST_SORT_STACK_SIZE];
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(func, list);
-   if (!list) return NULL;
+   if (!list)
+      return NULL;
+
    EINA_MAGIC_CHECK_LIST(list, NULL);
 
    /* if the caller specified an invalid size, sort the whole list */
    if ((size == 0) ||
        (size > list->accounting->count))
-     size = list->accounting->count;
+      size = list->accounting->count;
 
    if (size != list->accounting->count)
      {
-       unsort = eina_list_nth_list(list, size);
-       if (unsort)
-         unsort->prev->next = NULL;
+        unsort = eina_list_nth_list(list, size);
+        if (unsort)
+           unsort->prev->next = NULL;
      }
 
    while (tail)
      {
-       unsigned int idx, tmp;
+        unsigned int idx, tmp;
 
-       Eina_List *a = tail;
-       Eina_List *b = tail->next;
+        Eina_List *a = tail;
+        Eina_List *b = tail->next;
 
-       if (!b)
-        {
-          stack[i++] = a;
-          break;
-        }
+        if (!b)
+          {
+             stack[i++] = a;
+             break;
+          }
 
-       tail = b->next;
+        tail = b->next;
 
-       if (func(a->data, b->data) < 0)
-        ((stack[i++] = a)->next = b)->next = 0;
-       else
-        ((stack[i++] = b)->next = a)->next = 0;
+        if (func(a->data, b->data) < 0)
+           ((stack[i++] = a)->next = b)->next = 0;
+        else
+           ((stack[i++] = b)->next = a)->next = 0;
 
-       tmp = n++;
-       for (idx = n ^ tmp; idx &= idx - 1; i--)
-        stack[i-2] = eina_list_sort_merge(stack[i-2], stack[i-1], func);
+        tmp = n++;
+        for (idx = n ^ tmp; idx &= idx - 1; i--)
+           stack[i - 2] = eina_list_sort_merge(stack[i - 2], stack[i - 1], func);
      }
 
    while (i-- > 1)
-     stack[i-1] = eina_list_sort_merge(stack[i-1], stack[i], func);
+      stack[i - 1] = eina_list_sort_merge(stack[i - 1], stack[i], func);
 
    list = stack[0];
    tail = eina_list_sort_rebuild_prev(list);
 
    if (unsort)
      {
-       tail->next = unsort;
-       unsort->prev = tail;
+        tail->next = unsort;
+        unsort->prev = tail;
      }
    else
-     list->accounting->last = tail;
+      list->accounting->last = tail;
 
    return list;
 }
@@ -1477,8 +1543,11 @@ eina_list_merge(Eina_List *left, Eina_List *right)
 {
    unsigned int n_left, n_right;
 
-   if (!left) return right;
-   if (!right) return left;
+   if (!left)
+      return right;
+
+   if (!right)
+      return left;
 
    left->accounting->last->next = right;
    right->prev = left->accounting->last;
@@ -1488,32 +1557,32 @@ eina_list_merge(Eina_List *left, Eina_List *right)
 
    if (n_left >= n_right)
      {
-       Eina_List *itr = right;
-       left->accounting->last = right->accounting->last;
-       left->accounting->count += n_right;
-
-       _eina_list_mempool_accounting_free(right->accounting);
-
-       do
-         {
-            itr->accounting = left->accounting;
-            itr = itr->next;
-         }
-       while (itr);
+        Eina_List *itr = right;
+        left->accounting->last = right->accounting->last;
+        left->accounting->count += n_right;
+
+        _eina_list_mempool_accounting_free(right->accounting);
+
+        do
+          {
+             itr->accounting = left->accounting;
+             itr = itr->next;
+          }
+        while (itr);
      }
    else
      {
-       Eina_List *itr = left->accounting->last;
-       right->accounting->count += n_left;
+        Eina_List *itr = left->accounting->last;
+        right->accounting->count += n_left;
 
-       _eina_list_mempool_accounting_free(left->accounting);
+        _eina_list_mempool_accounting_free(left->accounting);
 
-       do
-         {
-            itr->accounting = right->accounting;
-            itr = itr->prev;
-         }
-       while (itr);
+        do
+          {
+             itr->accounting = right->accounting;
+             itr = itr->prev;
+          }
+        while (itr);
      }
 
    return left;
@@ -1536,22 +1605,28 @@ eina_list_merge(Eina_List *left, Eina_List *right)
  * list does not exist anymore after the split.
  *
  */
-   EAPI Eina_List *
+EAPI Eina_List *
 eina_list_split_list(Eina_List *list, Eina_List *relative, Eina_List **right)
 {
    Eina_List *next;
    Eina_List *itr;
 
-   if(!right) return list;
+   if(!right)
+      return list;
+
    *right = NULL;
 
-   if (!list) return NULL;
+   if (!list)
+      return NULL;
+
    if (!relative)
      {
-       *right = list;
-       return NULL;
+        *right = list;
+        return NULL;
      }
-   if (relative == eina_list_last(list)) return list;
+
+   if (relative == eina_list_last(list))
+      return list;
 
    next = eina_list_next(relative);
    next->prev = NULL;
@@ -1562,9 +1637,9 @@ eina_list_split_list(Eina_List *list, Eina_List *relative, Eina_List **right)
    itr = next;
    do
      {
-       itr->accounting = next->accounting;
-       next->accounting->count++;
-       itr = itr->next;
+        itr->accounting = next->accounting;
+        next->accounting->count++;
+        itr = itr->next;
      }
    while (itr);
 
@@ -1618,65 +1693,68 @@ eina_list_sorted_merge(Eina_List *left, Eina_List *right, Eina_Compare_Cb func)
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
 
-   if (!left) return right;
-   if (!right) return left;
+   if (!left)
+      return right;
+
+   if (!right)
+      return left;
 
    if (func(left->data, right->data) < 0)
      {
-       ret = left;
-       current = left;
-       left = left->next;
-       ret->accounting->count += right->accounting->count;
+        ret = left;
+        current = left;
+        left = left->next;
+        ret->accounting->count += right->accounting->count;
 
-       _eina_list_mempool_accounting_free(right->accounting);
+        _eina_list_mempool_accounting_free(right->accounting);
      }
    else
      {
-       ret = right;
-       current = right;
-       right = right->next;
-       ret->accounting->count += left->accounting->count;
+        ret = right;
+        current = right;
+        right = right->next;
+        ret->accounting->count += left->accounting->count;
 
-       _eina_list_mempool_accounting_free(left->accounting);
+        _eina_list_mempool_accounting_free(left->accounting);
      }
 
    while (left && right)
      {
-       if (func(left->data, right->data) < 0)
-         {
-            current->next = left;
-            left->prev = current;
-            left = left->next;
-         }
-       else
-         {
-            current->next = right;
-            right->prev = current;
-            right = right->next;
-         }
-
-       current = current->next;
-       current->accounting = ret->accounting;
+        if (func(left->data, right->data) < 0)
+          {
+             current->next = left;
+             left->prev = current;
+             left = left->next;
+          }
+        else
+          {
+             current->next = right;
+             right->prev = current;
+             right = right->next;
+          }
+
+        current = current->next;
+        current->accounting = ret->accounting;
      }
 
    if (left)
      {
-       current->next = left;
-       left->prev = current;
-       current->accounting = ret->accounting;
+        current->next = left;
+        left->prev = current;
+        current->accounting = ret->accounting;
      }
 
    if (right)
      {
-       current->next = right;
-       right->prev = current;
-       current->accounting = ret->accounting;
+        current->next = right;
+        right->prev = current;
+        current->accounting = ret->accounting;
      }
 
    while (current->next)
      {
-       current = current->next;
-       current->accounting = ret->accounting;
+        current = current->next;
+        current->accounting = ret->accounting;
      }
 
    ret->accounting->last = current;
@@ -1720,7 +1798,10 @@ eina_list_sorted_merge(Eina_List *left, Eina_List *right, Eina_Compare_Cb func)
  * @see eina_list_sorted_merge()
  */
 EAPI Eina_List *
-eina_list_search_sorted_near_list(const Eina_List *list, Eina_Compare_Cb func, const void *data, int *result_cmp)
+eina_list_search_sorted_near_list(const Eina_List *list,
+                                  Eina_Compare_Cb func,
+                                  const void *data,
+                                  int *result_cmp)
 {
    const Eina_List *ct;
    unsigned int inf, sup, cur;
@@ -1728,27 +1809,31 @@ eina_list_search_sorted_near_list(const Eina_List *list, Eina_Compare_Cb func, c
 
    if (!list)
      {
-       if (result_cmp) *result_cmp = 0;
-       return NULL;
+        if (result_cmp)
+           *result_cmp = 0;
+
+        return NULL;
      }
 
    if (list->accounting->count == 1)
      {
-       if (result_cmp) *result_cmp = func(list->data, data);
-       return (Eina_List *)list;
+        if (result_cmp)
+           *result_cmp = func(list->data, data);
+
+        return (Eina_List *)list;
      }
 
    /* list walk is expensive, do quick check: tail */
    ct = list->accounting->last;
    cmp = func(ct->data, data);
    if (cmp <= 0)
-     goto end;
+      goto end;
 
    /* list walk is expensive, do quick check: head */
    ct = list;
    cmp = func(ct->data, data);
    if (cmp >= 0)
-     goto end;
+      goto end;
 
    /* inclusive bounds */
    inf = 1;
@@ -1759,33 +1844,41 @@ eina_list_search_sorted_near_list(const Eina_List *list, Eina_Compare_Cb func, c
    /* no loop, just compare if comparison value is important to caller */
    if (inf > sup)
      {
-       if (result_cmp) cmp = func(ct->data, data);
-       goto end;
+        if (result_cmp)
+           cmp = func(ct->data, data);
+
+        goto end;
      }
 
    while (inf <= sup)
      {
-       unsigned int tmp = cur;
-       cur = inf + ((sup - inf) >> 1);
-       if      (tmp < cur) for (; tmp != cur; tmp++, ct = ct->next);
-       else if (tmp > cur) for (; tmp != cur; tmp--, ct = ct->prev);
-
-       cmp = func(ct->data, data);
-       if (cmp == 0)
-         break;
-       else if (cmp < 0)
-         inf = cur + 1;
-       else if (cmp > 0)
-         {
-            if (cur > 0)
-              sup = cur - 1;
-            else break;
-         }
-       else break;
+        unsigned int tmp = cur;
+        cur = inf + ((sup - inf) >> 1);
+        if      (tmp < cur)
+           for (; tmp != cur; tmp++, ct = ct->next) ;
+        else if (tmp > cur)
+           for (; tmp != cur; tmp--, ct = ct->prev) ;
+
+        cmp = func(ct->data, data);
+        if (cmp == 0)
+           break;
+        else if (cmp < 0)
+           inf = cur + 1;
+        else if (cmp > 0)
+          {
+             if (cur > 0)
+                sup = cur - 1;
+             else
+                break;
+          }
+        else
+           break;
      }
 
- end:
-   if (result_cmp) *result_cmp = cmp;
+end:
+   if (result_cmp)
+      *result_cmp = cmp;
+
    return (Eina_List *)ct;
 }
 
@@ -1821,15 +1914,20 @@ eina_list_search_sorted_near_list(const Eina_List *list, Eina_Compare_Cb func, c
  * @see eina_list_search_sorted_near_list()
  */
 EAPI Eina_List *
-eina_list_search_sorted_list(const Eina_List *list, Eina_Compare_Cb func, const void *data)
+eina_list_search_sorted_list(const Eina_List *list,
+                             Eina_Compare_Cb func,
+                             const void *data)
 {
    Eina_List *lnear;
    int cmp;
 
    lnear = eina_list_search_sorted_near_list(list, func, data, &cmp);
-   if (!lnear) return NULL;
+   if (!lnear)
+      return NULL;
+
    if (cmp == 0)
-     return lnear;
+      return lnear;
+
    return NULL;
 }
 
@@ -1866,7 +1964,9 @@ eina_list_search_sorted_list(const Eina_List *list, Eina_Compare_Cb func, const
  * @see eina_list_search_unsorted_list()
  */
 EAPI void *
-eina_list_search_sorted(const Eina_List *list, Eina_Compare_Cb func, const void *data)
+eina_list_search_sorted(const Eina_List *list,
+                        Eina_Compare_Cb func,
+                        const void *data)
 {
    return eina_list_data_get(eina_list_search_sorted_list(list, func, data));
 }
@@ -1893,16 +1993,18 @@ eina_list_search_sorted(const Eina_List *list, Eina_Compare_Cb func, const void
  * @see eina_list_search_unsorted()
  */
 EAPI Eina_List *
-eina_list_search_unsorted_list(const Eina_List *list, Eina_Compare_Cb func, const void *data)
+eina_list_search_unsorted_list(const Eina_List *list,
+                               Eina_Compare_Cb func,
+                               const void *data)
 {
    const Eina_List *l;
    void *d;
 
    EINA_LIST_FOREACH(list, l, d)
-     {
-       if (!func(d, data))
-        return (Eina_List*) l;
-     }
+   {
+      if (!func(d, data))
+         return (Eina_List *)l;
+   }
    return NULL;
 }
 
@@ -1929,7 +2031,9 @@ eina_list_search_unsorted_list(const Eina_List *list, Eina_Compare_Cb func, cons
  * @see eina_list_search_unsorted_list()
  */
 EAPI void *
-eina_list_search_unsorted(const Eina_List *list, Eina_Compare_Cb func, const void *data)
+eina_list_search_unsorted(const Eina_List *list,
+                          Eina_Compare_Cb func,
+                          const void *data)
 {
    return eina_list_data_get(eina_list_search_unsorted_list(list, func, data));
 }
@@ -1962,19 +2066,22 @@ eina_list_iterator_new(const Eina_List *list)
 
    eina_error_set(0);
    it = calloc(1, sizeof (Eina_Iterator_List));
-   if (!it) {
-      eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
-      return NULL;
-   }
+   if (!it)
+     {
+        eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+        return NULL;
+     }
 
-   EINA_MAGIC_SET(it, EINA_MAGIC_LIST_ITERATOR);
+   EINA_MAGIC_SET(it,            EINA_MAGIC_LIST_ITERATOR);
    EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
 
    it->head = list;
    it->current = list;
 
+   it->iterator.version = EINA_ITERATOR_VERSION;
    it->iterator.next = FUNC_ITERATOR_NEXT(eina_list_iterator_next);
-   it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(eina_list_iterator_get_container);
+   it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
+         eina_list_iterator_get_container);
    it->iterator.free = FUNC_ITERATOR_FREE(eina_list_iterator_free);
 
    return &it->iterator;
@@ -2007,21 +2114,24 @@ eina_list_iterator_reversed_new(const Eina_List *list)
 {
    Eina_Iterator_List *it;
 
-   eina_error_set(0);
+        eina_error_set(0);
    it = calloc(1, sizeof (Eina_Iterator_List));
-   if (!it) {
-      eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
-      return NULL;
-   }
+   if (!it)
+     {
+        eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+        return NULL;
+     }
 
-   EINA_MAGIC_SET(it, EINA_MAGIC_LIST_ITERATOR);
+   EINA_MAGIC_SET(it,            EINA_MAGIC_LIST_ITERATOR);
    EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
 
    it->head = eina_list_last(list);
    it->current = it->head;
 
+   it->iterator.version = EINA_ITERATOR_VERSION;
    it->iterator.next = FUNC_ITERATOR_NEXT(eina_list_iterator_prev);
-   it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(eina_list_iterator_get_container);
+   it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
+         eina_list_iterator_get_container);
    it->iterator.free = FUNC_ITERATOR_FREE(eina_list_iterator_free);
 
    return &it->iterator;
@@ -2044,22 +2154,25 @@ eina_list_accessor_new(const Eina_List *list)
 {
    Eina_Accessor_List *it;
 
-   eina_error_set(0);
+        eina_error_set(0);
    it = calloc(1, sizeof (Eina_Accessor_List));
-   if (!it) {
-      eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
-      return NULL;
-   }
+   if (!it)
+     {
+        eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+        return NULL;
+     }
 
-   EINA_MAGIC_SET(it, EINA_MAGIC_LIST_ACCESSOR);
+   EINA_MAGIC_SET(it,            EINA_MAGIC_LIST_ACCESSOR);
    EINA_MAGIC_SET(&it->accessor, EINA_MAGIC_ACCESSOR);
 
    it->head = list;
    it->current = list;
    it->index = 0;
 
+   it->accessor.version = EINA_ACCESSOR_VERSION;
    it->accessor.get_at = FUNC_ACCESSOR_GET_AT(eina_list_accessor_get_at);
-   it->accessor.get_container = FUNC_ACCESSOR_GET_CONTAINER(eina_list_accessor_get_container);
+   it->accessor.get_container = FUNC_ACCESSOR_GET_CONTAINER(
+         eina_list_accessor_get_container);
    it->accessor.free = FUNC_ACCESSOR_FREE(eina_list_accessor_free);
 
    return &it->accessor;
index 8df3434..f8af3b9 100644 (file)
 # include <unistd.h>
 #endif
 
-#ifdef EFL_HAVE_PTHREAD
+#ifdef EFL_HAVE_POSIX_THREADS
 # include <pthread.h>
 #endif
 
  */
 
 /*============================================================================*
- *                                  Local                                     *
- *============================================================================*/
+*                                  Local                                     *
+*============================================================================*/
 
 /**
  * @cond LOCAL
@@ -337,111 +337,104 @@ static Eina_Bool _disable_function = EINA_FALSE;
 static Eina_Bool _abort_on_critical = EINA_FALSE;
 static int _abort_level_on_critical = EINA_LOG_LEVEL_CRITICAL;
 
-#ifdef EFL_HAVE_PTHREAD
+#ifdef EFL_HAVE_THREADS
 
 static Eina_Bool _threads_enabled = EINA_FALSE;
-static pthread_t _main_thread;
 
-# define IS_MAIN(t)  pthread_equal(t, _main_thread)
-# define IS_OTHER(t) EINA_UNLIKELY(!IS_MAIN(t))
+# ifdef EFL_HAVE_POSIX_THREADS
 
-# ifdef _WIN32
-#  define CHECK_MAIN(...)                                              \
-  do {                                                                 \
-     if (!IS_MAIN(pthread_self())) {                                   \
-       pthread_t cur;                                                  \
-       cur = pthread_self();                                           \
-       fprintf(stderr,                                                 \
-               "ERR: not main thread! current=%p, main=%p\n",  \
-               cur.p, _main_thread.p);                                 \
-       return __VA_ARGS__;                                             \
-     }                                                                 \
-  } while (0)
-# else
-#  define CHECK_MAIN(...)                                              \
-  do {                                                                 \
-     if (!IS_MAIN(pthread_self())) {                                   \
-       fprintf(stderr,                                                 \
-               "ERR: not main thread! current=%lu, main=%lu\n",        \
-               pthread_self(), _main_thread);                          \
-       return __VA_ARGS__;                                             \
-     }                                                                 \
-  } while (0)
-# endif
+typedef pthread_t Thread;
 
-# ifdef EFL_HAVE_PTHREAD_SPINLOCK
+static pthread_t _main_thread;
 
-static pthread_spinlock_t _log_lock;
+#  define SELF() pthread_self()
+#  define IS_MAIN(t)  pthread_equal(t, _main_thread)
+#  define IS_OTHER(t) EINA_UNLIKELY(!IS_MAIN(t))
+#  define CHECK_MAIN(...)                                               \
+   do {                                                                  \
+        if (!IS_MAIN(pthread_self())) {                                    \
+                     fprintf(stderr,                                                 \
+                     "ERR: not main thread! current=%lu, main=%lu\n",        \
+                     pthread_self(), _main_thread);                          \
+             return __VA_ARGS__;                                             \
+          }                                                                  \
+     } while (0)
+
+#  ifdef EFL_HAVE_POSIX_THREADS_SPINLOCK
 
-#  ifdef _WIN32
-#   define LOG_LOCK()                                                  \
-  if(_threads_enabled) \
-  do {                                                                 \
-     pthread_t cur;                                                    \
-     cur = pthread_self();                                             \
-     if (0)                                                            \
-       fprintf(stderr, "+++LOG LOG_LOCKED!   [%s, %p]\n",              \
-              __FUNCTION__, cur.p);                                    \
-     if (EINA_UNLIKELY(_threads_enabled))                              \
-       pthread_spin_lock(&_log_lock);                                  \
-  } while (0)
-#  define LOG_UNLOCK()                                                 \
-  if(_threads_enabled) \
-  do {                                                                 \
-     pthread_t cur;                                                    \
-     cur = pthread_self();                                             \
-     if (EINA_UNLIKELY(_threads_enabled))                              \
-       pthread_spin_unlock(&_log_lock);                                        \
-     if (0)                                                            \
-       fprintf(stderr,                                                 \
-              "---LOG LOG_UNLOCKED! [%s, %p]\n",                       \
-              __FUNCTION__, cur.p);                                    \
-  } while (0)
-#  else
-#   define LOG_LOCK()                                                  \
-  if(_threads_enabled) \
-  do {                                                                 \
-     if (0)                                                            \
-       fprintf(stderr, "+++LOG LOG_LOCKED!   [%s, %lu]\n",             \
-              __FUNCTION__, pthread_self());                           \
-     if (EINA_UNLIKELY(_threads_enabled))                              \
-       pthread_spin_lock(&_log_lock);                                  \
-  } while (0)
-#  define LOG_UNLOCK()                                                 \
-  if(_threads_enabled) \
-  do {                                                                 \
-     if (EINA_UNLIKELY(_threads_enabled))                              \
-       pthread_spin_unlock(&_log_lock);                                        \
-     if (0)                                                            \
-       fprintf(stderr,                                                 \
-              "---LOG LOG_UNLOCKED! [%s, %lu]\n",                      \
-              __FUNCTION__, pthread_self());                           \
-  } while (0)
-#  endif
-#  define INIT() pthread_spin_init(&_log_lock, PTHREAD_PROCESS_PRIVATE);
-#  define SHUTDOWN() pthread_spin_destroy(&_log_lock);
-
-# else /* ! EFL_HAVE_PTHREAD_SPINLOCK */
+static pthread_spinlock_t _log_lock;
+#   define LOG_LOCK()                                                   \
+   if(_threads_enabled)                                                  \
+      do {                                                                  \
+           if (0) {                                                             \
+                fprintf(stderr, "+++LOG LOG_LOCKED!   [%s, %lu]\n",              \
+                        __FUNCTION__, pthread_self()); }                           \
+           if (EINA_UNLIKELY(_threads_enabled)) {                               \
+                pthread_spin_lock(&_log_lock); }                                   \
+        } while (0)
+#   define LOG_UNLOCK()                                                 \
+   if(_threads_enabled)                                                  \
+      do {                                                                  \
+           if (EINA_UNLIKELY(_threads_enabled)) {                               \
+                pthread_spin_unlock(&_log_lock); }                                 \
+           if (0) {                                                             \
+                     fprintf(stderr,                                                  \
+                        "---LOG LOG_UNLOCKED! [%s, %lu]\n",                      \
+                        __FUNCTION__, pthread_self()); }                           \
+        } while (0)
+#   define INIT() pthread_spin_init(&_log_lock, PTHREAD_PROCESS_PRIVATE)
+#   define SHUTDOWN() pthread_spin_destroy(&_log_lock)
+
+#  else /* ! EFL_HAVE_POSIX_THREADS_SPINLOCK */
 
 static pthread_mutex_t _log_mutex = PTHREAD_MUTEX_INITIALIZER;
-#  define LOG_LOCK() if(_threads_enabled) pthread_mutex_lock(&_log_mutex);
-#  define LOG_UNLOCK() if(_threads_enabled) pthread_mutex_unlock(&_log_mutex);
-#  define INIT() do {} while (0)
-#  define SHUTDOWN() do {} while (0)
+#   define LOG_LOCK() if(_threads_enabled) {pthread_mutex_lock(&_log_mutex); }
+#   define LOG_UNLOCK() if(_threads_enabled) {pthread_mutex_unlock(&_log_mutex); }
+#   define INIT() (1)
+#   define SHUTDOWN() do {} while (0)
+
+#  endif /* ! EFL_HAVE_POSIX_THREADS_SPINLOCK */
+
+# else /* EFL_HAVE_WIN32_THREADS */
+
+typedef DWORD Thread;
+
+static DWORD _main_thread;
 
-# endif /* ! EFL_HAVE_PTHREAD_SPINLOCK */
+#  define SELF() GetCurrentThreadId()
+#  define IS_MAIN(t)  (t == _main_thread)
+#  define IS_OTHER(t) EINA_UNLIKELY(!IS_MAIN(t))
+#  define CHECK_MAIN(...)                                               \
+   do {                                                                  \
+        if (!IS_MAIN(GetCurrentThreadId())) {                              \
+                     fprintf(stderr,                                                 \
+                     "ERR: not main thread! current=%lu, main=%lu\n",        \
+                     GetCurrentThreadId(), _main_thread);                    \
+             return __VA_ARGS__;                                             \
+          }                                                                  \
+     } while (0)
 
-#else /* ! EFL_HAVE_PTHREAD */
+static HANDLE _log_mutex = NULL;
+
+#  define LOG_LOCK() if(_threads_enabled) WaitForSingleObject(_log_mutex, \
+                                                              INFINITE)
+#  define LOG_UNLOCK() if(_threads_enabled) ReleaseMutex(_log_mutex)
+#  define INIT() ((_log_mutex = CreateMutex(NULL, FALSE, NULL)) ? 1 : 0)
+#  define SHUTDOWN()  if (_log_mutex) CloseHandle(_log_mutex)
+
+# endif /* EFL_HAVE_WIN32_THREADS */
+
+#else /* ! EFL_HAVE_THREADS */
 
 # define LOG_LOCK() do {} while (0)
 # define LOG_UNLOCK() do {} while (0)
 # define IS_MAIN(t)  (1)
 # define IS_OTHER(t) (0)
 # define CHECK_MAIN(...) do {} while (0)
-# define INIT() do {} while (0)
+# define INIT() (1)
 # define SHUTDOWN() do {} while (0)
 
-#endif /* ! EFL_HAVE_PTHREAD */
+#endif /* ! EFL_HAVE_THREADS */
 
 
 // List of domains registered
@@ -466,11 +459,11 @@ static Eina_Log_Level _log_level = EINA_LOG_LEVEL_ERR;
  *   eina_log_print_level_name_color_get()
  */
 static const char *_names[] = {
-  "CRI",
-  "ERR",
-  "WRN",
-  "INF",
-  "DBG",
+   "CRI",
+   "ERR",
+   "WRN",
+   "INF",
+   "DBG",
 };
 
 #ifdef _WIN32
@@ -486,55 +479,58 @@ eina_log_win32_color_get(const char *domain_str)
 
    str = strdup(domain_str);
    if (!str)
-     return 0;
+      return 0;
 
    /* this should not append */
    if (str[0] != '\033')
-     return 0;
+      return 0;
 
    /* we skip the first char and the [ */
    tmp = tmp2 = str + 2;
    while (*tmp != 'm')
      {
-       if (*tmp == ';')
-         {
-            *tmp = '\0';
-            code = atol(tmp2);
-            tmp++;
-            tmp2 = tmp;
-         }
-       tmp++;
+        if (*tmp == ';')
+          {
+             *tmp = '\0';
+             code = atol(tmp2);
+             tmp++;
+             tmp2 = tmp;
+          }
+
+        tmp++;
      }
    *tmp = '\0';
    if (code < 0)
-     code = atol(tmp2);
+      code = atol(tmp2);
    else
-     lighted = atol(tmp2);
+      lighted = atol(tmp2);
 
    free(str);
 
    if (code < lighted)
      {
-       int c;
+        int c;
 
-       c = code;
-       code = lighted;
-       lighted = c;
+        c = code;
+        code = lighted;
+        lighted = c;
      }
 
-   if (lighted) ret = FOREGROUND_INTENSITY;
+   if (lighted)
+      ret = FOREGROUND_INTENSITY;
+
    if (code == 31)
-     ret |= FOREGROUND_RED;
+      ret |= FOREGROUND_RED;
    else if (code == 32)
-     ret |= FOREGROUND_GREEN;
+      ret |= FOREGROUND_GREEN;
    else if (code == 33)
-     ret |= FOREGROUND_RED | FOREGROUND_GREEN;
+      ret |= FOREGROUND_RED | FOREGROUND_GREEN;
    else if (code == 34)
-     ret |= FOREGROUND_BLUE;
+      ret |= FOREGROUND_BLUE;
    else if (code == 36)
-     ret |= FOREGROUND_GREEN | FOREGROUND_BLUE;
+      ret |= FOREGROUND_GREEN | FOREGROUND_BLUE;
    else if (code == 37)
-     ret |= FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
+      ret |= FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
 
    return ret;
 }
@@ -550,21 +546,23 @@ eina_log_print_level_name_get(int level, const char **p_name)
     */
    if (EINA_UNLIKELY(level < 0))
      {
-       snprintf(buf, sizeof(buf), "%03d", level);
-       *p_name = buf;
+        snprintf(buf, sizeof(buf), "%03d", level);
+        *p_name = buf;
      }
    else if (EINA_UNLIKELY(level >= EINA_LOG_LEVELS))
      {
-       snprintf(buf, sizeof(buf), "%03d", level);
-       *p_name = buf;
+        snprintf(buf, sizeof(buf), "%03d", level);
+        *p_name = buf;
      }
    else
-       *p_name = _names[level];
+      *p_name = _names[level];
 }
 
 #ifdef _WIN32
 static inline void
-eina_log_print_level_name_color_get(int level, const char **p_name, int *p_color)
+eina_log_print_level_name_color_get(int level,
+                                    const char **p_name,
+                                    int *p_color)
 {
    static char buf[4];
    /* NOTE: if you change this, also change:
@@ -572,24 +570,24 @@ eina_log_print_level_name_color_get(int level, const char **p_name, int *p_color
     */
    if (EINA_UNLIKELY(level < 0))
      {
-       snprintf(buf, sizeof(buf), "%03d", level);
-       *p_name = buf;
+        snprintf(buf, sizeof(buf), "%03d", level);
+        *p_name = buf;
      }
    else if (EINA_UNLIKELY(level >= EINA_LOG_LEVELS))
      {
-       snprintf(buf, sizeof(buf), "%03d", level);
-       *p_name = buf;
+        snprintf(buf, sizeof(buf), "%03d", level);
+        *p_name = buf;
      }
    else
-     {
-       *p_name = _names[level];
-     }
+      *p_name = _names[level];
 
    *p_color = eina_log_win32_color_get(eina_log_level_color_get(level));
 }
 #else
 static inline void
-eina_log_print_level_name_color_get(int level, const char **p_name, const char **p_color)
+eina_log_print_level_name_color_get(int level,
+                                    const char **p_name,
+                                    const char **p_color)
 {
    static char buf[4];
    /* NOTE: if you change this, also change:
@@ -597,46 +595,63 @@ eina_log_print_level_name_color_get(int level, const char **p_name, const char *
     */
    if (EINA_UNLIKELY(level < 0))
      {
-       snprintf(buf, sizeof(buf), "%03d", level);
-       *p_name = buf;
+        snprintf(buf, sizeof(buf), "%03d", level);
+        *p_name = buf;
      }
    else if (EINA_UNLIKELY(level >= EINA_LOG_LEVELS))
      {
-       snprintf(buf, sizeof(buf), "%03d", level);
-       *p_name = buf;
+        snprintf(buf, sizeof(buf), "%03d", level);
+        *p_name = buf;
      }
    else
-     {
-       *p_name = _names[level];
-     }
+      *p_name = _names[level];
+
    *p_color = eina_log_level_color_get(level);
 }
 #endif
 
-#define DECLARE_LEVEL_NAME(level) const char *name; eina_log_print_level_name_get(level, &name)
+#define DECLARE_LEVEL_NAME(level) const char *name; \
+   eina_log_print_level_name_get(level, &name)
 #ifdef _WIN32
-# define DECLARE_LEVEL_NAME_COLOR(level) const char *name; int color; eina_log_print_level_name_color_get(level, &name, &color)
+# define DECLARE_LEVEL_NAME_COLOR(level) const char *name; int color; \
+   eina_log_print_level_name_color_get(level, &name, &color)
 #else
-# define DECLARE_LEVEL_NAME_COLOR(level) const char *name, *color; eina_log_print_level_name_color_get(level, &name, &color)
+# define DECLARE_LEVEL_NAME_COLOR(level) const char *name, *color; \
+   eina_log_print_level_name_color_get(level, &name, &color)
 #endif
 
 /** No threads, No color */
 static void
-eina_log_print_prefix_NOthreads_NOcolor_file_func(FILE *fp, const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line)
+eina_log_print_prefix_NOthreads_NOcolor_file_func(FILE *fp,
+                                                  const Eina_Log_Domain *d,
+                                                  Eina_Log_Level level,
+                                                  const char *file,
+                                                  const char *fnc,
+                                                  int line)
 {
    DECLARE_LEVEL_NAME(level);
    fprintf(fp, "%s:%s %s:%d %s() ", name, d->domain_str, file, line, fnc);
 }
 
 static void
-eina_log_print_prefix_NOthreads_NOcolor_NOfile_func(FILE *fp, const Eina_Log_Domain *d, Eina_Log_Level level, const char *file __UNUSED__, const char *fnc, int line __UNUSED__)
+eina_log_print_prefix_NOthreads_NOcolor_NOfile_func(FILE *fp,
+                                                    const Eina_Log_Domain *d,
+                                                    Eina_Log_Level level,
+                                                    const char *file __UNUSED__,
+                                                    const char *fnc,
+                                                    int line __UNUSED__)
 {
    DECLARE_LEVEL_NAME(level);
    fprintf(fp, "%s:%s %s() ", name, d->domain_str, fnc);
 }
 
 static void
-eina_log_print_prefix_NOthreads_NOcolor_file_NOfunc(FILE *fp, const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc __UNUSED__, int line)
+eina_log_print_prefix_NOthreads_NOcolor_file_NOfunc(FILE *fp,
+                                                    const Eina_Log_Domain *d,
+                                                    Eina_Log_Level level,
+                                                    const char *file,
+                                                    const char *fnc __UNUSED__,
+                                                    int line)
 {
    DECLARE_LEVEL_NAME(level);
    fprintf(fp, "%s:%s %s:%d ", name, d->domain_str, file, line);
@@ -644,347 +659,448 @@ eina_log_print_prefix_NOthreads_NOcolor_file_NOfunc(FILE *fp, const Eina_Log_Dom
 
 /* No threads, color */
 static void
-eina_log_print_prefix_NOthreads_color_file_func(FILE *fp, const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line)
+eina_log_print_prefix_NOthreads_color_file_func(FILE *fp,
+                                                const Eina_Log_Domain *d,
+                                                Eina_Log_Level level,
+                                                const char *file,
+                                                const char *fnc,
+                                                int line)
 {
    DECLARE_LEVEL_NAME_COLOR(level);
 #ifdef _WIN32
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
-                          color);
+                           color);
    fprintf(fp, "%s", name);
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
-                          FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
+                           FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
    fprintf(fp, ":");
-   SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), eina_log_win32_color_get(d->domain_str));
+   SetConsoleTextAttribute(GetStdHandle(
+                              STD_OUTPUT_HANDLE),
+                           eina_log_win32_color_get(d->domain_str));
    fprintf(fp, "%s", d->name);
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
-                          FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
+                           FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
    fprintf(fp, " %s:%d ", file, line);
-   SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
-                           FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
+   SetConsoleTextAttribute(GetStdHandle(
+                              STD_OUTPUT_HANDLE),
+                           FOREGROUND_INTENSITY | FOREGROUND_RED |
+                           FOREGROUND_GREEN | FOREGROUND_BLUE);
    fprintf(fp, "%s()", fnc);
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
-                           FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
+                           FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
    fprintf(fp, " ");
 #else
    fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s %s:%d "
-          EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
-          color, name, d->domain_str, file, line, fnc);
+           EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
+           color, name, d->domain_str, file, line, fnc);
 #endif
 }
 
 static void
-eina_log_print_prefix_NOthreads_color_NOfile_func(FILE *fp, const Eina_Log_Domain *d, Eina_Log_Level level, const char *file __UNUSED__, const char *fnc, int line __UNUSED__)
+eina_log_print_prefix_NOthreads_color_NOfile_func(FILE *fp,
+                                                  const Eina_Log_Domain *d,
+                                                  Eina_Log_Level level,
+                                                  const char *file __UNUSED__,
+                                                  const char *fnc,
+                                                  int line __UNUSED__)
 {
    DECLARE_LEVEL_NAME_COLOR(level);
 #ifdef _WIN32
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
-                          color);
+                           color);
    fprintf(fp, "%s", name);
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
-                          FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
+                           FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
    fprintf(fp, ":");
-   SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), eina_log_win32_color_get(d->domain_str));
+   SetConsoleTextAttribute(GetStdHandle(
+                              STD_OUTPUT_HANDLE),
+                           eina_log_win32_color_get(d->domain_str));
    fprintf(fp, "%s", d->name);
-   SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
-                           FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
+   SetConsoleTextAttribute(GetStdHandle(
+                              STD_OUTPUT_HANDLE),
+                           FOREGROUND_INTENSITY | FOREGROUND_RED |
+                           FOREGROUND_GREEN | FOREGROUND_BLUE);
    fprintf(fp, "%s()", fnc);
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
-                           FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
+                           FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
    fprintf(fp, " ");
 #else
    fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s "
-          EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
-          color, name, d->domain_str, fnc);
+           EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
+           color, name, d->domain_str, fnc);
 #endif
 }
 
 static void
-eina_log_print_prefix_NOthreads_color_file_NOfunc(FILE *fp, const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc __UNUSED__, int line)
+eina_log_print_prefix_NOthreads_color_file_NOfunc(FILE *fp,
+                                                  const Eina_Log_Domain *d,
+                                                  Eina_Log_Level level,
+                                                  const char *file,
+                                                  const char *fnc __UNUSED__,
+                                                  int line)
 {
    DECLARE_LEVEL_NAME_COLOR(level);
 #ifdef _WIN32
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
-                          color);
+                           color);
    fprintf(fp, "%s", name);
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
-                          FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
+                           FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
    fprintf(fp, ":");
-   SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), eina_log_win32_color_get(d->domain_str));
+   SetConsoleTextAttribute(GetStdHandle(
+                              STD_OUTPUT_HANDLE),
+                           eina_log_win32_color_get(d->domain_str));
    fprintf(fp, "%s", d->name);
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
-                          FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
+                           FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
    fprintf(fp, " %s:%d ", file, line);
 #else
    fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s %s:%d ",
-          color, name, d->domain_str, file, line);
+           color, name, d->domain_str, file, line);
 #endif
 }
 
 /** threads, No color */
-#ifdef EFL_HAVE_PTHREAD
+#ifdef EFL_HAVE_THREADS
 static void
-eina_log_print_prefix_threads_NOcolor_file_func(FILE *fp, const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line)
+eina_log_print_prefix_threads_NOcolor_file_func(FILE *fp,
+                                                const Eina_Log_Domain *d,
+                                                Eina_Log_Level level,
+                                                const char *file,
+                                                const char *fnc,
+                                                int line)
 {
-   pthread_t cur;
+   Thread cur;
 
    DECLARE_LEVEL_NAME(level);
-   cur = pthread_self();
+   cur = SELF();
    if (IS_OTHER(cur))
      {
-#ifdef _WIN32
-       fprintf(fp, "%s:%s[T:%p] %s:%d %s() ",
-               name, d->domain_str, cur.p, file, line, fnc);
-#else
-       fprintf(fp, "%s:%s[T:%lu] %s:%d %s() ",
-               name, d->domain_str, cur, file, line, fnc);
-#endif
-       return;
+        fprintf(fp, "%s:%s[T:%lu] %s:%d %s() ",
+                name, d->domain_str, cur, file, line, fnc);
+        return;
      }
-   fprintf(fp, "%s:%s %s:%d %s() ", name, d->domain_str, file, line, fnc);
+
+        fprintf(fp, "%s:%s %s:%d %s() ", name, d->domain_str, file, line, fnc);
 }
 
 static void
-eina_log_print_prefix_threads_NOcolor_NOfile_func(FILE *fp, const Eina_Log_Domain *d, Eina_Log_Level level, const char *file __UNUSED__, const char *fnc, int line __UNUSED__)
+eina_log_print_prefix_threads_NOcolor_NOfile_func(FILE *fp,
+                                                  const Eina_Log_Domain *d,
+                                                  Eina_Log_Level level,
+                                                  const char *file __UNUSED__,
+                                                  const char *fnc,
+                                                  int line __UNUSED__)
 {
-   pthread_t cur;
+   Thread cur;
 
    DECLARE_LEVEL_NAME(level);
-   cur = pthread_self();
+   cur = SELF();
    if (IS_OTHER(cur))
      {
-#ifdef _WIN32
-       fprintf(fp, "%s:%s[T:%p] %s() ",
-               name, d->domain_str, cur.p, fnc);
-#else
-       fprintf(fp, "%s:%s[T:%lu] %s() ",
-               name, d->domain_str, cur, fnc);
-#endif
-       return;
+        fprintf(fp, "%s:%s[T:%lu] %s() ",
+                name, d->domain_str, cur, fnc);
+        return;
      }
-   fprintf(fp, "%s:%s %s() ", name, d->domain_str, fnc);
+
+        fprintf(fp, "%s:%s %s() ", name, d->domain_str, fnc);
 }
 
 static void
-eina_log_print_prefix_threads_NOcolor_file_NOfunc(FILE *fp, const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc __UNUSED__, int line)
+eina_log_print_prefix_threads_NOcolor_file_NOfunc(FILE *fp,
+                                                  const Eina_Log_Domain *d,
+                                                  Eina_Log_Level level,
+                                                  const char *file,
+                                                  const char *fnc __UNUSED__,
+                                                  int line)
 {
-   pthread_t cur;
+   Thread cur;
 
    DECLARE_LEVEL_NAME(level);
-   cur = pthread_self();
+   cur = SELF();
    if (IS_OTHER(cur))
      {
-#ifdef _WIN32
-       fprintf(fp, "%s:%s[T:%p] %s:%d ",
-               name, d->domain_str, cur.p, file, line);
-#else
-       fprintf(fp, "%s:%s[T:%lu] %s:%d ",
-               name, d->domain_str, cur, file, line);
-#endif
-       return;
+        fprintf(fp, "%s:%s[T:%lu] %s:%d ",
+                name, d->domain_str, cur, file, line);
+        return;
      }
-   fprintf(fp, "%s:%s %s:%d ", name, d->domain_str, file, line);
+
+        fprintf(fp, "%s:%s %s:%d ", name, d->domain_str, file, line);
 }
 
 /* threads, color */
 static void
-eina_log_print_prefix_threads_color_file_func(FILE *fp, const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line)
+eina_log_print_prefix_threads_color_file_func(FILE *fp,
+                                              const Eina_Log_Domain *d,
+                                              Eina_Log_Level level,
+                                              const char *file,
+                                              const char *fnc,
+                                              int line)
 {
-   pthread_t cur;
+   Thread cur;
+
    DECLARE_LEVEL_NAME_COLOR(level);
-   cur = pthread_self();
+   cur = SELF();
    if (IS_OTHER(cur))
      {
 # ifdef _WIN32
-       SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
-                               color);
-       fprintf(fp, "%s", name);
-       SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
-                               FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
-       fprintf(fp, ":");
-       SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), eina_log_win32_color_get(d->domain_str));
-       fprintf(fp, "%s[T:", d->name);
-       SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
-                               FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
-       fprintf(fp, "[T:");
-       SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
-                               FOREGROUND_GREEN | FOREGROUND_BLUE);
-       fprintf(fp, "%lu", (unsigned long)cur.p);
-       SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
-                               FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
-       fprintf(fp, "] %s:%d ", file, line);
-       SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
-                               FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
-       fprintf(fp, "%s()", fnc);
-       SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
-                               FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
-       fprintf(fp, " ");
+        SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+                                color);
+        fprintf(fp, "%s", name);
+        SetConsoleTextAttribute(GetStdHandle(
+                                   STD_OUTPUT_HANDLE),
+                                FOREGROUND_RED | FOREGROUND_GREEN |
+                                FOREGROUND_BLUE);
+        fprintf(fp, ":");
+        SetConsoleTextAttribute(GetStdHandle(
+                                   STD_OUTPUT_HANDLE),
+                                eina_log_win32_color_get(d->domain_str));
+        fprintf(fp, "%s[T:", d->name);
+        SetConsoleTextAttribute(GetStdHandle(
+                                   STD_OUTPUT_HANDLE),
+                                FOREGROUND_RED | FOREGROUND_GREEN |
+                                FOREGROUND_BLUE);
+        fprintf(fp, "[T:");
+        SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+                                FOREGROUND_GREEN | FOREGROUND_BLUE);
+        fprintf(fp, "%lu", (unsigned long)cur);
+        SetConsoleTextAttribute(GetStdHandle(
+                                   STD_OUTPUT_HANDLE),
+                                FOREGROUND_RED | FOREGROUND_GREEN |
+                                FOREGROUND_BLUE);
+        fprintf(fp, "] %s:%d ", file, line);
+        SetConsoleTextAttribute(GetStdHandle(
+                                   STD_OUTPUT_HANDLE),
+                                FOREGROUND_INTENSITY | FOREGROUND_RED |
+                                FOREGROUND_GREEN | FOREGROUND_BLUE);
+        fprintf(fp, "%s()", fnc);
+        SetConsoleTextAttribute(GetStdHandle(
+                                   STD_OUTPUT_HANDLE),
+                                FOREGROUND_RED | FOREGROUND_GREEN |
+                                FOREGROUND_BLUE);
+        fprintf(fp, " ");
 # else
-       fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s[T:"
-               EINA_COLOR_ORANGE "%lu" EINA_COLOR_RESET "] %s:%d "
-               EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
-               color, name, d->domain_str, cur, file, line, fnc);
+        fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s[T:"
+                EINA_COLOR_ORANGE "%lu" EINA_COLOR_RESET "] %s:%d "
+                EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
+                color, name, d->domain_str, cur, file, line, fnc);
 # endif
-       return;
+        return;
      }
+
 # ifdef _WIN32
-   eina_log_print_prefix_NOthreads_color_file_func(fp, d, level, file, fnc, line);
+   eina_log_print_prefix_NOthreads_color_file_func(fp,
+                                                   d,
+                                                   level,
+                                                   file,
+                                                   fnc,
+                                                   line);
 # else
    fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s %s:%d "
-          EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
-          color, name, d->domain_str, file, line, fnc);
+           EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
+           color, name, d->domain_str, file, line, fnc);
 # endif
 }
 
 static void
-eina_log_print_prefix_threads_color_NOfile_func(FILE *fp, const Eina_Log_Domain *d, Eina_Log_Level level, const char *file __UNUSED__, const char *fnc, int line __UNUSED__)
+eina_log_print_prefix_threads_color_NOfile_func(FILE *fp,
+                                                const Eina_Log_Domain *d,
+                                                Eina_Log_Level level,
+                                                const char *file __UNUSED__,
+                                                const char *fnc,
+                                                int line __UNUSED__)
 {
-   pthread_t cur;
+   Thread cur;
 
    DECLARE_LEVEL_NAME_COLOR(level);
-   cur = pthread_self();
+   cur = SELF();
    if (IS_OTHER(cur))
      {
 # ifdef _WIN32
-       SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
-                               color);
-       fprintf(fp, "%s", name);
-       SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
-                               FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
-       fprintf(fp, ":");
-       SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), eina_log_win32_color_get(d->domain_str));
-       fprintf(fp, "%s[T:", d->name);
-       SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
-                               FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
-       fprintf(fp, "[T:");
-       SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
-                               FOREGROUND_GREEN | FOREGROUND_BLUE);
-       fprintf(fp, "%lu", (unsigned long)cur.p);
-       SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
-                               FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
-       fprintf(fp, "%s()", fnc);
-       SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
-                               FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
-       fprintf(fp, " ");
+        SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+                                color);
+        fprintf(fp, "%s", name);
+        SetConsoleTextAttribute(GetStdHandle(
+                                   STD_OUTPUT_HANDLE),
+                                FOREGROUND_RED | FOREGROUND_GREEN |
+                                FOREGROUND_BLUE);
+        fprintf(fp, ":");
+        SetConsoleTextAttribute(GetStdHandle(
+                                   STD_OUTPUT_HANDLE),
+                                eina_log_win32_color_get(d->domain_str));
+        fprintf(fp, "%s[T:", d->name);
+        SetConsoleTextAttribute(GetStdHandle(
+                                   STD_OUTPUT_HANDLE),
+                                FOREGROUND_RED | FOREGROUND_GREEN |
+                                FOREGROUND_BLUE);
+        fprintf(fp, "[T:");
+        SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+                                FOREGROUND_GREEN | FOREGROUND_BLUE);
+        fprintf(fp, "%lu", (unsigned long)cur);
+        SetConsoleTextAttribute(GetStdHandle(
+                                   STD_OUTPUT_HANDLE),
+                                FOREGROUND_INTENSITY | FOREGROUND_RED |
+                                FOREGROUND_GREEN | FOREGROUND_BLUE);
+        fprintf(fp, "%s()", fnc);
+        SetConsoleTextAttribute(GetStdHandle(
+                                   STD_OUTPUT_HANDLE),
+                                FOREGROUND_RED | FOREGROUND_GREEN |
+                                FOREGROUND_BLUE);
+        fprintf(fp, " ");
 # else
-       fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s[T:"
-               EINA_COLOR_ORANGE "%lu" EINA_COLOR_RESET "] "
-               EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
-               color, name, d->domain_str, cur, fnc);
+        fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s[T:"
+                EINA_COLOR_ORANGE "%lu" EINA_COLOR_RESET "] "
+                EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
+                color, name, d->domain_str, cur, fnc);
 # endif
-       return;
+        return;
      }
+
 # ifdef _WIN32
-   eina_log_print_prefix_NOthreads_color_NOfile_func(fp, d, level, file, fnc, line);
+   eina_log_print_prefix_NOthreads_color_NOfile_func(fp,
+                                                     d,
+                                                     level,
+                                                     file,
+                                                     fnc,
+                                                     line);
 # else
    fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s "
-          EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
-          color, name, d->domain_str, fnc);
+           EINA_COLOR_HIGH "%s()" EINA_COLOR_RESET " ",
+           color, name, d->domain_str, fnc);
 # endif
 }
 
 static void
-eina_log_print_prefix_threads_color_file_NOfunc(FILE *fp, const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc __UNUSED__, int line)
+eina_log_print_prefix_threads_color_file_NOfunc(FILE *fp,
+                                                const Eina_Log_Domain *d,
+                                                Eina_Log_Level level,
+                                                const char *file,
+                                                const char *fnc __UNUSED__,
+                                                int line)
 {
-   pthread_t cur;
+   Thread cur;
 
    DECLARE_LEVEL_NAME_COLOR(level);
-   cur = pthread_self();
+   cur = SELF();
    if (IS_OTHER(cur))
      {
 # ifdef _WIN32
-       SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
-                               color);
-       fprintf(fp, "%s", name);
-       SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
-                               FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
-       fprintf(fp, ":");
-       SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), eina_log_win32_color_get(d->domain_str));
-       fprintf(fp, "%s[T:", d->name);
-       SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
-                               FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
-       fprintf(fp, "[T:");
-       SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
-                               FOREGROUND_GREEN | FOREGROUND_BLUE);
-       fprintf(fp, "%lu", (unsigned long)cur.p);
-       SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
-                               FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
-       fprintf(fp, "] %s:%d ", file, line);
+        SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+                                color);
+        fprintf(fp, "%s", name);
+        SetConsoleTextAttribute(GetStdHandle(
+                                   STD_OUTPUT_HANDLE),
+                                FOREGROUND_RED | FOREGROUND_GREEN |
+                                FOREGROUND_BLUE);
+        fprintf(fp, ":");
+        SetConsoleTextAttribute(GetStdHandle(
+                                   STD_OUTPUT_HANDLE),
+                                eina_log_win32_color_get(d->domain_str));
+        fprintf(fp, "%s[T:", d->name);
+        SetConsoleTextAttribute(GetStdHandle(
+                                   STD_OUTPUT_HANDLE),
+                                FOREGROUND_RED | FOREGROUND_GREEN |
+                                FOREGROUND_BLUE);
+        fprintf(fp, "[T:");
+        SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
+                                FOREGROUND_GREEN | FOREGROUND_BLUE);
+        fprintf(fp, "%lu", (unsigned long)cur);
+        SetConsoleTextAttribute(GetStdHandle(
+                                   STD_OUTPUT_HANDLE),
+                                FOREGROUND_RED | FOREGROUND_GREEN |
+                                FOREGROUND_BLUE);
+        fprintf(fp, "] %s:%d ", file, line);
 # else
-       fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s[T:"
-               EINA_COLOR_ORANGE "%lu" EINA_COLOR_RESET "] %s:%d ",
-               color, name, d->domain_str, cur, file, line);
+        fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s[T:"
+                EINA_COLOR_ORANGE "%lu" EINA_COLOR_RESET "] %s:%d ",
+                color, name, d->domain_str, cur, file, line);
 # endif
-       return;
+        return;
      }
+
 # ifdef _WIN32
-   eina_log_print_prefix_NOthreads_color_file_NOfunc(fp, d, level, file, fnc, line);
+   eina_log_print_prefix_NOthreads_color_file_NOfunc(fp,
+                                                     d,
+                                                     level,
+                                                     file,
+                                                     fnc,
+                                                     line);
 # else
-   fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s %s:%d ",
-          color, name, d->domain_str, file, line);
+        fprintf(fp, "%s%s" EINA_COLOR_RESET ":%s %s:%d ",
+           color, name, d->domain_str, file, line);
 # endif
 }
-#endif
+#endif /* EFL_HAVE_THREADS */
 
-static void (*_eina_log_print_prefix)(FILE *fp, const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, const char *fnc, int line) = eina_log_print_prefix_NOthreads_color_file_func;
+static void (*_eina_log_print_prefix)(FILE *fp, const Eina_Log_Domain *d,
+                                      Eina_Log_Level level, const char *file,
+                                      const char *fnc,
+                                      int line) =
+   eina_log_print_prefix_NOthreads_color_file_func;
 
 static inline void
 eina_log_print_prefix_update(void)
 {
    if (_disable_file && _disable_function)
      {
-       fprintf(stderr, "ERROR: cannot have " EINA_LOG_ENV_FILE_DISABLE " and "
-               EINA_LOG_ENV_FUNCTION_DISABLE " set at the same time, will "
-               "just disable function.\n");
-       _disable_file = 0;
+        fprintf(stderr, "ERROR: cannot have " EINA_LOG_ENV_FILE_DISABLE " and "
+                EINA_LOG_ENV_FUNCTION_DISABLE " set at the same time, will "
+                                              "just disable function.\n");
+        _disable_file = 0;
      }
 
 #define S(NOthread, NOcolor, NOfile, NOfunc) \
-   _eina_log_print_prefix = eina_log_print_prefix_##NOthread##threads_##NOcolor##color_##NOfile##file_##NOfunc##func
+   _eina_log_print_prefix = \
+      eina_log_print_prefix_ ## NOthread ## threads_ ## NOcolor ## color_ ## \
+      NOfile \
+      ## file_ ## NOfunc ## func
 
-#ifdef EFL_HAVE_PTHREAD
+#ifdef EFL_HAVE_THREADS
    if (_threads_enabled)
      {
-       if (_disable_color)
-         {
-            if (_disable_file)
-              S(,NO,NO,);
-            else if (_disable_function)
-              S(,NO,,NO);
-            else
-              S(,NO,,);
-         }
-       else
-         {
-            if (_disable_file)
-              S(,,NO,);
-            else if (_disable_function)
-              S(,,,NO);
-            else
-              S(,,,);
-         }
-       return;
+        if (_disable_color)
+          {
+             if (_disable_file)
+                S(,NO,NO,);
+             else if (_disable_function)
+                S(,NO,,NO);
+             else
+                S(,NO,,);
+          }
+        else
+          {
+             if (_disable_file)
+                S(,,NO,);
+             else if (_disable_function)
+                S(,,,NO);
+             else
+                S(,,,);
+          }
+
+        return;
      }
+
 #endif
 
    if (_disable_color)
      {
-       if (_disable_file)
-         S(NO,NO,NO,);
-       else if (_disable_function)
-         S(NO,NO,,NO);
-       else
-         S(NO,NO,,);
+        if (_disable_file)
+                S(NO,NO,NO,);
+        else if (_disable_function)
+                S(NO,NO,,NO);
+        else
+                S(NO,NO,,);
      }
    else
      {
-       if (_disable_file)
-         S(NO,,NO,);
-       else if (_disable_function)
-         S(NO,,,NO);
-       else
-         S(NO,,,);
+        if (_disable_file)
+                S(NO,,NO,);
+        else if (_disable_function)
+                S(NO,,,NO);
+        else
+                S(NO,,,);
      }
+
 #undef S
 }
 
@@ -998,20 +1114,25 @@ eina_log_domain_str_get(const char *name, const char *color)
 
    if (color)
      {
-       size_t name_len;
-       size_t color_len;
-
-       name_len = strlen(name);
-       color_len = strlen(color);
-       d = malloc(sizeof(char) * (color_len + name_len + strlen(EINA_COLOR_RESET) + 1));
-       if (!d) return NULL;
-       memcpy((char *)d, color, color_len);
-       memcpy((char *)(d + color_len), name, name_len);
-       memcpy((char *)(d + color_len + name_len), EINA_COLOR_RESET, strlen(EINA_COLOR_RESET));
-       ((char *)d)[color_len + name_len + strlen(EINA_COLOR_RESET)] = '\0';
+        size_t name_len;
+        size_t color_len;
+
+        name_len = strlen(name);
+        color_len = strlen(color);
+        d =
+           malloc(sizeof(char) *
+                  (color_len + name_len + strlen(EINA_COLOR_RESET) + 1));
+        if (!d)
+           return NULL;
+
+               memcpy((char *)d,                          color, color_len);
+               memcpy((char *)(d + color_len),            name,  name_len);
+               memcpy((char *)(d + color_len + name_len), EINA_COLOR_RESET,
+               strlen(EINA_COLOR_RESET));
+        ((char *)d)[color_len + name_len + strlen(EINA_COLOR_RESET)] = '\0';
      }
    else
-       d = strdup(name);
+      d = strdup(name);
 
    return d;
 }
@@ -1023,7 +1144,7 @@ eina_log_domain_str_get(const char *name, const char *color)
 static Eina_Log_Domain *
 eina_log_domain_new(Eina_Log_Domain *d, const char *name, const char *color)
 {
-   EINA_SAFETY_ON_NULL_RETURN_VAL(d, NULL);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(d,    NULL);
    EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
 
    d->level = EINA_LOG_LEVEL_UNKNOWN;
@@ -1031,19 +1152,19 @@ eina_log_domain_new(Eina_Log_Domain *d, const char *name, const char *color)
 
    if (name)
      {
-       if ((color) && (!_disable_color))
-          d->domain_str = eina_log_domain_str_get(name, color);
-       else
-          d->domain_str = eina_log_domain_str_get(name, NULL);
+        if ((color) && (!_disable_color))
+           d->domain_str = eina_log_domain_str_get(name, color);
+        else
+           d->domain_str = eina_log_domain_str_get(name, NULL);
 
-       d->name = strdup(name);
-       d->namelen = strlen(name);
+        d->name = strdup(name);
+        d->namelen = strlen(name);
      }
    else
      {
-       d->domain_str = NULL;
-       d->name = NULL;
-       d->namelen = 0;
+        d->domain_str = NULL;
+        d->name = NULL;
+        d->namelen = 0;
      }
 
    return d;
@@ -1060,6 +1181,7 @@ eina_log_domain_free(Eina_Log_Domain *d)
 
    if (d->domain_str)
       free((char *)d->domain_str);
+
    if (d->name)
       free((char *)d->name);
 }
@@ -1072,37 +1194,44 @@ eina_log_domain_parse_pendings(void)
 {
    const char *start;
 
-   if (!(start = getenv(EINA_LOG_ENV_LEVELS))) return;
+   if (!(start = getenv(EINA_LOG_ENV_LEVELS)))
+      return;
 
    // name1:level1,name2:level2,name3:level3,...
    while (1)
      {
-       Eina_Log_Domain_Level_Pending *p;
-       char *end = NULL;
-       char *tmp = NULL;
-       long int level;
-
-       end = strchr(start, ':');
-       if (!end) break;
-
-       // Parse level, keep going if failed
-       level = strtol((char *)(end + 1), &tmp, 10);
-       if (tmp == (end + 1)) goto parse_end;
-
-       // Parse name
-       p = malloc(sizeof(Eina_Log_Domain_Level_Pending) + end - start + 1);
-       if (!p) break;
-       p->namelen = end - start;
-       memcpy((char *)p->name, start, end - start);
-       ((char *)p->name)[end - start] = '\0';
-       p->level = level;
-
-       _pending_list = eina_inlist_append(_pending_list, EINA_INLIST_GET(p));
-
-       parse_end:
-       start = strchr(tmp, ',');
-       if (start) start++;
-       else break;
+        Eina_Log_Domain_Level_Pending *p;
+        char *end = NULL;
+        char *tmp = NULL;
+        long int level;
+
+        end = strchr(start, ':');
+        if (!end)
+           break;
+
+        // Parse level, keep going if failed
+        level = strtol((char *)(end + 1), &tmp, 10);
+        if (tmp == (end + 1))
+           goto parse_end;
+
+        // Parse name
+        p = malloc(sizeof(Eina_Log_Domain_Level_Pending) + end - start + 1);
+        if (!p)
+           break;
+
+        p->namelen = end - start;
+        memcpy((char *)p->name, start, end - start);
+        ((char *)p->name)[end - start] = '\0';
+        p->level = level;
+
+        _pending_list = eina_inlist_append(_pending_list, EINA_INLIST_GET(p));
+
+parse_end:
+        start = strchr(tmp, ',');
+        if (start)
+           start++;
+        else
+           break;
      }
 }
 
@@ -1111,37 +1240,44 @@ eina_log_domain_parse_pending_globs(void)
 {
    const char *start;
 
-   if (!(start = getenv(EINA_LOG_ENV_LEVELS_GLOB))) return;
+   if (!(start = getenv(EINA_LOG_ENV_LEVELS_GLOB)))
+      return;
 
    // name1:level1,name2:level2,name3:level3,...
    while (1)
      {
-       Eina_Log_Domain_Level_Pending *p;
-       char *end = NULL;
-       char *tmp = NULL;
-       long int level;
-
-       end = strchr(start, ':');
-       if (!end) break;
-
-       // Parse level, keep going if failed
-       level = strtol((char *)(end + 1), &tmp, 10);
-       if (tmp == (end + 1)) goto parse_end;
-
-       // Parse name
-       p = malloc(sizeof(Eina_Log_Domain_Level_Pending) + end - start + 1);
-       if (!p) break;
-       p->namelen = 0; /* not that useful */
-       memcpy((char *)p->name, start, end - start);
-       ((char *)p->name)[end - start] = '\0';
-       p->level = level;
-
-       _glob_list = eina_inlist_append(_glob_list, EINA_INLIST_GET(p));
-
-       parse_end:
-       start = strchr(tmp, ',');
-       if (start) start++;
-       else break;
+        Eina_Log_Domain_Level_Pending *p;
+        char *end = NULL;
+        char *tmp = NULL;
+        long int level;
+
+        end = strchr(start, ':');
+        if (!end)
+           break;
+
+        // Parse level, keep going if failed
+        level = strtol((char *)(end + 1), &tmp, 10);
+        if (tmp == (end + 1))
+           goto parse_end;
+
+        // Parse name
+        p = malloc(sizeof(Eina_Log_Domain_Level_Pending) + end - start + 1);
+        if (!p)
+           break;
+
+        p->namelen = 0; /* not that useful */
+        memcpy((char *)p->name, start, end - start);
+        ((char *)p->name)[end - start] = '\0';
+        p->level = level;
+
+        _glob_list = eina_inlist_append(_glob_list, EINA_INLIST_GET(p));
+
+parse_end:
+        start = strchr(tmp, ',');
+        if (start)
+           start++;
+        else
+           break;
      }
 }
 
@@ -1154,66 +1290,67 @@ eina_log_domain_register_unlocked(const char *name, const char *color)
 
    for (i = 0; i < _log_domains_count; i++)
      {
-       if (_log_domains[i].deleted)
-         {
-            // Found a flagged slot, free domain_str and replace slot
-            eina_log_domain_new(&_log_domains[i], name, color);
-            goto finish_register;
-         }
+        if (_log_domains[i].deleted)
+          {
+             // Found a flagged slot, free domain_str and replace slot
+             eina_log_domain_new(&_log_domains[i], name, color);
+             goto finish_register;
+          }
      }
 
    if (_log_domains_count >= _log_domains_allocated)
      {
-       Eina_Log_Domain *tmp;
-       size_t size;
-
-       if (!_log_domains)
-         // special case for init, eina itself will allocate a dozen of domains
-         size = 24;
-       else
-         // grow 8 buckets to minimize reallocs
-         size = _log_domains_allocated + 8;
-
-       tmp = realloc(_log_domains, sizeof(Eina_Log_Domain) * size);
-
-       if (tmp)
-         {
-            // Success!
-            _log_domains = tmp;
-            _log_domains_allocated = size;
-         }
-       else
-          return -1;
+        Eina_Log_Domain *tmp;
+        size_t size;
+
+        if (!_log_domains)
+           // special case for init, eina itself will allocate a dozen of domains
+           size = 24;
+        else
+           // grow 8 buckets to minimize reallocs
+           size = _log_domains_allocated + 8;
+
+        tmp = realloc(_log_domains, sizeof(Eina_Log_Domain) * size);
+
+        if (tmp)
+          {
+             // Success!
+             _log_domains = tmp;
+             _log_domains_allocated = size;
+          }
+        else
+           return -1;
      }
 
    // Use an allocated slot
-   eina_log_domain_new(&_log_domains[i], name, color);
+             eina_log_domain_new(&_log_domains[i], name, color);
    _log_domains_count++;
 
 finish_register:
    namelen = _log_domains[i].namelen;
 
    EINA_INLIST_FOREACH(_pending_list, pending)
-     {
-       if ((namelen == pending->namelen) && (strcmp(pending->name, name) == 0))
-         {
-            _log_domains[i].level = pending->level;
-            _pending_list = eina_inlist_remove(_pending_list, EINA_INLIST_GET(pending));
-            free(pending);
-            break;
-         }
-     }
+   {
+      if ((namelen == pending->namelen) && (strcmp(pending->name, name) == 0))
+        {
+           _log_domains[i].level = pending->level;
+           _pending_list =
+              eina_inlist_remove(_pending_list, EINA_INLIST_GET(pending));
+           free(pending);
+           break;
+        }
+   }
 
    if (_log_domains[i].level == EINA_LOG_LEVEL_UNKNOWN)
      {
-       EINA_INLIST_FOREACH(_glob_list, pending)
-         {
-            if (!fnmatch(pending->name, name, 0))
-              {
-                 _log_domains[i].level = pending->level;
-                 break;
-              }
-         }
+        EINA_INLIST_FOREACH(_glob_list, pending)
+        {
+           if (!fnmatch(pending->name, name, 0))
+             {
+                _log_domains[i].level = pending->level;
+                break;
+             }
+        }
      }
 
    // Check if level is still UNKNOWN, set it to global
@@ -1229,35 +1366,41 @@ eina_log_term_color_supported(const char *term)
    const char *tail;
 
    if (!term)
-     return EINA_FALSE;
+      return EINA_FALSE;
 
    tail = term + 1;
    switch (term[0])
      {
-       /* list of known to support color terminals,
-        * take from gentoo's portage.
-        */
+      /* list of known to support color terminals,
+       * take from gentoo's portage.
+       */
 
       case 'x': /* xterm and xterm-color */
-        return ((strncmp(tail, "term", sizeof("term") - 1) == 0) &&
-                ((tail[sizeof("term") - 1] == '\0') ||
-                 (strcmp(tail + sizeof("term") - 1, "-color") == 0)));
+         return ((strncmp(tail, "term", sizeof("term") - 1) == 0) &&
+                 ((tail[sizeof("term") - 1] == '\0') ||
+                  (strcmp(tail + sizeof("term") - 1, "-color") == 0)));
+
       case 'E': /* Eterm */
       case 'a': /* aterm */
       case 'k': /* kterm */
-       return (strcmp(tail, "term") == 0);
+         return (strcmp(tail, "term") == 0);
+
       case 'r': /* xrvt or rxvt-unicode */
-        return ((strncmp(tail, "xvt", sizeof("xvt") - 1) == 0) &&
-                ((tail[sizeof("xvt") - 1] == '\0') ||
-                 (strcmp(tail + sizeof("xvt") - 1, "-unicode") == 0)));
+         return ((strncmp(tail, "xvt", sizeof("xvt") - 1) == 0) &&
+                 ((tail[sizeof("xvt") - 1] == '\0') ||
+                  (strcmp(tail + sizeof("xvt") - 1, "-unicode") == 0)));
+
       case 's': /* screen */
-        return (strcmp(tail, "creen") == 0);
+         return (strcmp(tail, "creen") == 0);
+
       case 'g': /* gnome */
-        return (strcmp(tail, "nome") == 0);
+         return (strcmp(tail, "nome") == 0);
+
       case 'i': /* interix */
-        return (strcmp(tail, "nterix") == 0);
+         return (strcmp(tail, "nterix") == 0);
+
       default:
-        return EINA_FALSE;
+         return EINA_FALSE;
      }
 }
 
@@ -1267,8 +1410,8 @@ eina_log_term_color_supported(const char *term)
 
 
 /*============================================================================*
- *                                 Global                                     *
- *============================================================================*/
+*                                 Global                                     *
+*============================================================================*/
 
 /**
  * @internal
@@ -1291,51 +1434,52 @@ eina_log_init(void)
    const char *level, *tmp;
    int color_disable;
 
-   assert((sizeof(_names)/sizeof(_names[0])) == EINA_LOG_LEVELS);
+   assert((sizeof(_names) / sizeof(_names[0])) == EINA_LOG_LEVELS);
 
    if ((tmp = getenv(EINA_LOG_ENV_COLOR_DISABLE)))
-     color_disable = atoi(tmp);
+      color_disable = atoi(tmp);
    else
-     color_disable = -1;
+      color_disable = -1;
 
    /* Check if color is explicitly disabled */
    if (color_disable == 1)
-     _disable_color = EINA_TRUE;
+      _disable_color = EINA_TRUE;
 
 #ifndef _WIN32
    /* color was not explicitly disabled or enabled, guess it */
    else if (color_disable == -1)
      {
-       if (!eina_log_term_color_supported(getenv("TERM")))
-         _disable_color = EINA_TRUE;
-       else {
-          /* if not a terminal, but redirected to a file, disable color */
-          int fd;
-
-          if (_print_cb == eina_log_print_cb_stderr)
-            fd = STDERR_FILENO;
-          else if (_print_cb == eina_log_print_cb_stdout)
-            fd = STDOUT_FILENO;
-          else
-            fd = -1;
-
-          if ((fd >= 0) && (!isatty(fd)))
-            _disable_color = EINA_TRUE;
-       }
+        if (!eina_log_term_color_supported(getenv("TERM")))
+           _disable_color = EINA_TRUE;
+        else
+          {
+             /* if not a terminal, but redirected to a file, disable color */
+             int fd;
+
+             if (_print_cb == eina_log_print_cb_stderr)
+                fd = STDERR_FILENO;
+             else if (_print_cb == eina_log_print_cb_stdout)
+                fd = STDOUT_FILENO;
+             else
+                fd = -1;
+
+             if ((fd >= 0) && (!isatty(fd)))
+                _disable_color = EINA_TRUE;
+          }
      }
 #endif
 
    if ((tmp = getenv(EINA_LOG_ENV_FILE_DISABLE)) && (atoi(tmp) == 1))
-     _disable_file = EINA_TRUE;
+      _disable_file = EINA_TRUE;
 
    if ((tmp = getenv(EINA_LOG_ENV_FUNCTION_DISABLE)) && (atoi(tmp) == 1))
-     _disable_function = EINA_TRUE;
+      _disable_function = EINA_TRUE;
 
    if ((tmp = getenv(EINA_LOG_ENV_ABORT)) && (atoi(tmp) == 1))
-     _abort_on_critical = EINA_TRUE;
+      _abort_on_critical = EINA_TRUE;
 
    if ((tmp = getenv(EINA_LOG_ENV_ABORT_LEVEL)))
-     _abort_level_on_critical = atoi(tmp);
+      _abort_level_on_critical = atoi(tmp);
 
    eina_log_print_prefix_update();
 
@@ -1348,8 +1492,8 @@ eina_log_init(void)
 
    if (EINA_LOG_DOMAIN_GLOBAL < 0)
      {
-       fprintf(stderr, "Failed to create global logging domain.\n");
-       return EINA_FALSE;
+        fprintf(stderr, "Failed to create global logging domain.\n");
+        return EINA_FALSE;
      }
 
    // Parse pending domains passed through EINA_LOG_LEVELS_GLOB
@@ -1383,12 +1527,13 @@ eina_log_shutdown(void)
 
    while (_log_domains_count--)
      {
-       if (_log_domains[_log_domains_count].deleted)
-          continue;
-       eina_log_domain_free(&_log_domains[_log_domains_count]);
+        if (_log_domains[_log_domains_count].deleted)
+           continue;
+
+        eina_log_domain_free(&_log_domains[_log_domains_count]);
      }
 
-   free(_log_domains);
+        free(_log_domains);
 
    _log_domains = NULL;
    _log_domains_count = 0;
@@ -1403,15 +1548,15 @@ eina_log_shutdown(void)
 
    while (_pending_list)
      {
-       tmp = _pending_list;
-       _pending_list = _pending_list->next;
-       free(tmp);
+        tmp = _pending_list;
+        _pending_list = _pending_list->next;
+        free(tmp);
      }
 
    return EINA_TRUE;
 }
 
-#ifdef EFL_HAVE_PTHREAD
+#ifdef EFL_HAVE_THREADS
 
 /**
  * @internal
@@ -1425,9 +1570,9 @@ eina_log_shutdown(void)
 void
 eina_log_threads_init(void)
 {
-   _main_thread = pthread_self();
-   _threads_enabled = EINA_TRUE;
-   INIT();
+   _main_thread = SELF();
+   if (INIT())
+      _threads_enabled = EINA_TRUE;
 }
 
 /**
@@ -1442,16 +1587,16 @@ eina_log_threads_init(void)
 void
 eina_log_threads_shutdown(void)
 {
-    CHECK_MAIN();
-    SHUTDOWN();
-    _threads_enabled = EINA_FALSE;
+   CHECK_MAIN();
+   SHUTDOWN();
+   _threads_enabled = EINA_FALSE;
 }
 
 #endif
 
 /*============================================================================*
- *                                   API                                      *
- *============================================================================*/
+*                                   API                                      *
+*============================================================================*/
 
 /**
  * @addtogroup Eina_Log_Group Log
@@ -1574,7 +1719,7 @@ EAPI int EINA_LOG_DOMAIN_GLOBAL = 0;
 EAPI void
 eina_log_threads_enable(void)
 {
-#ifdef EFL_HAVE_PTHREAD
+#ifdef EFL_HAVE_THREADS
    _threads_enabled = 1;
    eina_log_print_prefix_update();
 #endif
@@ -1618,8 +1763,8 @@ eina_log_level_set(int level)
 {
    _log_level = level;
    if (EINA_LIKELY((EINA_LOG_DOMAIN_GLOBAL >= 0) &&
-                  ((unsigned int)EINA_LOG_DOMAIN_GLOBAL < _log_domains_count)))
-     _log_domains[EINA_LOG_DOMAIN_GLOBAL].level = level;
+                   ((unsigned int)EINA_LOG_DOMAIN_GLOBAL < _log_domains_count)))
+      _log_domains[EINA_LOG_DOMAIN_GLOBAL].level = level;
 }
 
 /**
@@ -1650,8 +1795,8 @@ eina_log_level_get(void)
 EAPI Eina_Bool
 eina_log_main_thread_check(void)
 {
-#ifdef EFL_HAVE_PTHREAD
-   return ((!_threads_enabled) || pthread_equal(_main_thread, pthread_self()));
+#ifdef EFL_HAVE_THREADS
+   return ((!_threads_enabled) || IS_MAIN(SELF()));
 #else
    return EINA_TRUE;
 #endif
@@ -1840,7 +1985,8 @@ eina_log_domain_unregister_unlocked(int domain)
 {
    Eina_Log_Domain *d;
 
-   if ((unsigned int)domain >= _log_domains_count) return;
+   if ((unsigned int)domain >= _log_domains_count)
+      return;
 
    d = &_log_domains[domain];
    eina_log_domain_free(d);
@@ -1889,29 +2035,31 @@ eina_log_domain_level_set(const char *domain_name, int level)
 
    for (i = 0; i < _log_domains_count; i++)
      {
-       if (_log_domains[i].deleted)
-         continue;
-       if ((namelen != _log_domains[i].namelen) ||
-           (strcmp(_log_domains[i].name, domain_name) != 0))
-         continue;
-
-       _log_domains[i].level = level;
-       return;
+        if (_log_domains[i].deleted)
+           continue;
+
+        if ((namelen != _log_domains[i].namelen) ||
+            (strcmp(_log_domains[i].name, domain_name) != 0))
+           continue;
+
+        _log_domains[i].level = level;
+        return;
      }
 
    EINA_INLIST_FOREACH(_pending_list, pending)
-     {
-       if ((namelen == pending->namelen) &&
-           (strcmp(pending->name, domain_name) == 0))
-         {
-            pending->level = level;
-            return;
-         }
-     }
+   {
+      if ((namelen == pending->namelen) &&
+          (strcmp(pending->name, domain_name) == 0))
+        {
+           pending->level = level;
+           return;
+        }
+   }
 
    pending = malloc(sizeof(Eina_Log_Domain_Level_Pending) + namelen + 1);
    if (!pending)
-     return;
+      return;
+
    pending->level = level;
    pending->namelen = namelen;
    memcpy(pending->name, domain_name, namelen + 1);
@@ -1950,31 +2098,28 @@ eina_log_domain_level_get(const char *domain_name)
 
    for (i = 0; i < _log_domains_count; i++)
      {
-       if (_log_domains[i].deleted)
-         continue;
-       if ((namelen != _log_domains[i].namelen) ||
-           (strcmp(_log_domains[i].name, domain_name) != 0))
-         continue;
+        if (_log_domains[i].deleted)
+           continue;
 
-       return _log_domains[i].level;
+        if ((namelen != _log_domains[i].namelen) ||
+            (strcmp(_log_domains[i].name, domain_name) != 0))
+           continue;
+
+        return _log_domains[i].level;
      }
 
    EINA_INLIST_FOREACH(_pending_list, pending)
-     {
-       if ((namelen == pending->namelen) &&
-           (strcmp(pending->name, domain_name) == 0))
-         {
-            return pending->level;
-         }
-     }
+   {
+      if ((namelen == pending->namelen) &&
+          (strcmp(pending->name, domain_name) == 0))
+         return pending->level;
+   }
 
    EINA_INLIST_FOREACH(_glob_list, pending)
-     {
-       if (!fnmatch(pending->name, domain_name, 0))
-         {
-            return pending->level;
-         }
-     }
+   {
+      if (!fnmatch(pending->name, domain_name, 0))
+         return pending->level;
+   }
 
    return _log_level;
 }
@@ -1995,9 +2140,9 @@ eina_log_domain_registered_level_get(int domain)
 {
    EINA_SAFETY_ON_FALSE_RETURN_VAL(domain >= 0, EINA_LOG_LEVEL_UNKNOWN);
    EINA_SAFETY_ON_FALSE_RETURN_VAL((unsigned int)domain < _log_domains_count,
-                                  EINA_LOG_LEVEL_UNKNOWN);
+                                   EINA_LOG_LEVEL_UNKNOWN);
    EINA_SAFETY_ON_TRUE_RETURN_VAL(_log_domains[domain].deleted,
-                                 EINA_LOG_LEVEL_UNKNOWN);
+                                  EINA_LOG_LEVEL_UNKNOWN);
    return _log_domains[domain].level;
 }
 
@@ -2014,7 +2159,7 @@ eina_log_domain_registered_level_get(int domain)
  * -1), then Eina will disable color if terminal ($TERM) is
  * unsupported or if redirecting to a file.
 
-. Similarly, to disable file and line
+   . Similarly, to disable file and line
  * information, set EINA_LOG_FILE_DISABLE=1 or
  * EINA_LOG_FUNCTION_DISABLE=1 to avoid function name in output. It is
  * not acceptable to have both EINA_LOG_FILE_DISABLE and
@@ -2027,9 +2172,14 @@ eina_log_domain_registered_level_get(int domain)
  *       appended to domain name.
  */
 EAPI void
-eina_log_print_cb_stderr(const Eina_Log_Domain *d, Eina_Log_Level level,
-               const char *file, const char *fnc, int line, const char *fmt,
-               __UNUSED__ void *data, va_list args)
+eina_log_print_cb_stderr(const Eina_Log_Domain *d,
+                         Eina_Log_Level level,
+                         const char *file,
+                         const char *fnc,
+                         int line,
+                         const char *fmt,
+                         __UNUSED__ void *data,
+                         va_list args)
 {
    _eina_log_print_prefix(stderr, d, level, file, fnc, line);
    vfprintf(stderr, fmt, args);
@@ -2054,9 +2204,14 @@ eina_log_print_cb_stderr(const Eina_Log_Domain *d, Eina_Log_Level level,
  *       appended to domain name.
  */
 EAPI void
-eina_log_print_cb_stdout(const Eina_Log_Domain *d, Eina_Log_Level level,
-               const char *file, const char *fnc, int line, const char *fmt,
-               __UNUSED__ void *data, va_list args)
+eina_log_print_cb_stdout(const Eina_Log_Domain *d,
+                         Eina_Log_Level level,
+                         const char *file,
+                         const char *fnc,
+                         int line,
+                         const char *fmt,
+                         __UNUSED__ void *data,
+                         va_list args)
 {
    _eina_log_print_prefix(stdout, d, level, file, fnc, line);
    vprintf(fmt, args);
@@ -2073,36 +2228,46 @@ eina_log_print_cb_stdout(const Eina_Log_Domain *d, Eina_Log_Level level,
  *       appended to domain name.
  */
 EAPI void
-eina_log_print_cb_file(const Eina_Log_Domain *d, __UNUSED__ Eina_Log_Level level,
-               const char *file, const char *fnc, int line, const char *fmt,
-               void *data, va_list args)
+eina_log_print_cb_file(const Eina_Log_Domain *d,
+                       __UNUSED__ Eina_Log_Level level,
+                       const char *file,
+                       const char *fnc,
+                       int line,
+                       const char *fmt,
+                       void *data,
+                       va_list args)
 {
    FILE *f = data;
-#ifdef EFL_HAVE_PTHREAD
+#ifdef EFL_HAVE_THREADS
    if (_threads_enabled)
      {
-       pthread_t cur = pthread_self();
-       if (IS_OTHER(cur))
-         {
-# ifdef _WIN32
-            fprintf(f, "%s[T:%p] %s:%d %s() ", d->name, cur.p, file, line, fnc);
-# else
-            fprintf(f, "%s[T:%lu] %s:%d %s() ", d->name, cur, file, line, fnc);
-# endif
-            goto end;
-         }
+        Thread cur;
+
+        cur = SELF();
+        if (IS_OTHER(cur))
+          {
+             fprintf(f, "%s[T:%lu] %s:%d %s() ", d->name, cur, file, line, fnc);
+             goto end;
+          }
      }
+
 #endif
-   fprintf(f, "%s %s:%d %s() ", d->name, file, line, fnc);
-#ifdef EFL_HAVE_PTHREAD
- end:
+             fprintf(f, "%s %s:%d %s() ", d->name, file, line, fnc);
+#ifdef EFL_HAVE_THREADS
+end:
 #endif
    vfprintf(f, fmt, args);
    putc('\n', f);
 }
 
 static inline void
-eina_log_print_unlocked(int domain, Eina_Log_Level level, const char *file, const char *fnc, int line, const char *fmt, va_list args)
+eina_log_print_unlocked(int domain,
+                        Eina_Log_Level level,
+                        const char *file,
+                        const char *fnc,
+                        int line,
+                        const char *fmt,
+                        va_list args)
 {
    Eina_Log_Domain *d;
 
@@ -2110,30 +2275,73 @@ eina_log_print_unlocked(int domain, Eina_Log_Level level, const char *file, cons
    if (EINA_UNLIKELY((unsigned int)domain >= _log_domains_count) ||
        EINA_UNLIKELY(domain < 0))
      {
-       if (file && fnc && fmt)
-         fprintf(stderr, "CRI: %s:%d %s() eina_log_print() unknown domain %d, original message format '%s'\n", file, line, fnc, domain, fmt);
-       else
-         fprintf(stderr, "CRI: eina_log_print() unknown domain %d, original message format '%s'\n", domain, fmt ? fmt : "");
-       if (_abort_on_critical) abort();
-       return;
+        if (file && fnc && fmt)
+           fprintf(
+              stderr,
+              "CRI: %s:%d %s() eina_log_print() unknown domain %d, original message format '%s'\n",
+              file,
+              line,
+              fnc,
+              domain,
+              fmt);
+        else
+           fprintf(
+              stderr,
+              "CRI: eina_log_print() unknown domain %d, original message format '%s'\n",
+              domain,
+              fmt ? fmt : "");
+
+        if (_abort_on_critical)
+           abort();
+
+        return;
      }
+
 #endif
    d = _log_domains + domain;
 #ifdef EINA_SAFETY_CHECKS
    if (EINA_UNLIKELY(d->deleted))
      {
-       fprintf(stderr, "ERR: eina_log_print() domain %d is deleted\n", domain);
-       return;
+           fprintf(stderr,
+                "ERR: eina_log_print() domain %d is deleted\n",
+                domain);
+        return;
      }
+
 #endif
 
-   if (level > d->level) return;
+   if (level > d->level)
+      return;
 
+#ifdef _WIN32
+   {
+      char *wfmt;
+      char *tmp;
+
+      wfmt = strdup(fmt);
+      if (!wfmt)
+        {
+           fprintf(stderr, "ERR: %s: can not allocate memory\n", __FUNCTION__);
+           return;
+        }
+
+      tmp = wfmt;
+      while (strchr(tmp, "%"))
+        {
+           tmp++;
+           if (*tmp == 'z')
+              *tmp = 'I';
+        }
+      _print_cb(d, level, file, fnc, line, wfmt, _print_cb_data, args);
+      free(wfmt);
+   }
+#else
    _print_cb(d, level, file, fnc, line, fmt, _print_cb_data, args);
+#endif
 
    if (EINA_UNLIKELY(_abort_on_critical) &&
        EINA_UNLIKELY(level <= _abort_level_on_critical))
-     abort();
+      abort();
 }
 
 /**
@@ -2160,26 +2368,29 @@ eina_log_print_unlocked(int domain, Eina_Log_Level level, const char *file, cons
  */
 EAPI void
 eina_log_print(int domain, Eina_Log_Level level, const char *file,
-               const char *fnc, int line, const char *fmt, ...)
+               const char *fnc, int line, const char *fmt, ...)
 {
    va_list args;
 
 #ifdef EINA_SAFETY_CHECKS
    if (EINA_UNLIKELY(file == NULL))
      {
-       fputs("ERR: eina_log_print() file == NULL\n", stderr);
-       return;
+        fputs("ERR: eina_log_print() file == NULL\n", stderr);
+        return;
      }
+
    if (EINA_UNLIKELY(fnc == NULL))
      {
-       fputs("ERR: eina_log_print() fnc == NULL\n", stderr);
-       return;
+        fputs("ERR: eina_log_print() fnc == NULL\n", stderr);
+        return;
      }
+
    if (EINA_UNLIKELY(fmt == NULL))
      {
-       fputs("ERR: eina_log_print() fmt == NULL\n", stderr);
-       return;
+        fputs("ERR: eina_log_print() fmt == NULL\n", stderr);
+        return;
      }
+
 #endif
    va_start(args, fmt);
    LOG_LOCK();
@@ -2214,24 +2425,27 @@ eina_log_print(int domain, Eina_Log_Level level, const char *file,
  */
 EAPI void
 eina_log_vprint(int domain, Eina_Log_Level level, const char *file,
-               const char *fnc, int line, const char *fmt, va_list args)
+                const char *fnc, int line, const char *fmt, va_list args)
 {
 #ifdef EINA_SAFETY_CHECKS
    if (EINA_UNLIKELY(file == NULL))
      {
-       fputs("ERR: eina_log_print() file == NULL\n", stderr);
-       return;
+        fputs("ERR: eina_log_print() file == NULL\n", stderr);
+        return;
      }
+
    if (EINA_UNLIKELY(fnc == NULL))
      {
-       fputs("ERR: eina_log_print() fnc == NULL\n", stderr);
-       return;
+        fputs("ERR: eina_log_print() fnc == NULL\n", stderr);
+        return;
      }
+
    if (EINA_UNLIKELY(fmt == NULL))
      {
-       fputs("ERR: eina_log_print() fmt == NULL\n", stderr);
-       return;
+        fputs("ERR: eina_log_print() fmt == NULL\n", stderr);
+        return;
      }
+
 #endif
    LOG_LOCK();
    eina_log_print_unlocked(domain, level, file, fnc, line, fmt, args);
index 28dee38..be10303 100644 (file)
@@ -37,8 +37,8 @@
 #include "eina_magic.h"
 
 /*============================================================================*
- *                                  Local                                     *
- *============================================================================*/
+*                                  Local                                     *
+*============================================================================*/
 
 /**
  * @cond LOCAL
@@ -91,23 +91,28 @@ _eina_magic_strings_alloc(void)
 
    if (_eina_magic_strings_count == _eina_magic_strings_allocated)
      {
-       void *tmp;
-       size_t size;
-
-       if (EINA_UNLIKELY(_eina_magic_strings_allocated == 0))
-         size = 48;
-       else
-         size = _eina_magic_strings_allocated + 16;
-
-       tmp = realloc(_eina_magic_strings, sizeof(Eina_Magic_String) * size);
-       if (!tmp)
-         {
-            ERR("could not realloc magic_strings from %zu to %zu buckets.",
-                _eina_magic_strings_allocated, size);
-            return NULL;
-         }
-       _eina_magic_strings = tmp;
-       _eina_magic_strings_allocated = size;
+        void *tmp;
+        size_t size;
+
+        if (EINA_UNLIKELY(_eina_magic_strings_allocated == 0))
+           size = 48;
+        else
+           size = _eina_magic_strings_allocated + 16;
+
+        tmp = realloc(_eina_magic_strings, sizeof(Eina_Magic_String) * size);
+        if (!tmp)
+          {
+#ifdef _WIN32
+             ERR("could not realloc magic_strings from %Iu to %Iu buckets.",
+#else
+             ERR("could not realloc magic_strings from %zu to %zu buckets.",
+#endif
+                 _eina_magic_strings_allocated, size);
+             return NULL;
+          }
+
+        _eina_magic_strings = tmp;
+        _eina_magic_strings_allocated = size;
      }
 
    idx = _eina_magic_strings_count;
@@ -120,8 +125,8 @@ _eina_magic_strings_alloc(void)
  */
 
 /*============================================================================*
- *                                 Global                                     *
- *============================================================================*/
+*                                 Global                                     *
+*============================================================================*/
 
 /**
  * @internal
@@ -138,11 +143,11 @@ Eina_Bool
 eina_magic_string_init(void)
 {
    _eina_magic_string_log_dom = eina_log_domain_register
-     ("eina_magic_string", EINA_LOG_COLOR_DEFAULT);
+         ("eina_magic_string", EINA_LOG_COLOR_DEFAULT);
    if (_eina_magic_string_log_dom < 0)
      {
-       EINA_LOG_ERR("Could not register log domain: eina_magic_string");
-       return EINA_FALSE;
+        EINA_LOG_ERR("Could not register log domain: eina_magic_string");
+        return EINA_FALSE;
      }
 
    return EINA_TRUE;
@@ -168,10 +173,10 @@ eina_magic_string_shutdown(void)
    ems_end = ems + _eina_magic_strings_count;
 
    for (; ems < ems_end; ems++)
-     if (ems->string_allocated)
-       free((char *)ems->string);
+      if (ems->string_allocated)
+         free((char *)ems->string);
 
-   free(_eina_magic_strings);
+         free(_eina_magic_strings);
    _eina_magic_strings = NULL;
    _eina_magic_strings_count = 0;
    _eina_magic_strings_allocated = 0;
@@ -183,8 +188,8 @@ eina_magic_string_shutdown(void)
 }
 
 /*============================================================================*
- *                                   API                                      *
- *============================================================================*/
+*                                   API                                      *
+*============================================================================*/
 
 /**
  * @addtogroup Eina_Magic_Group Magic
@@ -250,6 +255,12 @@ eina_magic_string_shutdown(void)
  *    free(ptr->name);
  *    free(ptr);
  * }
+ * struct base *base_new(int id, const char *name) {
+ *    struct base *ptr = malloc(sizeof(struct base));
+ *    EINA_MAGIC_SET(ptr, BASE_MAGIC);
+ *    ptr->id = id;
+ *    ptr->name = strdup(name);
+ * }
  *
  * struct subtype {
  *    struct base base;
@@ -293,26 +304,27 @@ eina_magic_string_shutdown(void)
  *   - (undefined): magic was registered and found, but no string associated.
  *   - (unknown): magic was not found in the registry.
  */
-EAPI const char*
+EAPI const char *
 eina_magic_string_get(Eina_Magic magic)
 {
    Eina_Magic_String *ems;
 
    if (!_eina_magic_strings)
-     return "(none)";
+      return "(none)";
 
    if (_eina_magic_strings_dirty)
      {
-       qsort(_eina_magic_strings, _eina_magic_strings_count,
-             sizeof(Eina_Magic_String), _eina_magic_strings_sort_cmp);
-       _eina_magic_strings_dirty = 0;
+        qsort(_eina_magic_strings, _eina_magic_strings_count,
+              sizeof(Eina_Magic_String), _eina_magic_strings_sort_cmp);
+        _eina_magic_strings_dirty = 0;
      }
 
    ems = bsearch((void *)(long)magic, _eina_magic_strings,
-                _eina_magic_strings_count, sizeof(Eina_Magic_String),
-                _eina_magic_strings_find_cmp);
+                 _eina_magic_strings_count, sizeof(Eina_Magic_String),
+                 _eina_magic_strings_find_cmp);
    if (ems)
-     return ems->string ? ems->string : "(undefined)";
+      return ems->string ? ems->string : "(undefined)";
+
    return "(unknown)";
 }
 
@@ -340,17 +352,17 @@ eina_magic_string_set(Eina_Magic magic, const char *magic_name)
 
    ems = _eina_magic_strings_alloc();
    if (!ems)
-     return EINA_FALSE;
+      return EINA_FALSE;
 
    ems->magic = magic;
    ems->string_allocated = EINA_TRUE;
    ems->string = strdup(magic_name);
    if (!ems->string)
-     {
-       ERR("could not allocate string '%s'", magic_name);
-       _eina_magic_strings_count--;
-       return EINA_FALSE;
-     }
+   {
+      ERR("could not allocate string '%s'", magic_name);
+      _eina_magic_strings_count--;
+      return EINA_FALSE;
+   }
 
    _eina_magic_strings_dirty = 1;
    return EINA_TRUE;
@@ -381,7 +393,7 @@ eina_magic_string_static_set(Eina_Magic magic, const char *magic_name)
 
    ems = _eina_magic_strings_alloc();
    if (!ems)
-     return EINA_FALSE;
+      return EINA_FALSE;
 
    ems->magic = magic;
    ems->string_allocated = EINA_FALSE;
@@ -419,50 +431,55 @@ eina_magic_string_static_set(Eina_Magic magic, const char *magic_name)
  * with gdb.
  */
 EAPI void
-eina_magic_fail(void *d, Eina_Magic m, Eina_Magic req_m, const char *file, const char *fnc, int line)
+eina_magic_fail(void *d,
+                Eina_Magic m,
+                Eina_Magic req_m,
+                const char *file,
+                const char *fnc,
+                int line)
 {
    if (!d)
-     eina_log_print(EINA_LOG_DOMAIN_GLOBAL, EINA_LOG_LEVEL_CRITICAL,
-                   file, fnc, line,
-                   "*** Eina Magic Check Failed !!!\n"
-                   "    Input handle pointer is NULL !\n"
-                   "*** NAUGHTY PROGRAMMER!!!\n"
-                   "*** SPANK SPANK SPANK!!!\n"
-                   "*** Now go fix your code. Tut tut tut!\n"
-                   "\n");
+      eina_log_print(EINA_LOG_DOMAIN_GLOBAL, EINA_LOG_LEVEL_CRITICAL,
+                     file, fnc, line,
+                     "*** Eina Magic Check Failed !!!\n"
+                     "    Input handle pointer is NULL !\n"
+                     "*** NAUGHTY PROGRAMMER!!!\n"
+                     "*** SPANK SPANK SPANK!!!\n"
+                     "*** Now go fix your code. Tut tut tut!\n"
+                     "\n");
+   else
+   if (m == EINA_MAGIC_NONE)
+      eina_log_print(EINA_LOG_DOMAIN_GLOBAL, EINA_LOG_LEVEL_CRITICAL,
+                     file, fnc, line,
+                     "*** Eina Magic Check Failed !!!\n"
+                     "    Input handle has already been freed!\n"
+                     "*** NAUGHTY PROGRAMMER!!!\n"
+                     "*** SPANK SPANK SPANK!!!\n"
+                     "*** Now go fix your code. Tut tut tut!\n"
+                     "\n");
+   else
+   if (m != req_m)
+      eina_log_print(EINA_LOG_DOMAIN_GLOBAL, EINA_LOG_LEVEL_CRITICAL,
+                     file, fnc, line,
+                     "*** Eina Magic Check Failed !!!\n"
+                     "    Input handle is wrong type\n"
+                     "    Expected: %08x - %s\n"
+                     "    Supplied: %08x - %s\n"
+                     "*** NAUGHTY PROGRAMMER!!!\n"
+                     "*** SPANK SPANK SPANK!!!\n"
+                     "*** Now go fix your code. Tut tut tut!\n"
+                     "\n",
+                     req_m, eina_magic_string_get(req_m),
+                     m, eina_magic_string_get(m));
    else
-     if (m == EINA_MAGIC_NONE)
-       eina_log_print(EINA_LOG_DOMAIN_GLOBAL, EINA_LOG_LEVEL_CRITICAL,
-                     file, fnc, line,
-                     "*** Eina Magic Check Failed !!!\n"
-                     "    Input handle has already been freed!\n"
-                     "*** NAUGHTY PROGRAMMER!!!\n"
-                     "*** SPANK SPANK SPANK!!!\n"
-                     "*** Now go fix your code. Tut tut tut!\n"
-                     "\n");
-     else
-       if (m != req_m)
-       eina_log_print(EINA_LOG_DOMAIN_GLOBAL, EINA_LOG_LEVEL_CRITICAL,
-                     file, fnc, line,
-                     "*** Eina Magic Check Failed !!!\n"
-                     "    Input handle is wrong type\n"
-                     "    Expected: %08x - %s\n"
-                     "    Supplied: %08x - %s\n"
-                     "*** NAUGHTY PROGRAMMER!!!\n"
-                     "*** SPANK SPANK SPANK!!!\n"
-                     "*** Now go fix your code. Tut tut tut!\n"
-                     "\n",
-                     req_m, eina_magic_string_get(req_m),
-                     m, eina_magic_string_get(m));
-       else
-       eina_log_print(EINA_LOG_DOMAIN_GLOBAL, EINA_LOG_LEVEL_CRITICAL,
-                     file, fnc, line,
-                     "*** Eina Magic Check Failed !!!\n"
-                     "    Why did you call me !\n"
-                     "*** NAUGHTY PROGRAMMER!!!\n"
-                     "*** SPANK SPANK SPANK!!!\n"
-                     "*** Now go fix your code. Tut tut tut!\n"
-                     "\n");
+      eina_log_print(EINA_LOG_DOMAIN_GLOBAL, EINA_LOG_LEVEL_CRITICAL,
+                     file, fnc, line,
+                     "*** Eina Magic Check Failed !!!\n"
+                     "    Why did you call me !\n"
+                     "*** NAUGHTY PROGRAMMER!!!\n"
+                     "*** SPANK SPANK SPANK!!!\n"
+                     "*** Now go fix your code. Tut tut tut!\n"
+                     "\n");
 }
 
 /**
index 7ff8eda..bc18f23 100644 (file)
  * if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <stdio.h>
-
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
 
-#ifdef EFL_HAVE_PTHREAD
+#include <stdio.h>
+
+#ifdef EFL_HAVE_POSIX_THREADS
 # include <pthread.h>
 #endif
 
+#ifdef EFL_HAVE_WIN32_THREADS
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+# undef WIN32_LEAN_AND_MEAN
+#endif
+
 #include "eina_config.h"
 #include "eina_private.h"
 #include "eina_types.h"
@@ -33,7 +39,9 @@
 #include "eina_error.h"
 #include "eina_log.h"
 #include "eina_hash.h"
+#include "eina_binshare.h"
 #include "eina_stringshare.h"
+#include "eina_ustringshare.h"
 #include "eina_list.h"
 #include "eina_matrixsparse.h"
 #include "eina_array.h"
 #include "eina_rectangle.h"
 #include "eina_safety_checks.h"
 
-static Eina_Version _version = { VMAJ, VMIN, VMIC, VREV };
-EAPI Eina_Version *eina_version = &_version;
-
 /*============================================================================*
- *                                  Local                                     *
- *============================================================================*/
+*                                  Local                                     *
+*============================================================================*/
 
 /**
  * @cond LOCAL
  */
 
+static Eina_Version _version = { VMAJ, VMIN, VMIC, VREV };
+
 static int _eina_main_count = 0;
-#ifdef EFL_HAVE_PTHREAD
+#ifdef EFL_HAVE_THREADS
 static int _eina_main_thread_count = 0;
 #endif
 static int _eina_log_dom = -1;
@@ -70,40 +77,51 @@ static int _eina_log_dom = -1;
 #endif
 #define DBG(...) EINA_LOG_DOM_DBG(_eina_log_dom, __VA_ARGS__)
 
-#ifdef EFL_HAVE_PTHREAD
+#ifdef EFL_HAVE_THREADS
 static Eina_Bool _threads_activated = EINA_FALSE;
+# ifdef EFL_HAVE_POSIX_THREADS
 static pthread_mutex_t _mutex = PTHREAD_MUTEX_INITIALIZER;
-#define LOCK() if(_threads_activated) pthread_mutex_lock(&_mutex)
-#define UNLOCK() if(_threads_activated) pthread_mutex_unlock(&_mutex)
-#define UNLOCK_FORCE() pthread_mutex_unlock(&_mutex)
+#  define LOCK() if(_threads_activated) pthread_mutex_lock(&_mutex)
+#  define UNLOCK() if(_threads_activated) pthread_mutex_unlock(&_mutex)
+#  define UNLOCK_FORCE() pthread_mutex_unlock(&_mutex)
+# else /* EFL_HAVE_WIN32_THREADS */
+static HANDLE _mutex = NULL;
+#  define LOCK() if(_threads_activated) WaitForSingleObject(_mutex, INFINITE)
+#  define UNLOCK() if(_threads_activated) ReleaseMutex(_mutex)
+#  define UNLOCK_FORCE() ReleaseMutex(_mutex)
+# endif
 #else
-#define LOCK() do {} while (0)
-#define UNLOCK() do {} while (0)
-#define UNLOCK_FORCE() do {} while (0)
+# define LOCK() do {} while (0)
+# define UNLOCK() do {} while (0)
+# define UNLOCK_FORCE() do {} while (0)
 #endif
 
 /* place module init/shutdown functions here to avoid other modules
  * calling them by mistake.
  */
-#define S(x) extern Eina_Bool eina_##x##_init(void); extern Eina_Bool eina_##x##_shutdown(void)
-S(log);
-S(error);
-S(safety_checks);
-S(magic_string);
-S(iterator);
-S(accessor);
-S(array);
-S(module);
-S(mempool);
-S(list);
-S(stringshare);
-S(matrixsparse);
-S(convert);
-S(counter);
-S(benchmark);
-S(rectangle);
-S(strbuf);
-S(quadtree);
+#define S(x) extern Eina_Bool eina_ ## x ## _init(void); \
+   extern Eina_Bool eina_ ## x ## _shutdown(void)
+   S(log);
+   S(error);
+   S(safety_checks);
+   S(magic_string);
+   S(iterator);
+   S(accessor);
+   S(array);
+   S(module);
+   S(mempool);
+   S(list);
+   S(binshare);
+   S(stringshare);
+   S(ustringshare);
+   S(matrixsparse);
+   S(convert);
+   S(counter);
+   S(benchmark);
+   S(rectangle);
+   S(strbuf);
+   S(ustrbuf);
+   S(quadtree);
 #undef S
 
 struct eina_desc_setup
@@ -114,36 +132,40 @@ struct eina_desc_setup
 };
 
 static const struct eina_desc_setup _eina_desc_setup[] = {
-#define S(x) {#x, eina_##x##_init, eina_##x##_shutdown}
-  /* log is a special case as it needs printf */
-  S(error),
-  S(safety_checks),
-  S(magic_string),
-  S(iterator),
-  S(accessor),
-  S(array),
-  S(module),
-  S(mempool),
-  S(list),
-  S(stringshare),
-  S(matrixsparse),
-  S(convert),
-  S(counter),
-  S(benchmark),
-  S(rectangle),
-  S(strbuf),
-  S(quadtree)
+#define S(x) {# x, eina_ ## x ## _init, eina_ ## x ## _shutdown}
+   /* log is a special case as it needs printf */
+   S(error),
+   S(safety_checks),
+   S(magic_string),
+   S(iterator),
+   S(accessor),
+   S(array),
+   S(module),
+   S(mempool),
+   S(list),
+   S(binshare),
+   S(stringshare),
+   S(ustringshare),
+   S(matrixsparse),
+   S(convert),
+   S(counter),
+   S(benchmark),
+   S(rectangle),
+   S(strbuf),
+   S(ustrbuf),
+   S(quadtree)
 #undef S
 };
-static const size_t _eina_desc_setup_len = sizeof(_eina_desc_setup) / sizeof(_eina_desc_setup[0]);
+static const size_t _eina_desc_setup_len = sizeof(_eina_desc_setup) /
+   sizeof(_eina_desc_setup[0]);
 
 static void
 _eina_shutdown_from_desc(const struct eina_desc_setup *itr)
 {
    for (itr--; itr >= _eina_desc_setup; itr--)
      {
-       if (!itr->shutdown())
-         ERR("Problems shutting down eina module '%s', ignored.", itr->name);
+        if (!itr->shutdown())
+           ERR("Problems shutting down eina module '%s', ignored.", itr->name);
      }
 
    eina_log_domain_unregister(_eina_log_dom);
@@ -156,12 +178,13 @@ _eina_shutdown_from_desc(const struct eina_desc_setup *itr)
  */
 
 /*============================================================================*
- *                                 Global                                     *
- *============================================================================*/
+*                                 Global                                     *
+*============================================================================*/
+
 
 /*============================================================================*
- *                                   API                                      *
- *============================================================================*/
+*                                   API                                      *
+*============================================================================*/
 
 /**
  * @addtogroup Eina_Main_Group Main
@@ -173,6 +196,12 @@ _eina_shutdown_from_desc(const struct eina_desc_setup *itr)
  */
 
 /**
+ * @var eina_version
+ * @brief Eina version (defined at configuration time)
+ */
+EAPI Eina_Version *eina_version = &_version;
+
+/**
  * @brief Initialize the Eina library.
  *
  * @return 1 or greater on success, 0 on error.
@@ -191,31 +220,32 @@ eina_init(void)
    const struct eina_desc_setup *itr, *itr_end;
 
    if (EINA_LIKELY(_eina_main_count > 0))
-     return ++_eina_main_count;
+      return ++_eina_main_count;
 
    if (!eina_log_init())
      {
-       fprintf(stderr, "Could not initialize eina logging system.\n");
-       return 0;
+        fprintf(stderr, "Could not initialize eina logging system.\n");
+        return 0;
      }
+
    _eina_log_dom = eina_log_domain_register("eina", EINA_LOG_COLOR_DEFAULT);
    if (_eina_log_dom < 0)
      {
-       EINA_LOG_ERR("Could not register log domain: eina");
-       eina_log_shutdown();
-       return 0;
+        EINA_LOG_ERR("Could not register log domain: eina");
+        eina_log_shutdown();
+        return 0;
      }
 
    itr = _eina_desc_setup;
    itr_end = itr + _eina_desc_setup_len;
    for (; itr < itr_end; itr++)
      {
-       if (!itr->init())
-         {
-            ERR("Could not initialize eina module '%s'.", itr->name);
-            _eina_shutdown_from_desc(itr);
-            return 0;
-         }
+        if (!itr->init())
+          {
+             ERR("Could not initialize eina module '%s'.", itr->name);
+             _eina_shutdown_from_desc(itr);
+             return 0;
+          }
      }
 
    _eina_main_count = 1;
@@ -241,7 +271,8 @@ eina_shutdown(void)
 {
    _eina_main_count--;
    if (EINA_UNLIKELY(_eina_main_count == 0))
-     _eina_shutdown_from_desc(_eina_desc_setup + _eina_desc_setup_len);
+             _eina_shutdown_from_desc(_eina_desc_setup + _eina_desc_setup_len);
+
    return _eina_main_count;
 }
 
@@ -262,26 +293,35 @@ eina_shutdown(void)
 EAPI int
 eina_threads_init(void)
 {
-#ifdef EFL_HAVE_PTHREAD
-    int ret;
-    
-    LOCK();
-    ++_eina_main_thread_count;
-    ret = _eina_main_thread_count;
-
-    if(_eina_main_thread_count > 1) 
-    {
+#ifdef EFL_HAVE_THREADS
+   int ret;
+
+# ifdef EFL_HAVE_WIN32_THREADS
+   if (!_mutex)
+      _mutex = CreateMutex(NULL, FALSE, NULL);
+
+   if (!_mutex)
+      return 0;
+
+# endif
+
+   LOCK();
+   ++_eina_main_thread_count;
+   ret = _eina_main_thread_count;
+
+   if(_eina_main_thread_count > 1)
+     {
         UNLOCK();
         return ret;
-    }
+     }
 
-    eina_stringshare_threads_init();
-    eina_log_threads_init();
-    _threads_activated = EINA_TRUE;
+   eina_share_common_threads_init();
+   eina_log_threads_init();
+   _threads_activated = EINA_TRUE;
 
-    return ret;
+   return ret;
 #else
-    return 0;
+   return 0;
 #endif
 }
 
@@ -302,27 +342,33 @@ eina_threads_init(void)
 EAPI int
 eina_threads_shutdown(void)
 {
-#ifdef EFL_HAVE_PTHREAD
-    int ret;
+#ifdef EFL_HAVE_THREADS
+   int ret;
 
-    LOCK();
-    ret = --_eina_main_thread_count;
-    if(_eina_main_thread_count > 0) 
-    {
+   LOCK();
+   ret = --_eina_main_thread_count;
+   if(_eina_main_thread_count > 0)
+     {
         UNLOCK();
-        return ret; 
-    }
+        return ret;
+     }
+
+   eina_share_common_threads_shutdown();
+   eina_log_threads_shutdown();
+
+   _threads_activated = EINA_FALSE;
 
-    eina_stringshare_threads_shutdown();
-    eina_log_threads_shutdown();
+   UNLOCK_FORCE();
 
-    _threads_activated = EINA_FALSE;
+# ifdef EFL_HAVE_WIN32_THREADS
+   if (_mutex)
+      CloseHandle(_mutex);
 
-    UNLOCK_FORCE();
+# endif
 
-    return ret;
+   return ret;
 #else
-    return 0;
+   return 0;
 #endif
 }
 
index 6e74d5b..4857a53 100644 (file)
@@ -49,8 +49,8 @@
 
 
 /*============================================================================*
- *                                  Local                                     *
- *============================================================================*/
+*                                  Local                                     *
+*============================================================================*/
 
 /**
  * @cond LOCAL
 static const char EINA_MAGIC_MATRIXSPARSE_STR[] = "Eina Matrixsparse";
 static const char EINA_MAGIC_MATRIXSPARSE_ROW_STR[] = "Eina Matrixsparse Row";
 static const char EINA_MAGIC_MATRIXSPARSE_CELL_STR[] = "Eina Matrixsparse Cell";
-static const char EINA_MAGIC_MATRIXSPARSE_ITERATOR_STR[] = "Eina Matrixsparse Iterator";
-static const char EINA_MAGIC_MATRIXSPARSE_ROW_ACCESSOR_STR[] = "Eina Matrixsparse Row Accessor";
-static const char EINA_MAGIC_MATRIXSPARSE_ROW_ITERATOR_STR[] = "Eina Matrixsparse Row Iterator";
-static const char EINA_MAGIC_MATRIXSPARSE_CELL_ACCESSOR_STR[] = "Eina Matrixsparse Cell Accessor";
-static const char EINA_MAGIC_MATRIXSPARSE_CELL_ITERATOR_STR[] = "Eina Matrixsparse Cell Iterator";
-
-
-#define EINA_MAGIC_CHECK_MATRIXSPARSE(d, ...)          \
-  do {                                                 \
-     if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_MATRIXSPARSE))        \
-       {                                               \
-         EINA_MAGIC_FAIL(d, EINA_MAGIC_MATRIXSPARSE);  \
-         return __VA_ARGS__;                           \
-       }                                               \
-  } while(0)
-
-#define EINA_MAGIC_CHECK_MATRIXSPARSE_ROW(d, ...)              \
-  do {                                                         \
-     if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_MATRIXSPARSE_ROW))    \
-       {                                                       \
-         EINA_MAGIC_FAIL(d, EINA_MAGIC_MATRIXSPARSE_ROW);      \
-         return __VA_ARGS__;                                   \
-       }                                                       \
-  } while(0)
-
-#define EINA_MAGIC_CHECK_MATRIXSPARSE_CELL(d, ...)             \
-  do {                                                         \
-     if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_MATRIXSPARSE_CELL))   \
-       {                                                       \
-         EINA_MAGIC_FAIL(d, EINA_MAGIC_MATRIXSPARSE_CELL);     \
-         return __VA_ARGS__;                                   \
-       }                                                       \
-  } while(0)
-
-#define EINA_MAGIC_CHECK_MATRIXSPARSE_ITERATOR(d, ...)                 \
-  do {                                                                 \
-     if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_MATRIXSPARSE_ITERATOR))       \
-       {                                                               \
-         EINA_MAGIC_FAIL(d, EINA_MAGIC_MATRIXSPARSE_ITERATOR);         \
-         return __VA_ARGS__;                                           \
-       }                                                               \
-  } while(0)
+static const char EINA_MAGIC_MATRIXSPARSE_ITERATOR_STR[] =
+   "Eina Matrixsparse Iterator";
+static const char EINA_MAGIC_MATRIXSPARSE_ROW_ACCESSOR_STR[] =
+   "Eina Matrixsparse Row Accessor";
+static const char EINA_MAGIC_MATRIXSPARSE_ROW_ITERATOR_STR[] =
+   "Eina Matrixsparse Row Iterator";
+static const char EINA_MAGIC_MATRIXSPARSE_CELL_ACCESSOR_STR[] =
+   "Eina Matrixsparse Cell Accessor";
+static const char EINA_MAGIC_MATRIXSPARSE_CELL_ITERATOR_STR[] =
+   "Eina Matrixsparse Cell Iterator";
+
+
+#define EINA_MAGIC_CHECK_MATRIXSPARSE(d, ...)           \
+   do {                                                  \
+        if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_MATRIXSPARSE)) \
+          {                                                \
+             EINA_MAGIC_FAIL(d, EINA_MAGIC_MATRIXSPARSE);  \
+             return __VA_ARGS__;                           \
+          }                                                \
+     } while(0)
+
+#define EINA_MAGIC_CHECK_MATRIXSPARSE_ROW(d, ...)               \
+   do {                                                          \
+        if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_MATRIXSPARSE_ROW))     \
+          {                                                        \
+             EINA_MAGIC_FAIL(d, EINA_MAGIC_MATRIXSPARSE_ROW);      \
+             return __VA_ARGS__;                                   \
+          }                                                        \
+     } while(0)
+
+#define EINA_MAGIC_CHECK_MATRIXSPARSE_CELL(d, ...)              \
+   do {                                                          \
+        if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_MATRIXSPARSE_CELL))    \
+          {                                                        \
+             EINA_MAGIC_FAIL(d, EINA_MAGIC_MATRIXSPARSE_CELL);     \
+             return __VA_ARGS__;                                   \
+          }                                                        \
+     } while(0)
+
+#define EINA_MAGIC_CHECK_MATRIXSPARSE_ITERATOR(d, ...)                  \
+   do {                                                                  \
+        if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_MATRIXSPARSE_ITERATOR))        \
+          {                                                                \
+             EINA_MAGIC_FAIL(d, EINA_MAGIC_MATRIXSPARSE_ITERATOR);         \
+             return __VA_ARGS__;                                           \
+          }                                                                \
+     } while(0)
 
 struct _Eina_Matrixsparse_Cell
 {
@@ -152,14 +157,16 @@ struct _Eina_Matrixsparse
 };
 
 typedef struct _Eina_Matrixsparse_Iterator Eina_Matrixsparse_Iterator;
-typedef struct _Eina_Matrixsparse_Iterator_Complete Eina_Matrixsparse_Iterator_Complete;
+typedef struct _Eina_Matrixsparse_Iterator_Complete
+Eina_Matrixsparse_Iterator_Complete;
 
 struct _Eina_Matrixsparse_Iterator
 {
    Eina_Iterator iterator;
 
    const Eina_Matrixsparse *m;
-   struct {
+   struct
+   {
       const Eina_Matrixsparse_Row *row;
       const Eina_Matrixsparse_Cell *col;
    } ref;
@@ -172,16 +179,19 @@ struct _Eina_Matrixsparse_Iterator_Complete
    Eina_Iterator iterator;
 
    const Eina_Matrixsparse *m;
-   struct {
+   struct
+   {
       const Eina_Matrixsparse_Row *row;
       const Eina_Matrixsparse_Cell *col;
    } ref;
 
-   struct {
+   struct
+   {
       unsigned long row, col;
    } idx;
 
-   struct {
+   struct
+   {
       Eina_Matrixsparse_Row row;
       Eina_Matrixsparse_Cell col;
    } dummy;
@@ -212,10 +222,12 @@ static Eina_Mempool *_eina_matrixsparse_cell_mp = NULL;
 static Eina_Mempool *_eina_matrixsparse_row_mp = NULL;
 
 static inline void
-_eina_matrixsparse_cell_free(Eina_Matrixsparse_Cell *c, void (*free_func)(void *, void *), void *user_data)
+_eina_matrixsparse_cell_free(Eina_Matrixsparse_Cell *c, void (*free_func)(
+                                void *,
+                                void *), void *user_data)
 {
    if (free_func)
-     free_func(user_data, c->data);
+      free_func(user_data, c->data);
 
    EINA_MAGIC_SET(c, EINA_MAGIC_NONE);
    eina_mempool_free(_eina_matrixsparse_cell_mp, c);
@@ -228,43 +240,47 @@ _eina_matrixsparse_cell_unlink(Eina_Matrixsparse_Cell *c)
 
    if (r->last_used == c)
      {
-       if (c->next)
-         r->last_used = c->next;
-       else
-         r->last_used = c->prev;
+        if (c->next)
+           r->last_used = c->next;
+        else
+           r->last_used = c->prev;
      }
 
    if (r->last_col == c)
-     r->last_col = c->prev;
+      r->last_col = c->prev;
 
    if (r->cols == c)
-     r->cols = c->next;
+      r->cols = c->next;
 
    if (c->next && c->prev)
      {
-       c->next->prev = c->prev;
-       c->prev->next = c->next;
+        c->next->prev = c->prev;
+        c->prev->next = c->next;
      }
    else if (c->next)
-     c->next->prev = NULL;
+      c->next->prev = NULL;
    else if (c->prev)
-     c->prev->next = NULL;
+      c->prev->next = NULL;
 }
 
 static inline void
-_eina_matrixsparse_row_cells_free(Eina_Matrixsparse_Row *r, void (*free_func)(void *, void *), void *user_data)
+_eina_matrixsparse_row_cells_free(Eina_Matrixsparse_Row *r, void (*free_func)(
+                                     void *,
+                                     void *), void *user_data)
 {
    Eina_Matrixsparse_Cell *c = r->cols;
    while (c)
      {
-       Eina_Matrixsparse_Cell *c_aux = c;
-       c = c->next;
-       _eina_matrixsparse_cell_free(c_aux, free_func, user_data);
+        Eina_Matrixsparse_Cell *c_aux = c;
+        c = c->next;
+        _eina_matrixsparse_cell_free(c_aux, free_func, user_data);
      }
 }
 
 static inline void
-_eina_matrixsparse_row_free(Eina_Matrixsparse_Row *r, void (*free_func)(void *, void *), void *user_data)
+_eina_matrixsparse_row_free(Eina_Matrixsparse_Row *r, void (*free_func)(void *,
+                                                                        void *),
+                            void *user_data)
 {
    _eina_matrixsparse_row_cells_free(r, free_func, user_data);
    EINA_MAGIC_SET(r, EINA_MAGIC_NONE);
@@ -278,31 +294,34 @@ _eina_matrixsparse_row_unlink(Eina_Matrixsparse_Row *r)
 
    if (m->last_used == r)
      {
-       if (r->next)
-         m->last_used = r->next;
-       else
-         m->last_used = r->prev;
+        if (r->next)
+           m->last_used = r->next;
+        else
+           m->last_used = r->prev;
      }
 
    if (m->last_row == r)
-     m->last_row = r->prev;
+      m->last_row = r->prev;
 
    if (m->rows == r)
-     m->rows = r->next;
+      m->rows = r->next;
 
    if (r->next && r->prev)
      {
-       r->next->prev = r->prev;
-       r->prev->next = r->next;
+        r->next->prev = r->prev;
+        r->prev->next = r->next;
      }
    else if (r->next)
-     r->next->prev = NULL;
+      r->next->prev = NULL;
    else if (r->prev)
-     r->prev->next = NULL;
+      r->prev->next = NULL;
 }
 
 static inline void
-_eina_matrixsparse_row_find_parms_get(const Eina_Matrixsparse *m, unsigned long row, Eina_Matrixsparse_Row **p_r, int *p_dir)
+_eina_matrixsparse_row_find_parms_get(const Eina_Matrixsparse *m,
+                                      unsigned long row,
+                                      Eina_Matrixsparse_Row **p_r,
+                                      int *p_dir)
 {
    Eina_Matrixsparse_Row *r;
    unsigned long dist;
@@ -313,31 +332,28 @@ _eina_matrixsparse_row_find_parms_get(const Eina_Matrixsparse *m, unsigned long
    dir = 1;
    if (dist > m->last_row->row - row)
      {
-       dist = m->last_row->row - row;
-       r = m->last_row;
-       dir = -1;
+        dist = m->last_row->row - row;
+        r = m->last_row;
+        dir = -1;
      }
 
    if (m->last_used)
      {
-       if (m->last_used->row < row)
-         {
-            if (dist > row - m->last_used->row)
-              {
-/*               dist = row = m->last_used->row; */
-                 r = m->last_used;
-                 dir = 1;
-              }
-         }
-       else
-         {
-            if (dist > m->last_used->row - row)
-              {
-/*               dist = m->last_used->row - row; */
-                 r = m->last_used;
-                 dir = -1;
-              }
-         }
+        if (m->last_used->row < row)
+          {
+             if (dist > row - m->last_used->row)
+               {
+/*      dist = row = m->last_used->row; */
+                  r = m->last_used;
+                  dir = 1;
+               }
+          }
+        else if (dist > m->last_used->row - row)
+          {
+/*      dist = m->last_used->row - row; */
+             r = m->last_used;
+             dir = -1;
+          }
      }
 
    *p_r = r;
@@ -345,7 +361,10 @@ _eina_matrixsparse_row_find_parms_get(const Eina_Matrixsparse *m, unsigned long
 }
 
 static inline void
-_eina_matrixsparse_row_cell_find_parms_get(const Eina_Matrixsparse_Row *r, unsigned long col, Eina_Matrixsparse_Cell **p_c, int *p_dir)
+_eina_matrixsparse_row_cell_find_parms_get(const Eina_Matrixsparse_Row *r,
+                                           unsigned long col,
+                                           Eina_Matrixsparse_Cell **p_c,
+                                           int *p_dir)
 {
    Eina_Matrixsparse_Cell *c;
    unsigned long dist;
@@ -356,31 +375,28 @@ _eina_matrixsparse_row_cell_find_parms_get(const Eina_Matrixsparse_Row *r, unsig
    dir = 1;
    if (dist > r->last_col->col - col)
      {
-       dist = r->last_col->col - col;
-       c = r->last_col;
-       dir = -1;
+        dist = r->last_col->col - col;
+        c = r->last_col;
+        dir = -1;
      }
 
    if (r->last_used)
      {
-       if (r->last_used->col < col)
-         {
-            if (dist > col - r->last_used->col)
-              {
-/*               dist = col = r->last_used->col; */
-                 c = r->last_used;
-                 dir = 1;
-              }
-         }
-       else
-         {
-            if (dist > r->last_used->col - col)
-              {
-/*               dist = r->last_used->col - col; */
-                 c = r->last_used;
-                 dir = -1;
-              }
-         }
+        if (r->last_used->col < col)
+          {
+             if (dist > col - r->last_used->col)
+               {
+/*      dist = col = r->last_used->col; */
+                  c = r->last_used;
+                  dir = 1;
+               }
+          }
+        else if (dist > r->last_used->col - col)
+          {
+/*      dist = r->last_used->col - col; */
+             c = r->last_used;
+             dir = -1;
+          }
      }
 
    *p_c = c;
@@ -393,150 +409,174 @@ _eina_matrixsparse_row_idx_get(const Eina_Matrixsparse *m, unsigned long row)
    Eina_Matrixsparse_Row *r;
    int dir;
 
-   if (!m->rows) return NULL;
+   if (!m->rows)
+      return NULL;
 
-   if      (m->rows->row == row) return m->rows;
-   else if (m->rows->row > row) return NULL;
+   if      (m->rows->row == row)
+      return m->rows;
+   else if (m->rows->row > row)
+      return NULL;
 
-   if      (m->last_row->row == row) return m->last_row;
-   else if (m->last_row->row < row) return NULL;
+   if      (m->last_row->row == row)
+      return m->last_row;
+   else if (m->last_row->row < row)
+      return NULL;
 
-   if ((m->last_used) && (m->last_used->row == row)) return m->last_used;
+   if ((m->last_used) && (m->last_used->row == row))
+      return m->last_used;
 
    _eina_matrixsparse_row_find_parms_get(m, row, &r, &dir);
    assert(dir != 0);
    if (dir > 0)
      {
-       for (; r != NULL; r = r->next)
-         if (r->row == row)
-           {
-              ((Eina_Matrixsparse *)m)->last_used = r;
-              return r;
-           }
-         else if (r->row > row)
-           return NULL;
+        for (; r != NULL; r = r->next)
+           if (r->row == row)
+             {
+                ((Eina_Matrixsparse *)m)->last_used = r;
+                return r;
+             }
+           else if (r->row > row)
+              return NULL;
+
      }
    else if (dir < 0)
-     {
-       for (; r != NULL; r = r->prev)
-         if (r->row == row)
-           {
-              ((Eina_Matrixsparse *)m)->last_used = r;
-              return r;
-           }
-         else if (r->row < row)
-           return NULL;
-     }
+      for (; r != NULL; r = r->prev)
+         if (r->row == row)
+           {
+              ((Eina_Matrixsparse *)m)->last_used = r;
+              return r;
+           }
+         else if (r->row < row)
+            return NULL;
 
    return NULL;
 }
 
 static inline Eina_Matrixsparse_Cell *
-_eina_matrixsparse_row_cell_idx_get(const Eina_Matrixsparse_Row *r, unsigned long col)
+_eina_matrixsparse_row_cell_idx_get(const Eina_Matrixsparse_Row *r,
+                                    unsigned long col)
 {
    Eina_Matrixsparse_Cell *c;
    int dir;
 
-   if (!r->cols) return NULL;
-
-   if      (r->cols->col == col) return r->cols;
-   else if (r->cols->col > col) return NULL;
+   if (!r->cols)
+      return NULL;
 
-   if      (r->last_col->col == col) return r->last_col;
-   else if (r->last_col->col < col) return NULL;
+   if      (r->cols->col == col)
+      return r->cols;
+   else if (r->cols->col > col)
+      return NULL;
 
-   if ((r->last_used) && (r->last_used->col == col)) return r->last_used;
+   if      (r->last_col->col == col)
+      return r->last_col;
+   else if (r->last_col->col < col)
+      return NULL;
 
+   if ((r->last_used) && (r->last_used->col == col))
+      return r->last_used;
 
    _eina_matrixsparse_row_cell_find_parms_get(r, col, &c, &dir);
    assert(dir != 0);
    if (dir > 0)
      {
-       for (; r != NULL; c = c->next)
-         if (c->col == col)
-           {
-              ((Eina_Matrixsparse_Row *)r)->last_used = c;
-              return c;
-           }
-         else if (c->col > col)
-           return NULL;
+        for (; r != NULL; c = c->next)
+           if (c->col == col)
+             {
+                ((Eina_Matrixsparse_Row *)r)->last_used = c;
+                return c;
+             }
+           else if (c->col > col)
+              return NULL;
+
      }
    else if (dir < 0)
-     {
-       for (; r != NULL; c = c->prev)
-         if (c->col == col)
-           {
-              ((Eina_Matrixsparse_Row *)r)->last_used = c;
-              return c;
-           }
-         else if (c->col < col)
-           return NULL;
-     }
+      for (; r != NULL; c = c->prev)
+         if (c->col == col)
+           {
+              ((Eina_Matrixsparse_Row *)r)->last_used = c;
+              return c;
+           }
+         else if (c->col < col)
+            return NULL;
 
    return NULL;
 }
 
 static inline Eina_Matrixsparse_Cell *
-_eina_matrixsparse_cell_idx_get(const Eina_Matrixsparse *m, unsigned long row, unsigned long col)
+_eina_matrixsparse_cell_idx_get(const Eina_Matrixsparse *m,
+                                unsigned long row,
+                                unsigned long col)
 {
    Eina_Matrixsparse_Row *r = _eina_matrixsparse_row_idx_get(m, row);
-   if (!r) return NULL;
+   if (!r)
+      return NULL;
+
    return _eina_matrixsparse_row_cell_idx_get(r, col);
 }
 
 static inline void
-_eina_matrixsparse_row_idx_siblings_find(const Eina_Matrixsparse *m, unsigned long row, Eina_Matrixsparse_Row **p_prev, Eina_Matrixsparse_Row **p_next)
+_eina_matrixsparse_row_idx_siblings_find(const Eina_Matrixsparse *m,
+                                         unsigned long row,
+                                         Eina_Matrixsparse_Row **p_prev,
+                                         Eina_Matrixsparse_Row **p_next)
 {
    Eina_Matrixsparse_Row *r;
    int dir;
 
    _eina_matrixsparse_row_find_parms_get(m, row, &r, &dir);
-   assert(dir != 0);
+        assert(dir != 0);
    if (dir > 0)
      {
-       for (; r != NULL; r = r->next)
-         if (r->row > row)
-           break;
-       assert(r != NULL);
-       *p_prev = r->prev;
-       *p_next = r;
+        for (; r != NULL; r = r->next)
+           if (r->row > row)
+              break;
+
+        assert(r != NULL);
+        *p_prev = r->prev;
+        *p_next = r;
      }
    else if (dir < 0)
      {
-       for (; r != NULL; r = r->prev)
-         if (r->row < row)
-           break;
-       assert(r != NULL);
-       *p_prev = r;
-       *p_next = r->next;
+        for (; r != NULL; r = r->prev)
+           if (r->row < row)
+              break;
+
+        assert(r != NULL);
+        *p_prev = r;
+        *p_next = r->next;
      }
 }
 
 static inline void
-_eina_matrixsparse_row_cell_idx_siblings_find(const Eina_Matrixsparse_Row *r, unsigned long col, Eina_Matrixsparse_Cell **p_prev, Eina_Matrixsparse_Cell **p_next)
+_eina_matrixsparse_row_cell_idx_siblings_find(const Eina_Matrixsparse_Row *r,
+                                              unsigned long col,
+                                              Eina_Matrixsparse_Cell **p_prev,
+                                              Eina_Matrixsparse_Cell **p_next)
 {
    Eina_Matrixsparse_Cell *c;
    int dir;
 
    _eina_matrixsparse_row_cell_find_parms_get(r, col, &c, &dir);
-   assert(dir != 0);
+        assert(dir != 0);
    if (dir > 0)
      {
-       for (; c != NULL; c = c->next)
-         if (c->col > col)
-           break;
-       assert(c != NULL);
-       *p_prev = c->prev;
-       *p_next = c;
+        for (; c != NULL; c = c->next)
+           if (c->col > col)
+              break;
+
+        assert(c != NULL);
+        *p_prev = c->prev;
+        *p_next = c;
      }
    else if (dir < 0)
      {
-       for (; c != NULL; c = c->prev)
-         if (c->col < col)
-           break;
-       assert(c != NULL);
-       *p_prev = c;
-       *p_next = c->next;
+        for (; c != NULL; c = c->prev)
+           if (c->col < col)
+              break;
+
+        assert(c != NULL);
+        *p_prev = c;
+        *p_next = c->next;
      }
 }
 
@@ -544,40 +584,41 @@ static inline Eina_Matrixsparse_Row *
 _eina_matrixsparse_row_idx_add(Eina_Matrixsparse *m, unsigned long row)
 {
    Eina_Matrixsparse_Row *r = eina_mempool_malloc
-     (_eina_matrixsparse_row_mp, sizeof(Eina_Matrixsparse_Row));
-   if (!r) return NULL;
+         (_eina_matrixsparse_row_mp, sizeof(Eina_Matrixsparse_Row));
+   if (!r)
+      return NULL;
 
    if (!m->rows)
      {
-       r->prev = NULL;
-       r->next = NULL;
-       m->rows = r;
-       m->last_row = r;
+        r->prev = NULL;
+        r->next = NULL;
+        m->rows = r;
+        m->last_row = r;
      }
    else if (row < m->rows->row)
      {
-       r->prev = NULL;
-       r->next = m->rows;
-       m->rows->prev = r;
-       m->rows = r;
+        r->prev = NULL;
+        r->next = m->rows;
+        m->rows->prev = r;
+        m->rows = r;
      }
    else if (row > m->last_row->row)
      {
-       r->prev = m->last_row;
-       m->last_row->next = r;
-       r->next = NULL;
-       m->last_row = r;
+        r->prev = m->last_row;
+        m->last_row->next = r;
+        r->next = NULL;
+        m->last_row = r;
      }
    else
      {
-       Eina_Matrixsparse_Row *prev = NULL, *next = NULL;
-       _eina_matrixsparse_row_idx_siblings_find(m, row, &prev, &next);
-       assert(prev != NULL);
-       assert(next != NULL);
-       r->prev = prev;
-       r->next = next;
-       prev->next = r;
-       next->prev = r;
+        Eina_Matrixsparse_Row *prev = NULL, *next = NULL;
+        _eina_matrixsparse_row_idx_siblings_find(m, row, &prev, &next);
+        assert(prev != NULL);
+        assert(next != NULL);
+        r->prev = prev;
+        r->next = next;
+        prev->next = r;
+        next->prev = r;
      }
 
    r->cols = NULL;
@@ -591,43 +632,46 @@ _eina_matrixsparse_row_idx_add(Eina_Matrixsparse *m, unsigned long row)
 }
 
 static inline Eina_Matrixsparse_Cell *
-_eina_matrixsparse_row_cell_idx_add(Eina_Matrixsparse_Row *r, unsigned long col, const void *data)
+_eina_matrixsparse_row_cell_idx_add(Eina_Matrixsparse_Row *r,
+                                    unsigned long col,
+                                    const void *data)
 {
    Eina_Matrixsparse_Cell *c = eina_mempool_malloc
-     (_eina_matrixsparse_cell_mp, sizeof(Eina_Matrixsparse_Cell));
-   if (!c) return NULL;
+         (_eina_matrixsparse_cell_mp, sizeof(Eina_Matrixsparse_Cell));
+   if (!c)
+      return NULL;
 
    if (!r->cols)
      {
-       c->prev = NULL;
-       c->next = NULL;
-       r->cols = c;
-       r->last_col = c;
+        c->prev = NULL;
+        c->next = NULL;
+        r->cols = c;
+        r->last_col = c;
      }
    else if (col < r->cols->col)
      {
-       c->prev = NULL;
-       c->next = r->cols;
-       r->cols->prev = c;
-       r->cols = c;
+        c->prev = NULL;
+        c->next = r->cols;
+        r->cols->prev = c;
+        r->cols = c;
      }
    else if (col > r->last_col->col)
      {
-       c->prev = r->last_col;
-       r->last_col->next = c;
-       c->next = NULL;
-       r->last_col = c;
+        c->prev = r->last_col;
+        r->last_col->next = c;
+        c->next = NULL;
+        r->last_col = c;
      }
    else
      {
-       Eina_Matrixsparse_Cell *prev = NULL, *next = NULL;
-       _eina_matrixsparse_row_cell_idx_siblings_find(r, col, &prev, &next);
-       assert(prev != NULL);
-       assert(next != NULL);
-       c->prev = prev;
-       c->next = next;
-       prev->next = c;
-       next->prev = c;
+        Eina_Matrixsparse_Cell *prev = NULL, *next = NULL;
+        _eina_matrixsparse_row_cell_idx_siblings_find(r, col, &prev, &next);
+        assert(prev != NULL);
+        assert(next != NULL);
+        c->prev = prev;
+        c->next = next;
+        prev->next = c;
+        next->prev = c;
      }
 
    c->data = (void *)data;
@@ -639,27 +683,32 @@ _eina_matrixsparse_row_cell_idx_add(Eina_Matrixsparse_Row *r, unsigned long col,
 }
 
 static inline Eina_Bool
-_eina_matrixsparse_cell_idx_add(Eina_Matrixsparse *m, unsigned long row, unsigned long col, const void *data)
+_eina_matrixsparse_cell_idx_add(Eina_Matrixsparse *m,
+                                unsigned long row,
+                                unsigned long col,
+                                const void *data)
 {
    Eina_Matrixsparse_Row *r = _eina_matrixsparse_row_idx_get(m, row);
    if (!r)
-     r = _eina_matrixsparse_row_idx_add(m, row);
+      r = _eina_matrixsparse_row_idx_add(m, row);
+
    if (!r)
-     return 0;
+      return 0;
 
    if (_eina_matrixsparse_row_cell_idx_add(r, col, data))
-     return 1;
+      return 1;
 
    if (r->cols)
-     return 0;
+      return 0;
+
    _eina_matrixsparse_row_unlink(r);
    _eina_matrixsparse_row_free(r, m->free.func, m->free.user_data);
    return 0;
 }
 
 /*============================================================================*
- *                              Iterators                                    *
- *============================================================================*/
+*                Iterators                                    *
+*============================================================================*/
 static Eina_Bool
 _eina_matrixsparse_iterator_next(Eina_Matrixsparse_Iterator *it, void **data)
 {
@@ -667,16 +716,19 @@ _eina_matrixsparse_iterator_next(Eina_Matrixsparse_Iterator *it, void **data)
 
    /* do not touch it->idx */
 
-   if (!it->ref.col) return 0;
+   if (!it->ref.col)
+      return 0;
+
    *data = (Eina_Matrixsparse_Cell *)it->ref.col;
 
    it->ref.col = it->ref.col->next;
    if (!it->ref.col)
      {
-       it->ref.row = it->ref.row->next;
-       if (it->ref.row)
-         it->ref.col = it->ref.row->cols;
+        it->ref.row = it->ref.row->next;
+        if (it->ref.row)
+           it->ref.col = it->ref.row->cols;
      }
+
    return 1;
 }
 
@@ -691,68 +743,73 @@ static void
 _eina_matrixsparse_iterator_free(Eina_Matrixsparse_Iterator *it)
 {
    EINA_MAGIC_CHECK_MATRIXSPARSE_ITERATOR(it);
-   EINA_MAGIC_SET(it, EINA_MAGIC_NONE);
+   EINA_MAGIC_SET(it,            EINA_MAGIC_NONE);
    EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_NONE);
    free(it);
 }
 
 static Eina_Bool
-_eina_matrixsparse_iterator_complete_next(Eina_Matrixsparse_Iterator_Complete *it, void **data)
+_eina_matrixsparse_iterator_complete_next(
+   Eina_Matrixsparse_Iterator_Complete *it,
+   void **data)
 {
    EINA_MAGIC_CHECK_MATRIXSPARSE_ITERATOR(it, EINA_FALSE);
 
    if (it->idx.row >= it->m->size.rows)
-     return 0;
+      return 0;
 
    if (it->dummy.col.data != NULL)
-     ERR("Last iterator call changed dummy cell!");
+      ERR("Last iterator call changed dummy cell!");
 
    if ((it->ref.col) &&
        (it->ref.col->col == it->idx.col) &&
        (it->ref.row->row == it->idx.row))
      {
-       *data = (Eina_Matrixsparse_Cell *)it->ref.col;
-       it->ref.col = it->ref.col->next;
-       if (!it->ref.col)
-         {
-            it->ref.row = it->ref.row->next;
-            if (it->ref.row)
-              it->ref.col = it->ref.row->cols;
-         }
+        *data = (Eina_Matrixsparse_Cell *)it->ref.col;
+        it->ref.col = it->ref.col->next;
+        if (!it->ref.col)
+          {
+             it->ref.row = it->ref.row->next;
+             if (it->ref.row)
+                it->ref.col = it->ref.row->cols;
+          }
      }
    else
      {
-       it->dummy.col.data = NULL;
-       it->dummy.col.col = it->idx.col;
-       it->dummy.row.row = it->idx.row;
-       *data = &it->dummy.col;
+        it->dummy.col.data = NULL;
+        it->dummy.col.col = it->idx.col;
+        it->dummy.row.row = it->idx.row;
+        *data = &it->dummy.col;
      }
 
    it->idx.col++;
    if (it->idx.col == it->m->size.cols)
      {
-       it->idx.col = 0;
-       it->idx.row++;
+        it->idx.col = 0;
+        it->idx.row++;
      }
+
    return 1;
 }
 
 static Eina_Matrixsparse *
-_eina_matrixsparse_iterator_complete_get_container(Eina_Matrixsparse_Iterator_Complete *it)
+_eina_matrixsparse_iterator_complete_get_container(
+   Eina_Matrixsparse_Iterator_Complete *it)
 {
-   EINA_MAGIC_CHECK_MATRIXSPARSE_ITERATOR(it, NULL);
+      EINA_MAGIC_CHECK_MATRIXSPARSE_ITERATOR(it, NULL);
    return (Eina_Matrixsparse *)it->m;
 }
 
 static void
-_eina_matrixsparse_iterator_complete_free(Eina_Matrixsparse_Iterator_Complete *it)
+_eina_matrixsparse_iterator_complete_free(
+   Eina_Matrixsparse_Iterator_Complete *it)
 {
-   EINA_MAGIC_CHECK_MATRIXSPARSE_ITERATOR(it);
+      EINA_MAGIC_CHECK_MATRIXSPARSE_ITERATOR(it);
 
    if (it->dummy.col.data != NULL)
-     ERR("Last iterator call changed dummy cell!");
+      ERR("Last iterator call changed dummy cell!");
 
-   EINA_MAGIC_SET(it, EINA_MAGIC_NONE);
+   EINA_MAGIC_SET(it,            EINA_MAGIC_NONE);
    EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_NONE);
    free(it);
 }
@@ -763,8 +820,8 @@ _eina_matrixsparse_iterator_complete_free(Eina_Matrixsparse_Iterator_Complete *i
  */
 
 /*============================================================================*
- *                                 Global                                     *
- *============================================================================*/
+*                                 Global                                     *
+*============================================================================*/
 
 /**
  * @internal
@@ -786,11 +843,12 @@ eina_matrixsparse_init(void)
 {
    const char *choice, *tmp;
 
-   _eina_matrixsparse_log_dom = eina_log_domain_register("eina_matrixsparse", EINA_LOG_COLOR_DEFAULT);
+   _eina_matrixsparse_log_dom = eina_log_domain_register("eina_matrixsparse",
+                                                         EINA_LOG_COLOR_DEFAULT);
    if (_eina_matrixsparse_log_dom < 0)
      {
-       EINA_LOG_ERR("Could not register log domain: eina_matrixsparse");
-       return EINA_FALSE;
+        EINA_LOG_ERR("Could not register log domain: eina_matrixsparse");
+        return EINA_FALSE;
      }
 
 #ifdef EINA_DEFAULT_MEMPOOL
@@ -800,25 +858,31 @@ eina_matrixsparse_init(void)
 #endif
    tmp = getenv("EINA_MEMPOOL");
    if (tmp && tmp[0])
-     choice = tmp;
+      choice = tmp;
 
    _eina_matrixsparse_cell_mp = eina_mempool_add
-     (choice, "matrixsparse_cell", NULL, sizeof (Eina_Matrixsparse_Cell), 120);
+         (choice,
+         "matrixsparse_cell",
+         NULL,
+         sizeof (Eina_Matrixsparse_Cell),
+         120);
    if (!_eina_matrixsparse_cell_mp)
      {
-       ERR("Mempool for matrixsparse_cell cannot be allocated in matrixsparse init.");
-       goto on_init_fail;
+        ERR(
+           "Mempool for matrixsparse_cell cannot be allocated in matrixsparse init.");
+        goto on_init_fail;
      }
 
    _eina_matrixsparse_row_mp = eina_mempool_add
-     (choice, "matrixsparse_row", NULL, sizeof (Eina_Matrixsparse_Row), 120);
+         (choice, "matrixsparse_row", NULL, sizeof (Eina_Matrixsparse_Row), 120);
    if (!_eina_matrixsparse_row_mp)
      {
-       ERR("Mempool for matrixsparse_row cannot be allocated in matrixsparse init.");
-       goto on_init_fail;
+        ERR(
+           "Mempool for matrixsparse_row cannot be allocated in matrixsparse init.");
+        goto on_init_fail;
      }
 
-#define EMS(n) eina_magic_string_static_set(n, n##_STR)
+#define EMS(n) eina_magic_string_static_set(n, n ## _STR)
    EMS(EINA_MAGIC_MATRIXSPARSE);
    EMS(EINA_MAGIC_MATRIXSPARSE_ROW);
    EMS(EINA_MAGIC_MATRIXSPARSE_CELL);
@@ -831,7 +895,7 @@ eina_matrixsparse_init(void)
 
    return EINA_TRUE;
 
- on_init_fail:
+on_init_fail:
    eina_log_domain_unregister(_eina_matrixsparse_log_dom);
    _eina_matrixsparse_log_dom = -1;
    return EINA_FALSE;
@@ -860,8 +924,8 @@ eina_matrixsparse_shutdown(void)
 }
 
 /*============================================================================*
- *                                   API                                      *
- *============================================================================*/
+*                                   API                                      *
+*============================================================================*/
 
 /**
  * @addtogroup Eina_Matrixsparse_Group Sparse Matrix
@@ -891,7 +955,9 @@ eina_matrixsparse_shutdown(void)
  *         is set.
  */
 EAPI Eina_Matrixsparse *
-eina_matrixsparse_new(unsigned long rows, unsigned long cols, void (*free_func)(void *user_data, void *cell_data), const void *user_data)
+eina_matrixsparse_new(unsigned long rows, unsigned long cols, void (*free_func)(
+                         void *user_data,
+                         void *cell_data), const void *user_data)
 {
    Eina_Matrixsparse *m;
 
@@ -901,8 +967,8 @@ eina_matrixsparse_new(unsigned long rows, unsigned long cols, void (*free_func)(
    m = malloc(sizeof(Eina_Matrixsparse));
    if (!m)
      {
-       eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
-       return NULL;
+        eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+        return NULL;
      }
 
    m->rows = NULL;
@@ -939,9 +1005,9 @@ eina_matrixsparse_free(Eina_Matrixsparse *m)
    r = m->rows;
    while (r)
      {
-       Eina_Matrixsparse_Row *r_aux = r;
-       r = r->next;
-       _eina_matrixsparse_row_free(r_aux, free_func, user_data);
+        Eina_Matrixsparse_Row *r_aux = r;
+        r = r->next;
+        _eina_matrixsparse_row_free(r_aux, free_func, user_data);
      }
 
    EINA_MAGIC_SET(m, EINA_MAGIC_NONE);
@@ -961,13 +1027,22 @@ eina_matrixsparse_free(Eina_Matrixsparse *m)
  *        invalid, returned value is zero, otherwise it's a positive integer.
  */
 EAPI void
-eina_matrixsparse_size_get(const Eina_Matrixsparse *m, unsigned long *rows, unsigned long *cols)
+eina_matrixsparse_size_get(const Eina_Matrixsparse *m,
+                           unsigned long *rows,
+                           unsigned long *cols)
 {
-   if (rows) *rows = 0;
-   if (cols) *cols = 0;
+   if (rows)
+      *rows = 0;
+
+   if (cols)
+      *cols = 0;
+
    EINA_MAGIC_CHECK_MATRIXSPARSE(m);
-   if (rows) *rows = m->size.rows;
-   if (cols) *cols = m->size.cols;
+   if (rows)
+      *rows = m->size.rows;
+
+   if (cols)
+      *cols = m->size.cols;
 }
 
 /**
@@ -986,7 +1061,9 @@ eina_matrixsparse_size_get(const Eina_Matrixsparse *m, unsigned long *rows, unsi
  *     freed.
  */
 EAPI Eina_Bool
-eina_matrixsparse_size_set(Eina_Matrixsparse *m, unsigned long rows, unsigned long cols)
+eina_matrixsparse_size_set(Eina_Matrixsparse *m,
+                           unsigned long rows,
+                           unsigned long cols)
 {
    Eina_Bool update_last_used_row;
    Eina_Matrixsparse_Row *r;
@@ -997,7 +1074,8 @@ eina_matrixsparse_size_set(Eina_Matrixsparse *m, unsigned long rows, unsigned lo
    EINA_SAFETY_ON_FALSE_RETURN_VAL(rows > 0, 0);
    EINA_SAFETY_ON_FALSE_RETURN_VAL(cols > 0, 0);
 
-   if ((rows == m->size.rows) && (cols == m->size.cols)) return 1;
+   if ((rows == m->size.rows) && (cols == m->size.cols))
+      return 1;
 
    update_last_used_row = ((m->last_used) && (m->last_used->row >= rows));
    free_func = m->free.func;
@@ -1006,77 +1084,80 @@ eina_matrixsparse_size_set(Eina_Matrixsparse *m, unsigned long rows, unsigned lo
    r = m->last_row;
    while (r && r->row >= rows)
      {
-       Eina_Matrixsparse_Row *r_aux = r;
-       r = r->prev;
-       _eina_matrixsparse_row_free(r_aux, free_func, user_data);
+        Eina_Matrixsparse_Row *r_aux = r;
+        r = r->prev;
+        _eina_matrixsparse_row_free(r_aux, free_func, user_data);
      }
    if (!r)
      {
-       m->last_row = NULL;
-       m->rows = NULL;
+        m->last_row = NULL;
+        m->rows = NULL;
      }
    else if (r != m->last_row)
      {
-       r->next = NULL;
-       m->last_row = r;
+        r->next = NULL;
+        m->last_row = r;
      }
 
    if (update_last_used_row)
-     m->last_used = m->last_row;
+      m->last_used = m->last_row;
 
    r = m->rows;
    while (r)
      {
-       Eina_Matrixsparse_Cell *c = r->last_col;
-       Eina_Bool update_last_used_col;
-       update_last_used_col = ((r->last_used) && (r->last_used->col >= cols));
-       while (c && c->col >= cols)
-         {
-            Eina_Matrixsparse_Cell *c_aux = c;
-            c = c->prev;
-            _eina_matrixsparse_cell_free(c_aux, free_func, user_data);
-         }
-       if (!c)
-         {
-            Eina_Matrixsparse_Row *r_aux = r;
-            r->cols = NULL;
-            r->last_col = NULL;
-            if (r->next)
-              r->next->prev = r->prev;
-            else
-              m->last_row = r->prev;
-            if (r->prev)
-              r->prev->next = r->next;
-            else
-              m->rows = r->next;
-            r = r->next;
-            _eina_matrixsparse_row_free(r_aux, free_func, user_data);
-         }
-       else
-         {
-            if (c != r->last_col)
-              {
-                 c->next = NULL;
-                 r->last_col = c;
-              }
-            if (update_last_used_col)
-              r->last_used = r->last_col;
-
-            r = r->next;
-         }
+        Eina_Matrixsparse_Cell *c = r->last_col;
+        Eina_Bool update_last_used_col;
+        update_last_used_col = ((r->last_used) && (r->last_used->col >= cols));
+        while (c && c->col >= cols)
+          {
+             Eina_Matrixsparse_Cell *c_aux = c;
+             c = c->prev;
+             _eina_matrixsparse_cell_free(c_aux, free_func, user_data);
+          }
+        if (!c)
+          {
+             Eina_Matrixsparse_Row *r_aux = r;
+             r->cols = NULL;
+             r->last_col = NULL;
+             if (r->next)
+                r->next->prev = r->prev;
+             else
+                m->last_row = r->prev;
+
+             if (r->prev)
+                r->prev->next = r->next;
+             else
+                m->rows = r->next;
+
+             r = r->next;
+             _eina_matrixsparse_row_free(r_aux, free_func, user_data);
+          }
+        else
+          {
+             if (c != r->last_col)
+               {
+                  c->next = NULL;
+                  r->last_col = c;
+               }
+
+             if (update_last_used_col)
+                r->last_used = r->last_col;
+
+             r = r->next;
+          }
      }
 
    update_last_used_row = 0;
    if (m->last_used)
      {
-       if (m->last_row)
-         update_last_used_row = m->last_used->row > m->last_row->row;
-       else
-         update_last_used_row = 1;
+        if (m->last_row)
+           update_last_used_row = m->last_used->row > m->last_row->row;
+        else
+           update_last_used_row = 1;
      }
 
    if (update_last_used_row)
-     m->last_used = m->last_row;
+      m->last_used = m->last_row;
 
    m->size.rows = rows;
    m->size.cols = cols;
@@ -1098,7 +1179,10 @@ eina_matrixsparse_size_set(Eina_Matrixsparse *m, unsigned long rows, unsigned lo
  * @see eina_matrixsparse_data_idx_get()
  */
 EAPI Eina_Bool
-eina_matrixsparse_cell_idx_get(const Eina_Matrixsparse *m, unsigned long row, unsigned long col, Eina_Matrixsparse_Cell **cell)
+eina_matrixsparse_cell_idx_get(const Eina_Matrixsparse *m,
+                               unsigned long row,
+                               unsigned long col,
+                               Eina_Matrixsparse_Cell **cell)
 {
    EINA_MAGIC_CHECK_MATRIXSPARSE(m, 0);
    EINA_SAFETY_ON_NULL_RETURN_VAL(cell, 0);
@@ -1139,13 +1223,17 @@ eina_matrixsparse_cell_data_get(const Eina_Matrixsparse_Cell *cell)
  * @see eina_matrixsparse_cell_data_get()
  */
 EAPI void *
-eina_matrixsparse_data_idx_get(const Eina_Matrixsparse *m, unsigned long row, unsigned long col)
+eina_matrixsparse_data_idx_get(const Eina_Matrixsparse *m,
+                               unsigned long row,
+                               unsigned long col)
 {
    Eina_Matrixsparse_Cell *c;
    EINA_MAGIC_CHECK_MATRIXSPARSE(m, NULL);
    c = _eina_matrixsparse_cell_idx_get(m, row, col);
-   if (c) return c->data;
-   else   return NULL;
+   if (c)
+      return c->data;
+   else
+      return NULL;
 }
 
 /**
@@ -1158,14 +1246,24 @@ eina_matrixsparse_data_idx_get(const Eina_Matrixsparse *m, unsigned long row, un
  * @return 1 on success, 0 otherwise (@c cell is @c NULL).
  */
 EAPI Eina_Bool
-eina_matrixsparse_cell_position_get(const Eina_Matrixsparse_Cell *cell, unsigned long *row, unsigned long *col)
+eina_matrixsparse_cell_position_get(const Eina_Matrixsparse_Cell *cell,
+                                    unsigned long *row,
+                                    unsigned long *col)
 {
-   if (row) *row = 0;
-   if (col) *col = 0;
+   if (row)
+      *row = 0;
+
+   if (col)
+      *col = 0;
+
    EINA_MAGIC_CHECK_MATRIXSPARSE_CELL(cell, 0);
    EINA_MAGIC_CHECK_MATRIXSPARSE_ROW(cell->parent, 0);
-   if (row) *row = cell->parent->row;
-   if (col) *col = cell->col;
+   if (row)
+      *row = cell->parent->row;
+
+   if (col)
+      *col = cell->col;
+
    return 1;
 }
 
@@ -1182,12 +1280,18 @@ eina_matrixsparse_cell_position_get(const Eina_Matrixsparse_Cell *cell, unsigned
  * @see eina_matrixsparse_data_idx_replace()
  */
 EAPI Eina_Bool
-eina_matrixsparse_cell_data_replace(Eina_Matrixsparse_Cell *cell, const void *data, void **p_old)
+eina_matrixsparse_cell_data_replace(Eina_Matrixsparse_Cell *cell,
+                                    const void *data,
+                                    void **p_old)
 {
-   if (p_old) *p_old = NULL;
+   if (p_old)
+      *p_old = NULL;
+
    EINA_MAGIC_CHECK_MATRIXSPARSE_CELL(cell, 0);
 
-   if (p_old) *p_old = cell->data;
+   if (p_old)
+      *p_old = cell->data;
+
    cell->data = (void *)data;
    return 1;
 }
@@ -1218,7 +1322,7 @@ eina_matrixsparse_cell_data_set(Eina_Matrixsparse_Cell *cell, const void *data)
    m = cell->parent->parent;
 
    if (m->free.func)
-     m->free.func(m->free.user_data, cell->data);
+      m->free.func(m->free.user_data, cell->data);
 
    cell->data = (void *)data;
    return 1;
@@ -1240,11 +1344,17 @@ eina_matrixsparse_cell_data_set(Eina_Matrixsparse_Cell *cell, const void *data)
  * @see eina_matrixsparse_data_idx_set()
  */
 EAPI Eina_Bool
-eina_matrixsparse_data_idx_replace(Eina_Matrixsparse *m, unsigned long row, unsigned long col, const void *data, void **p_old)
+eina_matrixsparse_data_idx_replace(Eina_Matrixsparse *m,
+                                   unsigned long row,
+                                   unsigned long col,
+                                   const void *data,
+                                   void **p_old)
 {
    Eina_Matrixsparse_Cell *cell;
 
-   if (p_old) *p_old = NULL;
+   if (p_old)
+      *p_old = NULL;
+
    EINA_MAGIC_CHECK_MATRIXSPARSE(m, 0);
    EINA_SAFETY_ON_FALSE_RETURN_VAL(row < m->size.rows, 0);
    EINA_SAFETY_ON_FALSE_RETURN_VAL(col < m->size.cols, 0);
@@ -1252,9 +1362,11 @@ eina_matrixsparse_data_idx_replace(Eina_Matrixsparse *m, unsigned long row, unsi
    cell = _eina_matrixsparse_cell_idx_get(m, row, col);
    if (cell)
      {
-       if (p_old) *p_old = cell->data;
-       cell->data = (void *)data;
-       return 1;
+        if (p_old)
+           *p_old = cell->data;
+
+        cell->data = (void *)data;
+        return 1;
      }
 
    return _eina_matrixsparse_cell_idx_add(m, row, col, data);
@@ -1277,7 +1389,10 @@ eina_matrixsparse_data_idx_replace(Eina_Matrixsparse *m, unsigned long row, unsi
  * @see eina_matrixsparse_cell_data_replace()
  */
 EAPI Eina_Bool
-eina_matrixsparse_data_idx_set(Eina_Matrixsparse *m, unsigned long row, unsigned long col, const void *data)
+eina_matrixsparse_data_idx_set(Eina_Matrixsparse *m,
+                               unsigned long row,
+                               unsigned long col,
+                               const void *data)
 {
    Eina_Matrixsparse_Cell *cell;
 
@@ -1288,10 +1403,11 @@ eina_matrixsparse_data_idx_set(Eina_Matrixsparse *m, unsigned long row, unsigned
    cell = _eina_matrixsparse_cell_idx_get(m, row, col);
    if (cell)
      {
-       if (m->free.func)
-         m->free.func(m->free.user_data, cell->data);
-       cell->data = (void *)data;
-       return 1;
+        if (m->free.func)
+           m->free.func(m->free.user_data, cell->data);
+
+        cell->data = (void *)data;
+        return 1;
      }
 
    return _eina_matrixsparse_cell_idx_add(m, row, col, data);
@@ -1323,7 +1439,8 @@ eina_matrixsparse_row_idx_clear(Eina_Matrixsparse *m, unsigned long row)
    EINA_SAFETY_ON_FALSE_RETURN_VAL(row < m->size.rows, 0);
 
    r = _eina_matrixsparse_row_idx_get(m, row);
-   if (!r) return 1;
+   if (!r)
+      return 1;
 
    _eina_matrixsparse_row_unlink(r);
    _eina_matrixsparse_row_free(r, m->free.func, m->free.user_data);
@@ -1361,27 +1478,27 @@ eina_matrixsparse_column_idx_clear(Eina_Matrixsparse *m, unsigned long col)
    free_func = m->free.func;
    user_data = m->free.user_data;
 
-   for (r = m->rows; r != NULL;)
+   for (r = m->rows; r != NULL; )
      {
-       Eina_Matrixsparse_Row *r_aux = r;
-       Eina_Matrixsparse_Cell *c;
-
-       c = _eina_matrixsparse_row_cell_idx_get(r, col);
-       r = r->next;
-
-       if (!c)
-         continue;
-
-       if ((r_aux->cols != c) || (r_aux->last_col != c))
-         {
-            _eina_matrixsparse_cell_unlink(c);
-            _eina_matrixsparse_cell_free(c, free_func, user_data);
-         }
-       else
-         {
-            _eina_matrixsparse_row_unlink(r_aux);
-            _eina_matrixsparse_row_free(r_aux, free_func, user_data);
-         }
+        Eina_Matrixsparse_Row *r_aux = r;
+        Eina_Matrixsparse_Cell *c;
+
+        c = _eina_matrixsparse_row_cell_idx_get(r, col);
+        r = r->next;
+
+        if (!c)
+           continue;
+
+        if ((r_aux->cols != c) || (r_aux->last_col != c))
+          {
+             _eina_matrixsparse_cell_unlink(c);
+             _eina_matrixsparse_cell_free(c, free_func, user_data);
+          }
+        else
+          {
+             _eina_matrixsparse_row_unlink(r_aux);
+             _eina_matrixsparse_row_free(r_aux, free_func, user_data);
+          }
      }
 
    return 1;
@@ -1406,7 +1523,9 @@ eina_matrixsparse_column_idx_clear(Eina_Matrixsparse *m, unsigned long col)
  *     row if this cell was the last remainder.
  */
 EAPI Eina_Bool
-eina_matrixsparse_cell_idx_clear(Eina_Matrixsparse *m, unsigned long row, unsigned long col)
+eina_matrixsparse_cell_idx_clear(Eina_Matrixsparse *m,
+                                 unsigned long row,
+                                 unsigned long col)
 {
    Eina_Matrixsparse_Cell *c;
 
@@ -1415,7 +1534,8 @@ eina_matrixsparse_cell_idx_clear(Eina_Matrixsparse *m, unsigned long row, unsign
    EINA_SAFETY_ON_FALSE_RETURN_VAL(col < m->size.cols, 0);
 
    c = _eina_matrixsparse_cell_idx_get(m, row, col);
-   if (!c) return 1;
+   if (!c)
+      return 1;
 
    _eina_matrixsparse_cell_unlink(c);
    _eina_matrixsparse_cell_free(c, m->free.func, m->free.user_data);
@@ -1477,19 +1597,21 @@ eina_matrixsparse_iterator_new(const Eina_Matrixsparse *m)
    it = calloc(1, sizeof(*it));
    if (!it)
      {
-       eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
-       return NULL;
+        eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+        return NULL;
      }
 
-   EINA_MAGIC_SET(it, EINA_MAGIC_MATRIXSPARSE_ITERATOR);
+   EINA_MAGIC_SET(it,            EINA_MAGIC_MATRIXSPARSE_ITERATOR);
    EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
 
    it->m = m;
    it->ref.row = m->rows;
    it->ref.col = m->rows ? m->rows->cols : NULL;
 
+   it->iterator.version = EINA_ITERATOR_VERSION;
    it->iterator.next = FUNC_ITERATOR_NEXT(_eina_matrixsparse_iterator_next);
-   it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(_eina_matrixsparse_iterator_get_container);
+   it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
+         _eina_matrixsparse_iterator_get_container);
    it->iterator.free = FUNC_ITERATOR_FREE(_eina_matrixsparse_iterator_free);
    return &it->iterator;
 }
@@ -1526,11 +1648,11 @@ eina_matrixsparse_iterator_complete_new(const Eina_Matrixsparse *m)
    it = calloc(1, sizeof(*it));
    if (!it)
      {
-       eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
-       return NULL;
+        eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+        return NULL;
      }
 
-   EINA_MAGIC_SET(it, EINA_MAGIC_MATRIXSPARSE_ITERATOR);
+   EINA_MAGIC_SET(it,            EINA_MAGIC_MATRIXSPARSE_ITERATOR);
    EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
 
    it->m = m;
@@ -1549,9 +1671,13 @@ eina_matrixsparse_iterator_complete_new(const Eina_Matrixsparse *m)
    it->dummy.col.parent = &it->dummy.row;
    EINA_MAGIC_SET(&it->dummy.col, EINA_MAGIC_MATRIXSPARSE_CELL);
 
-   it->iterator.next = FUNC_ITERATOR_NEXT(_eina_matrixsparse_iterator_complete_next);
-   it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(_eina_matrixsparse_iterator_complete_get_container);
-   it->iterator.free = FUNC_ITERATOR_FREE(_eina_matrixsparse_iterator_complete_free);
+   it->iterator.version = EINA_ITERATOR_VERSION;
+   it->iterator.next = FUNC_ITERATOR_NEXT(
+         _eina_matrixsparse_iterator_complete_next);
+   it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
+         _eina_matrixsparse_iterator_complete_get_container);
+   it->iterator.free = FUNC_ITERATOR_FREE(
+         _eina_matrixsparse_iterator_complete_free);
    return &it->iterator;
 }
 
index c722d7a..0d37861 100644 (file)
@@ -37,8 +37,8 @@
 #include "eina_mempool.h"
 
 /*============================================================================*
- *                                  Local                                     *
- *============================================================================*/
+*                                  Local                                     *
+*============================================================================*/
 
 /**
  * @cond LOCAL
@@ -60,62 +60,71 @@ static int _eina_mempool_log_dom = -1;
 
 
 static Eina_Mempool *
-_new_va(const char *name, const char *context, const char *options, va_list args)
+_new_va(const char *name,
+        const char *context,
+        const char *options,
+        va_list args)
 {
-       Eina_Mempool_Backend *be;
-       Eina_Mempool *mp;
+   Eina_Mempool_Backend *be;
+   Eina_Mempool *mp;
 
-       Eina_Error err = EINA_ERROR_NOT_MEMPOOL_MODULE;
+   Eina_Error err = EINA_ERROR_NOT_MEMPOOL_MODULE;
 
-       eina_error_set(0);
-       be = eina_hash_find(_backends, name);
-       if (!be)
-               goto on_error;
+   eina_error_set(0);
+   be = eina_hash_find(_backends, name);
+   if (!be)
+      goto on_error;
 
-       err = EINA_ERROR_OUT_OF_MEMORY;
-       mp = malloc(sizeof(Eina_Mempool));
-       if (!mp) goto on_error;
+   err = EINA_ERROR_OUT_OF_MEMORY;
+   mp = malloc(sizeof(Eina_Mempool));
+   if (!mp)
+      goto on_error;
 
-       /* FIXME why backend is not a pointer? */
-       mp->backend = *be;
-       mp->backend_data = mp->backend.init(context, options, args);
+   /* FIXME why backend is not a pointer? */
+   mp->backend = *be;
+   mp->backend_data = mp->backend.init(context, options, args);
 
-       return mp;
+   return mp;
 
-  on_error:
-       eina_error_set(err);
-       return NULL;
+on_error:
+   eina_error_set(err);
+   return NULL;
 }
 
 /* Built-in backend's prototypes */
 #ifdef EINA_STATIC_BUILD_CHAINED_POOL
 Eina_Bool chained_init(void);
-void chained_shutdown(void);
+void      chained_shutdown(void);
 #endif
 
 #ifdef EINA_STATIC_BUILD_PASS_THROUGH
 Eina_Bool pass_through_init(void);
-void pass_through_shutdown(void);
+void      pass_through_shutdown(void);
 #endif
 
 #ifdef EINA_STATIC_BUILD_EMEMOA_UNKNOWN
 Eina_Bool ememoa_unknown_init(void);
-void ememoa_unknown_shutdown(void);
+void      ememoa_unknown_shutdown(void);
 #endif
 
 #ifdef EINA_STATIC_BUILD_EMEMOA_FIXED
 Eina_Bool ememoa_fixed_init(void);
-void ememoa_fixed_shutdown(void);
+void      ememoa_fixed_shutdown(void);
 #endif
 
 #ifdef EINA_STATIC_BUILD_FIXED_BITMAP
 Eina_Bool fixed_bitmap_init(void);
-void fixed_bitmap_shutdown(void);
+void      fixed_bitmap_shutdown(void);
 #endif
 
 #ifdef EINA_STATIC_BUILD_BUDDY
 Eina_Bool buddy_init(void);
-void buddy_shutdown(void);
+void      buddy_shutdown(void);
+#endif
+
+#ifdef EINA_STATIC_BUILD_ONE_BIG
+Eina_Bool one_big_init(void);
+void      one_big_shutdown(void);
 #endif
 
 /**
@@ -123,8 +132,8 @@ void buddy_shutdown(void);
  */
 
 /*============================================================================*
- *                                 Global                                     *
- *============================================================================*/
+*                                 Global                                     *
+*============================================================================*/
 
 /**
  * @cond LOCAL
@@ -132,7 +141,8 @@ void buddy_shutdown(void);
 
 EAPI Eina_Error EINA_ERROR_NOT_MEMPOOL_MODULE = 0;
 
-static const char EINA_ERROR_NOT_MEMPOOL_MODULE_STR[] = "Not a memory pool module.";
+static const char EINA_ERROR_NOT_MEMPOOL_MODULE_STR[] =
+   "Not a memory pool module.";
 
 /**
  * @endcond
@@ -159,39 +169,49 @@ eina_mempool_init(void)
 {
    char *path;
 
-   _eina_mempool_log_dom = eina_log_domain_register("eina_mempool", EINA_LOG_COLOR_DEFAULT);
+   _eina_mempool_log_dom = eina_log_domain_register("eina_mempool",
+                                                    EINA_LOG_COLOR_DEFAULT);
    if (_eina_mempool_log_dom < 0)
      {
-       EINA_LOG_ERR("Could not register log domain: eina_mempool");
-       return 0;
+        EINA_LOG_ERR("Could not register log domain: eina_mempool");
+        return 0;
      }
 
-   EINA_ERROR_NOT_MEMPOOL_MODULE = eina_error_msg_static_register(EINA_ERROR_NOT_MEMPOOL_MODULE_STR);
+   EINA_ERROR_NOT_MEMPOOL_MODULE = eina_error_msg_static_register(
+         EINA_ERROR_NOT_MEMPOOL_MODULE_STR);
    _backends = eina_hash_string_superfast_new(NULL);
 
    /* dynamic backends */
-   _modules = eina_module_arch_list_get(NULL, PACKAGE_LIB_DIR "/eina/modules/mp", MODULE_ARCH);
+   _modules = eina_module_arch_list_get(NULL,
+                                        PACKAGE_LIB_DIR "/eina/modules/mp",
+                                        MODULE_ARCH);
 
    path = eina_module_environment_path_get("HOME", "/.eina/mp/modules/mp");
    _modules = eina_module_arch_list_get(_modules, path, MODULE_ARCH);
-   if (path) free(path);
+   if (path)
+      free(path);
 
-   path = eina_module_environment_path_get("EINA_MODULES_MEMPOOL_DIR", "/eina/modules/mp");
+   path = eina_module_environment_path_get("EINA_MODULES_MEMPOOL_DIR",
+                                           "/eina/modules/mp");
    _modules = eina_module_arch_list_get(_modules, path, MODULE_ARCH);
-   if (path) free(path);
+   if (path)
+      free(path);
 
-   path = eina_module_symbol_path_get((const void *)eina_init, "/eina/modules/mp");
+   path = eina_module_symbol_path_get((const void *)eina_init,
+                                      "/eina/modules/mp");
    _modules = eina_module_arch_list_get(_modules, path, MODULE_ARCH);
-   if (path) free(path);
+   if (path)
+      free(path);
 
    if (!_modules)
      {
-       ERR("no mempool modules able to be loaded.");
-       eina_hash_free(_backends);
-       goto mempool_init_error;
+        ERR("no mempool modules able to be loaded.");
+        eina_hash_free(_backends);
+        goto mempool_init_error;
      }
+
    eina_module_list_load(_modules);
-   
+
    /* builtin backends */
 #ifdef EINA_STATIC_BUILD_CHAINED_POOL
    chained_init();
@@ -211,10 +231,13 @@ eina_mempool_init(void)
 #ifdef EINA_STATIC_BUILD_BUDDY
    buddy_init();
 #endif
+#ifdef EINA_STATIC_BUILD_ONE_BIG
+   one_big_init();
+#endif
 
    return EINA_TRUE;
 
- mempool_init_error:
+mempool_init_error:
    eina_log_domain_unregister(_eina_mempool_log_dom);
    _eina_mempool_log_dom = -1;
 
@@ -243,13 +266,16 @@ eina_mempool_shutdown(void)
 #ifdef EINA_STATIC_BUILD_BUDDY
    buddy_shutdown();
 #endif
+#ifdef EINA_STATIC_BUILD_ONE_BIG
+   one_big_shutdown();
+#endif
    /* dynamic backends */
    eina_module_list_free(_modules);
    if (_modules)
-     eina_array_free(_modules);
+      eina_array_free(_modules);
 
    if (_backends)
-     eina_hash_free(_backends);
+      eina_hash_free(_backends);
 
    eina_log_domain_unregister(_eina_mempool_log_dom);
    _eina_mempool_log_dom = -1;
@@ -258,8 +284,8 @@ eina_mempool_shutdown(void)
 }
 
 /*============================================================================*
- *                                   API                                      *
- *============================================================================*/
+*                                   API                                      *
+*============================================================================*/
 
 /**
  * @addtogroup Eina_Memory_Pool_Group Memory Pool
@@ -290,53 +316,82 @@ eina_mempool_shutdown(void)
  * @li @c pass_through: it just call malloc() and free(). It may be
  * faster on some computers than using our own allocators (like having
  * a huge L2 cache, over 4MB).
+ * @li @c one_big: It call just one time malloc for the requested number
+ * of items. Usefull when you know in advance how many object of some
+ * type will live during the life of the mempool.
  *
  * @{
  */
 
 EAPI Eina_Mempool *
-eina_mempool_add(const char *name, const char *context, const char *options, ...)
+eina_mempool_add(const char *name,
+                 const char *context,
+                 const char *options,
+                 ...)
 {
-       Eina_Mempool *mp;
-       va_list args;
+   Eina_Mempool *mp;
+   va_list args;
 
-       EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
-       DBG("name=%s, context=%s, options=%s",
-           name, context ? context : "", options ? options : "");
+   EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
+   DBG("name=%s, context=%s, options=%s",
+       name, context ? context : "", options ? options : "");
 
-       va_start(args, options);
-       mp = _new_va(name, context, options, args);
-       va_end(args);
+   va_start(args, options);
+   mp = _new_va(name, context, options, args);
+   va_end(args);
 
-       DBG("name=%s, context=%s, options=%s, mp=%p",
-           name, context ? context : "", options ? options : "", mp);
+   DBG("name=%s, context=%s, options=%s, mp=%p",
+       name, context ? context : "", options ? options : "", mp);
 
-       return mp;
+   return mp;
 }
 
 EAPI void eina_mempool_del(Eina_Mempool *mp)
 {
-        EINA_SAFETY_ON_NULL_RETURN(mp);
-       EINA_SAFETY_ON_NULL_RETURN(mp->backend.shutdown);
-       DBG("mp=%p", mp);
-       mp->backend.shutdown(mp->backend_data);
-       free(mp);
+   EINA_SAFETY_ON_NULL_RETURN(mp);
+   EINA_SAFETY_ON_NULL_RETURN(mp->backend.shutdown);
+   DBG("mp=%p", mp);
+   mp->backend.shutdown(mp->backend_data);
+   free(mp);
 }
 
 EAPI void eina_mempool_gc(Eina_Mempool *mp)
 {
-        EINA_SAFETY_ON_NULL_RETURN(mp);
-        EINA_SAFETY_ON_NULL_RETURN(mp->backend.garbage_collect);
-       DBG("mp=%p", mp);
-       mp->backend.garbage_collect(mp->backend_data);
+   EINA_SAFETY_ON_NULL_RETURN(mp);
+   EINA_SAFETY_ON_NULL_RETURN(mp->backend.garbage_collect);
+   DBG("mp=%p", mp);
+   mp->backend.garbage_collect(mp->backend_data);
 }
 
 EAPI void eina_mempool_statistics(Eina_Mempool *mp)
 {
-        EINA_SAFETY_ON_NULL_RETURN(mp);
-        EINA_SAFETY_ON_NULL_RETURN(mp->backend.statistics);
-       DBG("mp=%p", mp);
-       mp->backend.statistics(mp->backend_data);
+   EINA_SAFETY_ON_NULL_RETURN(mp);
+   EINA_SAFETY_ON_NULL_RETURN(mp->backend.statistics);
+   DBG("mp=%p", mp);
+   mp->backend.statistics(mp->backend_data);
+}
+
+EAPI unsigned int
+eina_mempool_alignof(unsigned int size)
+{
+   int align;
+
+   if (size <= 2)
+      align = 2;
+   else if (size < 8)
+      align = 4;
+   else
+#if __WORDSIZE == 32
+      align = 8;
+
+#else
+   if (size < 16)
+      align = 8;
+   else
+      align = 16;
+#endif
+
+   return ((size / align) + 1) * align;
 }
 
 /**
index 0bf8bb8..e30d79d 100644 (file)
@@ -69,8 +69,8 @@ void *alloca (size_t);
 #include "eina_module.h"
 
 /*============================================================================*
- *                                  Local                                     *
- *============================================================================*/
+*                                  Local                                     *
+*============================================================================*/
 
 /**
  * @cond LOCAL
@@ -121,13 +121,11 @@ static Eina_Bool _dir_list_get_cb(Eina_Module *m, void *data)
    Eina_Bool ret = EINA_TRUE;
 
    if (cb_data->cb)
-     {
-       ret = cb_data->cb(m, cb_data->data);
-     }
+      ret = cb_data->cb(m, cb_data->data);
+
    if (ret)
-     {
-       eina_array_push(cb_data->array, m);
-     }
+      eina_array_push(cb_data->array, m);
+
    return ret;
 }
 
@@ -138,25 +136,30 @@ static void _dir_list_cb(const char *name, const char *path, void *data)
 
    length = strlen(name);
    if (length < sizeof(SHARED_LIB_SUFFIX)) /* x.so */
-     return;
+      return;
+
    if (!strcmp(name + length - sizeof(SHARED_LIB_SUFFIX) + 1,
-              SHARED_LIB_SUFFIX))
+               SHARED_LIB_SUFFIX))
      {
-       char *file;
-       Eina_Module *m;
+        char *file;
+        Eina_Module *m;
+
+        length = strlen(path) + strlen(name) + 2;
 
-       length = strlen(path) + strlen(name) + 2;
+        file = alloca(sizeof (char) * length);
+        if (!file)
+           return;
 
-       file = alloca(sizeof (char) * length);
-       if (!file) return ;
+        snprintf(file, length, "%s/%s", path, name);
+        m = eina_module_new(file);
+        if (!m)
+          {
+             return; /* call the user provided cb on this module */
 
-       snprintf(file, length, "%s/%s", path, name);
-       m = eina_module_new(file);
-       if (!m)
-         return;
-       /* call the user provided cb on this module */
-       if (!cb_data->cb(m, cb_data->data))
-         eina_module_free(m);
+          }
+
+        if (!cb_data->cb(m, cb_data->data))
+           eina_module_free(m);
      }
 }
 
@@ -166,15 +169,17 @@ static void _dir_list_cb(const char *name, const char *path, void *data)
 
 
 /*============================================================================*
- *                                 Global                                     *
- *============================================================================*/
+*                                 Global                                     *
+*============================================================================*/
 
 /**
  * @cond LOCAL
  */
 
-static const char EINA_ERROR_WRONG_MODULE_STR[] = "Wrong file format or no file module found";
-static const char EINA_ERROR_MODULE_INIT_FAILED_STR[] = "Module initialisation function failed";
+static const char EINA_ERROR_WRONG_MODULE_STR[] =
+   "Wrong file format or no file module found";
+static const char EINA_ERROR_MODULE_INIT_FAILED_STR[] =
+   "Module initialisation function failed";
 
 EAPI Eina_Error EINA_ERROR_WRONG_MODULE = 0;
 EAPI Eina_Error EINA_ERROR_MODULE_INIT_FAILED = 0;
@@ -202,14 +207,14 @@ Eina_Bool
 eina_module_init(void)
 {
    EINA_MODULE_LOG_DOM = eina_log_domain_register
-     ("eina_module", EINA_LOG_COLOR_DEFAULT);
+         ("eina_module", EINA_LOG_COLOR_DEFAULT);
    if (EINA_MODULE_LOG_DOM < 0)
      {
-       EINA_LOG_ERR("Could not register log domain: eina_module");
-       return EINA_FALSE;
+        EINA_LOG_ERR("Could not register log domain: eina_module");
+        return EINA_FALSE;
      }
 
-#define EEMR(n) n = eina_error_msg_static_register(n##_STR)
+#define EEMR(n) n = eina_error_msg_static_register(n ## _STR)
    EEMR(EINA_ERROR_WRONG_MODULE);
    EEMR(EINA_ERROR_MODULE_INIT_FAILED);
 #undef EEMR
@@ -241,8 +246,8 @@ eina_module_shutdown(void)
 }
 
 /*============================================================================*
- *                                   API                                      *
- *============================================================================*/
+*                                   API                                      *
+*============================================================================*/
 
 /**
  * @addtogroup Eina_Module_Group Module
@@ -279,10 +284,13 @@ EAPI Eina_Module *eina_module_new(const char *file)
    EINA_SAFETY_ON_FALSE_RETURN_VAL(len > 0, NULL);
 
    m = malloc(sizeof(Eina_Module) + len + 1);
-   if (!m) {
-      ERR("could not malloc(%lu)", (unsigned long)(sizeof(Eina_Module) + len + 1));
-      return NULL;
-   }
+   if (!m)
+     {
+        ERR("could not malloc(%lu)",
+            (unsigned long)(sizeof(Eina_Module) + len + 1));
+        return NULL;
+     }
+
    memcpy((char *)m->file, file, len + 1);
    m->ref = 0;
    m->handle = NULL;
@@ -309,10 +317,9 @@ EAPI Eina_Bool eina_module_free(Eina_Module *m)
    DBG("m=%p, handle=%p, file=%s, refs=%d", m, m->handle, m->file, m->ref);
 
    if (m->handle)
-     {
-       if (eina_module_unload(m) == EINA_FALSE)
-         return EINA_FALSE;
-     }
+      if (eina_module_unload(m) == EINA_FALSE)
+         return EINA_FALSE;
+
    free(m);
    return EINA_TRUE;
 }
@@ -346,31 +353,33 @@ EAPI Eina_Bool eina_module_load(Eina_Module *m)
 
    DBG("m=%p, handle=%p, file=%s, refs=%d", m, m->handle, m->file, m->ref);
 
-   if (m->handle) goto loaded;
+   if (m->handle)
+      goto loaded;
 
    dl_handle = dlopen(m->file, RTLD_NOW);
    if (!dl_handle)
      {
-       WRN("could not dlopen(\"%s\", RTLD_NOW): %s", m->file, dlerror());
-       eina_error_set(EINA_ERROR_WRONG_MODULE);
-       return EINA_FALSE;
+        WRN("could not dlopen(\"%s\", RTLD_NOW): %s", m->file, dlerror());
+        eina_error_set(EINA_ERROR_WRONG_MODULE);
+        return EINA_FALSE;
      }
 
    initcall = dlsym(dl_handle, EINA_MODULE_SYMBOL_INIT);
    if ((!initcall) || (!(*initcall)))
-     goto ok;
+      goto ok;
+
    if ((*initcall)() == EINA_TRUE)
-     goto ok;
+      goto ok;
 
    WRN("could not find eina's entry symbol %s inside module %s",
        EINA_MODULE_SYMBOL_INIT, m->file);
    eina_error_set(EINA_ERROR_MODULE_INIT_FAILED);
    dlclose(dl_handle);
    return EINA_FALSE;
- ok:
+ok:
    DBG("successfully loaded %s", m->file);
    m->handle = dl_handle;
- loaded:
+loaded:
    m->ref++;
    DBG("ref %d", m->ref);
 
@@ -402,14 +411,16 @@ EAPI Eina_Bool eina_module_unload(Eina_Module *m)
    m->ref--;
    if (!m->ref)
      {
-       shut = dlsym(m->handle, EINA_MODULE_SYMBOL_SHUTDOWN);
-       if ((shut) && (*shut))
-         (*shut)();
-       dlclose(m->handle);
-       m->handle = NULL;
-       DBG("unloaded module %s", m->file);
-       return EINA_TRUE;
+        shut = dlsym(m->handle, EINA_MODULE_SYMBOL_SHUTDOWN);
+        if ((shut) && (*shut))
+           (*shut)();
+
+        dlclose(m->handle);
+        m->handle = NULL;
+        DBG("unloaded module %s", m->file);
+        return EINA_TRUE;
      }
+
    return EINA_FALSE;
 }
 
@@ -425,9 +436,9 @@ EAPI Eina_Bool eina_module_unload(Eina_Module *m)
  * is @c NULL, or if it has not been correctly loaded before, the
  * function returns immediatly @c NULL.
  */
-EAPI void * eina_module_symbol_get(const Eina_Module *m, const char *symbol)
+EAPI void *eina_module_symbol_get(const Eina_Module *m, const char *symbol)
 {
-   EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(m,         NULL);
    EINA_SAFETY_ON_NULL_RETURN_VAL(m->handle, NULL);
    return dlsym(m->handle, symbol);
 }
@@ -442,7 +453,7 @@ EAPI void * eina_module_symbol_get(const Eina_Module *m, const char *symbol)
  * @c NULL, the function returns immediatly @c NULL. The returned
  * value must no be freed.
  */
-EAPI const char * eina_module_file_get(const Eina_Module *m)
+EAPI const char *eina_module_file_get(const Eina_Module *m)
 {
    EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL);
    return m->file;
@@ -456,35 +467,37 @@ EAPI char *eina_module_symbol_path_get(const void *symbol, const char *sub_dir)
    EINA_SAFETY_ON_NULL_RETURN_VAL(symbol, NULL);
 
    if (dladdr(symbol, &eina_dl))
-     {
-       if (strrchr(eina_dl.dli_fname, '/'))
-         {
-            char *path;
-            int l0;
-            int l1;
-            int l2 = 0;
-
-            l0 = strlen(eina_dl.dli_fname);
-            l1 = strlen(strrchr(eina_dl.dli_fname, '/'));
-            if (sub_dir && (*sub_dir != '\0'))
-              l2 = strlen(sub_dir);
-            path = malloc(l0 - l1 + l2 + 1);
-            if (path)
-              {
-                 memcpy(path, eina_dl.dli_fname, l0 - l1);
-                 if (sub_dir && (*sub_dir != '\0'))
-                   memcpy(path + l0 - l1, sub_dir, l2);
-                 path[l0 - l1 + l2] = '\0';
-                 return path;
-              }
-         }
-     }
+      if (strrchr(eina_dl.dli_fname, '/'))
+        {
+           char *path;
+           int l0;
+           int l1;
+           int l2 = 0;
+
+           l0 = strlen(eina_dl.dli_fname);
+           l1 = strlen(strrchr(eina_dl.dli_fname, '/'));
+           if (sub_dir && (*sub_dir != '\0'))
+              l2 = strlen(sub_dir);
+
+           path = malloc(l0 - l1 + l2 + 1);
+           if (path)
+             {
+                   memcpy(path,           eina_dl.dli_fname, l0 - l1);
+                if (sub_dir && (*sub_dir != '\0'))
+                   memcpy(path + l0 - l1, sub_dir,           l2);
+
+                path[l0 - l1 + l2] = '\0';
+                return path;
+             }
+        }
+
 #endif /* ! HAVE_DLADDR */
 
    return NULL;
 }
 
-EAPI char *eina_module_environment_path_get(const char *env, const char *sub_dir)
+EAPI char *eina_module_environment_path_get(const char *env,
+                                            const char *sub_dir)
 {
    const char *env_dir;
 
@@ -493,24 +506,25 @@ EAPI char *eina_module_environment_path_get(const char *env, const char *sub_dir
    env_dir = getenv(env);
    if (env_dir)
      {
-       char  *path;
-       size_t l1;
-       size_t l2 = 0;
-
-       l1 = strlen(env_dir);
-       if (sub_dir && (*sub_dir != '\0'))
-         l2 = strlen(sub_dir);
-
-       path = (char *)malloc(l1 + l2 + 1);
-       if (path)
-         {
-            memcpy(path, env_dir, l1);
-            if (sub_dir && (*sub_dir != '\0'))
-              memcpy(path + l1, sub_dir, l2);
-            path[l1 + l2] = '\0';
-
-            return path;
-         }
+        char *path;
+        size_t l1;
+        size_t l2 = 0;
+
+        l1 = strlen(env_dir);
+        if (sub_dir && (*sub_dir != '\0'))
+           l2 = strlen(sub_dir);
+
+        path = (char *)malloc(l1 + l2 + 1);
+        if (path)
+          {
+                memcpy(path,      env_dir, l1);
+             if (sub_dir && (*sub_dir != '\0'))
+                memcpy(path + l1, sub_dir, l2);
+
+             path[l1 + l2] = '\0';
+
+             return path;
+          }
      }
 
    return NULL;
@@ -524,15 +538,16 @@ static void _dir_arch_list_db(const char *name, const char *path, void *data)
    size_t length;
 
    length = strlen(path) + 1 + strlen(name) + 1 +
-     strlen((char *)(cb_data->data)) + 1 + sizeof("module") +
-     sizeof(SHARED_LIB_SUFFIX) + 1;
+      strlen((char *)(cb_data->data)) + 1 + sizeof("module") +
+      sizeof(SHARED_LIB_SUFFIX) + 1;
 
    file = alloca(length);
    snprintf(file, length, "%s/%s/%s/module" SHARED_LIB_SUFFIX,
             path, name, (char *)(cb_data->data));
    m = eina_module_new(file);
    if (!m)
-     return;
+      return;
+
    eina_array_push(cb_data->array, m);
 }
 
@@ -546,11 +561,14 @@ static void _dir_arch_list_db(const char *name, const char *path, void *data)
  * it won't be added to the list, if it is one, it will.
  * @param data Data passed to the callback function
  */
-EAPI Eina_Array * eina_module_arch_list_get(Eina_Array *array, const char *path, const char *arch)
+EAPI Eina_Array *eina_module_arch_list_get(Eina_Array *array,
+                                           const char *path,
+                                           const char *arch)
 {
    Dir_List_Get_Cb_Data list_get_cb_data;
 
-   if ((!path) || (!arch)) return array;
+   if ((!path) || (!arch))
+      return array;
 
    list_get_cb_data.array = array ? array : eina_array_new(4);
    list_get_cb_data.cb = NULL;
@@ -571,12 +589,17 @@ EAPI Eina_Array * eina_module_arch_list_get(Eina_Array *array, const char *path,
  * it won't be added to the list, if it is one, it will.
  * @param data Data passed to the callback function
  */
-EAPI Eina_Array * eina_module_list_get(Eina_Array *array, const char *path, unsigned int recursive, Eina_Module_Cb cb, void *data)
+EAPI Eina_Array *eina_module_list_get(Eina_Array *array,
+                                      const char *path,
+                                      unsigned int recursive,
+                                      Eina_Module_Cb cb,
+                                      void *data)
 {
    Dir_List_Get_Cb_Data list_get_cb_data;
    Dir_List_Cb_Data list_cb_data;
 
-   if (!path) return array;
+   if (!path)
+      return array;
 
    list_get_cb_data.array = array ? array : eina_array_new(4);
    list_get_cb_data.cb = cb;
@@ -607,22 +630,25 @@ eina_module_find(const Eina_Array *array, const char *module)
    Eina_Module *m;
 
    EINA_ARRAY_ITER_NEXT(array, i, m, iterator)
-   {
-      char *file_m;
-      char *tmp;
-      ssize_t len;
-
-      /* basename() can modify its argument, so we first get a copie */
-      /* do not use strdupa, as opensolaris does not have it */
-      len = strlen(eina_module_file_get(m));
-      tmp = alloca(len + 1);
-      memcpy(tmp, eina_module_file_get(m), len + 1);
-      file_m = basename(tmp);
-      len = strlen(file_m);
-      len -= sizeof(SHARED_LIB_SUFFIX) - 1;
-      if (len <= 0) continue;
-      if (!strncmp(module, file_m, len)) return m;
-   }
+     {
+        char *file_m;
+        char *tmp;
+        ssize_t len;
+
+        /* basename() can modify its argument, so we first get a copie */
+        /* do not use strdupa, as opensolaris does not have it */
+        len = strlen(eina_module_file_get(m));
+        tmp = alloca(len + 1);
+        memcpy(tmp, eina_module_file_get(m), len + 1);
+        file_m = basename(tmp);
+        len = strlen(file_m);
+        len -= sizeof(SHARED_LIB_SUFFIX) - 1;
+        if (len <= 0)
+           continue;
+
+        if (!strncmp(module, file_m, len))
+          return m;;
+     }
 
    return NULL;
 }
diff --git a/src/lib/eina_private.h b/src/lib/eina_private.h
new file mode 100644 (file)
index 0000000..2f8ff81
--- /dev/null
@@ -0,0 +1,135 @@
+/* EINA - EFL data type library
+ * Copyright (C) 2008 Carsten Haitzler, Vincent Torri, Jorge Luis Zapata Muga
+ *
+ * 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/>.
+ */
+
+#ifndef EINA_PRIVATE_H_
+#define EINA_PRIVATE_H_
+
+#include <stdarg.h>
+
+#if HAVE___ATTRIBUTE__
+# define __UNUSED__ __attribute__((unused))
+#else
+# define __UNUSED__
+#endif
+
+#include "eina_magic.h"
+#include "eina_iterator.h"
+#include "eina_accessor.h"
+
+#ifndef MIN
+# define MIN(x, y) (((x) > (y)) ? (y) : (x))
+#endif
+
+#ifndef MAX
+# define MAX(x, y) (((x) > (y)) ? (x) : (y))
+#endif
+
+#ifndef ABS
+# define ABS(x) ((x) < 0 ? -(x) : (x))
+#endif
+
+#ifndef CLAMP
+# define CLAMP(x, min, \
+               max) (((x) > (max)) ? (max) : (((x) < (min)) ? (min) : (x)))
+#endif
+
+#define READBUFSIZ 65536
+
+#define EINA_LOG_COLOR_DEFAULT "\033[36m"
+
+/* eina magic types */
+#define EINA_MAGIC_SHARE 0x98761234
+#define EINA_MAGIC_SHARE_HEAD 0x98761235
+#define EINA_MAGIC_STRINGSHARE_NODE 0x98761254
+#define EINA_MAGIC_USTRINGSHARE_NODE 0x98761255
+#define EINA_MAGIC_BINSHARE_NODE 0x98761256
+
+#define EINA_MAGIC_LIST 0x98761237
+#define EINA_MAGIC_LIST_ITERATOR 0x98761238
+#define EINA_MAGIC_LIST_ACCESSOR 0x98761239
+#define EINA_MAGIC_LIST_ACCOUNTING 0x9876123a
+
+#define EINA_MAGIC_ARRAY 0x9876123b
+#define EINA_MAGIC_ARRAY_ITERATOR 0x9876123c
+#define EINA_MAGIC_ARRAY_ACCESSOR 0x9876123d
+
+#define EINA_MAGIC_HASH 0x9876123e
+#define EINA_MAGIC_HASH_ITERATOR 0x9876123f
+
+#define EINA_MAGIC_TILER 0x98761240
+#define EINA_MAGIC_TILER_ITERATOR 0x98761241
+
+#define EINA_MAGIC_MATRIXSPARSE 0x98761242
+#define EINA_MAGIC_MATRIXSPARSE_ROW 0x98761243
+#define EINA_MAGIC_MATRIXSPARSE_CELL 0x98761244
+#define EINA_MAGIC_MATRIXSPARSE_ITERATOR 0x98761245
+#define EINA_MAGIC_MATRIXSPARSE_ROW_ITERATOR 0x98761246
+#define EINA_MAGIC_MATRIXSPARSE_ROW_ACCESSOR 0x98761247
+#define EINA_MAGIC_MATRIXSPARSE_CELL_ITERATOR 0x98761248
+#define EINA_MAGIC_MATRIXSPARSE_CELL_ACCESSOR 0x98761249
+
+#define EINA_MAGIC_STRBUF 0x98761250
+#define EINA_MAGIC_USTRBUF 0x98761257
+
+#define EINA_MAGIC_QUADTREE 0x98761251
+#define EINA_MAGIC_QUADTREE_ROOT 0x98761252
+#define EINA_MAGIC_QUADTREE_ITEM 0x98761253
+
+/* undef the following, we want out version */
+#undef FREE
+#define FREE(ptr)                              \
+  do {                                         \
+     free(ptr);                                        \
+     ptr = NULL;                               \
+  } while(0);
+
+#undef IF_FREE
+#define IF_FREE(ptr)                           \
+  do {                                         \
+     if (ptr) {                                        \
+       free(ptr);                              \
+       ptr = NULL;                             \
+     }                                         \
+  } while(0);
+
+#undef IF_FN_DEL
+#define IF_FN_DEL(_fn, ptr)                    \
+  do {                                         \
+     if (ptr) {                                        \
+       _fn(ptr);                               \
+       ptr = NULL;                             \
+     }                                         \
+  } while(0);
+
+#define MAGIC_FREE(ptr)                                \
+  do {                                         \
+     if (ptr) {                                        \
+       EINA_MAGIC_SET(ptr, EINA_MAGIC_NONE);   \
+       FREE(ptr);                              \
+     }                                         \
+  } while(0);
+
+#ifdef EFL_HAVE_THREADS
+void eina_share_common_threads_init(void);
+void eina_share_common_threads_shutdown(void);
+void eina_log_threads_init(void);
+void eina_log_threads_shutdown(void);
+#endif
+
+#endif /* EINA_PRIVATE_H_ */
+
index 3514a2c..668de1f 100644 (file)
@@ -1,6 +1,3 @@
-/*
- * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
- */
 /* EINA - EFL data type library
  * Copyright (C) 2010 Cedric Bail
  *
@@ -50,32 +47,32 @@ static const char EINA_MAGIC_QUADTREE_STR[] = "Eina QuadTree";
 static const char EINA_MAGIC_QUADTREE_ROOT_STR[] = "Eina QuadTree Root";
 static const char EINA_MAGIC_QUADTREE_ITEM_STR[] = "Eina QuadTree Item";
 
-#define EINA_MAGIC_CHECK_QUADTREE(d, ...)              \
-  do {                                                 \
-     if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_QUADTREE))    \
-       {                                               \
-         EINA_MAGIC_FAIL(d, EINA_MAGIC_QUADTREE);      \
-         return __VA_ARGS__;                           \
-       }                                               \
-  } while(0);
-
-#define EINA_MAGIC_CHECK_QUADTREE_ROOT(d, ...)                 \
-  do {                                                         \
-     if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_QUADTREE_ROOT))       \
-       {                                                       \
-         EINA_MAGIC_FAIL(d, EINA_MAGIC_QUADTREE_ROOT);         \
-         return __VA_ARGS__;                                   \
-       }                                                       \
-  } while(0);
-
-#define EINA_MAGIC_CHECK_QUADTREE_ITEM(d, ...)                 \
-  do {                                                         \
-     if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_QUADTREE_ITEM))       \
-       {                                                       \
-         EINA_MAGIC_FAIL(d, EINA_MAGIC_QUADTREE_ITEM);         \
-         return __VA_ARGS__;                                   \
-       }                                                       \
-  } while(0);
+#define EINA_MAGIC_CHECK_QUADTREE(d, ...)               \
+   do {                                                  \
+        if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_QUADTREE))     \
+          {                                                \
+             EINA_MAGIC_FAIL(d, EINA_MAGIC_QUADTREE);      \
+             return __VA_ARGS__;                           \
+          }                                                \
+     } while(0);
+
+#define EINA_MAGIC_CHECK_QUADTREE_ROOT(d, ...)                  \
+   do {                                                          \
+        if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_QUADTREE_ROOT))        \
+          {                                                        \
+             EINA_MAGIC_FAIL(d, EINA_MAGIC_QUADTREE_ROOT);         \
+             return __VA_ARGS__;                                   \
+          }                                                        \
+     } while(0);
+
+#define EINA_MAGIC_CHECK_QUADTREE_ITEM(d, ...)                  \
+   do {                                                          \
+        if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_QUADTREE_ITEM))        \
+          {                                                        \
+             EINA_MAGIC_FAIL(d, EINA_MAGIC_QUADTREE_ITEM);         \
+             return __VA_ARGS__;                                   \
+          }                                                        \
+     } while(0);
 
 struct _Eina_QuadTree
 {
@@ -97,12 +94,14 @@ struct _Eina_QuadTree
 
    size_t index;
 
-   struct {
+   struct
+   {
       Eina_Quad_Callback v;
       Eina_Quad_Callback h;
    } func;
 
-   struct {
+   struct
+   {
       size_t w;
       size_t h;
    } geom;
@@ -171,12 +170,13 @@ eina_quadtree_root_free(Eina_QuadTree *q, Eina_QuadTree_Root *root)
 {
    Eina_QuadTree_Item *item;
 
-   if (!root) return NULL;
+   if (!root)
+      return NULL;
 
    EINA_MAGIC_CHECK_QUADTREE_ROOT(root, NULL);
 
    EINA_LIST_FREE(root->both, item)
-     eina_mempool_free(items_mp, item);
+   eina_mempool_free(items_mp, item);
 
    root->left = eina_quadtree_root_free(q, root->left);
    root->right = eina_quadtree_root_free(q, root->right);
@@ -189,39 +189,36 @@ eina_quadtree_root_free(Eina_QuadTree *q, Eina_QuadTree_Root *root)
 
 static Eina_QuadTree_Root *
 eina_quadtree_root_rebuild_pre(Eina_QuadTree *q,
-                              Eina_Inlist **change,
-                              Eina_QuadTree_Root *root)
+                               Eina_Inlist **change,
+                               Eina_QuadTree_Root *root)
 {
    Eina_QuadTree_Item *item;
 
-   if (!root) return NULL;
+   if (!root)
+      return NULL;
 
    EINA_LIST_FREE(root->both, item)
-     {
-       if (item->visible)
-         {
-            *change = eina_inlist_append(*change, EINA_INLIST_GET(item));
-         }
-       else if (!item->hidden)
-         {
-            q->hidden = eina_list_append(q->hidden, item);
-            item->hidden = EINA_TRUE;
-            item->root = NULL;
-         }
-     }
+   {
+      if (item->visible)
+         *change = eina_inlist_append(*change, EINA_INLIST_GET(item));
+      else if (!item->hidden)
+        {
+           q->hidden = eina_list_append(q->hidden, item);
+           item->hidden = EINA_TRUE;
+           item->root = NULL;
+        }
+   }
 
    root->left = eina_quadtree_root_rebuild_pre(q, change, root->left);
    root->right = eina_quadtree_root_rebuild_pre(q, change, root->right);
 
    EINA_MAGIC_SET(root, 0);
    if (q->root_count > 50)
-     {
-       eina_mempool_free(root_mp, root);
-     }
+      eina_mempool_free(root_mp, root);
    else
      {
-       eina_trash_push(&q->root_trash, root);
-       q->root_count++;
+        eina_trash_push(&q->root_trash, root);
+        q->root_count++;
      }
 
    return NULL;
@@ -229,107 +226,110 @@ eina_quadtree_root_rebuild_pre(Eina_QuadTree *q,
 
 static size_t
 _eina_quadtree_split(Eina_Inlist *objects,
-                    Eina_QuadTree_Root *root,
-                    Eina_Inlist **left,
-                    Eina_Inlist **right,
-                    Eina_Quad_Callback func,
-                    int border,
-                    int middle)
+                     Eina_QuadTree_Root *root,
+                     Eina_Inlist **left,
+                     Eina_Inlist **right,
+                     Eina_Quad_Callback func,
+                     int border,
+                     int middle)
 {
    Eina_QuadTree_Item *object;
 
    middle /= 2;
 
    if (middle <= 4)
-     {
-       while (objects)
-         {
-            object = EINA_INLIST_CONTAINER_GET(objects, Eina_QuadTree_Item);
-            objects = objects->next;
-
-            object->change = EINA_FALSE;
-            if (!object->visible)
-              {
-                 if (!object->hidden)
-                   {
-                      object->hidden = EINA_TRUE;
-                      object->quad->hidden = eina_list_append(object->quad->hidden,
-                                                              object);
-                   }
-                 continue;
-              }
-            if (object->hidden)
-              {
-                 object->hidden = EINA_FALSE;
-                 object->quad->hidden = eina_list_remove(object->quad->hidden, object);
-              }
-            if (!object->delete_me)
-              {
-                 if (root->sorted)
-                   {
-                      root->both = eina_list_sorted_insert(root->both,
-                                                           _eina_quadtree_item_cmp,
-                                                           object);
-                   }
-                 else
-                   {
-                      root->both = eina_list_append(root->both, object);
-                   }
-                 object->root = root;
-              }
-            else
-              {
-                 eina_quadtree_del(object);
-              }
-         }
-     }
+      while (objects)
+        {
+           object = EINA_INLIST_CONTAINER_GET(objects, Eina_QuadTree_Item);
+           objects = objects->next;
+
+           object->change = EINA_FALSE;
+           if (!object->visible)
+             {
+                if (!object->hidden)
+                  {
+                     object->hidden = EINA_TRUE;
+                     object->quad->hidden = eina_list_append(
+                           object->quad->hidden,
+                           object);
+                  }
+
+                continue;
+             }
+
+           if (object->hidden)
+             {
+                object->hidden = EINA_FALSE;
+                object->quad->hidden = eina_list_remove(object->quad->hidden,
+                                                        object);
+             }
+
+           if (!object->delete_me)
+             {
+                if (root->sorted)
+                   root->both = eina_list_sorted_insert(root->both,
+                                                        _eina_quadtree_item_cmp,
+                                                        object);
+                else
+                   root->both = eina_list_append(root->both, object);
+
+                object->root = root;
+             }
+           else
+              eina_quadtree_del(object);
+        }
    else
-     {
-       while (objects)
-         {
-            object = EINA_INLIST_CONTAINER_GET(objects, Eina_QuadTree_Item);
-            objects = objects->next;
-
-            object->change = EINA_FALSE;
-            if (!object->visible)
-              {
-                 if (!object->hidden)
-                   {
-                      object->hidden = EINA_TRUE;
-                      object->quad->hidden = eina_list_append(object->quad->hidden,
-                                                              object);
-                   }
-                 continue;
-              }
-            if (object->hidden)
-              {
-                 object->hidden = EINA_FALSE;
-                 object->quad->hidden = eina_list_remove(object->quad->hidden, object);
-              }
-            if (!object->delete_me)
-              {
-                 switch (func(object->object, border + middle))
-                   {
-                    case EINA_QUAD_LEFT:
-                       *left = eina_inlist_append(*left, EINA_INLIST_GET(object));
-                       break;
-                    case EINA_QUAD_RIGHT:
-                       *right = eina_inlist_append(*right, EINA_INLIST_GET(object));
-                       break;
-                    case EINA_QUAD_BOTH:
-                       root->both = eina_list_append(root->both, object);
-                       object->root = root;
-                       break;
-                    default:
-                       abort();
-                   }
-              }
-            else
-              {
-                 eina_quadtree_del(object);
-              }
-         }
-     }
+      while (objects)
+        {
+           object = EINA_INLIST_CONTAINER_GET(objects, Eina_QuadTree_Item);
+           objects = objects->next;
+
+           object->change = EINA_FALSE;
+           if (!object->visible)
+             {
+                if (!object->hidden)
+                  {
+                     object->hidden = EINA_TRUE;
+                     object->quad->hidden = eina_list_append(
+                           object->quad->hidden,
+                           object);
+                  }
+
+                continue;
+             }
+
+           if (object->hidden)
+             {
+                object->hidden = EINA_FALSE;
+                object->quad->hidden = eina_list_remove(object->quad->hidden,
+                                                        object);
+             }
+
+           if (!object->delete_me)
+             {
+                switch (func(object->object, border + middle))
+                  {
+                   case EINA_QUAD_LEFT:
+                      *left = eina_inlist_append(*left, EINA_INLIST_GET(object));
+                      break;
+
+                   case EINA_QUAD_RIGHT:
+                      *right =
+                         eina_inlist_append(*right, EINA_INLIST_GET(object));
+                      break;
+
+                   case EINA_QUAD_BOTH:
+                      root->both = eina_list_append(root->both, object);
+                      object->root = root;
+                      break;
+
+                   default:
+                      abort();
+                  }
+             }
+           else
+              eina_quadtree_del(object);
+        }
 
    return middle;
 }
@@ -337,8 +337,8 @@ _eina_quadtree_split(Eina_Inlist *objects,
 
 static Eina_QuadTree_Root *
 _eina_quadtree_update(Eina_QuadTree *q, Eina_QuadTree_Root *parent,
-                     Eina_QuadTree_Root *root, Eina_Inlist *objects,
-                     Eina_Bool direction, Eina_Rectangle *size)
+                      Eina_QuadTree_Root *root, Eina_Inlist *objects,
+                      Eina_Bool direction, Eina_Rectangle *size)
 {
    Eina_Inlist *right = NULL;
    Eina_Inlist *left = NULL;
@@ -346,48 +346,49 @@ _eina_quadtree_update(Eina_QuadTree *q, Eina_QuadTree_Root *parent,
    size_t h2;
 
    if (!objects)
-     return root;
+      return root;
 
    if (!root)
      {
-       root = eina_trash_pop(&q->root_trash);
-       if (!root) root = eina_mempool_malloc(root_mp, sizeof (Eina_QuadTree_Root));
-       else q->root_count--;
-       if (!root)
-         {
-            /* FIXME: NOT GOOD TIMING, WE ARE GOING TO LEAK MORE MEMORY */
-            return NULL;
-         }
-
-       root->parent = parent;
-       root->both = NULL;
-       root->left = NULL;
-       root->right = NULL;
-       root->sorted = EINA_TRUE;
-
-       EINA_MAGIC_SET(root, EINA_MAGIC_QUADTREE_ROOT);
+        root = eina_trash_pop(&q->root_trash);
+        if (!root)
+           root = eina_mempool_malloc(root_mp, sizeof (Eina_QuadTree_Root));
+        else
+           q->root_count--;
+
+        if (!root)
+           /* FIXME: NOT GOOD TIMING, WE ARE GOING TO LEAK MORE MEMORY */
+           return NULL;
+
+        root->parent = parent;
+        root->both = NULL;
+        root->left = NULL;
+        root->right = NULL;
+        root->sorted = EINA_TRUE;
+
+        EINA_MAGIC_SET(root, EINA_MAGIC_QUADTREE_ROOT);
      }
 
    w2 = 0;
    h2 = 0;
 
    if (direction)
-     w2 = _eina_quadtree_split(objects, root,
-                              &left, &right,
-                              q->func.h, size->x, size->w);
+      w2 = _eina_quadtree_split(objects, root,
+                                &left, &right,
+                                q->func.h, size->x, size->w);
    else
-     h2 = _eina_quadtree_split(objects, root,
-                              &left, &right,
-                              q->func.v, size->y, size->h);
+      h2 = _eina_quadtree_split(objects, root,
+                                &left, &right,
+                                q->func.v, size->y, size->h);
 
    size->w -= w2; size->h -= h2;
    root->left = _eina_quadtree_update(q, root,
-                                     root->left, left,
-                                     !direction, size);
+                                      root->left, left,
+                                      !direction, size);
    size->x += w2; size->y += h2;
    root->right = _eina_quadtree_update(q, root,
-                                      root->right, right,
-                                      !direction, size);
+                                       root->right, right,
+                                       !direction, size);
    size->x -= w2; size->y -= h2;
    size->w += w2; size->h += h2;
 
@@ -396,22 +397,24 @@ _eina_quadtree_update(Eina_QuadTree *q, Eina_QuadTree_Root *parent,
 
 static Eina_Inlist *
 _eina_quadtree_merge(Eina_Inlist *result,
-                    Eina_List *both)
+                     Eina_List *both)
 {
    Eina_QuadTree_Item *item;
    Eina_QuadTree_Item *b;
    Eina_Inlist *moving;
 
-   if (!both) return result;
+   if (!both)
+      return result;
+
    if (!result)
      {
-       Eina_List *l;
+        Eina_List *l;
 
-       EINA_LIST_FOREACH(both, l, item)
-         if (item->visible)
-           result = eina_inlist_append(result, EINA_INLIST_GET(item));
+        EINA_LIST_FOREACH(both, l, item)
+        if (item->visible)
+           result = eina_inlist_append(result, EINA_INLIST_GET(item));
 
-       return result;
+        return result;
      }
 
    moving = result;
@@ -421,52 +424,55 @@ _eina_quadtree_merge(Eina_Inlist *result,
 
    while (both && moving)
      {
-       if (!b->visible)
-         {
-            both = eina_list_next(both);
-            b = eina_list_data_get(both);
-            continue ;
-         }
-       if (_eina_quadtree_item_cmp(item, b) < 0)
-         {
-            /* moving is still lower than item, so we can continue to the next one. */
-            moving = moving->next;
-            item = EINA_INLIST_CONTAINER_GET(moving, Eina_QuadTree_Item);
-         }
-       else
-         {
-            /* we just get above the limit of both, so insert it */
-            result = eina_inlist_prepend_relative(result,
-                                                  EINA_INLIST_GET(b),
-                                                  moving);
-            both = eina_list_next(both);
-            b = eina_list_data_get(both);
-         }
+        if (!b->visible)
+          {
+             both = eina_list_next(both);
+             b = eina_list_data_get(both);
+             continue;
+          }
+
+        if (_eina_quadtree_item_cmp(item, b) < 0)
+          {
+             /* moving is still lower than item, so we can continue to the next one. */
+             moving = moving->next;
+             item = EINA_INLIST_CONTAINER_GET(moving, Eina_QuadTree_Item);
+          }
+        else
+          {
+             /* we just get above the limit of both, so insert it */
+             result = eina_inlist_prepend_relative(result,
+                                                   EINA_INLIST_GET(b),
+                                                   moving);
+             both = eina_list_next(both);
+             b = eina_list_data_get(both);
+          }
      }
 
    item = EINA_INLIST_CONTAINER_GET(result->last, Eina_QuadTree_Item);
 
    while (both)
      {
-       b = eina_list_data_get(both);
-       if (b->visible)
-         {
-            if (_eina_quadtree_item_cmp(item, b) < 0)
-              break;
-
-            result = eina_inlist_prepend_relative(result,
-                                                  EINA_INLIST_GET(b),
-                                                  result->last);
-         }
-       both = eina_list_next(both);
+        b = eina_list_data_get(both);
+        if (b->visible)
+          {
+             if (_eina_quadtree_item_cmp(item, b) < 0)
+                break;
+
+             result = eina_inlist_prepend_relative(result,
+                                                   EINA_INLIST_GET(b),
+                                                   result->last);
+          }
+
+        both = eina_list_next(both);
      }
 
    while (both)
      {
-       b = eina_list_data_get(both);
-       if (b->visible)
-         result = eina_inlist_append(result, EINA_INLIST_GET(b));
-       both = eina_list_next(both);
+        b = eina_list_data_get(both);
+        if (b->visible)
+           result = eina_inlist_append(result, EINA_INLIST_GET(b));
+
+        both = eina_list_next(both);
      }
 
    return result;
@@ -474,16 +480,17 @@ _eina_quadtree_merge(Eina_Inlist *result,
 
 static Eina_Inlist *
 _eina_quadtree_collide(Eina_Inlist *result,
-                      Eina_QuadTree_Root *root,
-                      Eina_Bool direction, Eina_Rectangle *size,
-                      Eina_Rectangle *target)
+                       Eina_QuadTree_Root *root,
+                       Eina_Bool direction, Eina_Rectangle *size,
+                       Eina_Rectangle *target)
 {
-   if (!root) return result;
+   if (!root)
+      return result;
 
    if (!root->sorted)
      {
-       root->both = eina_list_sort(root->both, -1, _eina_quadtree_item_cmp);
-       root->sorted = EINA_TRUE;
+        root->both = eina_list_sort(root->both, -1, _eina_quadtree_item_cmp);
+        root->sorted = EINA_TRUE;
      }
 
    result = _eina_quadtree_merge(result, root->both);
@@ -493,38 +500,41 @@ _eina_quadtree_collide(Eina_Inlist *result,
 
    if (direction)
      {
-       int middle = size->w / 2;
-
-       size->w -= middle;
-       if (eina_spans_intersect(size->x, size->w, target->x, target->w))
-         result = _eina_quadtree_collide(result, root->left,
-                                         !direction, size,
-                                         target);
-
-       size->x += middle;
-       if (eina_spans_intersect(size->x, size->w, target->x, target->w))
-         result = _eina_quadtree_collide(result, root->right,
-                                         !direction, size,
-                                         target);
-       size->x -= middle;
-       size->w += middle;
+        int middle = size->w / 2;
+
+        size->w -= middle;
+        if (eina_spans_intersect(size->x, size->w, target->x, target->w))
+           result = _eina_quadtree_collide(result, root->left,
+                                           !direction, size,
+                                           target);
+
+        size->x += middle;
+        if (eina_spans_intersect(size->x, size->w, target->x, target->w))
+           result = _eina_quadtree_collide(result, root->right,
+                                           !direction, size,
+                                           target);
+
+        size->x -= middle;
+        size->w += middle;
      }
    else
      {
-       int middle = size->h / 2;
-
-       size->h -= middle;
-       if (eina_spans_intersect(size->y, size->h, target->y, target->h))
-         result = _eina_quadtree_collide(result, root->left,
-                                         !direction, size,
-                                         target);
-       size->y += middle;
-       if (eina_spans_intersect(size->y, size->h, target->y, target->h))
-         result = _eina_quadtree_collide(result, root->right,
-                                         !direction, size,
-                                         target);
-       size->y -= middle;
-       size->h += middle;
+        int middle = size->h / 2;
+
+        size->h -= middle;
+        if (eina_spans_intersect(size->y, size->h, target->y, target->h))
+           result = _eina_quadtree_collide(result, root->left,
+                                           !direction, size,
+                                           target);
+
+        size->y += middle;
+        if (eina_spans_intersect(size->y, size->h, target->y, target->h))
+           result = _eina_quadtree_collide(result, root->right,
+                                           !direction, size,
+                                           target);
+
+        size->y -= middle;
+        size->h += middle;
      }
 
    return result;
@@ -533,53 +543,56 @@ _eina_quadtree_collide(Eina_Inlist *result,
 static void
 _eina_quadtree_remove(Eina_QuadTree_Item *object)
 {
-   if (!object->root) return ;
+   if (!object->root)
+      return;
 
    object->root->both = eina_list_remove(object->root->both, object);
-   if (object->root->both) goto end;
-   if (object->root->left) goto end;
-   if (object->root->right) goto end;
+   if (object->root->both)
+      goto end;
+
+   if (object->root->left)
+      goto end;
+
+   if (object->root->right)
+      goto end;
 
    /* The root is not usefull anymore... */
    if (object->root->parent)
      {
-       if (object->root->parent->left == object->root)
-         object->root->parent->left = NULL;
-       else
-         object->root->parent->right = NULL;
-       object->root->parent = NULL;
+        if (object->root->parent->left == object->root)
+           object->root->parent->left = NULL;
+        else
+           object->root->parent->right = NULL;
+
+        object->root->parent = NULL;
      }
    else
-     {
-       object->quad->root = NULL;
-     }
+      object->quad->root = NULL;
 
    if (object->quad->root_count > 50)
-     {
-       eina_mempool_free(root_mp, object->root);
-     }
+      eina_mempool_free(root_mp, object->root);
    else
      {
-       eina_trash_push(&object->quad->root_trash, object->root);
-       object->quad->root_count++;
+        eina_trash_push(&object->quad->root_trash, object->root);
+        object->quad->root_count++;
      }
 
- end:
+end:
    object->root = NULL;
 }
 
 EAPI Eina_QuadTree *
 eina_quadtree_new(size_t w, size_t h,
-                 Eina_Quad_Callback vertical, Eina_Quad_Callback horizontal)
+                  Eina_Quad_Callback vertical, Eina_Quad_Callback horizontal)
 {
    Eina_QuadTree *result;
 
    if (!vertical || !horizontal || h == 0 || w == 0)
-     return NULL;
+      return NULL;
 
    result = calloc(1, sizeof (Eina_QuadTree));
    if (!result)
-     return NULL;
+      return NULL;
 
    result->func.v = vertical;
    result->func.h = horizontal;
@@ -601,38 +614,39 @@ eina_quadtree_free(Eina_QuadTree *q)
 {
    Eina_QuadTree_Item *item;
 
-   if (!q) return ;
+   if (!q)
+      return;
 
    EINA_MAGIC_CHECK_QUADTREE(q);
 
    while (q->change)
      {
-       item = EINA_INLIST_CONTAINER_GET(q->change, Eina_QuadTree_Item);
-       q->change = q->change->next;
-       if (!item->hidden)
-         eina_mempool_free(items_mp, item);
+        item = EINA_INLIST_CONTAINER_GET(q->change, Eina_QuadTree_Item);
+        q->change = q->change->next;
+        if (!item->hidden)
+           eina_mempool_free(items_mp, item);
      }
 
    EINA_LIST_FREE(q->hidden, item)
-     eina_mempool_free(items_mp, item);
+   eina_mempool_free(items_mp, item);
 
    eina_quadtree_root_free(q, q->root);
 
    while (q->items_trash)
      {
-       item = eina_trash_pop(&q->items_trash);
-       eina_mempool_free(items_mp, item);
+        item = eina_trash_pop(&q->items_trash);
+        eina_mempool_free(items_mp, item);
      }
 
    while (q->root_trash)
      {
-       Eina_QuadTree_Root *root;
+        Eina_QuadTree_Root *root;
 
-       root = eina_trash_pop(&q->root_trash);
-       eina_mempool_free(root_mp, root);
+        root = eina_trash_pop(&q->root_trash);
+        eina_mempool_free(root_mp, root);
      }
 
-   EINA_MAGIC_SET(q, 0);
+        EINA_MAGIC_SET(q, 0);
    free(q);
 }
 
@@ -643,18 +657,24 @@ eina_quadtree_add(Eina_QuadTree *q, const void *object)
 
    EINA_MAGIC_CHECK_QUADTREE(q, NULL);
 
-   if (!object) return NULL;
+   if (!object)
+      return NULL;
 
    result = eina_trash_pop(&q->items_trash);
-   if (!result) result = eina_mempool_malloc(items_mp, sizeof (Eina_QuadTree_Item));
-   else q->items_count--;
-   if (!result) return NULL;
+   if (!result)
+      result = eina_mempool_malloc(items_mp, sizeof (Eina_QuadTree_Item));
+   else
+      q->items_count--;
+
+   if (!result)
+      return NULL;
 
    result->quad = q;
    result->root = NULL;
    result->object = object;
 
-   result->index = 0;
+   result->index = q->index++;
+
    result->change = EINA_TRUE;
    result->delete_me = EINA_FALSE;
    result->visible = EINA_TRUE;
@@ -671,7 +691,8 @@ eina_quadtree_add(Eina_QuadTree *q, const void *object)
 EAPI Eina_Bool
 eina_quadtree_del(Eina_QuadTree_Item *object)
 {
-   if (!object) return EINA_FALSE;
+   if (!object)
+      return EINA_FALSE;
 
    EINA_MAGIC_CHECK_QUADTREE_ITEM(object, EINA_FALSE);
 
@@ -679,28 +700,26 @@ eina_quadtree_del(Eina_QuadTree_Item *object)
 
    if (object->change)
      {
-       /* This object is still in the update array, delaying it's removal !*/
-       object->delete_me = EINA_TRUE;
-       object->visible = EINA_TRUE;
-       return EINA_TRUE;
+        /* This object is still in the update array, delaying it's removal !*/
+        object->delete_me = EINA_TRUE;
+        object->visible = EINA_TRUE;
+        return EINA_TRUE;
      }
 
    if (object->hidden)
      {
-       object->quad->hidden = eina_list_remove(object->quad->hidden, object);
-       object->hidden = EINA_TRUE;
+        object->quad->hidden = eina_list_remove(object->quad->hidden, object);
+        object->hidden = EINA_TRUE;
      }
 
    /* This object is not anymore inside the tree, we can remove it now !*/
    EINA_MAGIC_SET(object, 0);
    if (object->quad->items_count > 256)
-     {
-       eina_mempool_free(items_mp, object);
-     }
+      eina_mempool_free(items_mp, object);
    else
      {
-       object->quad->items_count++;
-       eina_trash_push(&object->quad->items_trash, object);
+        object->quad->items_count++;
+        eina_trash_push(&object->quad->items_trash, object);
      }
 
    return EINA_TRUE;
@@ -712,15 +731,16 @@ eina_quadtree_change(Eina_QuadTree_Item *object)
    EINA_MAGIC_CHECK_QUADTREE_ITEM(object, EINA_FALSE);
 
    if (object->delete_me || !object->visible)
-     return EINA_FALSE;
+      return EINA_FALSE;
 
    if (object->quad->resize)
-     return EINA_TRUE;
+      return EINA_TRUE;
 
    /* Delaying change until needed */
    if (!object->change)
-     object->quad->change = eina_inlist_append(object->quad->change,
-                                              EINA_INLIST_GET(object));
+      object->quad->change = eina_inlist_append(object->quad->change,
+                                                EINA_INLIST_GET(object));
+
    object->change = EINA_TRUE;
 
    _eina_quadtree_remove(object);
@@ -741,25 +761,16 @@ eina_quadtree_hide(Eina_QuadTree_Item *object)
 EAPI Eina_Bool
 eina_quadtree_show(Eina_QuadTree_Item *object)
 {
-   size_t tmp;
-
    EINA_MAGIC_CHECK_QUADTREE_ITEM(object, EINA_FALSE);
 
-   tmp = object->quad->index++;
-   if (object->index == tmp
-       && object->visible)
-     return EINA_TRUE;
-
-   object->index = tmp;
-   if (object->root)
-     object->root->sorted = EINA_FALSE;
    object->quad->lost = EINA_TRUE;
 
-   if (object->visible) return EINA_TRUE;
+   if (object->visible)
+      return EINA_TRUE;
 
    object->visible = EINA_TRUE;
    if (!object->change)
-     return eina_quadtree_change(object);
+      return eina_quadtree_change(object);
 
    return EINA_TRUE;
 }
@@ -774,20 +785,20 @@ eina_quadtree_collide(Eina_QuadTree *q, int x, int y, int w, int h)
    /* Now we need the tree to be up to date, so it's time */
    if (q->resize) /* Full rebuild needed ! */
      {
-       DBG("resizing quadtree");
-       q->root = eina_quadtree_root_rebuild_pre(q, &q->change, q->root);
-       q->resize = EINA_FALSE;
+        DBG("resizing quadtree");
+        q->root = eina_quadtree_root_rebuild_pre(q, &q->change, q->root);
+        q->resize = EINA_FALSE;
      }
 
    EINA_RECTANGLE_SET(&canvas, 0, 0, q->geom.w, q->geom.h);
 
    if (q->change)
      {
-       DBG("updating quadtree content");
-       q->root = _eina_quadtree_update(q, NULL, q->root, q->change,
-                                       EINA_FALSE, &canvas);
-       q->change = NULL;
-       q->lost = EINA_TRUE;
+        DBG("updating quadtree content");
+        q->root = _eina_quadtree_update(q, NULL, q->root, q->change,
+                                        EINA_FALSE, &canvas);
+        q->change = NULL;
+        q->lost = EINA_TRUE;
      }
 
    if (q->target.x != x
@@ -795,18 +806,18 @@ eina_quadtree_collide(Eina_QuadTree *q, int x, int y, int w, int h)
        || q->target.w != w
        || q->target.h != h)
      {
-       DBG("new target");
-       EINA_RECTANGLE_SET(&q->target, x, y, w, h);
-       q->lost = EINA_TRUE;
+        DBG("new target");
+        EINA_RECTANGLE_SET(&q->target, x, y, w, h);
+        q->lost = EINA_TRUE;
      }
 
    if (q->lost)
      {
-       DBG("computing collide");
-       q->cached = _eina_quadtree_collide(NULL, q->root,
-                                          EINA_FALSE, &canvas,
-                                          &q->target);
-       q->lost = EINA_FALSE;
+        DBG("computing collide");
+        q->cached = _eina_quadtree_collide(NULL, q->root,
+                                           EINA_FALSE, &canvas,
+                                           &q->target);
+        q->lost = EINA_FALSE;
      }
 
    return q->cached;
@@ -817,16 +828,19 @@ eina_quadtree_object(Eina_Inlist *item)
 {
    Eina_QuadTree_Item *qi;
 
-   if (!item) return NULL;
+   if (!item)
+      return NULL;
 
    qi = EINA_INLIST_CONTAINER_GET(item, Eina_QuadTree_Item);
-   if (!qi) return NULL;
+   if (!qi)
+      return NULL;
 
    EINA_MAGIC_CHECK_QUADTREE_ITEM(qi, NULL);
 
-   if (!qi->visible) return NULL;
+   if (!qi->visible)
+      return NULL;
 
-   return (void*) qi->object;
+   return (void *)qi->object;
 }
 
 EAPI void
@@ -836,7 +850,7 @@ eina_quadtree_resize(Eina_QuadTree *q, size_t w, size_t h)
 
    if (q->geom.w == w
        && q->geom.h == h)
-     return ;
+      return;
 
    q->resize = EINA_TRUE;
    q->geom.w = w;
@@ -851,26 +865,41 @@ eina_quadtree_cycle(Eina_QuadTree *q)
    q->index = 0;
 }
 
+EAPI void
+eina_quadtree_increase(Eina_QuadTree_Item *object)
+{
+   size_t tmp;
+
+   tmp = object->quad->index++;
+   if (object->index == tmp)
+      return;
+
+   object->index = tmp;
+   if (object->root)
+      object->root->sorted = EINA_FALSE;
+}
+
 Eina_Bool
 eina_quadtree_init(void)
 {
-   _eina_log_qd_dom = eina_log_domain_register("eina_quadtree", EINA_LOG_COLOR_DEFAULT);
+   _eina_log_qd_dom = eina_log_domain_register("eina_quadtree",
+                                               EINA_LOG_COLOR_DEFAULT);
    if (_eina_log_qd_dom < 0)
      {
-       EINA_LOG_ERR("Could not register log domain: eina_quadtree");
-       return EINA_FALSE;
+        EINA_LOG_ERR("Could not register log domain: eina_quadtree");
+        return EINA_FALSE;
      }
 
-#define EMS(n) eina_magic_string_static_set(n, n##_STR)
+#define EMS(n) eina_magic_string_static_set(n, n ## _STR)
    EMS(EINA_MAGIC_QUADTREE);
    EMS(EINA_MAGIC_QUADTREE_ROOT);
    EMS(EINA_MAGIC_QUADTREE_ITEM);
 #undef EMS
 
    items_mp = eina_mempool_add("chained_mempool", "QuadTree Item", NULL,
-                              sizeof (Eina_QuadTree_Item), 320);
+                               sizeof (Eina_QuadTree_Item), 320);
    root_mp = eina_mempool_add("chained_mempool", "QuadTree Root", NULL,
-                             sizeof (Eina_QuadTree_Root), 32);
+                              sizeof (Eina_QuadTree_Root), 32);
 
    return EINA_TRUE;
 }
index 7ed4d19..6d4130b 100644 (file)
@@ -33,8 +33,8 @@
 #include "eina_rbtree.h"
 
 /*============================================================================*
- *                                  Local                                     *
- *============================================================================*/
+*                                  Local                                     *
+*============================================================================*/
 
 #define EINA_RBTREE_ITERATOR_PREFIX_MASK  0x1
 #define EINA_RBTREE_ITERATOR_INFIX_MASK   0x2
@@ -65,14 +65,15 @@ _eina_rbtree_iterator_list_new(const Eina_Rbtree *tree)
 {
    Eina_Iterator_Rbtree_List *new;
 
-   eina_error_set(0);
+        eina_error_set(0);
    new = malloc(sizeof (Eina_Iterator_Rbtree_List));
-   if (!new) {
-      eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
-      return NULL;
-   }
+   if (!new)
+     {
+        eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+        return NULL;
+     }
 
-   new->tree = (Eina_Rbtree*) tree;
+   new->tree = (Eina_Rbtree *)tree;
    new->dir = EINA_RBTREE_RIGHT;
    new->up = EINA_FALSE;
 
@@ -82,7 +83,9 @@ _eina_rbtree_iterator_list_new(const Eina_Rbtree *tree)
 static Eina_Rbtree *
 _eina_rbtree_iterator_get_content(Eina_Iterator_Rbtree *it)
 {
-   if (eina_array_count_get(it->stack) <= 0) return NULL;
+   if (eina_array_count_get(it->stack) <= 0)
+      return NULL;
+
    return eina_array_data_get(it->stack, 0);
 }
 
@@ -97,7 +100,7 @@ _eina_rbtree_iterator_free(Eina_Iterator_Rbtree *it)
      free(item);
 
    eina_array_free(it->stack);
-   free(it);
+                     free(it);
 }
 
 static Eina_Bool
@@ -107,58 +110,70 @@ _eina_rbtree_iterator_next(Eina_Iterator_Rbtree *it, void **data)
    Eina_Iterator_Rbtree_List *new;
    Eina_Rbtree *tree;
 
-   if (eina_array_count_get(it->stack) <= 0) return EINA_FALSE;
+   if (eina_array_count_get(it->stack) <= 0)
+      return EINA_FALSE;
 
    last = eina_array_data_get(it->stack, eina_array_count_get(it->stack) - 1);
    tree = last->tree;
 
    if (last->tree == NULL || last->up == EINA_TRUE)
      {
-       last = eina_array_pop(it->stack);
-       while (last->dir == EINA_RBTREE_LEFT
-              || last->tree == NULL)
-         {
-            if (tree)
-              if ((it->mask & EINA_RBTREE_ITERATOR_POSTFIX_MASK) == EINA_RBTREE_ITERATOR_POSTFIX_MASK)
-                {
-                   free(last);
-
-                   if (eina_array_count_get(it->stack) > 0)
-                     {
-                        last = eina_array_data_get(it->stack, eina_array_count_get(it->stack) - 1);
-                        last->up = EINA_TRUE;
-                     }
-
-                   goto onfix;
-                }
-
-            free(last);
-
-            last = eina_array_pop(it->stack);
-            if (!last) return EINA_FALSE;
-            tree = last->tree;
-         }
-
-       last->dir = EINA_RBTREE_LEFT;
-       last->up = EINA_FALSE;
-
-       eina_array_push(it->stack, last);
-
-       if ((it->mask & EINA_RBTREE_ITERATOR_INFIX_MASK) == EINA_RBTREE_ITERATOR_INFIX_MASK)
-         goto onfix;
+        last = eina_array_pop(it->stack);
+        while (last->dir == EINA_RBTREE_LEFT
+               || last->tree == NULL)
+          {
+             if (tree)
+                if ((it->mask & EINA_RBTREE_ITERATOR_POSTFIX_MASK) ==
+                    EINA_RBTREE_ITERATOR_POSTFIX_MASK)
+                  {
+                     free(last);
+
+                     if (eina_array_count_get(it->stack) > 0)
+                       {
+                          last = eina_array_data_get(it->stack,
+                                                     eina_array_count_get(
+                                                        it->
+                                                        stack)
+                                                     - 1);
+                          last->up = EINA_TRUE;
+                       }
+
+                     goto onfix;
+                  }
+
+             free(last);
+
+             last = eina_array_pop(it->stack);
+             if (!last)
+                return EINA_FALSE;
+
+             tree = last->tree;
+          }
+
+        last->dir = EINA_RBTREE_LEFT;
+        last->up = EINA_FALSE;
+
+        eina_array_push(it->stack, last);
+
+        if ((it->mask & EINA_RBTREE_ITERATOR_INFIX_MASK) ==
+            EINA_RBTREE_ITERATOR_INFIX_MASK)
+           goto onfix;
      }
 
    new = _eina_rbtree_iterator_list_new(last->tree->son[last->dir]);
-   if (!new) return EINA_FALSE;
-   eina_array_push(it->stack, new);
+   if (!new)
+      return EINA_FALSE;
+
+        eina_array_push(it->stack, new);
 
    if (last->dir == EINA_RBTREE_RIGHT)
-     if ((it->mask & EINA_RBTREE_ITERATOR_PREFIX_MASK) == EINA_RBTREE_ITERATOR_PREFIX_MASK)
-       goto onfix;
+      if ((it->mask & EINA_RBTREE_ITERATOR_PREFIX_MASK) ==
+          EINA_RBTREE_ITERATOR_PREFIX_MASK)
+         goto onfix;
 
    return _eina_rbtree_iterator_next(it, data);
 
- onfix:
+onfix:
    *data = tree;
    return EINA_TRUE;
 }
@@ -171,31 +186,38 @@ _eina_rbtree_iterator_build(const Eina_Rbtree *root, unsigned char mask)
 
    eina_error_set(0);
    it = calloc(1, sizeof (Eina_Iterator_Rbtree));
-   if (!it) {
-      eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
-      return NULL;
-   }
+   if (!it)
+     {
+        eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+        return NULL;
+     }
 
    it->stack = eina_array_new(8);
-   if (!it->stack) goto on_error;
+   if (!it->stack)
+      goto on_error2;
 
    first = _eina_rbtree_iterator_list_new(root);
-   if (!first) goto on_error;
+   if (!first)
+      goto on_error;
+
    eina_array_push(it->stack, first);
 
    it->mask = mask;
 
+   it->iterator.version = EINA_ITERATOR_VERSION;
    it->iterator.next = FUNC_ITERATOR_NEXT(_eina_rbtree_iterator_next);
-   it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(_eina_rbtree_iterator_get_content);
+   it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
+         _eina_rbtree_iterator_get_content);
    it->iterator.free = FUNC_ITERATOR_FREE(_eina_rbtree_iterator_free);
 
    EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
 
    return &it->iterator;
 
- on_error:
-   if (it && it->stack) eina_array_free(it->stack);
-   if (it) free(it);
+on_error:
+   eina_array_free(it->stack);
+on_error2:
+   free(it);
 
    return NULL;
 }
@@ -208,7 +230,8 @@ _eina_rbtree_iterator_build(const Eina_Rbtree *root, unsigned char mask)
 static void
 _eina_rbtree_node_init(Eina_Rbtree *node)
 {
-   if (!node) return ;
+   if (!node)
+      return;
 
    node->son[0] = NULL;
    node->son[1] = NULL;
@@ -223,7 +246,8 @@ _eina_rbtree_is_red(Eina_Rbtree *node)
 }
 
 static inline Eina_Rbtree *
-_eina_rbtree_inline_single_rotation(Eina_Rbtree *node, Eina_Rbtree_Direction dir)
+_eina_rbtree_inline_single_rotation(Eina_Rbtree *node,
+                                    Eina_Rbtree_Direction dir)
 {
    Eina_Rbtree *save = node->son[!dir];
 
@@ -237,26 +261,30 @@ _eina_rbtree_inline_single_rotation(Eina_Rbtree *node, Eina_Rbtree_Direction dir
 }
 
 static inline Eina_Rbtree *
-_eina_rbtree_inline_double_rotation(Eina_Rbtree *node, Eina_Rbtree_Direction dir)
+_eina_rbtree_inline_double_rotation(Eina_Rbtree *node,
+                                    Eina_Rbtree_Direction dir)
 {
    node->son[!dir] = _eina_rbtree_inline_single_rotation(node->son[!dir], !dir);
    return _eina_rbtree_inline_single_rotation(node, dir);
 }
 
 /*============================================================================*
- *                                 Global                                     *
- *============================================================================*/
+*                                 Global                                     *
+*============================================================================*/
 
 /*============================================================================*
- *                                   API                                      *
- *============================================================================*/
+*                                   API                                      *
+*============================================================================*/
 
 EAPI Eina_Rbtree *
-eina_rbtree_inline_insert(Eina_Rbtree *root, Eina_Rbtree *node, Eina_Rbtree_Cmp_Node_Cb cmp, const void *data)
+eina_rbtree_inline_insert(Eina_Rbtree *root,
+                          Eina_Rbtree *node,
+                          Eina_Rbtree_Cmp_Node_Cb cmp,
+                          const void *data)
 {
    Eina_Rbtree head;
-   Eina_Rbtree *g, *t;  /* Grandparent & parent */
-   Eina_Rbtree *p, *q;  /* Iterator & parent */
+   Eina_Rbtree *g, *t; /* Grandparent & parent */
+   Eina_Rbtree *p, *q; /* Iterator & parent */
    /* WARNING:
       Compiler is not able to understand the underlying algorithm and don't know that
       first top node is always black, so it will never use last before running the loop
@@ -265,16 +293,17 @@ eina_rbtree_inline_insert(Eina_Rbtree *root, Eina_Rbtree *node, Eina_Rbtree_Cmp_
    Eina_Rbtree_Direction dir, last;
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(node, root);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(cmp, root);
+   EINA_SAFETY_ON_NULL_RETURN_VAL( cmp, root);
 
-   if (!node) return root;
+   if (!node)
+      return root;
 
    _eina_rbtree_node_init(node);
 
    if (!root)
      {
-       root = node;
-       goto end_add;
+        root = node;
+        goto end_add;
      }
 
    memset(&head, 0, sizeof (Eina_Rbtree));
@@ -286,52 +315,51 @@ eina_rbtree_inline_insert(Eina_Rbtree *root, Eina_Rbtree *node, Eina_Rbtree_Cmp_
    q = t->son[1] = root;
 
    /* Search down the tree */
-   for (;;)
+   for (;; )
      {
-       if (q == NULL)
-         {
-            /* Insert new node at the bottom */
-            p->son[dir] = q = node;
-         }
-       else if (_eina_rbtree_is_red(q->son[0])
-                && _eina_rbtree_is_red(q->son[1]))
-         {
-            /* Color flip */
-            q->color = EINA_RBTREE_RED;
-            q->son[0]->color = EINA_RBTREE_BLACK;
-            q->son[1]->color = EINA_RBTREE_BLACK;
-         }
-
-       /* Fix red violation */
-       if (_eina_rbtree_is_red(q) && _eina_rbtree_is_red(p))
-         {
-            Eina_Rbtree_Direction dir2;
-
-            dir2 = (t->son[1] == g) ? EINA_RBTREE_RIGHT : EINA_RBTREE_LEFT;
-
-            if (q == p->son[last])
-              t->son[dir2] = _eina_rbtree_inline_single_rotation(g, !last);
-            else
-              t->son[dir2] = _eina_rbtree_inline_double_rotation(g, !last);
-         }
-
-       /* Stop if found */
-       if (q == node)
-         break;
-
-       last = dir;
-       dir = cmp(q, node, (void*) data);
-
-       /* Update helpers */
-       if ( g != NULL )
-         t = g;
-       g = p, p = q;
-       q = q->son[dir];
+        if (q == NULL)
+           /* Insert new node at the bottom */
+           p->son[dir] = q = node;
+        else if (_eina_rbtree_is_red(q->son[0])
+                 && _eina_rbtree_is_red(q->son[1]))
+          {
+             /* Color flip */
+             q->color = EINA_RBTREE_RED;
+             q->son[0]->color = EINA_RBTREE_BLACK;
+             q->son[1]->color = EINA_RBTREE_BLACK;
+          }
+
+        /* Fix red violation */
+        if (_eina_rbtree_is_red(q) && _eina_rbtree_is_red(p))
+          {
+             Eina_Rbtree_Direction dir2;
+
+             dir2 = (t->son[1] == g) ? EINA_RBTREE_RIGHT : EINA_RBTREE_LEFT;
+
+             if (q == p->son[last])
+                t->son[dir2] = _eina_rbtree_inline_single_rotation(g, !last);
+             else
+                t->son[dir2] = _eina_rbtree_inline_double_rotation(g, !last);
+          }
+
+        /* Stop if found */
+        if (q == node)
+           break;
+
+        last = dir;
+        dir = cmp(q, node, (void *)data);
+
+        /* Update helpers */
+        if ( g != NULL )
+           t = g;
+
+        g = p, p = q;
+        q = q->son[dir];
      }
 
    root = head.son[1];
 
- end_add:
+end_add:
    /* Make root black */
    root->color = EINA_RBTREE_BLACK;
 
@@ -339,7 +367,10 @@ eina_rbtree_inline_insert(Eina_Rbtree *root, Eina_Rbtree *node, Eina_Rbtree_Cmp_
 }
 
 EAPI Eina_Rbtree *
-eina_rbtree_inline_remove(Eina_Rbtree *root, Eina_Rbtree *node, Eina_Rbtree_Cmp_Node_Cb cmp, const void *data)
+eina_rbtree_inline_remove(Eina_Rbtree *root,
+                          Eina_Rbtree *node,
+                          Eina_Rbtree_Cmp_Node_Cb cmp,
+                          const void *data)
 {
    Eina_Rbtree head;
    Eina_Rbtree *q, *p;
@@ -347,9 +378,10 @@ eina_rbtree_inline_remove(Eina_Rbtree *root, Eina_Rbtree *node, Eina_Rbtree_Cmp_
    Eina_Rbtree_Direction dir;
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(node, root);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(cmp, root);
+   EINA_SAFETY_ON_NULL_RETURN_VAL( cmp, root);
 
-   if (!root || !node) return root;
+   if (!root || !node)
+      return root;
 
    memset(&head, 0, sizeof(Eina_Rbtree));
 
@@ -361,94 +393,100 @@ eina_rbtree_inline_remove(Eina_Rbtree *root, Eina_Rbtree *node, Eina_Rbtree_Cmp_
    /* Search and push a red down */
    while (q->son[dir] != NULL)
      {
-       Eina_Rbtree_Direction last = dir;
-       Eina_Rbtree *g;
-
-       /* Update helpers */
-       g = p; p = q;
-       q = q->son[dir];
-       dir = cmp(q, node, (void*) data);
-
-       /* Save parent node found */
-       if (q == node)
-         f = p;
-
-       /* Push the red node down */
-       if (!_eina_rbtree_is_red(q)
-           && !_eina_rbtree_is_red(q->son[dir]))
-         {
-            if (_eina_rbtree_is_red(q->son[!dir]))
-              q = p->son[last] = _eina_rbtree_inline_single_rotation(q, dir);
-            else if (!_eina_rbtree_is_red(q->son[!dir])) {
-               Eina_Rbtree *s = p->son[!last];
-
-               if (s != NULL)
-                 {
-                    if (!_eina_rbtree_is_red(s->son[EINA_RBTREE_LEFT])
-                        && !_eina_rbtree_is_red(s->son[EINA_RBTREE_RIGHT]))
-                      {
-                         /* Color flip */
-                         p->color = EINA_RBTREE_BLACK;
-                         p->son[EINA_RBTREE_LEFT]->color = EINA_RBTREE_RED;
-                         p->son[EINA_RBTREE_RIGHT]->color = EINA_RBTREE_RED;
-                      }
-                    else
-                      {
-                         Eina_Rbtree_Direction dir2;
-
-                         dir2 = g->son[1] == p ? EINA_RBTREE_RIGHT : EINA_RBTREE_LEFT;
-
-                         if (_eina_rbtree_is_red(s->son[last]))
-                           {
-                              g->son[dir2] = _eina_rbtree_inline_double_rotation(p, last);
-                              if (f == g)
-                                {
-                                   p = g->son[dir2]->son[last];
-                                   f = g->son[dir2];
-                                }
-                           }
-                         else if (_eina_rbtree_is_red(s->son[!last]))
-                           {
-                              g->son[dir2] = _eina_rbtree_inline_single_rotation(p, last);
-                              if (f == g)
-                                {
-                                   p = g->son[dir2]->son[last];
-                                   f = g->son[dir2];
-                                }
-                           }
-
-                         /* Ensure correct coloring */
-                         q->color = g->son[dir2]->color = EINA_RBTREE_RED;
-                         g->son[dir2]->son[EINA_RBTREE_LEFT]->color = EINA_RBTREE_BLACK;
-                         g->son[dir2]->son[EINA_RBTREE_RIGHT]->color = EINA_RBTREE_BLACK;
-                      }
-                 }
-            }
-         }
+        Eina_Rbtree_Direction last = dir;
+        Eina_Rbtree *g;
+
+        /* Update helpers */
+        g = p; p = q;
+        q = q->son[dir];
+        dir = cmp(q, node, (void *)data);
+
+        /* Save parent node found */
+        if (q == node)
+           f = p;
+
+        /* Push the red node down */
+        if (!_eina_rbtree_is_red(q)
+            && !_eina_rbtree_is_red(q->son[dir]))
+          {
+             if (_eina_rbtree_is_red(q->son[!dir]))
+                q = p->son[last] = _eina_rbtree_inline_single_rotation(q, dir);
+             else if (!_eina_rbtree_is_red(q->son[!dir]))
+               {
+                  Eina_Rbtree *s = p->son[!last];
+
+                  if (s != NULL)
+                    {
+                       if (!_eina_rbtree_is_red(s->son[EINA_RBTREE_LEFT])
+                           && !_eina_rbtree_is_red(s->son[EINA_RBTREE_RIGHT]))
+                         {
+/* Color flip */
+                            p->color = EINA_RBTREE_BLACK;
+                            p->son[EINA_RBTREE_LEFT]->color = EINA_RBTREE_RED;
+                            p->son[EINA_RBTREE_RIGHT]->color = EINA_RBTREE_RED;
+                         }
+                       else
+                         {
+                            Eina_Rbtree_Direction dir2;
+
+                            dir2 = g->son[1] ==
+                               p ? EINA_RBTREE_RIGHT : EINA_RBTREE_LEFT;
+
+                            if (_eina_rbtree_is_red(s->son[last]))
+                              {
+                                 g->son[dir2] =
+                                    _eina_rbtree_inline_double_rotation(p, last);
+                                 if (f == g)
+                                   {
+                                      p = g->son[dir2]->son[last];
+                                      f = g->son[dir2];
+                                   }
+                              }
+                            else if (_eina_rbtree_is_red(s->son[!last]))
+                              {
+                                 g->son[dir2] =
+                                    _eina_rbtree_inline_single_rotation(p, last);
+                                 if (f == g)
+                                   {
+                                      p = g->son[dir2]->son[last];
+                                      f = g->son[dir2];
+                                   }
+                              }
+
+/* Ensure correct coloring */
+                            q->color = g->son[dir2]->color = EINA_RBTREE_RED;
+                            g->son[dir2]->son[EINA_RBTREE_LEFT]->color =
+                               EINA_RBTREE_BLACK;
+                            g->son[dir2]->son[EINA_RBTREE_RIGHT]->color =
+                               EINA_RBTREE_BLACK;
+                         }
+                    }
+               }
+          }
      }
 
    /* Replace and remove if found */
    if (f != NULL)
      {
-       /* 'q' should take the place of 'node' parent */
-       f->son[f->son[1] == node] = q;
+        /* 'q' should take the place of 'node' parent */
+        f->son[f->son[1] == node] = q;
 
-       /* Switch the link from the parent to q's son */
-       p->son[p->son[1] == q] = q->son[q->son[0] == NULL];
+        /* Switch the link from the parent to q's son */
+        p->son[p->son[1] == q] = q->son[q->son[0] == NULL];
 
-       /* Put q at the place of node */
-       q->son[0] = node->son[0];
-       q->son[1] = node->son[1];
-       q->color = node->color;
+        /* Put q at the place of node */
+        q->son[0] = node->son[0];
+        q->son[1] = node->son[1];
+        q->color = node->color;
 
-       /* Reset node link */
-       node->son[0] = NULL;
-       node->son[1] = NULL;
+        /* Reset node link */
+        node->son[0] = NULL;
+        node->son[1] = NULL;
      }
 
    root = head.son[1];
    if (root != NULL)
-     root->color = EINA_RBTREE_BLACK;
+      root->color = EINA_RBTREE_BLACK;
 
    return root;
 }
@@ -531,7 +569,8 @@ eina_rbtree_iterator_postfix(const Eina_Rbtree *root)
 EAPI void
 eina_rbtree_delete(Eina_Rbtree *root, Eina_Rbtree_Free_Cb func, void *data)
 {
-   if (!root) return ;
+   if (!root)
+      return;
 
    EINA_SAFETY_ON_NULL_RETURN(func);
 
index 169768e..9f7920b 100644 (file)
@@ -40,8 +40,8 @@
 #include "eina_rectangle.h"
 
 /*============================================================================*
- *                                  Local                                     *
- *============================================================================*/
+*                                  Local                                     *
+*============================================================================*/
 
 /**
  * @cond LOCAL
@@ -78,17 +78,17 @@ struct _Eina_Rectangle_Alloc
    EINA_MAGIC
 };
 
-#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_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)
+#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)
 
 static Eina_Mempool *_eina_rectangle_alloc_mp = NULL;
 static Eina_Mempool *_eina_rectangle_mp = NULL;
@@ -123,47 +123,49 @@ _eina_rectangle_merge_list(Eina_List *empty, Eina_Rectangle *r)
 
    if (r->w == 0 || r->h == 0)
      {
-       eina_rectangle_free(r);
-       return empty;
+        eina_rectangle_free(r);
+        return empty;
      }
 
- start_again:
+start_again:
    xw = r->x + r->w;
    yh = r->y + r->h;
 
    EINA_LIST_FOREACH(empty, l, match)
-     {
-       if (match->x == r->x && match->w == r->w
-           && (match->y == yh || r->y == match->y + match->h))
-         {
-            if (match->y > r->y)
-              match->y = r->y;
-            match->h += r->h;
+   {
+      if (match->x == r->x && match->w == r->w
+          && (match->y == yh || r->y == match->y + match->h))
+        {
+           if (match->y > r->y)
+              match->y = r->y;
 
-            eina_rectangle_free(r);
+           match->h += r->h;
 
-            empty = eina_list_remove_list(empty, l);
+           eina_rectangle_free(r);
 
-            r = match;
+           empty = eina_list_remove_list(empty, l);
 
-            goto start_again;
-         }
-       else if (match->y == r->y && match->h == r->h
-                && (match->x == xw || r->x == match->x + match->w))
-         {
-            if (match->x > r->x)
-              match->x = r->x;
-            match->w += r->w;
+           r = match;
 
-            eina_rectangle_free(r);
+           goto start_again;
+        }
+      else if (match->y == r->y && match->h == r->h
+               && (match->x == xw || r->x == match->x + match->w))
+        {
+           if (match->x > r->x)
+              match->x = r->x;
 
-            empty = eina_list_remove_list(empty, l);
+           match->w += r->w;
 
-            r = match;
+           eina_rectangle_free(r);
 
-            goto start_again;
-         }
-     }
+           empty = eina_list_remove_list(empty, l);
+
+           r = match;
+
+           goto start_again;
+        }
+   }
 
    return eina_list_append(empty, r);
 }
@@ -175,60 +177,65 @@ _eina_rectangle_empty_space_find(Eina_List *empty, int w, int h, int *x, int *y)
    Eina_List *l;
 
    EINA_LIST_FOREACH(empty, l, r)
-     {
-       if (r->w >= w && r->h >= h)
-         {
-            /* 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;
-              }
-            else if (r->h == h)
-              {
-                 r->x += w;
-                 r->w -= w;
-              }
-            else
-              {
-                 int rx1, ry1, rw1, rh1;
-                 int x2, y2, w2, h2;
-
-                 rx1 = r->x + w;
-                 ry1 = r->y;
-                 rw1 = 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 (rw1 * r->h > h2 * r->w)
-                   {
-                      rh1 = r->h;
-                      w2 = w;
-                   }
-                 else
-                   {
-                      rh1 = h;
-                      w2 = r->w;
-                   }
-
-                 EINA_RECTANGLE_SET(r, rx1, ry1, rw1, rh1);
-                 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;
-         }
-     }
+   {
+      if (r->w >= w && r->h >= h)
+        {
+           /* 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;
+             }
+           else if (r->h == h)
+             {
+                r->x += w;
+                r->w -= w;
+             }
+           else
+             {
+                int rx1, ry1, rw1, rh1;
+                int x2, y2, w2, h2;
+
+                rx1 = r->x + w;
+                ry1 = r->y;
+                rw1 = 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 (rw1 * r->h > h2 * r->w)
+                  {
+                     rh1 = r->h;
+                     w2 = w;
+                  }
+                else
+                  {
+                     rh1 = h;
+                     w2 = r->w;
+                  }
+
+                EINA_RECTANGLE_SET(r, rx1, ry1, rw1, rh1);
+                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;
+        }
+   }
 
    *x = -1;
    *y = -1;
@@ -240,19 +247,20 @@ _eina_rectangle_empty_space_find(Eina_List *empty, int w, int h, int *x, int *y)
  */
 
 /*============================================================================*
- *                                 Global                                     *
- *============================================================================*/
+*                                 Global                                     *
+*============================================================================*/
 
 Eina_Bool
 eina_rectangle_init(void)
 {
    const char *choice, *tmp;
 
-   _eina_rectangle_log_dom = eina_log_domain_register("eina_rectangle", EINA_LOG_COLOR_DEFAULT);
+   _eina_rectangle_log_dom = eina_log_domain_register("eina_rectangle",
+                                                      EINA_LOG_COLOR_DEFAULT);
    if (_eina_rectangle_log_dom < 0)
      {
-       EINA_LOG_ERR("Could not register log domain: eina_rectangle");
-       return EINA_FALSE;
+        EINA_LOG_ERR("Could not register log domain: eina_rectangle");
+        return EINA_FALSE;
      }
 
 #ifdef EINA_DEFAULT_MEMPOOL
@@ -262,11 +270,11 @@ eina_rectangle_init(void)
 #endif
    tmp = getenv("EINA_MEMPOOL");
    if (tmp && tmp[0])
-     choice = tmp;
+      choice = tmp;
 
    _eina_rectangle_alloc_mp = eina_mempool_add
-     (choice, "rectangle-alloc", NULL,
-      sizeof(Eina_Rectangle_Alloc) + sizeof(Eina_Rectangle), 1024);
+         (choice, "rectangle-alloc", NULL,
+         sizeof(Eina_Rectangle_Alloc) + sizeof(Eina_Rectangle), 1024);
    if (!_eina_rectangle_alloc_mp)
      {
         ERR("Mempool for rectangle cannot be allocated in rectangle init.");
@@ -274,7 +282,7 @@ eina_rectangle_init(void)
      }
 
    _eina_rectangle_mp = eina_mempool_add
-     (choice, "rectangle", NULL, sizeof(Eina_Rectangle), 256);
+         (choice, "rectangle", NULL, sizeof(Eina_Rectangle), 256);
    if (!_eina_rectangle_mp)
      {
         ERR("Mempool for rectangle cannot be allocated in rectangle init.");
@@ -283,7 +291,7 @@ eina_rectangle_init(void)
 
    return EINA_TRUE;
 
- init_error:
+init_error:
    eina_log_domain_unregister(_eina_rectangle_log_dom);
    _eina_rectangle_log_dom = -1;
 
@@ -296,7 +304,7 @@ eina_rectangle_shutdown(void)
    Eina_Rectangle *del;
 
    while ((del = eina_trash_pop(&_eina_rectangles)))
-     eina_mempool_free(_eina_rectangle_mp, del);
+      eina_mempool_free(_eina_rectangle_mp, del);
    _eina_rectangles_count = 0;
 
    eina_mempool_del(_eina_rectangle_alloc_mp);
@@ -309,8 +317,8 @@ eina_rectangle_shutdown(void)
 }
 
 /*============================================================================*
- *                                   API                                      *
- *============================================================================*/
+*                                   API                                      *
+*============================================================================*/
 
 /**
  * @brief Create a new rectangle.
@@ -333,14 +341,14 @@ eina_rectangle_new(int x, int y, int w, int h)
 
    if (_eina_rectangles)
      {
-       rect = eina_trash_pop(&_eina_rectangles);
-       _eina_rectangles_count--;
+        rect = eina_trash_pop(&_eina_rectangles);
+        _eina_rectangles_count--;
      }
    else
-     {
-       rect = eina_mempool_malloc(_eina_rectangle_mp, sizeof (Eina_Rectangle));
-     }
-   if (!rect) return NULL;
+      rect = eina_mempool_malloc(_eina_rectangle_mp, sizeof (Eina_Rectangle));
+
+   if (!rect)
+      return NULL;
 
    EINA_RECTANGLE_SET(rect, x, y, w, h);
 
@@ -360,13 +368,11 @@ eina_rectangle_free(Eina_Rectangle *rect)
    EINA_SAFETY_ON_NULL_RETURN(rect);
 
    if (_eina_rectangles_count > BUCKET_THRESHOLD)
-     {
-       eina_mempool_free(_eina_rectangle_mp, rect);
-     }
+      eina_mempool_free(_eina_rectangle_mp, rect);
    else
      {
-       eina_trash_push(&_eina_rectangles, rect);
-       _eina_rectangles_count++;
+        eina_trash_push(&_eina_rectangles, rect);
+        _eina_rectangles_count++;
      }
 }
 
@@ -376,7 +382,8 @@ eina_rectangle_pool_new(int w, int h)
    Eina_Rectangle_Pool *new;
 
    new = malloc(sizeof (Eina_Rectangle_Pool));
-   if (!new) return NULL;
+   if (!new)
+      return NULL;
 
    new->head = NULL;
    new->empty = eina_list_append(NULL, eina_rectangle_new(0, 0, w, h));
@@ -403,21 +410,21 @@ eina_rectangle_pool_free(Eina_Rectangle_Pool *pool)
        pool, pool->w, pool->h, pool->references);
    while (pool->head)
      {
-       del = (Eina_Rectangle_Alloc*) pool->head;
+        del = (Eina_Rectangle_Alloc *)pool->head;
 
-       pool->head = (EINA_INLIST_GET(del))->next;
+        pool->head = (EINA_INLIST_GET(del))->next;
 
-       EINA_MAGIC_SET(del, EINA_MAGIC_NONE);
-       eina_mempool_free(_eina_rectangle_alloc_mp, del);
+        EINA_MAGIC_SET(del, EINA_MAGIC_NONE);
+        eina_mempool_free(_eina_rectangle_alloc_mp, del);
      }
 
    while (pool->bucket)
      {
-       del = eina_trash_pop(&pool->bucket);
-       eina_mempool_free(_eina_rectangle_alloc_mp, del);
+        del = eina_trash_pop(&pool->bucket);
+        eina_mempool_free(_eina_rectangle_alloc_mp, del);
      }
 
-   MAGIC_FREE(pool);
+        MAGIC_FREE(pool);
 }
 
 /**
@@ -448,33 +455,40 @@ eina_rectangle_pool_request(Eina_Rectangle_Pool *pool, int w, int h)
    DBG("pool=%p, size=(%d, %d), references=%u",
        pool, pool->w, pool->h, pool->references);
 
-   if (w <= 0 || h <= 0) return NULL;
-   if (w > pool->w || h > pool->h) return NULL;
+   if (w <= 0 || h <= 0)
+      return NULL;
+
+   if (w > pool->w || h > pool->h)
+      return NULL;
 
    /* 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_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;
+   if (x == -1)
+      return NULL;
+
    pool->sorted = EINA_FALSE;
 
    if (pool->bucket_count > 0)
      {
-       new = eina_trash_pop(&pool->bucket);
-       pool->bucket_count--;
+        new = eina_trash_pop(&pool->bucket);
+        pool->bucket_count--;
      }
    else
-     {
-       new = eina_mempool_malloc(_eina_rectangle_alloc_mp,
-                                 sizeof (Eina_Rectangle_Alloc) + sizeof (Eina_Rectangle));
-     }
-   if (!new) return NULL;
+      new = eina_mempool_malloc(_eina_rectangle_alloc_mp,
+                                sizeof (Eina_Rectangle_Alloc) +
+                                sizeof (Eina_Rectangle));
 
-   rect = (Eina_Rectangle*) (new + 1);
+   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));
@@ -492,7 +506,7 @@ eina_rectangle_pool_request(Eina_Rectangle_Pool *pool, int w, int h)
 EAPI void
 eina_rectangle_pool_release(Eina_Rectangle *rect)
 {
-   Eina_Rectangle_Alloc *era = ((Eina_Rectangle_Alloc *) rect) - 1;
+   Eina_Rectangle_Alloc *era = ((Eina_Rectangle_Alloc *)rect) - 1;
    Eina_Rectangle *r;
 
    EINA_SAFETY_ON_NULL_RETURN(rect);
@@ -509,23 +523,23 @@ eina_rectangle_pool_release(Eina_Rectangle *rect)
    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;
+        era->pool->empty = _eina_rectangle_merge_list(era->pool->empty, r);
+        era->pool->sorted = EINA_FALSE;
      }
 
    if (era->pool->bucket_count < BUCKET_THRESHOLD)
      {
-       Eina_Rectangle_Pool *pool;
+        Eina_Rectangle_Pool *pool;
 
-       pool = era->pool;
+        pool = era->pool;
 
-       pool->bucket_count++;
-       eina_trash_push(&pool->bucket, era);
+        pool->bucket_count++;
+        eina_trash_push(&pool->bucket, era);
      }
    else
      {
-       EINA_MAGIC_SET(era, EINA_MAGIC_NONE);
-       eina_mempool_free(_eina_rectangle_alloc_mp, era);
+        EINA_MAGIC_SET(era, EINA_MAGIC_NONE);
+        eina_mempool_free(_eina_rectangle_alloc_mp, era);
      }
 }
 
@@ -541,7 +555,7 @@ eina_rectangle_pool_release(Eina_Rectangle *rect)
 EAPI Eina_Rectangle_Pool *
 eina_rectangle_pool_get(Eina_Rectangle *rect)
 {
-   Eina_Rectangle_Alloc *era = ((Eina_Rectangle_Alloc *) rect) - 1;
+   Eina_Rectangle_Alloc *era = ((Eina_Rectangle_Alloc *)rect) - 1;
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(rect, NULL);
 
@@ -569,7 +583,7 @@ eina_rectangle_pool_data_set(Eina_Rectangle_Pool *pool, const void *data)
    DBG("data=%p pool=%p, size=(%d, %d), references=%u",
        data, pool, pool->w, pool->h, pool->references);
 
-   pool->data = (void*) data;
+   pool->data = (void *)data;
 }
 
 /**
@@ -607,13 +621,17 @@ eina_rectangle_pool_data_get(Eina_Rectangle_Pool *pool)
 EAPI Eina_Bool
 eina_rectangle_pool_geometry_get(Eina_Rectangle_Pool *pool, int *w, int *h)
 {
-   if (!pool) return EINA_FALSE;
+   if (!pool)
+      return EINA_FALSE;
 
    EINA_MAGIC_CHECK_RECTANGLE_POOL(pool);
    EINA_SAFETY_ON_NULL_RETURN_VAL(pool, EINA_FALSE);
 
-   if (w) *w = pool->w;
-   if (h) *h = pool->h;
+   if (w)
+      *w = pool->w;
+
+   if (h)
+      *h = pool->h;
 
    return EINA_TRUE;
 }
index d897be7..09aa298 100644 (file)
 #include "eina_safety_checks.h"
 
 /*============================================================================*
- *                                  Local                                     *
- *============================================================================*/
+*                                  Local                                     *
+*============================================================================*/
 
 /*============================================================================*
- *                                 Global                                     *
- *============================================================================*/
+*                                 Global                                     *
+*============================================================================*/
 
 /**
  * @internal
@@ -51,8 +51,8 @@ eina_safety_checks_shutdown(void)
 }
 
 /*============================================================================*
- *                                   API                                      *
- *============================================================================*/
+*                                   API                                      *
+*============================================================================*/
 
 /**
  * @addtogroup Eina_Safety_Checks_Group Safety Checks
@@ -104,7 +104,8 @@ static const char EINA_ERROR_SAFETY_FAILED_STR[] = "Safety check failed.";
 Eina_Bool
 eina_safety_checks_init(void)
 {
-   EINA_ERROR_SAFETY_FAILED = eina_error_msg_static_register(EINA_ERROR_SAFETY_FAILED_STR);
+   EINA_ERROR_SAFETY_FAILED = eina_error_msg_static_register(
+         EINA_ERROR_SAFETY_FAILED_STR);
    return EINA_TRUE;
 }
 
diff --git a/src/lib/eina_share_common.c b/src/lib/eina_share_common.c
new file mode 100644 (file)
index 0000000..876b1ee
--- /dev/null
@@ -0,0 +1,973 @@
+/* EINA - EFL data type library
+ * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2010
+ *                         Carsten Haitzler,
+ *                         Jorge Luis Zapata Muga,
+ *                         Cedric Bail,
+ *                         Gustavo Sverzut Barbieri
+ *                         Tom Hacohen
+ *                         Brett Nash
+ *
+ * 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/>.
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright (C) 2008 Peter Wehrfritz
+ *
+ *  Permission is hereby granted, free of charge, to any person obtaining a copy
+ *  of this software and associated documentation files (the "Software"), to
+ *  deal in the Software without restriction, including without limitation the
+ *  rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ *  sell copies of the Software, and to permit persons to whom the Software is
+ *  furnished to do so, subject to the following conditions:
+ *
+ *  The above copyright notice and this permission notice shall be included in
+ *  all copies of the Software and its Copyright notices. In addition publicly
+ *  documented acknowledgment must be given that this software has been used if no
+ *  source code of this software is made available publicly. This includes
+ *  acknowledgments in either Copyright notices, Manuals, Publicity and Marketing
+ *  documents or any documentation provided with any product containing this
+ *  software. This License does not apply to any software that links to the
+ *  libraries provided by this software (statically or dynamically), but only to
+ *  the software provided.
+ *
+ *  Please see the OLD-COPYING.PLAIN for a plain-english explanation of this notice
+ *  and it's intent.
+ *
+ *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ *  THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ *  IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ *  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <stddef.h>
+
+#ifdef EFL_HAVE_POSIX_THREADS
+# include <pthread.h>
+#endif
+
+#ifdef HAVE_EVIL
+# include <Evil.h>
+#endif
+
+#include "eina_config.h"
+#include "eina_private.h"
+#include "eina_hash.h"
+#include "eina_rbtree.h"
+#include "eina_error.h"
+
+/* undefs EINA_ARG_NONULL() so NULL checks are not compiled out! */
+#include "eina_safety_checks.h"
+#include "eina_share_common.h"
+
+/*============================================================================*
+*                                  Local                                     *
+*============================================================================*/
+
+/**
+ * @cond LOCAL
+ */
+
+#define EINA_SHARE_COMMON_BUCKETS 256
+#define EINA_SHARE_COMMON_MASK 0xFF
+
+static const char EINA_MAGIC_SHARE_STR[] = "Eina Share";
+static const char EINA_MAGIC_SHARE_HEAD_STR[] = "Eina Share Head";
+
+
+#define EINA_MAGIC_CHECK_SHARE_COMMON_HEAD(d, unlock, ...)      \
+   do {                                                          \
+        if (!EINA_MAGIC_CHECK((d), EINA_MAGIC_SHARE_HEAD))  \
+          {                                                           \
+             EINA_MAGIC_FAIL((d), EINA_MAGIC_SHARE_HEAD);    \
+             unlock;                                                 \
+             return __VA_ARGS__;                                     \
+          }                                                           \
+     } while (0)
+
+#define EINA_MAGIC_CHECK_SHARE_COMMON_NODE(d, _node_magic, unlock)              \
+   do {                                                          \
+        if (!EINA_MAGIC_CHECK((d), _node_magic))    \
+          {                                                           \
+             unlock;                                                   \
+             EINA_MAGIC_FAIL((d), _node_magic);        \
+          }                                                           \
+     } while (0)
+
+#ifdef EINA_SHARE_USAGE
+typedef struct _Eina_Share_Common_Population Eina_Share_Common_Population;
+#endif
+
+typedef struct _Eina_Share_Common Eina_Share_Common;
+typedef struct _Eina_Share_Common_Node Eina_Share_Common_Node;
+typedef struct _Eina_Share_Common_Head Eina_Share_Common_Head;
+
+int _eina_share_common_log_dom = -1;
+
+struct _Eina_Share
+{
+   Eina_Share_Common *share;
+   Eina_Magic node_magic;
+#ifdef EINA_SHARE_COMMON_USAGE
+   Eina_Share_Common_Population population;
+   int max_node_population;
+#endif
+};
+
+struct _Eina_Share_Common
+{
+   Eina_Share_Common_Head *buckets[EINA_SHARE_COMMON_BUCKETS];
+
+   EINA_MAGIC
+};
+
+struct _Eina_Share_Common_Node
+{
+   Eina_Share_Common_Node *next;
+
+   EINA_MAGIC
+
+   unsigned int length;
+   unsigned int references;
+   char str[];
+};
+
+struct _Eina_Share_Common_Head
+{
+   EINA_RBTREE;
+   EINA_MAGIC
+
+   int hash;
+
+#ifdef EINA_SHARE_COMMON_USAGE
+   int population;
+#endif
+
+   Eina_Share_Common_Node *head;
+   Eina_Share_Common_Node builtin_node;
+};
+
+#ifdef EFL_HAVE_THREADS
+Eina_Bool _share_common_threads_activated = EINA_FALSE;
+
+# ifdef EFL_HAVE_POSIX_THREADS
+static pthread_mutex_t _mutex_big = PTHREAD_MUTEX_INITIALIZER;
+#  define SHARE_COMMON_LOCK_BIG() if(_share_common_threads_activated) \
+      pthread_mutex_lock(&_mutex_big)
+#  define SHARE_COMMON_UNLOCK_BIG() if(_share_common_threads_activated) \
+      pthread_mutex_unlock(&_mutex_big)
+# else /* EFL_HAVE_WIN32_THREADS */
+static HANDLE _mutex_big = NULL;
+#  define SHARE_COMMON_LOCK_BIG() if(_share_common_threads_activated) \
+      WaitForSingleObject(_mutex_big, INFINITE)
+#  define SHARE_COMMON_UNLOCK_BIG() if(_share_common_threads_activated) \
+      ReleaseMutex(_mutex_big)
+
+# endif /* EFL_HAVE_WIN32_THREADS */
+#else /* EFL_HAVE_THREADS */
+# define SHARE_COMMON_LOCK_BIG() do {} while (0)
+# define SHARE_COMMON_UNLOCK_BIG() do {} while (0)
+#endif
+
+#ifdef EINA_SHARE_COMMON_USAGE
+struct _Eina_Share_Common_Population
+{
+   int count;
+   int max;
+};
+
+static Eina_Share_Common_Population population = { 0, 0 };
+
+static Eina_Share_Common_Population population_group[4] =
+{
+   { 0, 0 },
+   { 0, 0 },
+   { 0, 0 },
+   { 0, 0 }
+};
+
+static void
+_eina_share_common_population_init(Eina_Share *share)
+{
+   unsigned int i;
+
+   for (i = 0;
+        i < sizeof (share->population_group) /
+        sizeof (share->population_group[0]);
+        ++i)
+     {
+        share->population_group[i].count = 0;
+        share->population_group[i].max = 0;
+     }
+}
+
+static void
+_eina_share_common_population_shutdown(Eina_Share *share)
+{
+   unsigned int i;
+
+   share->max_node_population = 0;
+   share->population.count = 0;
+   share->population.max = 0;
+
+   for (i = 0;
+        i < sizeof (share->population_group) /
+        sizeof (share->population_group[0]);
+        ++i)
+     {
+        share->population_group[i].count = 0;
+        share->population_group[i].max = 0;
+     }
+}
+
+static void
+_eina_share_common_population_stats(Eina_Share *share)
+{
+   unsigned int i;
+
+      fprintf(stderr, "eina share_common statistic:\n");
+      fprintf(stderr,
+           " * maximum shared strings : %i\n",
+           share->population.max);
+      fprintf(stderr,
+           " * maximum shared strings per node : %i\n",
+           share->max_node_population);
+
+   for (i = 0;
+        i < sizeof (share->population_group) /
+        sizeof (share->population_group[0]);
+        ++i)
+      fprintf(stderr,
+              "DDD: %i strings of length %i, max strings: %i\n",
+              share->population_group[i].count,
+              i,
+              share->population_group[i].max);
+}
+
+void
+eina_share_common_population_add(Eina_Share *share, int slen)
+{
+   SHARE_COMMON_LOCK_BIG();
+
+   share->population.count++;
+   if (share->population.count > share->population.max)
+      share->population.max = share->population.count;
+
+   if (slen < 4)
+     {
+        share->population_group[slen].count++;
+        if (share->population_group[slen].count >
+            share->population_group[slen].max)
+           share->population_group[slen].max =
+              share->population_group[slen].count;
+     }
+
+   SHARE_COMMON_UNLOCK_BIG();
+}
+
+void
+eina_share_common_population_del(Eina_Share *share, int slen)
+{
+   SHARE_COMMON_LOCK_BIG();
+
+   share->population.count--;
+   if (slen < 4)
+      share->population_group[slen].count--;
+
+   SHARE_COMMON_UNLOCK_BIG();
+}
+
+static void
+_eina_share_common_population_head_init(Eina_Share *share,
+                                        Eina_Share_Common_Head *head)
+{
+   head->population = 1;
+}
+
+static void
+_eina_share_common_population_head_add(Eina_Share *share,
+                                       Eina_Share_Common_Head *head)
+{
+   head->population++;
+   if (head->population > share->max_node_population)
+      share->max_node_population = head->population;
+}
+
+static void
+_eina_share_common_population_head_del(Eina_Share *share,
+                                       Eina_Share_Common_Head *head)
+{
+   head->population--;
+}
+
+#else /* EINA_SHARE_COMMON_USAGE undefined */
+
+static void _eina_share_common_population_init(__UNUSED__ Eina_Share *share) {
+}
+static void _eina_share_common_population_shutdown(__UNUSED__ Eina_Share *share)
+{
+}
+static void _eina_share_common_population_stats(__UNUSED__ Eina_Share *share) {
+}
+void eina_share_common_population_add(__UNUSED__ Eina_Share *share,
+                                      __UNUSED__ int slen) {
+}
+void eina_share_common_population_del(__UNUSED__ Eina_Share *share,
+                                      __UNUSED__ int slen) {
+}
+static void _eina_share_common_population_head_init(
+   __UNUSED__ Eina_Share *share,
+   __UNUSED__ Eina_Share_Common_Head *head) {
+}
+static void _eina_share_common_population_head_add(
+   __UNUSED__ Eina_Share *share,
+   __UNUSED__
+   Eina_Share_Common_Head *head) {
+}
+static void _eina_share_common_population_head_del(
+   __UNUSED__ Eina_Share *share,
+   __UNUSED__
+   Eina_Share_Common_Head *head) {
+}
+#endif
+
+static int
+_eina_share_common_cmp(const Eina_Share_Common_Head *ed,
+                       const int *hash,
+                       __UNUSED__ int length,
+                       __UNUSED__ void *data)
+{
+   EINA_MAGIC_CHECK_SHARE_COMMON_HEAD(ed, , 0);
+
+   return ed->hash - *hash;
+}
+
+static Eina_Rbtree_Direction
+_eina_share_common_node(const Eina_Share_Common_Head *left,
+                        const Eina_Share_Common_Head *right,
+                        __UNUSED__ void *data)
+{
+   EINA_MAGIC_CHECK_SHARE_COMMON_HEAD(left,  , 0);
+   EINA_MAGIC_CHECK_SHARE_COMMON_HEAD(right, , 0);
+
+   if (left->hash - right->hash < 0)
+      return EINA_RBTREE_LEFT;
+
+   return EINA_RBTREE_RIGHT;
+}
+
+static void
+_eina_share_common_head_free(Eina_Share_Common_Head *ed, __UNUSED__ void *data)
+{
+   EINA_MAGIC_CHECK_SHARE_COMMON_HEAD(ed, );
+
+   while (ed->head)
+     {
+        Eina_Share_Common_Node *el = ed->head;
+
+        ed->head = ed->head->next;
+        if (el != &ed->builtin_node)
+           MAGIC_FREE(el);
+     }
+           MAGIC_FREE(ed);
+}
+
+static void
+_eina_share_common_node_init(Eina_Share_Common_Node *node,
+                             const char *str,
+                             int slen,
+                             unsigned int null_size,
+                             Eina_Magic node_magic)
+{
+   EINA_MAGIC_SET(node, node_magic);
+   node->references = 1;
+   node->length = slen;
+   memcpy(node->str, str, slen);
+   memset(node->str + slen, 0, null_size); /* Nullify the null */
+
+   (void) node_magic; /* When magic are disable, node_magic is unused, this remove a warning. */
+}
+
+static Eina_Share_Common_Head *
+_eina_share_common_head_alloc(int slen)
+{
+   Eina_Share_Common_Head *head;
+   const size_t head_size = offsetof(Eina_Share_Common_Head, builtin_node.str);
+
+   head = malloc(head_size + slen);
+   if (!head)
+      eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+
+   return head;
+}
+
+static const char *
+_eina_share_common_add_head(Eina_Share *share,
+                            Eina_Share_Common_Head **p_bucket,
+                            int hash,
+                            const char *str,
+                            unsigned int slen,
+                            unsigned int null_size)
+{
+   Eina_Rbtree **p_tree = (Eina_Rbtree **)p_bucket;
+   Eina_Share_Common_Head *head;
+
+   head = _eina_share_common_head_alloc(slen + null_size);
+   if (!head)
+      return NULL;
+
+   EINA_MAGIC_SET(head, EINA_MAGIC_SHARE_HEAD);
+   head->hash = hash;
+   head->head = &head->builtin_node;
+   _eina_share_common_node_init(head->head,
+                                str,
+                                slen,
+                                null_size,
+                                share->node_magic);
+   head->head->next = NULL;
+
+   _eina_share_common_population_head_init(share, head);
+
+   *p_tree = eina_rbtree_inline_insert
+         (*p_tree, EINA_RBTREE_GET(head),
+         EINA_RBTREE_CMP_NODE_CB(_eina_share_common_node), NULL);
+
+   return head->head->str;
+}
+
+static void
+_eina_share_common_del_head(Eina_Share_Common_Head **p_bucket,
+                            Eina_Share_Common_Head *head)
+{
+   Eina_Rbtree **p_tree = (Eina_Rbtree **)p_bucket;
+
+   *p_tree = eina_rbtree_inline_remove
+         (*p_tree, EINA_RBTREE_GET(head),
+         EINA_RBTREE_CMP_NODE_CB(_eina_share_common_node), NULL);
+
+         MAGIC_FREE(head);
+}
+
+
+static inline Eina_Bool
+_eina_share_common_node_eq(const Eina_Share_Common_Node *node,
+                           const char *str,
+                           unsigned int slen)
+{
+   return ((node->length == slen) &&
+           (memcmp(node->str, str, slen) == 0));
+}
+
+static Eina_Share_Common_Node *
+_eina_share_common_head_find(Eina_Share_Common_Head *head,
+                             const char *str,
+                             unsigned int slen)
+{
+   Eina_Share_Common_Node *node, *prev;
+
+   node = head->head;
+   if (_eina_share_common_node_eq(node, str, slen))
+      return node;
+
+   prev = node;
+   node = node->next;
+   for (; node != NULL; prev = node, node = node->next)
+      if (_eina_share_common_node_eq(node, str, slen))
+        {
+           /* promote node, make hot items be at the beginning */
+           prev->next = node->next;
+           node->next = head->head;
+           head->head = node;
+           return node;
+        }
+
+   return NULL;
+}
+
+static Eina_Bool
+_eina_share_common_head_remove_node(Eina_Share_Common_Head *head,
+                                    const Eina_Share_Common_Node *node)
+{
+   Eina_Share_Common_Node *cur, *prev;
+
+   if (head->head == node)
+     {
+        head->head = node->next;
+        return 1;
+     }
+
+   prev = head->head;
+   cur = head->head->next;
+   for (; cur != NULL; prev = cur, cur = cur->next)
+      if (cur == node)
+        {
+           prev->next = cur->next;
+           return 1;
+        }
+
+   return 0;
+}
+
+static Eina_Share_Common_Head *
+_eina_share_common_find_hash(Eina_Share_Common_Head *bucket, int hash)
+{
+   return (Eina_Share_Common_Head *)eina_rbtree_inline_lookup
+             (EINA_RBTREE_GET(bucket), &hash, 0,
+             EINA_RBTREE_CMP_KEY_CB(_eina_share_common_cmp), NULL);
+}
+
+static Eina_Share_Common_Node *
+_eina_share_common_node_alloc(unsigned int slen, unsigned int null_size)
+{
+   Eina_Share_Common_Node *node;
+   const size_t node_size = offsetof(Eina_Share_Common_Node, str);
+
+   node = malloc(node_size + slen + null_size);
+   if (!node)
+      eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+
+   return node;
+}
+
+static Eina_Share_Common_Node *
+_eina_share_common_node_from_str(const char *str, Eina_Magic node_magic)
+{
+   Eina_Share_Common_Node *node;
+   const size_t offset = offsetof(Eina_Share_Common_Node, str);
+
+   node = (Eina_Share_Common_Node *)(str - offset);
+   EINA_MAGIC_CHECK_SHARE_COMMON_NODE(node, node_magic, );
+   return node;
+
+   (void) node_magic; /* When magic are disable, node_magic is unused, this remove a warning. */
+}
+
+static Eina_Bool
+eina_iterator_array_check(const Eina_Rbtree *rbtree __UNUSED__,
+                          Eina_Share_Common_Head *head,
+                          struct dumpinfo *fdata)
+{
+   Eina_Share_Common_Node *node;
+
+   SHARE_COMMON_LOCK_BIG();
+
+   fdata->used += sizeof(Eina_Share_Common_Head);
+   for (node = head->head; node; node = node->next)
+     {
+        printf("DDD: %5i %5i ", node->length, node->references);
+        printf("'%.*s'\n", node->length, ((char *)node) + sizeof(Eina_Share_Common_Node));
+        fdata->used += sizeof(Eina_Share_Common_Node);
+        fdata->used += node->length;
+        fdata->saved += (node->references - 1) * node->length;
+        fdata->dups += node->references - 1;
+        fdata->unique++;
+     }
+
+   SHARE_COMMON_UNLOCK_BIG();
+
+   return EINA_TRUE;
+}
+
+/**
+ * @endcond
+ */
+
+
+/*============================================================================*
+*                                 Global                                     *
+*============================================================================*/
+
+/**
+ * @internal
+ * @brief Initialize the share_common module.
+ *
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function sets up the share_common module of Eina. It is called by
+ * eina_init().
+ *
+ * @see eina_init()
+ */
+Eina_Bool
+eina_share_common_init(Eina_Share **_share,
+                       Eina_Magic node_magic,
+                       const char *node_magic_STR)
+{
+   Eina_Share *share;
+   share = *_share = calloc(sizeof(Eina_Share), 1);
+   if (!share)
+      return EINA_FALSE;
+
+   if (_eina_share_common_log_dom < 0) /*Only register if not already */
+      _eina_share_common_log_dom = eina_log_domain_register(
+            "eina_share",
+            EINA_LOG_COLOR_DEFAULT);
+
+   if (_eina_share_common_log_dom < 0)
+     {
+        EINA_LOG_ERR("Could not register log domain: eina_share_common");
+        return EINA_FALSE;
+     }
+
+   share->share = calloc(1, sizeof(Eina_Share_Common));
+   if (!share->share)
+     {
+        if (_eina_share_common_log_dom > 0)
+          {
+             eina_log_domain_unregister(_eina_share_common_log_dom);
+             _eina_share_common_log_dom = -1;
+          }
+
+        return EINA_FALSE;
+     }
+
+   share->node_magic = node_magic;
+#define EMS(n) eina_magic_string_static_set(n, n ## _STR)
+   EMS(EINA_MAGIC_SHARE);
+   EMS(EINA_MAGIC_SHARE_HEAD);
+   EMS(node_magic);
+#undef EMS
+   EINA_MAGIC_SET(share->share, EINA_MAGIC_SHARE);
+
+   _eina_share_common_population_init(share);
+   return EINA_TRUE;
+}
+
+/**
+ * @internal
+ * @brief Shut down the share_common module.
+ *
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function shuts down the share_common module set up by
+ * eina_share_common_init(). It is called by eina_shutdown().
+ *
+ * @see eina_shutdown()
+ */
+Eina_Bool
+eina_share_common_shutdown(Eina_Share **_share)
+{
+   unsigned int i;
+   Eina_Share *share = *_share;
+
+   SHARE_COMMON_LOCK_BIG();
+
+   _eina_share_common_population_stats(share);
+
+   /* remove any string still in the table */
+   for (i = 0; i < EINA_SHARE_COMMON_BUCKETS; i++)
+     {
+        eina_rbtree_delete(EINA_RBTREE_GET(
+                              share->share->buckets[i]),
+                           EINA_RBTREE_FREE_CB(
+                              _eina_share_common_head_free), NULL);
+        share->share->buckets[i] = NULL;
+     }
+   MAGIC_FREE(share->share);
+
+   _eina_share_common_population_shutdown(share);
+   if (_eina_share_common_log_dom > 0) /* Only free if necessary */
+     {
+        eina_log_domain_unregister(_eina_share_common_log_dom);
+        _eina_share_common_log_dom = -1;
+     }
+
+   SHARE_COMMON_UNLOCK_BIG();
+
+   free(*_share);
+   *_share = NULL;
+   return EINA_TRUE;
+}
+
+#ifdef EFL_HAVE_THREADS
+
+/**
+ * @internal
+ * @brief Activate the share_common mutexs.
+ *
+ * This function activate the mutexs in the eina share_common module. It is called by
+ * eina_thread_init().
+ *
+ * @see eina_thread_init()
+ */
+void
+eina_share_common_threads_init(void)
+{
+   _share_common_threads_activated = EINA_TRUE;
+}
+
+/**
+ * @internal
+ * @brief Shut down the share_common mutexs.
+ *
+ * This function shuts down the mutexs in the share_common module.
+ * It is called by eina_thread_shutdown().
+ *
+ * @see eina_thread_shutdown()
+ */
+void
+eina_share_common_threads_shutdown(void)
+{
+   _share_common_threads_activated = EINA_FALSE;
+}
+
+#endif
+
+/*============================================================================*
+*                                   API                                      *
+*============================================================================*/
+
+/**
+ * @cond LOCAL
+ */
+
+const char *
+eina_share_common_add_length(Eina_Share *share,
+                             const char *str,
+                             unsigned int slen,
+                             unsigned int null_size)
+{
+   Eina_Share_Common_Head **p_bucket, *ed;
+   Eina_Share_Common_Node *el;
+   int hash_num, hash;
+
+   if (!str)
+      return NULL;
+
+   eina_share_common_population_add(share, slen);
+
+   if (slen <= 0)
+      return NULL;
+
+   hash = eina_hash_superfast(str, slen);
+   hash_num = hash & 0xFF;
+   hash = (hash >> 8) & EINA_SHARE_COMMON_MASK;
+
+   SHARE_COMMON_LOCK_BIG();
+   p_bucket = share->share->buckets + hash_num;
+
+   ed = _eina_share_common_find_hash(*p_bucket, hash);
+   if (!ed)
+     {
+        const char *s = _eina_share_common_add_head(share,
+                                                    p_bucket,
+                                                    hash,
+                                                    str,
+                                                    slen,
+                                                    null_size);
+        SHARE_COMMON_UNLOCK_BIG();
+        return s;
+     }
+
+   EINA_MAGIC_CHECK_SHARE_COMMON_HEAD(ed, SHARE_COMMON_UNLOCK_BIG(), NULL);
+
+   el = _eina_share_common_head_find(ed, str, slen);
+   if (el)
+     {
+        EINA_MAGIC_CHECK_SHARE_COMMON_NODE(el,
+                                           share->node_magic,
+                                           SHARE_COMMON_UNLOCK_BIG());
+        el->references++;
+                                           SHARE_COMMON_UNLOCK_BIG();
+        return el->str;
+     }
+
+   el = _eina_share_common_node_alloc(slen, null_size);
+   if (!el)
+     {
+                                           SHARE_COMMON_UNLOCK_BIG();
+        return NULL;
+     }
+
+   _eina_share_common_node_init(el, str, slen, null_size, share->node_magic);
+   el->next = ed->head;
+   ed->head = el;
+   _eina_share_common_population_head_add(share, ed);
+
+   SHARE_COMMON_UNLOCK_BIG();
+
+   return el->str;
+}
+
+const char *
+eina_share_common_ref(Eina_Share *share, const char *str)
+{
+   Eina_Share_Common_Node *node;
+
+   if (!str)
+      return NULL;
+
+   SHARE_COMMON_LOCK_BIG();
+   node = _eina_share_common_node_from_str(str, share->node_magic);
+   node->references++;
+   DBG("str=%p refs=%u", str, node->references);
+
+   SHARE_COMMON_UNLOCK_BIG();
+
+   eina_share_common_population_add(share, node->length);
+
+   return str;
+}
+
+
+void
+eina_share_common_del(Eina_Share *share, const char *str)
+{
+   unsigned int slen;
+   Eina_Share_Common_Head *ed;
+   Eina_Share_Common_Head **p_bucket;
+   Eina_Share_Common_Node *node;
+   int hash_num, hash;
+
+   if (!str)
+      return;
+
+   SHARE_COMMON_LOCK_BIG();
+
+   node = _eina_share_common_node_from_str(str, share->node_magic);
+   slen = node->length;
+   eina_share_common_population_del(share, slen);
+   if (node->references > 1)
+     {
+        node->references--;
+        DBG("str=%p refs=%u", str, node->references);
+        SHARE_COMMON_UNLOCK_BIG();
+        return;
+     }
+
+   DBG("str=%p refs=0, delete.", str);
+   node->references = 0;
+
+   hash = eina_hash_superfast(str, slen);
+   hash_num = hash & 0xFF;
+   hash = (hash >> 8) & EINA_SHARE_COMMON_MASK;
+
+   p_bucket = share->share->buckets + hash_num;
+   ed = _eina_share_common_find_hash(*p_bucket, hash);
+   if (!ed)
+      goto on_error;
+
+   EINA_MAGIC_CHECK_SHARE_COMMON_HEAD(ed, SHARE_COMMON_UNLOCK_BIG());
+
+   if (!_eina_share_common_head_remove_node(ed, node))
+      goto on_error;
+
+   if (node != &ed->builtin_node)
+      MAGIC_FREE(node);
+
+   if (!ed->head)
+      _eina_share_common_del_head(p_bucket, ed);
+   else
+      _eina_share_common_population_head_del(share, ed);
+
+   SHARE_COMMON_UNLOCK_BIG();
+
+   return;
+
+on_error:
+   SHARE_COMMON_UNLOCK_BIG();
+   /* possible segfault happened before here, but... */
+   CRITICAL("EEEK trying to del non-shared share_common \"%s\"", str);
+}
+
+int
+eina_share_common_length(__UNUSED__ Eina_Share *share, const char *str)
+{
+   const Eina_Share_Common_Node *node;
+
+   if (!str)
+      return -1;
+
+   node = _eina_share_common_node_from_str(str, share->node_magic);
+   return node->length;
+}
+
+void
+eina_share_common_dump(Eina_Share *share, void (*additional_dump)(
+                          struct dumpinfo *), int used)
+{
+   Eina_Iterator *it;
+   unsigned int i;
+   struct dumpinfo di;
+
+   if (!share)
+      return;
+
+   di.used = used;
+   di.saved = 0;
+   di.dups = 0;
+   di.unique = 0;
+   printf("DDD:   len   ref string\n");
+   printf("DDD:-------------------\n");
+
+   SHARE_COMMON_LOCK_BIG();
+   for (i = 0; i < EINA_SHARE_COMMON_BUCKETS; i++)
+     {
+        if (!share->share->buckets[i])
+          {
+             continue; //      printf("DDD: BUCKET # %i (HEAD=%i, NODE=%i)\n", i,
+
+          }
+
+//            sizeof(Eina_Share_Common_Head), sizeof(Eina_Share_Common_Node));
+        it = eina_rbtree_iterator_prefix(
+              (Eina_Rbtree *)share->share->buckets[i]);
+        eina_iterator_foreach(it, EINA_EACH_CB(eina_iterator_array_check), &di);
+        eina_iterator_free(it);
+     }
+   if (additional_dump)
+      additional_dump(&di);
+
+#ifdef EINA_SHARE_COMMON_USAGE
+   /* One character strings are not counted in the hash. */
+   di.saved += share->population_group[0].count * sizeof(char);
+   di.saved += share->population_group[1].count * sizeof(char) * 2;
+#endif
+   printf("DDD:-------------------\n");
+   printf("DDD: usage (bytes) = %i, saved = %i (%3.0f%%)\n",
+          di.used, di.saved, di.used ? (di.saved * 100.0 / di.used) : 0.0);
+   printf("DDD: unique: %d, duplicates: %d (%3.0f%%)\n",
+          di.unique, di.dups, di.unique ? (di.dups * 100.0 / di.unique) : 0.0);
+
+#ifdef EINA_SHARE_COMMON_USAGE
+   printf("DDD: Allocated strings: %i\n",     share->population.count);
+   printf("DDD: Max allocated strings: %i\n", share->population.max);
+
+   for (i = 0;
+        i < sizeof (share->population_group) /
+        sizeof (share->population_group[0]);
+        ++i)
+      fprintf(stderr,
+              "DDD: %i strings of length %i, max strings: %i\n",
+              share->population_group[i].count,
+              i,
+              share->population_group[i].max);
+#endif
+
+   SHARE_COMMON_UNLOCK_BIG();
+}
+
+/**
+ * @endcond
+ */
diff --git a/src/lib/eina_share_common.h b/src/lib/eina_share_common.h
new file mode 100644 (file)
index 0000000..002c652
--- /dev/null
@@ -0,0 +1,103 @@
+/* EINA - EFL data type library
+ * Copyright (C) 2002-2008 Carsten Haitzler, Jorge Luis Zapata Muga, Cedric Bail
+ *
+ * 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/>.
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright (C) 2008 Peter Wehrfritz
+ *
+ *  Permission is hereby granted, free of charge, to any person obtaining a copy
+ *  of this software and associated documentation files (the "Software"), to
+ *  deal in the Software without restriction, including without limitation the
+ *  rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ *  sell copies of the Software, and to permit persons to whom the Software is
+ *  furnished to do so, subject to the following conditions:
+ *
+ *  The above copyright notice and this permission notice shall be included in
+ *  all copies of the Software and its Copyright notices. In addition publicly
+ *  documented acknowledgment must be given that this software has been used if no
+ *  source code of this software is made available publicly. This includes
+ *  acknowledgments in either Copyright notices, Manuals, Publicity and Marketing
+ *  documents or any documentation provided with any product containing this
+ *  software. This License does not apply to any software that links to the
+ *  libraries provided by this software (statically or dynamically), but only to
+ *  the software provided.
+ *
+ *  Please see the OLD-COPYING.PLAIN for a plain-english explanation of this notice
+ *  and it's intent.
+ *
+ *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ *  THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ *  IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ *  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef EINA_SHARE_COMMON_H_
+#define EINA_SHARE_COMMON_H_
+
+#include "eina_types.h"
+#include "eina_magic.h"
+
+typedef struct _Eina_Share Eina_Share;
+
+struct dumpinfo
+{
+   int used, saved, dups, unique;
+};
+
+Eina_Bool   eina_share_common_init(Eina_Share **share,
+                                   Eina_Magic node_magic,
+                                   const char *node_magic_STR);
+Eina_Bool   eina_share_common_shutdown(Eina_Share **share);
+const char *eina_share_common_add_length(Eina_Share *share,
+                                         const char *str,
+                                         unsigned int slen,
+                                         unsigned int null_size)
+EINA_WARN_UNUSED_RESULT;
+const char *eina_share_common_ref(Eina_Share *share, const char *str);
+void        eina_share_common_del(Eina_Share *share, const char *str);
+int         eina_share_common_length(Eina_Share *share,
+                                     const char *str) EINA_CONST
+EINA_WARN_UNUSED_RESULT;
+void        eina_share_common_dump(Eina_Share *share, void (*additional_dump)(
+                                      struct dumpinfo *), int used);
+
+
+/* Population functions */
+void        eina_share_common_population_add(Eina_Share *share, int slen);
+void        eina_share_common_population_del(Eina_Share *share, int slen);
+
+/* Share logging */
+#ifdef CRITICAL
+#undef CRITICAL
+#endif
+#define CRITICAL(...) EINA_LOG_DOM_CRIT(_eina_share_common_log_dom, __VA_ARGS__)
+
+#ifdef ERR
+#undef ERR
+#endif
+#define ERR(...) EINA_LOG_DOM_ERR(_eina_share_common_log_dom, __VA_ARGS__)
+
+#ifdef DBG
+#undef DBG
+#endif
+#define DBG(...) EINA_LOG_DOM_DBG(_eina_share_common_log_dom, __VA_ARGS__)
+extern int _eina_share_common_log_dom;
+
+#endif /* EINA_STRINGSHARE_H_ */
index cfdb228..7776eb2 100644 (file)
@@ -1,6 +1,3 @@
-/*
- * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
- */
 /* Leave the OpenBSD version below so we can track upstream fixes */
 /*      $OpenBSD: strlcpy.c,v 1.11 2006/05/05 15:27:38 millert Exp $        */
 
@@ -20,9 +17,6 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/*
- * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
- */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -32,6 +26,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <limits.h>
+#include <ctype.h>
 
 #ifdef HAVE_ICONV
 # include <errno.h>
@@ -42,8 +37,8 @@
 #include "eina_str.h"
 
 /*============================================================================*
- *                                  Local                                     *
- *============================================================================*/
+*                                  Local                                     *
+*============================================================================*/
 
 /**
  * @cond LOCAL
@@ -55,8 +50,8 @@
  */
 static inline Eina_Bool
 eina_str_has_suffix_helper(const char *str,
-                          const char *suffix,
-                          int (*cmp)(const char *, const char *))
+                           const char *suffix,
+                           int (*cmp)(const char *, const char *))
 {
    size_t str_len;
    size_t suffix_len;
@@ -64,13 +59,16 @@ eina_str_has_suffix_helper(const char *str,
    str_len = strlen(str);
    suffix_len = eina_strlen_bounded(suffix, str_len);
    if (suffix_len == (size_t)-1)
-     return EINA_FALSE;
+      return EINA_FALSE;
 
    return cmp(str + str_len - suffix_len, suffix) == 0;
 }
 
 static inline char **
-eina_str_split_full_helper(const char *str, const char *delim, int max_tokens, unsigned int *elements)
+eina_str_split_full_helper(const char *str,
+                           const char *delim,
+                           int max_tokens,
+                           unsigned int *elements)
 {
    char *s, **str_array;
    const char *src;
@@ -80,8 +78,10 @@ eina_str_split_full_helper(const char *str, const char *delim, int max_tokens, u
    dlen = strlen(delim);
    if (dlen == 0)
      {
-       if (elements) *elements = 0;
-       return NULL;
+        if (elements)
+           *elements = 0;
+
+        return NULL;
      }
 
    tokens = 0;
@@ -89,39 +89,43 @@ eina_str_split_full_helper(const char *str, const char *delim, int max_tokens, u
    /* count tokens and check strlen(str) */
    while (*src != '\0')
      {
-       const char *d = delim, *d_end = d + dlen;
-       const char *tmp = src;
-       for (; (d < d_end) && (*tmp != '\0'); d++, tmp++)
-         {
-            if (EINA_LIKELY(*d != *tmp))
-              break;
-         }
-       if (EINA_UNLIKELY(d == d_end))
-         {
-            src = tmp;
-            tokens++;
-         }
-       else
-         src++;
+        const char *d = delim, *d_end = d + dlen;
+        const char *tmp = src;
+        for (; (d < d_end) && (*tmp != '\0'); d++, tmp++)
+          {
+             if (EINA_LIKELY(*d != *tmp))
+                break;
+          }
+        if (EINA_UNLIKELY(d == d_end))
+          {
+             src = tmp;
+             tokens++;
+          }
+        else
+           src++;
      }
    len = src - str;
 
    if ((max_tokens > 0) && (tokens > (unsigned int)max_tokens))
-     tokens = max_tokens;
+      tokens = max_tokens;
 
    str_array = malloc(sizeof(char *) * (tokens + 2));
    if (!str_array)
      {
-       if (elements) *elements = 0;
-       return NULL;
+        if (elements)
+           *elements = 0;
+
+        return NULL;
      }
 
    s = malloc(len + 1);
    if (!s)
      {
-       free(str_array);
-       if (elements) *elements = 0;
-       return NULL;
+        free(str_array);
+        if (elements)
+           *elements = 0;
+
+        return NULL;
      }
 
    /* copy tokens and string */
@@ -130,31 +134,33 @@ eina_str_split_full_helper(const char *str, const char *delim, int max_tokens, u
    src = str;
    while (*src != '\0')
      {
-       const char *d = delim, *d_end = d + dlen;
-       const char *tmp = src;
-       for (; (d < d_end) && (*tmp != '\0'); d++, tmp++)
-         {
-            if (EINA_LIKELY(*d != *tmp))
-              break;
-         }
-       if (EINA_UNLIKELY(d == d_end))
-         {
-            src = tmp;
-            *s = '\0';
-            s += dlen;
-            tokens++;
-            str_array[tokens] = s;
-         }
-       else
-         {
-            *s = *src;
-            s++;
-            src++;
-         }
+        const char *d = delim, *d_end = d + dlen;
+        const char *tmp = src;
+        for (; (d < d_end) && (*tmp != '\0'); d++, tmp++)
+          {
+             if (EINA_LIKELY(*d != *tmp))
+                break;
+          }
+        if (EINA_UNLIKELY(d == d_end))
+          {
+             src = tmp;
+             *s = '\0';
+             s += dlen;
+             tokens++;
+             str_array[tokens] = s;
+          }
+        else
+          {
+             *s = *src;
+             s++;
+             src++;
+          }
      }
    *s = '\0';
    str_array[tokens + 1] = NULL;
-   if (elements) *elements = (tokens + 1);
+   if (elements)
+      *elements = (tokens + 1);
+
    return str_array;
 }
 
@@ -163,12 +169,12 @@ eina_str_split_full_helper(const char *str, const char *delim, int max_tokens, u
  */
 
 /*============================================================================*
- *                                 Global                                     *
- *============================================================================*/
+*                                 Global                                     *
+*============================================================================*/
 
 /*============================================================================*
- *                                   API                                      *
- *============================================================================*/
+*                                   API                                      *
+*============================================================================*/
 
 /**
  * @addtogroup Eina_String_Group String
@@ -205,24 +211,23 @@ eina_strlcpy(char *dst, const char *src, size_t siz)
 
    /* Copy as many bytes as will fit */
    if (n != 0)
-     {
-       while (--n != 0)
-         {
-            if ((*d++ = *s++) == '\0')
-              break;
-         }
-     }
+      while (--n != 0)
+        {
+           if ((*d++ = *s++) == '\0')
+              break;
+        }
 
    /* Not enough room in dst, add NUL and traverse rest of src */
    if (n == 0)
      {
-       if (siz != 0)
-         *d = '\0';                /* NUL-terminate dst */
-       while (*s++)
-         ;
+        if (siz != 0)
+           *d = '\0';  /* NUL-terminate dst */
+
+        while (*s++)
+           ;
      }
 
-   return(s - src - 1);        /* count does not include NUL */
+   return(s - src - 1); /* count does not include NUL */
 #endif
 }
 
@@ -251,22 +256,25 @@ eina_strlcat(char *dst, const char *src, size_t siz)
 
    /* Find the end of dst and adjust bytes left but don't go past end */
    while (n-- != 0 && *d != '\0')
-     d++;
+      d++;
    dlen = d - dst;
    n = siz - dlen;
 
    if (n == 0)
-     return(dlen + strlen(s));
+      return(dlen + strlen(s));
+
    while (*s != '\0') {
-       if (n != 1) {
-            *d++ = *s;
-            n--;
-       }
-       s++;
-   }
+        if (n != 1)
+          {
+             *d++ = *s;
+             n--;
+          }
+
+        s++;
+     }
    *d = '\0';
 
-   return(dlen + (s - src));        /* count does not include NUL */
+   return(dlen + (s - src)); /* count does not include NUL */
 }
 
 /**
@@ -289,7 +297,7 @@ eina_str_has_prefix(const char *str, const char *prefix)
    str_len = strlen(str);
    prefix_len = eina_strlen_bounded(prefix, str_len);
    if (prefix_len == (size_t)-1)
-     return EINA_FALSE;
+      return EINA_FALSE;
 
    return (strncmp(str, prefix, prefix_len) == 0);
 }
@@ -341,7 +349,8 @@ eina_str_has_extension(const char *str, const char *ext)
  * @param max_tokens The maximum number of strings to split string into.
  * @param elements Where to return the number of elements in returned
  *        array (not counting the terminating @c NULL). May be @c NULL.
- * @return A newly-allocated NULL-terminated array of strings.
+ * @return A newly-allocated NULL-terminated array of strings or NULL if it
+ * fails to allocate the array.
  *
  * This functin splits @p str into a maximum of @p max_tokens pieces,
  * using the given delimiter @p delim. @p delim is not included in any
@@ -349,13 +358,17 @@ eina_str_has_extension(const char *str, const char *ext)
  * @p max_tokens is less than @c 1, the string is splitted completely. If
  * @p max_tokens is reached, the last string in the returned string
  * array contains the remainder of string. The returned value is a
- * newly allocated NUL-terminated array of string. To free it, free
- * the first element of the array and the array itself.
+ * newly allocated NULL-terminated array of strings or NULL if it fails to
+ * allocate the array. To free it, free the first element of the array and the
+ * array itself.
  *
  * @see eina_str_split()
  */
 EAPI char **
-eina_str_split_full(const char *str, const char *delim, int max_tokens, unsigned int *elements)
+eina_str_split_full(const char *str,
+                    const char *delim,
+                    int max_tokens,
+                    unsigned int *elements)
 {
    return eina_str_split_full_helper(str, delim, max_tokens, elements);
 }
@@ -367,7 +380,8 @@ eina_str_split_full(const char *str, const char *delim, int max_tokens, unsigned
  * @param str The string to split.
  * @param delim The string which specifies the places at which to split the string.
  * @param max_tokens The maximum number of strings to split string into.
- * @return A newly-allocated NULL-terminated array of strings.
+ * @return A newly-allocated NULL-terminated array of strings or NULL if it
+ * fails to allocate the array.
  *
  * This functin splits @p str into a maximum of @p max_tokens pieces,
  * using the given delimiter @p delim. @p delim is not included in any
@@ -375,8 +389,9 @@ eina_str_split_full(const char *str, const char *delim, int max_tokens, unsigned
  * @p max_tokens is less than @c 1, the string is splitted completely. If
  * @p max_tokens is reached, the last string in the returned string
  * array contains the remainder of string. The returned value is a
- * newly allocated NUL-terminated array of string. To free it, free
- * the first element of the array and the array itself.
+ * newly allocated NULL-terminated array of strings or NULL if it fails to
+ * allocate the array. To free it, free the first element of the array and the
+ * array itself.
  */
 EAPI char **
 eina_str_split(const char *str, const char *delim, int max_tokens)
@@ -411,27 +426,34 @@ eina_str_split(const char *str, const char *delim, int max_tokens)
  * @see eina_str_join_static()
  */
 EAPI size_t
-eina_str_join_len(char *dst, size_t size, char sep, const char *a, size_t a_len, const char *b, size_t b_len)
+eina_str_join_len(char *dst,
+                  size_t size,
+                  char sep,
+                  const char *a,
+                  size_t a_len,
+                  const char *b,
+                  size_t b_len)
 {
    size_t ret = a_len + b_len + 1;
    size_t off;
 
-   if (size < 1) return ret;
+   if (size < 1)
+      return ret;
 
    if (size <= a_len)
      {
-       memcpy(dst, a, size - 1);
-       dst[size - 1] = '\0';
-       return ret;
+        memcpy(dst, a, size - 1);
+        dst[size - 1] = '\0';
+        return ret;
      }
 
-   memcpy(dst, a, a_len);
+        memcpy(dst, a, a_len);
    off = a_len;
 
    if (size <= off + 1)
      {
-       dst[size - 1] = '\0';
-       return ret;
+        dst[size - 1] = '\0';
+        return ret;
      }
 
    dst[off] = sep;
@@ -439,12 +461,12 @@ eina_str_join_len(char *dst, size_t size, char sep, const char *a, size_t a_len,
 
    if (size <= off + b_len + 1)
      {
-       memcpy(dst + off, b, size - off - 1);
-       dst[size - 1] = '\0';
-       return ret;
+        memcpy(dst + off, b, size - off - 1);
+        dst[size - 1] = '\0';
+        return ret;
      }
 
-   memcpy(dst + off, b, b_len);
+        memcpy(dst + off, b, b_len);
    dst[off + b_len] = '\0';
    return ret;
 }
@@ -465,65 +487,80 @@ eina_str_convert(const char *enc_from, const char *enc_to, const char *text)
    char *new_txt, *inp, *outp;
    size_t inb, outb, outlen, tob, outalloc;
 
-   if (!text) return NULL;
+   if (!text)
+      return NULL;
+
    ic = iconv_open(enc_to, enc_from);
-   if (ic == (iconv_t)(-1)) return NULL;
-   new_txt  = malloc(64);
-   inb      = strlen(text);
-   outb     = 64;
-   inp      = (char*)text;
-   outp     = new_txt;
+   if (ic == (iconv_t)(-1))
+      return NULL;
+
+   new_txt = malloc(64);
+   inb = strlen(text);
+   outb = 64;
+   inp = (char *)text;
+   outp = new_txt;
    outalloc = 64;
-   outlen   = 0;
+   outlen = 0;
 
-   for (;;)
+   for (;; )
      {
-       size_t count;
-
-       tob = outb;
-       count = iconv(ic, &inp, &inb, &outp, &outb);
-       outlen += tob - outb;
-       if (count == (size_t)(-1))
-         {
-            if (errno == E2BIG)
-              {
-                 new_txt = realloc(new_txt, outalloc + 64);
-                 outp = new_txt + outlen;
-                 outalloc += 64;
-                 outb += 64;
-              }
-            else if (errno == EILSEQ)
-              {
-                 if (new_txt) free(new_txt);
-                 new_txt = NULL;
-                 break;
-              }
-            else if (errno == EINVAL)
-              {
-                 if (new_txt) free(new_txt);
-                 new_txt = NULL;
-                 break;
-              }
-            else
-              {
-                 if (new_txt) free(new_txt);
-                 new_txt = NULL;
-                 break;
-              }
-         }
-       if (inb == 0)
-         {
-            if (outalloc == outlen) new_txt = realloc(new_txt, outalloc + 1);
-            new_txt[outlen] = 0;
-            break;
-         }
+        size_t count;
+
+        tob = outb;
+        count = iconv(ic, &inp, &inb, &outp, &outb);
+        outlen += tob - outb;
+        if (count == (size_t)(-1))
+          {
+             if (errno == E2BIG)
+               {
+                  new_txt = realloc(new_txt, outalloc + 64);
+                  outp = new_txt + outlen;
+                  outalloc += 64;
+                  outb += 64;
+               }
+             else if (errno == EILSEQ)
+               {
+                  if (new_txt)
+                     free(new_txt);
+
+                  new_txt = NULL;
+                  break;
+               }
+             else if (errno == EINVAL)
+               {
+                  if (new_txt)
+                     free(new_txt);
+
+                  new_txt = NULL;
+                  break;
+               }
+             else
+               {
+                  if (new_txt)
+                     free(new_txt);
+
+                  new_txt = NULL;
+                  break;
+               }
+          }
+
+        if (inb == 0)
+          {
+             if (outalloc == outlen)
+                new_txt = realloc(new_txt, outalloc + 1);
+
+             new_txt[outlen] = 0;
+             break;
+          }
      }
    iconv_close(ic);
    return new_txt;
 }
 #else
 EAPI char *
-eina_str_convert(const char *enc_from __UNUSED__, const char *enc_to __UNUSED__, const char *text __UNUSED__)
+eina_str_convert(const char *enc_from __UNUSED__,
+                 const char *enc_to __UNUSED__,
+                 const char *text __UNUSED__)
 {
    return NULL;
 }
@@ -543,20 +580,60 @@ eina_str_escape(const char *str)
    const char *s;
 
    s2 = malloc((strlen(str) * 2) + 1);
-   if (!s2) return NULL;
+   if (!s2)
+      return NULL;
+
    for (s = str, d = s2; *s != 0; s++, d++)
      {
-       if ((*s == ' ') || (*s == '\\') || (*s == '\''))
-         {
-            *d = '\\';
-            d++;
-         }
-       *d = *s;
+        if ((*s == ' ') || (*s == '\\') || (*s == '\''))
+          {
+             *d = '\\';
+             d++;
+          }
+
+        *d = *s;
      }
    *d = 0;
    return s2;
 }
 
 /**
+ * @brief Lowercase all the characters in range [A-Z] in the given string.
+ *
+ * @param str the string to lowercase
+ *
+ * This modifies the original string, changing all characters in [A-Z] to lowercase.
+ */
+EAPI void
+eina_str_tolower(char **str)
+{
+   char *p;
+   if ((!str) || (!(*str)))
+      return;
+
+   for (p = *str; (*p); p++)
+      *p = tolower(*p);
+}
+
+/**
+ * @brief Uppercase all the characters in range [a-z] in the given string.
+ *
+ * @param str the string to uppercase
+ *
+ * This modifies the original string, changing all characters in [a-z] to uppercase.
+ */
+EAPI void
+eina_str_toupper(char **str)
+{
+   char *p;
+   if ((!str) || (!(*str)))
+      return;
+
+   for (p = *str; (*p); p++)
+      *p = toupper(*p);
+}
+
+
+/**
  * @}
  */
index ca849db..519695f 100644 (file)
@@ -1,27 +1,16 @@
-/*
- * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
- */
-
-#define _GNU_SOURCE
-
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
 
+#define _GNU_SOURCE
+
 #include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
 
-#ifdef _WIN32
-# include <Evil.h>
-#endif
-
 #include "eina_private.h"
 #include "eina_str.h"
-#include "eina_magic.h"
-#include "eina_error.h"
-#include "eina_safety_checks.h"
-#include "eina_strbuf.h"
+#include "eina_strbuf_common.h"
+#include "eina_unicode.h"
 
 /*============================================================================*
  *                                  Local                                     *
  * @cond LOCAL
  */
 
-static const char EINA_MAGIC_STRBUF_STR[] = "Eina Strbuf";
-
-#define EINA_MAGIC_CHECK_STRBUF(d, ...)                                \
-   do {                                                                \
-       if (!EINA_MAGIC_CHECK((d), EINA_MAGIC_STRBUF))          \
-         {                                                     \
-            EINA_MAGIC_FAIL((d), EINA_MAGIC_STRBUF);           \
-            return __VA_ARGS__;                                \
-         }                                                     \
-   } while (0)
+#ifdef _STRBUF_DATA_TYPE
+# undef _STRBUF_DATA_TYPE
+#endif
 
-#define EINA_STRBUF_INIT_SIZE 32
-#define EINA_STRBUF_INIT_STEP 32
-#define EINA_STRBUF_MAX_STEP 4096
+#ifdef _STRBUF_CSIZE
+# undef _STRBUF_CSIZE
+#endif
 
-struct _Eina_Strbuf
-{
-   char *buf;
-   size_t len;
-   size_t size;
-   size_t step;
+#ifdef _STRBUF_STRUCT_NAME
+# undef _STRBUF_STRUCT_NAME
+#endif
 
-   EINA_MAGIC
-};
+#ifdef _STRBUF_STRLEN_FUNC
+# undef _STRBUF_STRLEN_FUNC
+#endif
 
-/**
- * @internal
- *
- * init the buffer
- * @param buf the buffer to init
- *
- * @return #EINA_TRUE on success, #EINA_FALSE on failure.
- */
-static Eina_Bool
-_eina_strbuf_init(Eina_Strbuf *buf)
-{
-   buf->len = 0;
-   buf->size = EINA_STRBUF_INIT_SIZE;
-   buf->step = EINA_STRBUF_INIT_STEP;
-
-   eina_error_set(0);
-   buf->buf = malloc(buf->size);
-   if (EINA_UNLIKELY(!buf->buf))
-     {
-       eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
-       return EINA_FALSE;
-     }
-   buf->buf[0] = '\0';
-   return EINA_TRUE;
-}
+#ifdef _STRBUF_STRESCAPE_FUNC
+# undef _STRBUF_STRESCAPE_FUNC
+#endif
 
-/**
- * @internal
- *
- * resize the buffer
- * @param buf the buffer to resize
- * @param size the minimum size of the buffer
- *
- * @return #EINA_TRUE on success, #EINA_FALSE on failure.
- */
-static inline Eina_Bool
-_eina_strbuf_resize(Eina_Strbuf *buf, size_t size)
-{
-   size_t new_size, new_step, delta;
-   char *buffer;
-
-   size += 1; // Add extra space for '\0'
-
-   if (size == buf->size)
-     /* nothing to do */
-     return EINA_TRUE;
-   else if (size > buf->size)
-     delta = size - buf->size;
-   else
-     delta = buf->size - size;
-
-   /* check if should keep the same step (just used while growing) */
-   if ((delta <= buf->step) && (size > buf->size))
-     new_step = buf->step;
-   else
-     {
-       new_step = (((delta / EINA_STRBUF_INIT_STEP) + 1)
-                   * EINA_STRBUF_INIT_STEP);
-
-       if (new_step > EINA_STRBUF_MAX_STEP)
-         new_step = EINA_STRBUF_MAX_STEP;
-     }
-
-   new_size = (((size / new_step) + 1) * new_step);
-
-   /* reallocate the buffer to the new size */
-   buffer = realloc(buf->buf, new_size);
-   if (EINA_UNLIKELY(!buffer))
-     {
-       eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
-       return EINA_FALSE;
-     }
-
-   buf->buf = buffer;
-   buf->size = new_size;
-   buf->step = new_step;
-   eina_error_set(0);
-   return EINA_TRUE;
-}
+#ifdef _STRBUF_MAGIC
+# undef _STRBUF_MAGIC
+#endif
 
-/**
- * @internal
- *
- * If required, enlarge the buffer to fit the new size.
- *
- * @param buf the buffer to resize
- * @param size the minimum size of the buffer
- *
- * @return #EINA_TRUE on success, #EINA_FALSE on failure.
- */
-static inline Eina_Bool
-_eina_strbuf_grow(Eina_Strbuf *buf, size_t size)
-{
-   if ((size + 1) < buf->size)
-     return EINA_TRUE;
-   return _eina_strbuf_resize(buf, size);
-}
+#ifdef _STRBUF_MAGIC_STR
+# undef _STRBUF_MAGIC_STR
+#endif
 
-/**
- * @internal
- *
- * insert string of known length at random within existing strbuf limits.
- *
- * @param buf the buffer to resize, must be valid.
- * @param str the string to copy, must be valid (!NULL and smaller than @a len)
- * @param len the amount of bytes in @a str to copy, must be valid.
- * @param pos the position inside buffer to insert, must be valid (smaller
- *        than eina_strbuf_length_get())
- *
- * @return #EINA_TRUE on success, #EINA_FALSE on failure.
- */
-static inline Eina_Bool
-_eina_strbuf_insert_length(Eina_Strbuf *buf, const char *str, size_t len, size_t pos)
-{
-   if (EINA_UNLIKELY(!_eina_strbuf_grow(buf, buf->len + len)))
-     return EINA_FALSE;
+#ifdef _FUNC_EXPAND
+# undef _FUNC_EXPAND
+#endif
 
-   /* move the existing text */
-   memmove(buf->buf + len + pos, buf->buf + pos, buf->len - pos);
 
-   /* and now insert the given string */
-   memcpy(buf->buf + pos, str, len);
+#define _STRBUF_DATA_TYPE         char
+#define _STRBUF_CSIZE             sizeof(_STRBUF_DATA_TYPE)
+#define _STRBUF_STRUCT_NAME       Eina_Strbuf
+#define _STRBUF_STRLEN_FUNC(x)    strlen(x)
+#define _STRBUF_STRESCAPE_FUNC(x) eina_str_escape(x)
+#define _STRBUF_MAGIC             EINA_MAGIC_STRBUF
+#define _STRBUF_MAGIC_STR         __STRBUF_MAGIC_STR
+static const char __STRBUF_MAGIC_STR[] = "Eina Strbuf";
 
-   buf->len += len;
-   buf->buf[buf->len] = '\0';
-   return EINA_TRUE;
-}
+#define _FUNC_EXPAND(y) eina_strbuf_ ## y
 
 /**
  * @endcond
  */
 
+
 /*============================================================================*
  *                                 Global                                     *
  *============================================================================*/
 
-/**
- * @cond LOCAL
- */
-
-/**
- * @internal
- * @brief Initialize the strbuf module.
- *
- * @return #EINA_TRUE on success, #EINA_FALSE on failure.
- *
- * This function sets up the strbuf module of Eina. It is called by
- * eina_init().
- *
- * @see eina_init()
- */
-Eina_Bool
-eina_strbuf_init(void)
-{
-   eina_magic_string_static_set(EINA_MAGIC_STRBUF, EINA_MAGIC_STRBUF_STR);
-   return EINA_TRUE;
-}
-
-/**
- * @internal
- * @brief Shut down the strbuf module.
- *
- * @return #EINA_TRUE on success, #EINA_FALSE on failure.
- *
- * This function shuts down the strbuf module set up by
- * eina_strbuf_init(). It is called by eina_shutdown().
- *
- * @see eina_shutdown()
- */
-Eina_Bool
-eina_strbuf_shutdown(void)
-{
-   return EINA_TRUE;
-}
-
-/**
- * @endcond
- */
 
 /*============================================================================*
  *                                   API                                      *
  *============================================================================*/
 
+
 /**
  * @addtogroup Eina_String_Buffer_Group String Buffer
  *
  * @brief These functions provide string buffers management.
  *
  * The String Buffer data type is designed to be a mutable string,
- * allowing to append, prepend or insert a string to a buffer. 
+ * allowing to append, prepend or insert a string to a buffer.
  *
  * @{
  */
 
-/**
- * @brief Create a new string buffer.
- *
- * @return Newly allocated string buffer instance.
- *
- * This function creates a new string buffer. On error, @c NULL is
- * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To
- * free the resources, use eina_strbuf_free().
- *
- * @see eina_strbuf_free()
- * @see eina_strbuf_append()
- * @see eina_strbuf_string_get()
- */
-EAPI Eina_Strbuf *
-eina_strbuf_new(void)
-{
-   Eina_Strbuf *buf;
-
-   eina_error_set(0);
-   buf = malloc(sizeof(Eina_Strbuf));
-   if (EINA_UNLIKELY(!buf))
-     {
-       eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
-       return NULL;
-     }
-   EINA_MAGIC_SET(buf, EINA_MAGIC_STRBUF);
-
-   if (EINA_UNLIKELY(!_eina_strbuf_init(buf)))
-     {
-       eina_strbuf_free(buf);
-       return NULL;
-     }
-
-   return buf;
-}
-
-/**
- * @brief Free a string buffer.
- *
- * @param buf The string buffer to free.
- *
- * This function frees the memory of @p buf. @p buf must have been
- * created by eina_strbuf_new().
- */
-EAPI void
-eina_strbuf_free(Eina_Strbuf *buf)
-{
-   EINA_MAGIC_CHECK_STRBUF(buf);
-   EINA_MAGIC_SET(buf, EINA_MAGIC_NONE);
-
-   free(buf->buf);
-   free(buf);
-}
-
-/**
- * @brief Reset a string buffer.
- *
- * @param buf The string buffer to reset.
- *
- * This function reset @p buf: the buffer len is set to 0, and the
- * string is set to '\\0'. No memory is free'd.
- */
-EAPI void
-eina_strbuf_reset(Eina_Strbuf *buf)
-{
-   EINA_MAGIC_CHECK_STRBUF(buf);
-   buf->len = 0;
-   buf->step = EINA_STRBUF_INIT_STEP;
-
-   buf->buf[0] = '\0';
-}
-
-/**
- * @brief Append a string to a buffer, reallocating as necessary.
- *
- * @param buf The string buffer to append to.
- * @param str The string to append.
- * @return #EINA_TRUE on success, #EINA_FALSE on failure.
- *
- * This function appends @p str to @p buf. It computes the length of
- * @p str, so is slightly slower than eina_strbuf_append_length(). If
- * the length is known beforehand, consider using that variant. If
- * @p buf can't append it, #EINA_FALSE is returned, otherwise
- * #EINA_TRUE is returned.
- *
- * @see eina_strbuf_append()
- * @see eina_strbuf_append_length()
- */
-EAPI Eina_Bool
-eina_strbuf_append(Eina_Strbuf *buf, const char *str)
-{
-   size_t len;
-
-   EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
-   EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE);
-
-   len = strlen(str);
-   if (EINA_UNLIKELY(!_eina_strbuf_grow(buf, buf->len + len)))
-     return EINA_FALSE;
-   memcpy(buf->buf + buf->len, str, len + 1);
-   buf->len += len;
-   return EINA_TRUE;
-}
-
-/**
- * @brief Append an escaped string to a buffer, reallocating as necessary.
- *
- * @param buf The string buffer to append to.
- * @param str The string to append.
- * @return #EINA_TRUE on success, #EINA_FALSE on failure.
- *
- * This function appends the escaped string @p str to @p buf. If @p
- * str can not be appended, #EINA_FALSE is returned, otherwise,
- * #EINA_TRUE is returned.
- */
-EAPI Eina_Bool
-eina_strbuf_append_escaped(Eina_Strbuf *buf, const char *str)
-{
-   size_t len;
-   char *esc;
-
-   EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
-   EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE);
-
-   esc = eina_str_escape(str);
-   if (EINA_UNLIKELY(!esc))
-     return EINA_FALSE;
-   len = strlen(esc);
-   if (EINA_UNLIKELY(!_eina_strbuf_grow(buf, buf->len + len)))
-     {
-       free(esc);
-       return EINA_FALSE;
-     }
-   memcpy(buf->buf + buf->len, esc, len + 1);
-   buf->len += len;
-   free(esc);
-   return EINA_TRUE;
-}
-
-/**
- * @brief Append a string to a buffer, reallocating as necessary,
- * limited by the given length.
- *
- * @param buf The string buffer to append to.
- * @param str The string to append.
- * @param maxlen The maximum number of characters to append.
- * @return #EINA_TRUE on success, #EINA_FALSE on failure.
- *
- * This function appends at most @p maxlen characters of @p str to
- * @p buf. It can't appends more than the length of @p str. It
- * computes the length of @p str, so is slightly slower than
- * eina_strbuf_append_length(). If the length is known beforehand,
- * consider using that variant (@p maxlen should then be checked so
- * that it is greater than the size of @p str). If @p str can not be
- * appended, #EINA_FALSE is returned, otherwise, #EINA_TRUE is
- * returned.
- *
- * @see eina_strbuf_append()
- * @see eina_strbuf_append_length()
- */
-EAPI Eina_Bool
-eina_strbuf_append_n(Eina_Strbuf *buf, const char *str, size_t maxlen)
-{
-   size_t len;
-
-   EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
-   EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE);
-
-   len = strlen(str);
-   if (len > maxlen) len = maxlen;
-   if (EINA_UNLIKELY(!_eina_strbuf_grow(buf, buf->len + len)))
-     return EINA_FALSE;
-
-   memcpy(buf->buf + buf->len, str, len);
-   buf->len += len;
-   buf->buf[buf->len] = '\0';
-   return EINA_TRUE;
-}
-
-/**
- * @brief Append a string of exact length to a buffer, reallocating as necessary.
- *
- * @param buf The string buffer to append to.
- * @param str The string to append.
- * @param length The exact length to use.
- * @return #EINA_TRUE on success, #EINA_FALSE on failure.
- *
- * This function appends @p str to @p buf. @p str must be of size at
- * most @p length. It is slightly faster than eina_strbuf_append() as
- * it does not compute the size of @p str. It is useful when dealing
- * with strings of known size, such as eina_strngshare. If @p buf
- * can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
- * returned.
- *
- * @see eina_stringshare_length()
- * @see eina_strbuf_append()
- * @see eina_strbuf_append_n()
- */
-EAPI Eina_Bool
-eina_strbuf_append_length(Eina_Strbuf *buf, const char *str, size_t length)
-{
-   EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
-   EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE);
-
-   if (EINA_UNLIKELY(!_eina_strbuf_grow(buf, buf->len + length)))
-     return EINA_FALSE;
-
-   memcpy(buf->buf + buf->len, str, length);
-   buf->len += length;
-   buf->buf[buf->len] = '\0';
-   return EINA_TRUE;
-}
-
-/**
- * @brief Append a string to a buffer, reallocating as necessary.
- *
- * @param buf The string buffer to append to.
- * @param fmt The string to append.
- * @return #EINA_TRUE on success, #EINA_FALSE on failure.
- *
- * @see eina_strbuf_append()
- */
 EAPI Eina_Bool
 eina_strbuf_append_printf(Eina_Strbuf *buf, const char *fmt, ...)
 {
@@ -480,30 +98,18 @@ eina_strbuf_append_printf(Eina_Strbuf *buf, const char *fmt, ...)
    size_t len;
    Eina_Bool ret;
 
-   EINA_SAFETY_ON_NULL_RETURN_VAL(fmt, EINA_FALSE);
-   EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE);
-
    va_start(args, fmt);
    len = vasprintf(&str, fmt, args);
    va_end(args);
 
    if (len <= 0 || !str)
-     return EINA_FALSE;
+      return EINA_FALSE;
 
    ret = eina_strbuf_append_length(buf, str, len);
    free(str);
    return ret;
 }
 
-/**
- * @brief Append a string to a buffer, reallocating as necessary.
- *
- * @param buf The string buffer to append to.
- * @param fmt The string to append.
- * @return #EINA_TRUE on success, #EINA_FALSE on failure.
- *
- * @see eina_strbuf_append()
- */
 EAPI Eina_Bool
 eina_strbuf_append_vprintf(Eina_Strbuf *buf, const char *fmt, va_list args)
 {
@@ -511,201 +117,16 @@ eina_strbuf_append_vprintf(Eina_Strbuf *buf, const char *fmt, va_list args)
    size_t len;
    Eina_Bool ret;
 
-   EINA_SAFETY_ON_NULL_RETURN_VAL(fmt, EINA_FALSE);
-   EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE);
-
    len = vasprintf(&str, fmt, args);
 
    if (len <= 0 || !str)
-     return EINA_FALSE;
+      return EINA_FALSE;
 
    ret = eina_strbuf_append_length(buf, str, len);
    free(str);
    return ret;
 }
 
-/**
- * @brief Insert a string to a buffer, reallocating as necessary.
- *
- * @param buf The string buffer to insert.
- * @param str The string to insert.
- * @param pos The position to insert the string.
- * @return #EINA_TRUE on success, #EINA_FALSE on failure.
- *
- * This function inserts @p str to @p buf at position @p pos. It
- * computes the length of @p str, so is slightly slower than
- * eina_strbuf_insert_length(). If  the length is known beforehand,
- * consider using that variant. If @p buf can't insert it, #EINA_FALSE
- * is returned, otherwise #EINA_TRUE is returned.
- */
-EAPI Eina_Bool
-eina_strbuf_insert(Eina_Strbuf *buf, const char *str, size_t pos)
-{
-   size_t len;
-
-   EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
-   EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE);
-
-   if (pos >= buf->len)
-     return eina_strbuf_append(buf, str);
-
-   len = strlen(str);
-   return _eina_strbuf_insert_length(buf, str, len, pos);
-}
-
-/**
- * @brief Insert an escaped string to a buffer, reallocating as
- * necessary.
- *
- * @param buf The string buffer to insert to.
- * @param str The string to insert.
- * @param pos The position to insert the string.
- * @return #EINA_TRUE on success, #EINA_FALSE on failure.
- *
- * This function inserts the escaped string @p str to @p buf at
- * position @p pos. If @p buf can't insert @p str, #EINA_FALSE is
- * returned, otherwise #EINA_TRUE is returned.
- */
-EAPI Eina_Bool
-eina_strbuf_insert_escaped(Eina_Strbuf *buf, const char *str, size_t pos)
-{
-   Eina_Bool ret;
-   size_t len;
-   char *esc;
-
-   EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
-   EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE);
-
-   esc = eina_str_escape(str);
-   if (EINA_UNLIKELY(!esc))
-     return EINA_FALSE;
-   len = strlen(esc);
-   ret = _eina_strbuf_insert_length(buf, esc, len, pos);
-   free(esc);
-   return ret;
-}
-
-/**
- * @brief Insert a string to a buffer, reallocating as necessary. Limited by maxlen.
- *
- * @param buf The string buffer to insert to.
- * @param str The string to insert.
- * @param maxlen The maximum number of chars to insert.
- * @param pos The position to insert the string.
- * @return #EINA_TRUE on success, #EINA_FALSE on failure.
- *
- * This function inserts @p str ot @p buf at position @p pos, with at
- * most @p maxlen bytes. The number of inserted characters can not be
- * greater than the length of @p str. It computes the length of
- * @p str, so is slightly slower than eina_strbuf_insert_length(). If the
- * length is known beforehand, consider using that variant (@p maxlen
- * should then be checked so that it is greater than the size of
- * @p str). If @p str can not be inserted, #EINA_FALSE is returned,
- * otherwise, #EINA_TRUE is returned.
- */
-EAPI Eina_Bool
-eina_strbuf_insert_n(Eina_Strbuf *buf, const char *str, size_t maxlen, size_t pos)
-{
-   size_t len;
-
-   EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
-   EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE);
-
-   if (pos >= buf->len)
-     return eina_strbuf_append_n(buf, str, maxlen);
-
-   len = strlen(str);
-   if (len > maxlen) len = maxlen;
-   return _eina_strbuf_insert_length(buf, str, len, pos);
-}
-
-/**
- * @brief Insert a string of exact length to a buffer, reallocating as necessary.
- *
- * @param buf The string buffer to insert to.
- * @param str The string to insert.
- * @param length The exact length to use.
- * @param pos The position to insert the string.
- * @return #EINA_TRUE on success, #EINA_FALSE on failure.
- *
- * This function inserts @p str to @p buf. @p str must be of size at
- * most @p length. It is slightly faster than eina_strbuf_insert() as
- * it does not compute the size of @p str. It is useful when dealing
- * with strings of known size, such as eina_strngshare. If @p buf
- * can't insert it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
- * returned.
- *
- * @see eina_stringshare_length()
- * @see eina_strbuf_insert()
- * @see eina_strbuf_insert_n()
- */
-EAPI Eina_Bool
-eina_strbuf_insert_length(Eina_Strbuf *buf, const char *str, size_t length, size_t pos)
-{
-   EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
-   EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE);
-
-   if (pos >= buf->len)
-     return eina_strbuf_append_length(buf, str, length);
-
-   return _eina_strbuf_insert_length(buf, str, length, pos);
-}
-
-/**
- * @brief Append a character to a string buffer, reallocating as
- * necessary.
- *
- * @param buf The string buffer to append to.
- * @param c The char to append.
- * @return #EINA_TRUE on success, #EINA_FALSE on failure.
- *
- * This function inserts @p c to @p buf. If it can not insert it,
- * #EINA_FALSE is returned, otherwise #EINA_TRUE is returned.
- */
-EAPI Eina_Bool
-eina_strbuf_append_char(Eina_Strbuf *buf, char c)
-{
-   EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE);
-
-   if (EINA_UNLIKELY(!_eina_strbuf_grow(buf, buf->len + 1)))
-     return EINA_FALSE;
-   buf->buf[(buf->len)++] = c;
-   buf->buf[buf->len] = '\0';
-   return EINA_TRUE;
-}
-
-/**
- * @brief Insert a character to a string buffer, reallocating as
- * necessary.
- *
- * @param buf The string buffer to insert to.
- * @param c The char to insert.
- * @param pos The position to insert the char.
- * @return #EINA_TRUE on success, #EINA_FALSE on failure.
- *
- * This function inserts @p c to @p buf at position @p pos. If @p buf
- * can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
- * returned.
- */
-EAPI Eina_Bool
-eina_strbuf_insert_char(Eina_Strbuf *buf, char c, size_t pos)
-{
-   EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE);
-
-   if (pos >= buf->len)
-     return eina_strbuf_append_char(buf, c);
-
-   return _eina_strbuf_insert_length(buf, &c, 1, pos);
-}
-
-/**
- * @brief Insert a string to a buffer, reallocating as necessary.
- *
- * @param buf The string buffer to insert.
- * @param fmt The string to insert.
- * @param pos The position to insert the string.
- * @return #EINA_TRUE on success, #EINA_FALSE on failure.
- */
 EAPI Eina_Bool
 eina_strbuf_insert_printf(Eina_Strbuf *buf, const char *fmt, size_t pos, ...)
 {
@@ -714,301 +135,41 @@ eina_strbuf_insert_printf(Eina_Strbuf *buf, const char *fmt, size_t pos, ...)
    size_t len;
    Eina_Bool ret;
 
-   EINA_SAFETY_ON_NULL_RETURN_VAL(fmt, EINA_FALSE);
-   EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE);
-
    va_start(args, pos);
    len = vasprintf(&str, fmt, args);
    va_end(args);
 
    if (len <= 0 || !str)
-     return EINA_FALSE;
+      return EINA_FALSE;
 
    ret = eina_strbuf_insert(buf, str, pos);
    free(str);
    return ret;
 }
 
-/**
- * @brief Insert a string to a buffer, reallocating as necessary.
- *
- * @param buf The string buffer to insert.
- * @param fmt The string to insert.
- * @param pos The position to insert the string.
- * @return #EINA_TRUE on success, #EINA_FALSE on failure.
- */
 EAPI Eina_Bool
-eina_strbuf_insert_vprintf(Eina_Strbuf *buf, const char *fmt, size_t pos, va_list args)
+eina_strbuf_insert_vprintf(Eina_Strbuf *buf,
+                           const char *fmt,
+                           size_t pos,
+                           va_list args)
 {
    char *str;
    size_t len;
    Eina_Bool ret;
 
-   EINA_SAFETY_ON_NULL_RETURN_VAL(fmt, EINA_FALSE);
-   EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE);
-
    len = vasprintf(&str, fmt, args);
 
    if (len <= 0 || !str)
-     return EINA_FALSE;
+      return EINA_FALSE;
 
    ret = eina_strbuf_insert(buf, str, pos);
    free(str);
    return ret;
 }
 
-/**
- * @brief Remove a slice of the given string buffer.
- *
- * @param buf The string buffer to remove a slice.
- * @param start The initial (inclusive) slice position to start
- *        removing, in bytes.
- * @param end The final (non-inclusive) slice position to finish
- *        removing, in bytes.
- * @return #EINA_TRUE on success, #EINA_FALSE on failure.
- *
- * This function removes a slice of @p buf, starting at @p start
- * (inclusive) and ending at @p end (non-inclusive). Both values are
- * in bytes. It returns #EINA_FALSE on failure, #EINA_TRUE otherwise.
- */
-EAPI Eina_Bool
-eina_strbuf_remove(Eina_Strbuf *buf, size_t start, size_t end)
-{
-   size_t remove_len, tail_len;
-
-   EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE);
-
-   if (end >= buf->len)
-     end = buf->len;
-
-   if (end <= start)
-     return EINA_TRUE;
-
-   remove_len = end - start;
-   if (remove_len == buf->len)
-     {
-       free(buf->buf);
-       return _eina_strbuf_init(buf);
-     }
-
-   tail_len = buf->len - end + 1; /* includes '\0' */
-   memmove(buf->buf + start, buf->buf + end, tail_len);
-   buf->len -= remove_len;
-   return _eina_strbuf_resize(buf, buf->len);
-}
+/* Unicode */
 
-/**
- * @brief Retrieve a pointer to the contents of a string buffer
- *
- * @param buf The string buffer.
- * @return The current string in the string buffer.
- *
- * This function returns the string contained in @p buf. The returned
- * value must not be modified and will no longer be valid if @p buf is
- * modified. In other words, any eina_strbuf_append() or similar will
- * make that pointer invalid.
- *
- * @see eina_strbuf_string_steal()
- */
-EAPI const char *
-eina_strbuf_string_get(const Eina_Strbuf *buf)
-{
-   EINA_MAGIC_CHECK_STRBUF(buf, NULL);
-
-   return buf->buf;
-}
-
-/**
- * @brief Steal the contents of a string buffer.
- *
- * @param buf The string buffer to steal.
- * @return The current string in the string buffer.
- *
- * This function returns the string contained in @p buf. @p buf is
- * then initialized and does not own anymore the returned string. The
- * caller must release the memory of the returned string by calling
- * free(). 
- *
- * @see eina_strbuf_string_get()
- */
-EAPI char *
-eina_strbuf_string_steal(Eina_Strbuf *buf)
-{
-   char *ret;
-
-   EINA_MAGIC_CHECK_STRBUF(buf, NULL);
-
-   ret = buf->buf;
-   // TODO: Check return value and do something clever
-   _eina_strbuf_init(buf);
-   return ret;
-}
-
-/**
- * @brief Retrieve the length of the string buffer content.
- *
- * @param buf The string buffer.
- * @return The current length of the string, in bytes.
- *
- * This function returns the length of @p buf.
- */
-EAPI size_t
-eina_strbuf_length_get(const Eina_Strbuf *buf)
-{
-   EINA_MAGIC_CHECK_STRBUF(buf, 0);
-
-   return buf->len;
-}
-
-/**
- * @ brief Replace the n-th string with an other string.
- *
- * @param buf The string buffer to work with.
- * @param str The string to replace.
- * @param with The replaceing string.
- * @param n The number of the fitting string.
- * @return #EINA_TRUE on success, #EINA_FALSE on failure.
- *
- * This function replaces the n-th occurence of @p str in @p buf with
- * @p with. It returns #EINA_FALSE on failure, #EINA_TRUE otherwise.
- */
-EAPI Eina_Bool
-eina_strbuf_replace(Eina_Strbuf *buf, const char *str, const char *with, unsigned int n)
-{
-   size_t len1, len2;
-   char *spos;
-   size_t pos;
-
-   EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(with, EINA_FALSE);
-   EINA_MAGIC_CHECK_STRBUF(buf, 0);
-
-   if (n == 0)
-     return EINA_FALSE;
-
-   spos = buf->buf;
-   while (n--)
-     {
-       spos = strstr(spos, str);
-       if (!spos || *spos == '\0')
-         return EINA_FALSE;
-       if (n) spos++;
-     }
-
-   pos = spos - buf->buf;
-   len1 = strlen(str);
-   len2 = strlen(with);
-   if (len1 != len2)
-     {
-       /* resize the buffer if necessary */
-       if (EINA_UNLIKELY(!_eina_strbuf_grow(buf, buf->len - len1 + len2)))
-         return EINA_FALSE;
-       /* move the existing text */
-       memmove(buf->buf + pos + len2, buf->buf + pos + len1,
-             buf->len - pos - len1);
-     }
-   /* and now insert the given string */
-   memcpy(buf->buf + pos, with, len2);
-   buf->len += len2 - len1;
-   buf->buf[buf->len] = 0;
-
-   return EINA_TRUE;
-}
-
-/**
- * @brief Replace all strings with an other string.
-
- * @param buf the string buffer to work with.
- * @param str The string to replace.
- * @param with The replaceing string.
- * @return How often the string was replaced.
- *
- * This function replaces all the occurences of @p str in @ buf with
- * the string @p with. This function returns the number of times @p str
- * has been replaced. On failure, it returns 0.
- */
-EAPI int
-eina_strbuf_replace_all(Eina_Strbuf *buf, const char *str, const char *with)
-{
-   size_t len1, len2, len;
-   char *tmp_buf = NULL;
-   char *spos;
-   size_t pos, start;
-   size_t pos_tmp, start_tmp;
-   int n = 0;
-
-   EINA_SAFETY_ON_NULL_RETURN_VAL(str, 0);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(with, 0);
-   EINA_MAGIC_CHECK_STRBUF(buf, 0);
-
-   spos = strstr(buf->buf, str);
-   if (!spos || *spos == '\0')
-     return 0;
-
-   len1 = strlen(str);
-   len2 = strlen(with);
-
-   /* if the size of the two string is equal, it is fairly easy to replace them
-    * we don't need to resize the buffer or doing other calculations */
-   if (len1 == len2)
-     {
-       while (spos)
-         {
-            memcpy(spos, with, len2);
-            spos = strstr(spos + len2, str);
-            n++;
-         }
-       return n;
-     }
-
-   pos = pos_tmp = spos - buf->buf;
-   tmp_buf = buf->buf;
-   buf->buf = malloc(buf->size);
-   if (EINA_UNLIKELY(!buf->buf))
-     {
-       buf->buf = tmp_buf;
-       return 0;
-     }
-   start = start_tmp = 0;
-   len = buf->len;
-
-   while (spos)
-     {
-       n++;
-       len = (len + len2) - len1;
-       /* resize the buffer if necessary */
-       if (EINA_UNLIKELY(!_eina_strbuf_grow(buf, len)))
-         {
-            /* we have to stop replacing here, because we haven't enough
-             * memory to go on */
-            len = (len + len1) - len2;
-            break;
-         }
-
-       /* copy the untouched text */
-       memcpy(buf->buf + start, tmp_buf + start_tmp, pos - start);
-       /* copy the new string */
-       memcpy(buf->buf + pos, with, len2);
-
-       /* calculate the next positions */
-       start_tmp = pos_tmp + len1;
-       start = pos + len2;
-       spos = strstr(tmp_buf + start_tmp, str);
-       /* this calculations don't make sense if spos == NULL, but the
-        * calculated values won't be used, because the loop will stop
-        * then */
-       pos_tmp = spos - tmp_buf;
-       pos = start + pos_tmp - start_tmp;
-     }
-   /* and now copy the rest of the text */
-   memcpy(buf->buf + start, tmp_buf + start_tmp, len - start);
-   buf->len = len;
-   buf->buf[buf->len] = 0;
-
-   free(tmp_buf);
-
-   return n;
-}
+#include "eina_strbuf_template_c.x"
 
 /**
  * @}
diff --git a/src/lib/eina_strbuf_common.c b/src/lib/eina_strbuf_common.c
new file mode 100644 (file)
index 0000000..eee3323
--- /dev/null
@@ -0,0 +1,862 @@
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#define _GNU_SOURCE
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef _WIN32
+# include <Evil.h>
+#endif
+
+#include "eina_private.h"
+#include "eina_str.h"
+#include "eina_magic.h"
+#include "eina_error.h"
+#include "eina_safety_checks.h"
+#include "eina_strbuf.h"
+#include "eina_strbuf_common.h"
+
+/*============================================================================*
+*                                  Local                                     *
+*============================================================================*/
+
+/**
+ * @cond LOCAL
+ */
+
+#define EINA_STRBUF_INIT_SIZE 32
+#define EINA_STRBUF_INIT_STEP 32
+#define EINA_STRBUF_MAX_STEP 4096
+
+/**
+ * @endcond
+ */
+
+/*============================================================================*
+*                                 Global                                     *
+*============================================================================*/
+
+/**
+ * @internal
+ * @brief Initialize the strbuf module.
+ *
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function sets up the strbuf module of Eina. It is called by
+ * eina_init().
+ *
+ * @see eina_init()
+ */
+Eina_Bool
+eina_strbuf_common_init(void)
+{
+   return EINA_TRUE;
+}
+
+/**
+ * @internal
+ * @brief Shut down the strbuf module.
+ *
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function shuts down the strbuf module set up by
+ * eina_strbuf_common_init(). It is called by eina_shutdown().
+ *
+ * @see eina_shutdown()
+ */
+Eina_Bool
+eina_strbuf_common_shutdown(void)
+{
+   return EINA_TRUE;
+}
+
+/**
+ * @internal
+ *
+ * init the buffer
+ * @param buf the buffer to init
+ *
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ */
+static Eina_Bool
+_eina_strbuf_common_init(size_t csize, Eina_Strbuf *buf)
+{
+   buf->len = 0;
+   buf->size = EINA_STRBUF_INIT_SIZE;
+   buf->step = EINA_STRBUF_INIT_STEP;
+
+        eina_error_set(0);
+   buf->buf = calloc(csize, buf->size);
+   if (EINA_UNLIKELY(!buf->buf))
+     {
+        eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+        return EINA_FALSE;
+     }
+
+   return EINA_TRUE;
+}
+
+/**
+ * @internal
+ *
+ * resize the buffer
+ * @param buf the buffer to resize
+ * @param size the minimum size of the buffer
+ *
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ */
+static inline Eina_Bool
+_eina_strbuf_common_resize(size_t csize, Eina_Strbuf *buf, size_t size)
+{
+   size_t new_size, new_step, delta;
+   void *buffer;
+
+   size += 1; // Add extra space for '\0'
+
+   if (size == buf->size)
+      /* nothing to do */
+      return EINA_TRUE;
+   else if (size > buf->size)
+      delta = size - buf->size;
+   else
+      delta = buf->size - size;
+
+   /* check if should keep the same step (just used while growing) */
+   if ((delta <= buf->step) && (size > buf->size))
+      new_step = buf->step;
+   else
+     {
+        new_step = (((delta / EINA_STRBUF_INIT_STEP) + 1)
+                    * EINA_STRBUF_INIT_STEP);
+
+        if (new_step > EINA_STRBUF_MAX_STEP)
+           new_step = EINA_STRBUF_MAX_STEP;
+     }
+
+   new_size = (((size / new_step) + 1) * new_step);
+
+   /* reallocate the buffer to the new size */
+   buffer = realloc(buf->buf, new_size * csize);
+   if (EINA_UNLIKELY(!buffer))
+     {
+        eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+        return EINA_FALSE;
+     }
+
+   buf->buf = buffer;
+   buf->size = new_size;
+   buf->step = new_step;
+        eina_error_set(0);
+   return EINA_TRUE;
+}
+
+/**
+ * @internal
+ *
+ * If required, enlarge the buffer to fit the new size.
+ *
+ * @param buf the buffer to resize
+ * @param size the minimum size of the buffer
+ *
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ */
+Eina_Bool
+_eina_strbuf_common_grow(size_t csize, Eina_Strbuf *buf, size_t size)
+{
+   if ((size + 1) < buf->size)
+      return EINA_TRUE;
+
+   return _eina_strbuf_common_resize(csize, buf, size);
+}
+
+/**
+ * @internal
+ *
+ * insert string of known length at random within existing strbuf limits.
+ *
+ * @param buf the buffer to resize, must be valid.
+ * @param str the string to copy, must be valid (!NULL and smaller than @a len)
+ * @param len the amount of bytes in @a str to copy, must be valid.
+ * @param pos the position inside buffer to insert, must be valid (smaller
+ *        than eina_strbuf_common_length_get())
+ *
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ */
+static inline Eina_Bool
+_eina_strbuf_common_insert_length(size_t csize,
+                                  Eina_Strbuf *buf,
+                                  const void *str,
+                                  size_t len,
+                                  size_t pos)
+{
+   if (EINA_UNLIKELY(!_eina_strbuf_common_grow(csize, buf, buf->len + len)))
+      return EINA_FALSE;
+
+   /* move the existing text */
+   memmove(buf->buf + ((len + pos) * csize), buf->buf + (pos * csize),
+           (buf->len - pos) * csize);
+
+   /* and now insert the given string */
+   memcpy(buf->buf + (pos * csize), str, len * csize);
+
+   buf->len += len;
+   memset(buf->buf + (buf->len * csize), 0, csize);
+   return EINA_TRUE;
+}
+
+/*============================================================================*
+*                                   API                                      *
+*============================================================================*/
+
+/**
+ * @brief Create a new string buffer.
+ *
+ * @return Newly allocated string buffer instance.
+ *
+ * This function creates a new string buffer. On error, @c NULL is
+ * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To
+ * free the resources, use eina_strbuf_common_free().
+ *
+ * @see eina_strbuf_common_free()
+ * @see eina_strbuf_common_append()
+ * @see eina_strbuf_common_string_get()
+ */
+Eina_Strbuf *
+eina_strbuf_common_new(size_t csize)
+{
+   Eina_Strbuf *buf;
+
+        eina_error_set(0);
+   buf = malloc(sizeof(Eina_Strbuf));
+   if (EINA_UNLIKELY(!buf))
+     {
+        eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+        return NULL;
+     }
+
+   if (EINA_UNLIKELY(!_eina_strbuf_common_init(csize, buf)))
+     {
+        eina_strbuf_common_free(buf);
+        return NULL;
+     }
+
+   return buf;
+}
+
+/**
+ * @brief Free a string buffer.
+ *
+ * @param buf The string buffer to free.
+ *
+ * This function frees the memory of @p buf. @p buf must have been
+ * created by eina_strbuf_common_new().
+ */
+void
+eina_strbuf_common_free(Eina_Strbuf *buf)
+{
+   free(buf->buf);
+   free(buf);
+}
+
+/**
+ * @brief Reset a string buffer.
+ *
+ * @param buf The string buffer to reset.
+ *
+ * This function reset @p buf: the buffer len is set to 0, and the
+ * string is set to '\\0'. No memory is free'd.
+ */
+void
+eina_strbuf_common_reset(size_t csize, Eina_Strbuf *buf)
+{
+   buf->len = 0;
+   buf->step = EINA_STRBUF_INIT_STEP;
+
+   memset(buf->buf, 0, csize);
+}
+
+/**
+ * @brief Append a string to a buffer, reallocating as necessary.
+ *
+ * @param buf The string buffer to append to.
+ * @param str The string to append.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function appends @p str to @p buf. It computes the length of
+ * @p str, so is slightly slower than eina_strbuf_common_append_length(). If
+ * the length is known beforehand, consider using that variant. If
+ * @p buf can't append it, #EINA_FALSE is returned, otherwise
+ * #EINA_TRUE is returned.
+ *
+ * @see eina_strbuf_common_append()
+ * @see eina_strbuf_common_append_length()
+ */
+Eina_Bool
+eina_strbuf_common_append(size_t csize,
+                          Eina_Strbuf *buf,
+                          const void *str,
+                          size_t len)
+{
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
+
+   if (EINA_UNLIKELY(!_eina_strbuf_common_grow(csize, buf, buf->len + len)))
+      return EINA_FALSE;
+
+   memcpy(buf->buf + (buf->len * csize), str, (len + 1) * csize);
+   buf->len += len;
+   return EINA_TRUE;
+}
+
+/**
+ * @brief Append a string to a buffer, reallocating as necessary,
+ * limited by the given length.
+ *
+ * @param buf The string buffer to append to.
+ * @param str The string to append.
+ * @param maxlen The maximum number of characters to append.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function appends at most @p maxlen characters of @p str to
+ * @p buf. It can't appends more than the length of @p str. It
+ * computes the length of @p str, so is slightly slower than
+ * eina_strbuf_common_append_length(). If the length is known beforehand,
+ * consider using that variant (@p maxlen should then be checked so
+ * that it is greater than the size of @p str). If @p str can not be
+ * appended, #EINA_FALSE is returned, otherwise, #EINA_TRUE is
+ * returned.
+ *
+ * @see eina_strbuf_common_append()
+ * @see eina_strbuf_common_append_length()
+ */
+Eina_Bool
+eina_strbuf_common_append_n(size_t csize,
+                            Eina_Strbuf *buf,
+                            const void *str,
+                            size_t len,
+                            size_t maxlen)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
+
+   if (len > maxlen)
+      len = maxlen;
+
+   if (EINA_UNLIKELY(!_eina_strbuf_common_grow(csize, buf, buf->len + len)))
+      return EINA_FALSE;
+
+   memcpy(buf->buf + (buf->len * csize), str, len * csize);
+   buf->len += len;
+   memset(buf->buf + (buf->len * csize), 0, csize);
+   return EINA_TRUE;
+}
+
+/**
+ * @brief Append a string of exact length to a buffer, reallocating as necessary.
+ *
+ * @param buf The string buffer to append to.
+ * @param str The string to append.
+ * @param length The exact length to use.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function appends @p str to @p buf. @p str must be of size at
+ * most @p length. It is slightly faster than eina_strbuf_common_append() as
+ * it does not compute the size of @p str. It is useful when dealing
+ * with strings of known size, such as eina_strngshare. If @p buf
+ * can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
+ * returned.
+ *
+ * @see eina_stringshare_length()
+ * @see eina_strbuf_common_append()
+ * @see eina_strbuf_common_append_n()
+ */
+Eina_Bool
+eina_strbuf_common_append_length(size_t csize,
+                                 Eina_Strbuf *buf,
+                                 const void *str,
+                                 size_t length)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
+
+   if (EINA_UNLIKELY(!_eina_strbuf_common_grow(csize, buf, buf->len + length)))
+      return EINA_FALSE;
+
+   memcpy(buf->buf + (buf->len * csize), str, length * csize);
+   buf->len += length;
+   memset(buf->buf + (buf->len * csize), 0, csize);
+   return EINA_TRUE;
+}
+
+/**
+ * @brief Insert a string to a buffer, reallocating as necessary.
+ *
+ * @param buf The string buffer to insert.
+ * @param str The string to insert.
+ * @param pos The position to insert the string.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function inserts @p str to @p buf at position @p pos. It
+ * computes the length of @p str, so is slightly slower than
+ * eina_strbuf_common_insert_length(). If  the length is known beforehand,
+ * consider using that variant. If @p buf can't insert it, #EINA_FALSE
+ * is returned, otherwise #EINA_TRUE is returned.
+ */
+Eina_Bool
+eina_strbuf_common_insert(size_t csize,
+                          Eina_Strbuf *buf,
+                          const void *str,
+                          size_t len,
+                          size_t pos)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
+
+   if (pos >= buf->len)
+      return eina_strbuf_common_append(csize, buf, str, len);
+
+   return _eina_strbuf_common_insert_length(csize, buf, str, len, pos);
+}
+
+/**
+ * @brief Insert a string to a buffer, reallocating as necessary. Limited by maxlen.
+ *
+ * @param buf The string buffer to insert to.
+ * @param str The string to insert.
+ * @param maxlen The maximum number of chars to insert.
+ * @param pos The position to insert the string.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function inserts @p str ot @p buf at position @p pos, with at
+ * most @p maxlen bytes. The number of inserted characters can not be
+ * greater than the length of @p str. It computes the length of
+ * @p str, so is slightly slower than eina_strbuf_common_insert_length(). If the
+ * length is known beforehand, consider using that variant (@p maxlen
+ * should then be checked so that it is greater than the size of
+ * @p str). If @p str can not be inserted, #EINA_FALSE is returned,
+ * otherwise, #EINA_TRUE is returned.
+ */
+Eina_Bool
+eina_strbuf_common_insert_n(size_t csize,
+                            Eina_Strbuf *buf,
+                            const void *str,
+                            size_t len,
+                            size_t maxlen,
+                            size_t pos)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
+
+   if (pos >= buf->len)
+      return eina_strbuf_common_append_n(csize, buf, str, len, maxlen);
+
+   if (len > maxlen)
+      len = maxlen;
+
+   return _eina_strbuf_common_insert_length(csize, buf, str, len, pos);
+}
+
+/**
+ * @brief Insert a string of exact length to a buffer, reallocating as necessary.
+ *
+ * @param buf The string buffer to insert to.
+ * @param str The string to insert.
+ * @param length The exact length to use.
+ * @param pos The position to insert the string.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function inserts @p str to @p buf. @p str must be of size at
+ * most @p length. It is slightly faster than eina_strbuf_common_insert() as
+ * it does not compute the size of @p str. It is useful when dealing
+ * with strings of known size, such as eina_strngshare. If @p buf
+ * can't insert it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
+ * returned.
+ *
+ * @see eina_stringshare_length()
+ * @see eina_strbuf_common_insert()
+ * @see eina_strbuf_common_insert_n()
+ */
+Eina_Bool
+eina_strbuf_common_insert_length(size_t csize,
+                                 Eina_Strbuf *buf,
+                                 const void *str,
+                                 size_t length,
+                                 size_t pos)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(str, EINA_FALSE);
+
+   if (pos >= buf->len)
+      return eina_strbuf_common_append_length(csize, buf, str, length);
+
+   return _eina_strbuf_common_insert_length(csize, buf, str, length, pos);
+}
+
+/**
+ * @brief Append a character to a string buffer, reallocating as
+ * necessary.
+ *
+ * @param buf The string buffer to append to.
+ * @param c The char to append.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function inserts @p c to @p buf. If it can not insert it,
+ * #EINA_FALSE is returned, otherwise #EINA_TRUE is returned.
+ */
+Eina_Bool
+eina_strbuf_common_append_char(size_t csize, Eina_Strbuf *buf, const void *c)
+{
+
+   if (EINA_UNLIKELY(!_eina_strbuf_common_grow(csize, buf, buf->len + 1)))
+      return EINA_FALSE;
+
+   memcpy(buf->buf + ((buf->len)++ *csize), c, csize);
+   memset(buf->buf + (buf->len * csize), 0, csize);
+   return EINA_TRUE;
+}
+
+/**
+ * @brief Insert a character to a string buffer, reallocating as
+ * necessary.
+ *
+ * @param buf The string buffer to insert to.
+ * @param c The char to insert.
+ * @param pos The position to insert the char.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function inserts @p c to @p buf at position @p pos. If @p buf
+ * can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
+ * returned.
+ */
+Eina_Bool
+eina_strbuf_common_insert_char(size_t csize,
+                               Eina_Strbuf *buf,
+                               const void *c,
+                               size_t pos)
+{
+
+   if (pos >= buf->len)
+      return eina_strbuf_common_append_char(csize, buf, c);
+
+   return _eina_strbuf_common_insert_length(csize, buf, c, 1, pos);
+}
+
+/**
+ * @brief Remove a slice of the given string buffer.
+ *
+ * @param buf The string buffer to remove a slice.
+ * @param start The initial (inclusive) slice position to start
+ *        removing, in bytes.
+ * @param end The final (non-inclusive) slice position to finish
+ *        removing, in bytes.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function removes a slice of @p buf, starting at @p start
+ * (inclusive) and ending at @p end (non-inclusive). Both values are
+ * in bytes. It returns #EINA_FALSE on failure, #EINA_TRUE otherwise.
+ */
+Eina_Bool
+eina_strbuf_common_remove(size_t csize,
+                          Eina_Strbuf *buf,
+                          size_t start,
+                          size_t end)
+{
+   size_t remove_len, tail_len;
+
+   if (end >= buf->len)
+      end = buf->len;
+
+   if (end <= start)
+      return EINA_TRUE;
+
+   remove_len = end - start;
+   if (remove_len == buf->len)
+     {
+        free(buf->buf);
+        return _eina_strbuf_common_init(csize, buf);
+     }
+
+   tail_len = buf->len - end + 1; /* includes '\0' */
+   memmove(buf->buf + (start * csize),
+           buf->buf + (end * csize),
+           tail_len * csize);
+   buf->len -= remove_len;
+   return _eina_strbuf_common_resize(csize, buf, buf->len);
+}
+
+/**
+ * @brief Retrieve a pointer to the contents of a string buffer
+ *
+ * @param buf The string buffer.
+ * @return The current string in the string buffer.
+ *
+ * This function returns the string contained in @p buf. The returned
+ * value must not be modified and will no longer be valid if @p buf is
+ * modified. In other words, any eina_strbuf_common_append() or similar will
+ * make that pointer invalid.
+ *
+ * @see eina_strbuf_common_string_steal()
+ */
+const void *
+eina_strbuf_common_string_get(const Eina_Strbuf *buf)
+{
+   return buf->buf;
+}
+
+/**
+ * @brief Steal the contents of a string buffer.
+ *
+ * @param buf The string buffer to steal.
+ * @return The current string in the string buffer.
+ *
+ * This function returns the string contained in @p buf. @p buf is
+ * then initialized and does not own the returned string anymore. The
+ * caller must release the memory of the returned string by calling
+ * free().
+ *
+ * @see eina_strbuf_common_string_get()
+ */
+void *
+eina_strbuf_common_string_steal(size_t csize, Eina_Strbuf *buf)
+{
+   void *ret;
+
+   ret = buf->buf;
+   // TODO: Check return value and do something clever
+   _eina_strbuf_common_init(csize, buf);
+   return ret;
+}
+
+/**
+ * @brief Free the contents of a string buffer but not the buffer.
+ *
+ * @param buf The string buffer to free the string of.
+ *
+ * This function frees the string contained in @p buf without freeing
+ * @p buf.
+ */
+void
+eina_strbuf_common_string_free(size_t csize, Eina_Strbuf *buf)
+{
+   free(buf->buf);
+   _eina_strbuf_common_init(csize, buf);
+}
+
+/**
+ * @brief Retrieve the length of the string buffer content.
+ *
+ * @param buf The string buffer.
+ * @return The current length of the string, in bytes.
+ *
+ * This function returns the length of @p buf.
+ */
+size_t
+eina_strbuf_common_length_get(const Eina_Strbuf *buf)
+{
+   return buf->len;
+}
+
+/**
+ * @addtogroup Eina_String_Buffer_Group String Buffer
+ *
+ * @brief These functions provide string buffers management.
+ *
+ * The String Buffer data type is designed to be a mutable string,
+ * allowing to append, prepend or insert a string to a buffer.
+ *
+ * @{
+ */
+
+
+/**
+ * @cond LOCAL
+ */
+
+/*FIXME: Implementing them here is a hack! */
+
+#ifdef _STRBUF_CSIZE
+# undef _STRBUF_CSIZE
+#endif
+
+#ifdef _STRBUF_MAGIC
+# undef _STRBUF_MAGIC
+#endif
+
+#ifdef _STRBUF_MAGIC_STR
+# undef _STRBUF_MAGIC_STR
+#endif
+
+#define _STRBUF_CSIZE 1
+#define _STRBUF_MAGIC             EINA_MAGIC_STRBUF
+#define _STRBUF_MAGIC_STR         __STRBUF_STR_MAGIC_STR
+static const char __STRBUF_STR_MAGIC_STR[] = "Eina Strbuf";
+
+
+/**
+ * @endcond
+ */
+
+
+/**
+ * @brief Replace the n-th string with an other string.
+ *
+ * @param buf The string buffer to work with.
+ * @param str The string to replace.
+ * @param with The replaceing string.
+ * @param n The number of the fitting string.
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function replaces the n-th occurence of @p str in @p buf with
+ * @p with. It returns #EINA_FALSE on failure, #EINA_TRUE otherwise.
+ */
+EAPI Eina_Bool
+eina_strbuf_replace(Eina_Strbuf *buf,
+                    const char *str,
+                    const char *with,
+                    unsigned int n)
+{
+   size_t len1, len2;
+   char *spos;
+   size_t pos;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL( str, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(with, EINA_FALSE);
+   EINA_MAGIC_CHECK_STRBUF(buf, 0);
+
+   if (n == 0)
+      return EINA_FALSE;
+
+   spos = buf->buf;
+   while (n--)
+     {
+        spos = strstr(spos, str);
+        if (!spos || *spos == '\0')
+           return EINA_FALSE;
+
+        if (n)
+           spos++;
+     }
+
+   pos = spos - (const char *)buf->buf;
+   len1 = strlen(str);
+   len2 = strlen(with);
+   if (len1 != len2)
+     {
+        /* resize the buffer if necessary */
+        if (EINA_UNLIKELY(!_eina_strbuf_common_grow(_STRBUF_CSIZE, buf,
+                                                    buf->len - len1 + len2)))
+          {
+             return EINA_FALSE; /* move the existing text */
+
+          }
+
+        memmove(buf->buf + pos + len2, buf->buf + pos + len1,
+                buf->len - pos - len1);
+     }
+
+   /* and now insert the given string */
+   memcpy(buf->buf + pos, with, len2);
+   buf->len += len2 - len1;
+   memset((char *)buf->buf + buf->len, 0, 1);
+
+   return EINA_TRUE;
+}
+
+/**
+ * @brief Replace all strings with an other string.
+
+ * @param buf the string buffer to work with.
+ * @param str The string to replace.
+ * @param with The replaceing string.
+ * @return How often the string was replaced.
+ *
+ * This function replaces all the occurences of @p str in @ buf with
+ * the string @p with. This function returns the number of times @p str
+ * has been replaced. On failure, it returns 0.
+ */
+EAPI int
+eina_strbuf_replace_all(Eina_Strbuf *buf, const char *str, const char *with)
+{
+   size_t len1, len2, len;
+   char *tmp_buf = NULL;
+   char *spos;
+   size_t pos, start;
+   size_t pos_tmp, start_tmp;
+   int n = 0;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL( str, 0);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(with, 0);
+   EINA_MAGIC_CHECK_STRBUF(buf, 0);
+
+   spos = strstr(buf->buf, str);
+   if (!spos || *spos == '\0')
+      return 0;
+
+   len1 = strlen(str);
+   len2 = strlen(with);
+
+   /* if the size of the two string is equal, it is fairly easy to replace them
+    * we don't need to resize the buffer or doing other calculations */
+   if (len1 == len2)
+     {
+        while (spos)
+          {
+             memcpy(spos, with, len2);
+             spos = strstr(spos + len2, str);
+             n++;
+          }
+        return n;
+     }
+
+   pos = pos_tmp = spos - (const char *)buf->buf;
+   tmp_buf = buf->buf;
+   buf->buf = malloc(buf->size);
+   if (EINA_UNLIKELY(!buf->buf))
+     {
+        buf->buf = tmp_buf;
+        return 0;
+     }
+
+   start = start_tmp = 0;
+   len = buf->len;
+
+   while (spos)
+     {
+        n++;
+        len = (len + len2) - len1;
+        /* resize the buffer if necessary */
+        if (EINA_UNLIKELY(!_eina_strbuf_common_grow(_STRBUF_CSIZE, buf, len)))
+          {
+             /* we have to stop replacing here, because we haven't enough
+              * memory to go on */
+             len = (len + len1) - len2;
+             break;
+          }
+
+        /* copy the untouched text */
+             memcpy(buf->buf + start, tmp_buf + start_tmp, pos - start);
+        /* copy the new string */
+             memcpy(buf->buf + pos,   with,                len2);
+
+        /* calculate the next positions */
+        start_tmp = pos_tmp + len1;
+        start = pos + len2;
+        spos = strstr(tmp_buf + start_tmp, str);
+        /* this calculations don't make sense if spos == NULL, but the
+         * calculated values won't be used, because the loop will stop
+         * then */
+        pos_tmp = spos - tmp_buf;
+        pos = start + pos_tmp - start_tmp;
+     }
+   /* and now copy the rest of the text */
+             memcpy(buf->buf + start, tmp_buf + start_tmp, len - start);
+   buf->len = len;
+             memset((char *)buf->buf + buf->len, 0, 1);
+
+   free(tmp_buf);
+
+   return n;
+}
+
+/**
+ * @}
+ */
diff --git a/src/lib/eina_strbuf_common.h b/src/lib/eina_strbuf_common.h
new file mode 100644 (file)
index 0000000..3713f2c
--- /dev/null
@@ -0,0 +1,112 @@
+#ifndef EINA_STRBUF_COMMON_H
+#define EINA_STRBUF_COMMON_H
+
+#include <stdlib.h>
+
+#include "eina_private.h"
+#include "eina_magic.h"
+#include "eina_strbuf.h"
+
+struct _Eina_Strbuf
+{
+   void *buf;
+   size_t len;
+   size_t size;
+   size_t step;
+
+   EINA_MAGIC
+};
+
+#define EINA_MAGIC_CHECK_STRBUF(d, ...)                         \
+   do {                                                         \
+        if (!EINA_MAGIC_CHECK((d), _STRBUF_MAGIC))              \
+          {                                                     \
+             EINA_MAGIC_FAIL((d), _STRBUF_MAGIC);               \
+             return __VA_ARGS__;                                \
+          }                                                     \
+     } while (0)
+
+Eina_Bool
+eina_strbuf_common_init(void);
+
+Eina_Bool
+eina_strbuf_common_shutdown(void);
+Eina_Strbuf *
+eina_strbuf_common_new(size_t csize);
+void
+eina_strbuf_common_free(Eina_Strbuf *buf);
+void
+eina_strbuf_common_reset(size_t csize, Eina_Strbuf *buf);
+Eina_Bool
+eina_strbuf_common_append(size_t csize,
+                          Eina_Strbuf *buf,
+                          const void *str,
+                          size_t len);
+Eina_Bool
+eina_strbuf_common_append_escaped(size_t csize,
+                                  Eina_Strbuf *buf,
+                                  const void *str);
+Eina_Bool
+eina_strbuf_common_append_n(size_t csize,
+                            Eina_Strbuf *buf,
+                            const void *str,
+                            size_t len,
+                            size_t maxlen);
+Eina_Bool
+eina_strbuf_common_append_length(size_t csize,
+                                 Eina_Strbuf *buf,
+                                 const void *str,
+                                 size_t length);
+Eina_Bool
+eina_strbuf_common_insert(size_t csize,
+                          Eina_Strbuf *buf,
+                          const void *str,
+                          size_t len,
+                          size_t pos);
+Eina_Bool
+eina_strbuf_common_insert_escaped(size_t csize,
+                                  Eina_Strbuf *buf,
+                                  const void *str,
+                                  size_t len,
+                                  size_t pos);
+Eina_Bool
+eina_strbuf_common_insert_n(size_t csize,
+                            Eina_Strbuf *buf,
+                            const void *str,
+                            size_t len,
+                            size_t maxlen,
+                            size_t pos);
+Eina_Bool
+eina_strbuf_common_insert_length(size_t csize,
+                                 Eina_Strbuf *buf,
+                                 const void *str,
+                                 size_t length,
+                                 size_t pos);
+Eina_Bool
+eina_strbuf_common_append_char(size_t csize, Eina_Strbuf *buf, const void *c);
+Eina_Bool
+eina_strbuf_common_insert_char(size_t csize,
+                               Eina_Strbuf *buf,
+                               const void *c,
+                               size_t pos);
+Eina_Bool
+eina_strbuf_common_remove(size_t csize,
+                          Eina_Strbuf *buf,
+                          size_t start,
+                          size_t end);
+const void *
+eina_strbuf_common_string_get(const Eina_Strbuf *buf);
+void *
+eina_strbuf_common_string_steal(size_t csize, Eina_Strbuf *buf);
+void
+eina_strbuf_common_string_free(size_t csize, Eina_Strbuf *buf);
+size_t
+eina_strbuf_common_length_get(const Eina_Strbuf *buf);
+
+Eina_Bool
+_eina_strbuf_common_grow(size_t csize, Eina_Strbuf *buf, size_t size);
+/**
+ * @}
+ */
+
+#endif
diff --git a/src/lib/eina_strbuf_template_c.x b/src/lib/eina_strbuf_template_c.x
new file mode 100644 (file)
index 0000000..2f3aeae
--- /dev/null
@@ -0,0 +1,216 @@
+/*
+ * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
+ */
+
+/* This file should be included from files implementing strbuf. The including file
+ * should define the following macros:
+ * _STRBUF_DATA_TYPE
+ * _STRBUF_CSIZE
+ * _STRBUF_STRUCT_NAME
+ * _STRBUF_STRLEN_FUNC(x)
+ * _STRBUF_STRESCAPE_FUNC(x)
+ * _STRBUF_STRSTR_FUNC(x, y)
+ * _STRBUF_MAGIC
+ * _STRBUF_MAGIC_STR
+ * See how it's done in eina_ustrbuf.c and eina_strbuf.c. This just makes things
+ * a lot easier since those are essentially the same just with different sizes.
+ */
+
+/*============================================================================*
+ *                                  Local                                     *
+ *============================================================================*/
+
+
+/*============================================================================*
+ *                                 Global                                     *
+ *============================================================================*/
+
+/**
+ * @internal
+ * @brief Initialize the strbuf module.
+ *
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function sets up the strbuf module of Eina. It is called by
+ * eina_init().
+ *
+ * @see eina_init()
+ */
+Eina_Bool
+_FUNC_EXPAND(init)(void)
+{
+   eina_magic_string_static_set(_STRBUF_MAGIC, _STRBUF_MAGIC_STR);
+   return eina_strbuf_common_init();
+}
+
+/**
+ * @internal
+ * @brief Shut down the strbuf module.
+ *
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function shuts down the strbuf module set up by
+ * eina_ustrbuf_init(). It is called by eina_shutdown().
+ *
+ * @see eina_shutdown()
+ */
+Eina_Bool
+_FUNC_EXPAND(shutdown)(void)
+{
+   return eina_strbuf_common_shutdown();
+}
+
+/*============================================================================*
+ *                                   API                                      *
+ *============================================================================*/
+
+EAPI _STRBUF_STRUCT_NAME *
+_FUNC_EXPAND(new)(void)
+{
+   _STRBUF_STRUCT_NAME *buf = eina_strbuf_common_new(_STRBUF_CSIZE);
+   EINA_MAGIC_SET(buf, _STRBUF_MAGIC);
+   return buf;
+}
+
+EAPI void
+_FUNC_EXPAND(free)(_STRBUF_STRUCT_NAME *buf)
+{
+   EINA_MAGIC_CHECK_STRBUF(buf);
+   EINA_MAGIC_SET(buf, EINA_MAGIC_NONE);
+   eina_strbuf_common_free(buf);
+}
+
+EAPI void
+_FUNC_EXPAND(reset)(_STRBUF_STRUCT_NAME *buf)
+{
+   EINA_MAGIC_CHECK_STRBUF(buf);
+   eina_strbuf_common_reset(_STRBUF_CSIZE, buf);
+}
+
+EAPI Eina_Bool
+_FUNC_EXPAND(append)(_STRBUF_STRUCT_NAME *buf, const _STRBUF_DATA_TYPE *str)
+{
+   EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE);
+   return eina_strbuf_common_append(_STRBUF_CSIZE, buf, (const void *) str, _STRBUF_STRLEN_FUNC(str));
+}
+
+EAPI Eina_Bool
+_FUNC_EXPAND(append_escaped)(_STRBUF_STRUCT_NAME *buf, const _STRBUF_DATA_TYPE *str)
+{
+   _STRBUF_DATA_TYPE *esc;
+   Eina_Bool ret;
+
+   EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE);
+   esc = _STRBUF_STRESCAPE_FUNC(str);
+   if (!esc) {
+      return _FUNC_EXPAND(append)(buf, str);
+   }
+   ret = _FUNC_EXPAND(append)(buf, esc);
+   if (esc)
+      free(esc);
+
+   return ret;
+}
+
+EAPI Eina_Bool
+_FUNC_EXPAND(append_n)(_STRBUF_STRUCT_NAME *buf, const _STRBUF_DATA_TYPE *str, size_t maxlen)
+{
+   EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE);
+   return eina_strbuf_common_append_n(_STRBUF_CSIZE, buf, (const void *) str, _STRBUF_STRLEN_FUNC(str), maxlen);
+}
+
+EAPI Eina_Bool
+_FUNC_EXPAND(append_length)(_STRBUF_STRUCT_NAME *buf, const _STRBUF_DATA_TYPE *str, size_t length)
+{
+   EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE);
+   return eina_strbuf_common_append_length(_STRBUF_CSIZE, buf, (const void *) str, length);
+}
+
+EAPI Eina_Bool
+_FUNC_EXPAND(insert)(_STRBUF_STRUCT_NAME *buf, const _STRBUF_DATA_TYPE *str, size_t pos)
+{
+   EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE);
+   return eina_strbuf_common_insert(_STRBUF_CSIZE, buf, (const void *) str, _STRBUF_STRLEN_FUNC(str), pos);
+}
+
+EAPI Eina_Bool
+_FUNC_EXPAND(insert_escaped)(_STRBUF_STRUCT_NAME *buf, const _STRBUF_DATA_TYPE *str, size_t pos)
+{
+   _STRBUF_DATA_TYPE *esc;
+   Eina_Bool ret;
+   EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE);
+
+   esc = _STRBUF_STRESCAPE_FUNC(str);
+   if (!esc) {
+      return _FUNC_EXPAND(insert)(buf, str, pos);
+   }
+   ret = _FUNC_EXPAND(insert)(buf, esc, pos);
+   if (esc)
+      free(esc);
+
+   return ret;
+}
+
+EAPI Eina_Bool
+_FUNC_EXPAND(insert_n)(_STRBUF_STRUCT_NAME *buf, const _STRBUF_DATA_TYPE *str, size_t maxlen, size_t pos)
+{
+   EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE);
+   return eina_strbuf_common_insert_n(_STRBUF_CSIZE, buf, (const void *) str, _STRBUF_STRLEN_FUNC(str), maxlen, pos);
+}
+
+EAPI Eina_Bool
+_FUNC_EXPAND(insert_length)(_STRBUF_STRUCT_NAME *buf, const _STRBUF_DATA_TYPE *str, size_t length, size_t pos)
+{
+   EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE);
+   return eina_strbuf_common_insert_length(_STRBUF_CSIZE, buf, (const void *) str, length, pos);
+}
+
+EAPI Eina_Bool
+_FUNC_EXPAND(append_char)(_STRBUF_STRUCT_NAME *buf, _STRBUF_DATA_TYPE c)
+{
+   EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE);
+   return eina_strbuf_common_append_char(_STRBUF_CSIZE, buf, (const void *) &c);
+}
+
+EAPI Eina_Bool
+_FUNC_EXPAND(insert_char)(_STRBUF_STRUCT_NAME *buf, _STRBUF_DATA_TYPE c, size_t pos)
+{
+   EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE);
+   return eina_strbuf_common_insert_char(_STRBUF_CSIZE, buf, (const void *) &c, pos);
+}
+
+EAPI Eina_Bool
+_FUNC_EXPAND(remove)(_STRBUF_STRUCT_NAME *buf, size_t start, size_t end)
+{
+   EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE);
+   return eina_strbuf_common_remove(_STRBUF_CSIZE, buf, start, end);
+}
+
+EAPI const _STRBUF_DATA_TYPE *
+_FUNC_EXPAND(string_get)(const _STRBUF_STRUCT_NAME *buf)
+{
+   EINA_MAGIC_CHECK_STRBUF(buf, NULL);
+   return (const _STRBUF_DATA_TYPE *) eina_strbuf_common_string_get(buf);
+}
+
+EAPI _STRBUF_DATA_TYPE *
+_FUNC_EXPAND(string_steal)(_STRBUF_STRUCT_NAME *buf)
+{
+   EINA_MAGIC_CHECK_STRBUF(buf, NULL);
+   return (_STRBUF_DATA_TYPE *) eina_strbuf_common_string_steal(_STRBUF_CSIZE, buf);
+}
+
+
+EAPI void
+_FUNC_EXPAND(string_free)(_STRBUF_STRUCT_NAME *buf)
+{
+   EINA_MAGIC_CHECK_STRBUF(buf);
+   eina_strbuf_common_string_free(_STRBUF_CSIZE, buf);
+}
+
+EAPI size_t
+_FUNC_EXPAND(length_get)(const _STRBUF_STRUCT_NAME *buf)
+{
+   EINA_MAGIC_CHECK_STRBUF(buf, 0);
+   return eina_strbuf_common_length_get(buf);
+}
index b0b58ad..a35f08f 100644 (file)
@@ -1,11 +1,11 @@
-/*
- * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
- */
 /* EINA - EFL data type library
- * Copyright (C) 2002-2008 Carsten Haitzler,
+ * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2010
+ *                        Carsten Haitzler,
  *                         Jorge Luis Zapata Muga,
  *                         Cedric Bail,
  *                         Gustavo Sverzut Barbieri
+ *                         Tom Hacohen
+ *                         Brett Nash
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * 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/>.
- *
- * This file incorporates work covered by the following copyright and
- * permission notice:
- *
- * Copyright (C) 2008 Peter Wehrfritz
- *
- *  Permission is hereby granted, free of charge, to any person obtaining a copy
- *  of this software and associated documentation files (the "Software"), to
- *  deal in the Software without restriction, including without limitation the
- *  rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- *  sell copies of the Software, and to permit persons to whom the Software is
- *  furnished to do so, subject to the following conditions:
- *
- *  The above copyright notice and this permission notice shall be included in
- *  all copies of the Software and its Copyright notices. In addition publicly
- *  documented acknowledgment must be given that this software has been used if no
- *  source code of this software is made available publicly. This includes
- *  acknowledgments in either Copyright notices, Manuals, Publicity and Marketing
- *  documents or any documentation provided with any product containing this
- *  software. This License does not apply to any software that links to the
- *  libraries provided by this software (statically or dynamically), but only to
- *  the software provided.
- *
- *  Please see the OLD-COPYING.PLAIN for a plain-english explanation of this notice
- *  and it's intent.
- *
- *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- *  THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
- *  IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- *  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
-
 /**
  * @page tutorial_stringshare_page Stringshare Tutorial
  *
 # include "config.h"
 #endif
 
+#define _GNU_SOURCE
+
+#ifdef HAVE_ALLOCA_H
+# include <alloca.h>
+#elif defined __GNUC__
+# define alloca __builtin_alloca
+#elif defined _AIX
+# define alloca __alloca
+#elif defined _MSC_VER
+# include <malloc.h>
+# define alloca _alloca
+#else
+# include <stddef.h>
+# ifdef  __cplusplus
+extern "C"
+# endif
+void *alloca (size_t);
+#endif
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 
-#ifdef EFL_HAVE_PTHREAD
+#ifdef EFL_HAVE_POSIX_THREADS
 # include <pthread.h>
 #endif
 
 #include "eina_hash.h"
 #include "eina_rbtree.h"
 #include "eina_error.h"
+#include "eina_stringshare.h"
 
 /* undefs EINA_ARG_NONULL() so NULL checks are not compiled out! */
 #include "eina_safety_checks.h"
-#include "eina_stringshare.h"
+#include "eina_share_common.h"
 
-/*============================================================================*
- *                                  Local                                     *
- *============================================================================*/
-
-/**
- * @cond LOCAL
- */
-
-#define EINA_STRINGSHARE_BUCKETS 256
-#define EINA_STRINGSHARE_MASK 0xFF
-
-static const char EINA_MAGIC_STRINGSHARE_STR[] = "Eina Stringshare";
-static const char EINA_MAGIC_STRINGSHARE_HEAD_STR[] = "Eina Stringshare Head";
+/* The actual share */
+static Eina_Share *stringshare_share;
 static const char EINA_MAGIC_STRINGSHARE_NODE_STR[] = "Eina Stringshare Node";
 
+#ifdef EFL_HAVE_THREADS
+extern Eina_Bool _share_common_threads_activated;
 
-#define EINA_MAGIC_CHECK_STRINGSHARE_HEAD(d, unlock, ...)      \
-  do {                                                         \
-    if (!EINA_MAGIC_CHECK((d), EINA_MAGIC_STRINGSHARE_HEAD))   \
-    {                                                          \
-        EINA_MAGIC_FAIL((d), EINA_MAGIC_STRINGSHARE_HEAD);     \
-        unlock;                                                        \
-        return __VA_ARGS__;                                    \
-    }                                                          \
-  } while (0)
-
-#define EINA_MAGIC_CHECK_STRINGSHARE_NODE(d, unlock)           \
-  do {                                                         \
-    if (!EINA_MAGIC_CHECK((d), EINA_MAGIC_STRINGSHARE_NODE))   \
-    {                                                          \
-      unlock;                                                  \
-      EINA_MAGIC_FAIL((d), EINA_MAGIC_STRINGSHARE_NODE);       \
-    }                                                          \
-  } while (0)
-
-typedef struct _Eina_Stringshare             Eina_Stringshare;
-typedef struct _Eina_Stringshare_Node        Eina_Stringshare_Node;
-typedef struct _Eina_Stringshare_Head        Eina_Stringshare_Head;
-
-struct _Eina_Stringshare
-{
-   Eina_Stringshare_Head *buckets[EINA_STRINGSHARE_BUCKETS];
-
-   EINA_MAGIC
-};
-
-struct _Eina_Stringshare_Node
-{
-   Eina_Stringshare_Node *next;
-
-   EINA_MAGIC
-
-   unsigned int           length;
-   unsigned int           references;
-   char                   str[];
-};
-
-struct _Eina_Stringshare_Head
-{
-   EINA_RBTREE;
-   EINA_MAGIC
-
-   int                    hash;
-
-#ifdef EINA_STRINGSHARE_USAGE
-   int                    population;
-#endif
-
-   Eina_Stringshare_Node *head;
-   Eina_Stringshare_Node  builtin_node;
-};
-
-static Eina_Stringshare *share = NULL;
-static int _eina_stringshare_log_dom = -1;
-
-#ifdef CRITICAL
-#undef CRITICAL
-#endif
-#define CRITICAL(...) EINA_LOG_DOM_CRIT(_eina_stringshare_log_dom, __VA_ARGS__)
-
-#ifdef ERR
-#undef ERR
-#endif
-#define ERR(...) EINA_LOG_DOM_ERR(_eina_stringshare_log_dom, __VA_ARGS__)
-
-#ifdef DBG
-#undef DBG
-#endif
-#define DBG(...) EINA_LOG_DOM_DBG(_eina_stringshare_log_dom, __VA_ARGS__)
-
-
-
-#ifdef EFL_HAVE_PTHREAD
-static Eina_Bool _stringshare_threads_activated = EINA_FALSE;
-//string < 4
+# ifdef EFL_HAVE_POSIX_THREADS
 static pthread_mutex_t _mutex_small = PTHREAD_MUTEX_INITIALIZER;
-//string >= 4
-static pthread_mutex_t _mutex_big = PTHREAD_MUTEX_INITIALIZER;
-#define STRINGSHARE_LOCK_SMALL() if(_stringshare_threads_activated) pthread_mutex_lock(&_mutex_small)
-#define STRINGSHARE_UNLOCK_SMALL() if(_stringshare_threads_activated) pthread_mutex_unlock(&_mutex_small)
-#define STRINGSHARE_LOCK_BIG() if(_stringshare_threads_activated) pthread_mutex_lock(&_mutex_big)
-#define STRINGSHARE_UNLOCK_BIG() if(_stringshare_threads_activated) pthread_mutex_unlock(&_mutex_big)
-#else
-#define STRINGSHARE_LOCK_SMALL() do {} while (0)
-#define STRINGSHARE_UNLOCK_SMALL() do {} while (0)
-#define STRINGSHARE_LOCK_BIG() do {} while (0)
-#define STRINGSHARE_UNLOCK_BIG() do {} while (0)
+#  define STRINGSHARE_LOCK_SMALL() if(_share_common_threads_activated) \
+      pthread_mutex_lock(&_mutex_small)
+#  define STRINGSHARE_UNLOCK_SMALL() if(_share_common_threads_activated) \
+      pthread_mutex_unlock(&_mutex_small)
+# else /* EFL_HAVE_WIN32_THREADS */
+static HANDLE _mutex_small = NULL;
+#  define STRINGSHARE_LOCK_SMALL() if(_share_common_threads_activated) \
+      WaitForSingleObject(_mutex_small, INFINITE)
+#  define STRINGSHARE_UNLOCK_SMALL() if(_share_common_threads_activated) \
+      ReleaseMutex(_mutex_small)
+
+# endif /* EFL_HAVE_WIN32_THREADS */
+#else /* EFL_HAVE_THREADS */
+# define STRINGSHARE_LOCK_SMALL() do {} while (0)
+# define STRINGSHARE_UNLOCK_SMALL() do {} while (0)
 #endif
 
-
+/* Stringshare optimizations */
 static const unsigned char _eina_stringshare_single[512] = {
-  0,0,1,0,2,0,3,0,4,0,5,0,6,0,7,0,8,0,9,0,10,0,11,0,12,0,13,0,14,0,15,0,
-  16,0,17,0,18,0,19,0,20,0,21,0,22,0,23,0,24,0,25,0,26,0,27,0,28,0,29,0,30,0,
-  31,0,32,0,33,0,34,0,35,0,36,0,37,0,38,0,39,0,40,0,41,0,42,0,43,0,44,0,45,0,
-  46,0,47,0,48,0,49,0,50,0,51,0,52,0,53,0,54,0,55,0,56,0,57,0,58,0,59,0,60,0,
-  61,0,62,0,63,0,64,0,65,0,66,0,67,0,68,0,69,0,70,0,71,0,72,0,73,0,74,0,75,0,
-  76,0,77,0,78,0,79,0,80,0,81,0,82,0,83,0,84,0,85,0,86,0,87,0,88,0,89,0,90,0,
-  91,0,92,0,93,0,94,0,95,0,96,0,97,0,98,0,99,0,100,0,101,0,102,0,103,0,104,0,105,0,
-  106,0,107,0,108,0,109,0,110,0,111,0,112,0,113,0,114,0,115,0,116,0,117,0,118,0,119,0,120,0,
-  121,0,122,0,123,0,124,0,125,0,126,0,127,0,128,0,129,0,130,0,131,0,132,0,133,0,134,0,135,0,
-  136,0,137,0,138,0,139,0,140,0,141,0,142,0,143,0,144,0,145,0,146,0,147,0,148,0,149,0,150,0,
-  151,0,152,0,153,0,154,0,155,0,156,0,157,0,158,0,159,0,160,0,161,0,162,0,163,0,164,0,165,0,
-  166,0,167,0,168,0,169,0,170,0,171,0,172,0,173,0,174,0,175,0,176,0,177,0,178,0,179,0,180,0,
-  181,0,182,0,183,0,184,0,185,0,186,0,187,0,188,0,189,0,190,0,191,0,192,0,193,0,194,0,195,0,
-  196,0,197,0,198,0,199,0,200,0,201,0,202,0,203,0,204,0,205,0,206,0,207,0,208,0,209,0,210,0,
-  211,0,212,0,213,0,214,0,215,0,216,0,217,0,218,0,219,0,220,0,221,0,222,0,223,0,224,0,225,0,
-  226,0,227,0,228,0,229,0,230,0,231,0,232,0,233,0,234,0,235,0,236,0,237,0,238,0,239,0,240,0,
-  241,0,242,0,243,0,244,0,245,0,246,0,247,0,248,0,249,0,250,0,251,0,252,0,253,0,254,0,255,0
+   0,0,1,0,2,0,3,0,4,0,5,0,6,0,7,0,8,0,9,0,10,0,11,0,12,0,13,0,14,0,15,0,
+   16,0,17,0,18,0,19,0,20,0,21,0,22,0,23,0,24,0,25,0,26,0,27,0,28,0,29,0,30,0,
+   31,0,32,0,33,0,34,0,35,0,36,0,37,0,38,0,39,0,40,0,41,0,42,0,43,0,44,0,45,0,
+   46,0,47,0,48,0,49,0,50,0,51,0,52,0,53,0,54,0,55,0,56,0,57,0,58,0,59,0,60,0,
+   61,0,62,0,63,0,64,0,65,0,66,0,67,0,68,0,69,0,70,0,71,0,72,0,73,0,74,0,75,0,
+   76,0,77,0,78,0,79,0,80,0,81,0,82,0,83,0,84,0,85,0,86,0,87,0,88,0,89,0,90,0,
+   91,0,92,0,93,0,94,0,95,0,96,0,97,0,98,0,99,0,100,0,101,0,102,0,103,0,104,0,
+   105,0,
+   106,0,107,0,108,0,109,0,110,0,111,0,112,0,113,0,114,0,115,0,116,0,117,0,118,
+   0,119,0,120,0,
+   121,0,122,0,123,0,124,0,125,0,126,0,127,0,128,0,129,0,130,0,131,0,132,0,133,
+   0,134,0,135,0,
+   136,0,137,0,138,0,139,0,140,0,141,0,142,0,143,0,144,0,145,0,146,0,147,0,148,
+   0,149,0,150,0,
+   151,0,152,0,153,0,154,0,155,0,156,0,157,0,158,0,159,0,160,0,161,0,162,0,163,
+   0,164,0,165,0,
+   166,0,167,0,168,0,169,0,170,0,171,0,172,0,173,0,174,0,175,0,176,0,177,0,178,
+   0,179,0,180,0,
+   181,0,182,0,183,0,184,0,185,0,186,0,187,0,188,0,189,0,190,0,191,0,192,0,193,
+   0,194,0,195,0,
+   196,0,197,0,198,0,199,0,200,0,201,0,202,0,203,0,204,0,205,0,206,0,207,0,208,
+   0,209,0,210,0,
+   211,0,212,0,213,0,214,0,215,0,216,0,217,0,218,0,219,0,220,0,221,0,222,0,223,
+   0,224,0,225,0,
+   226,0,227,0,228,0,229,0,230,0,231,0,232,0,233,0,234,0,235,0,236,0,237,0,238,
+   0,239,0,240,0,
+   241,0,242,0,243,0,244,0,245,0,246,0,247,0,248,0,249,0,250,0,251,0,252,0,253,
+   0,254,0,255,0
 };
 
-typedef struct _Eina_Stringshare_Small        Eina_Stringshare_Small;
+typedef struct _Eina_Stringshare_Small Eina_Stringshare_Small;
 typedef struct _Eina_Stringshare_Small_Bucket Eina_Stringshare_Small_Bucket;
 
 struct _Eina_Stringshare_Small_Bucket
 {
    /* separate arrays for faster lookups */
-   const char    **strings;
-   unsigned char  *lengths;
+   const char **strings;
+   unsigned char *lengths;
    unsigned short *references;
    int count;
    int size;
@@ -239,173 +154,11 @@ struct _Eina_Stringshare_Small
 #define EINA_STRINGSHARE_SMALL_BUCKET_STEP 8
 static Eina_Stringshare_Small _eina_small_share;
 
-
-#ifdef EINA_STRINGSHARE_USAGE
-typedef struct _Eina_Stringshare_Population Eina_Stringshare_Population;
-struct _Eina_Stringshare_Population
-{
-   int count;
-   int max;
-};
-
-static Eina_Stringshare_Population population = { 0, 0 };
-
-static Eina_Stringshare_Population population_group[4] =
-  {
-    { 0, 0 },
-    { 0, 0 },
-    { 0, 0 },
-    { 0, 0 }
-  };
-
-static int max_node_population = 0;
-
-
-static void
-_eina_stringshare_population_init(void)
-{
-   unsigned int i;
-
-   for (i = 0; i < sizeof (population_group) / sizeof (population_group[0]); ++i)
-     {
-       population_group[i].count = 0;
-       population_group[i].max = 0;
-     }
-}
-
-static void
-_eina_stringshare_population_shutdown(void)
-{
-   unsigned int i;
-
-   max_node_population = 0;
-   population.count = 0;
-   population.max = 0;
-
-   for (i = 0; i < sizeof (population_group) / sizeof (population_group[0]); ++i)
-     {
-       population_group[i].count = 0;
-       population_group[i].max = 0;
-     }
-}
-
-static void
-_eina_stringshare_population_stats(void)
-{
-   unsigned int i;
-
-   fprintf(stderr, "eina stringshare statistic:\n");
-   fprintf(stderr, " * maximum shared strings : %i\n", population.max);
-   fprintf(stderr, " * maximum shared strings per node : %i\n", max_node_population);
-
-   for (i = 0; i < sizeof (population_group) / sizeof (population_group[0]); ++i)
-     fprintf(stderr, "DDD: %i strings of length %i, max strings: %i\n", population_group[i].count, i, population_group[i].max);
-}
-
-static void
-_eina_stringshare_population_add(int slen)
-{
-   STRINGSHARE_LOCK_SMALL();
-   STRINGSHARE_LOCK_BIG();
-
-   population.count++;
-   if (population.count > population.max)
-     population.max = population.count;
-
-   if (slen < 4)
-     {
-       population_group[slen].count++;
-       if (population_group[slen].count > population_group[slen].max)
-         population_group[slen].max = population_group[slen].count;
-     }
-
-   STRINGSHARE_UNLOCK_BIG();
-   STRINGSHARE_UNLOCK_SMALL();
-}
-
-static void
-_eina_stringshare_population_del(int slen)
-{
-   STRINGSHARE_LOCK_SMALL();
-   STRINGSHARE_LOCK_BIG();
-
-   population.count--;
-   if (slen < 4)
-     population_group[slen].count--;
-
-   STRINGSHARE_UNLOCK_BIG();
-   STRINGSHARE_UNLOCK_SMALL();
-}
-
-static void
-_eina_stringshare_population_head_init(Eina_Stringshare_Head *head)
-{
-   head->population = 1;
-}
-
-static void
-_eina_stringshare_population_head_add(Eina_Stringshare_Head *head)
-{
-   head->population++;
-   if (head->population > max_node_population)
-     max_node_population = head->population;
-}
-
-static void
-_eina_stringshare_population_head_del(Eina_Stringshare_Head *head)
-{
-   head->population--;
-}
-
-#else /* EINA_STRINGSHARE_USAGE undefined */
-
-static void _eina_stringshare_population_init(void) {}
-static void _eina_stringshare_population_shutdown(void) {}
-static void _eina_stringshare_population_stats(void) {}
-static void _eina_stringshare_population_add(__UNUSED__ int slen) {}
-static void _eina_stringshare_population_del(__UNUSED__ int slen) {}
-static void _eina_stringshare_population_head_init(__UNUSED__ Eina_Stringshare_Head *head) {}
-static void _eina_stringshare_population_head_add(__UNUSED__ Eina_Stringshare_Head *head) {}
-static void _eina_stringshare_population_head_del(__UNUSED__ Eina_Stringshare_Head *head) {}
-#endif
-
-static int
-_eina_stringshare_cmp(const Eina_Stringshare_Head *ed, const int *hash, __UNUSED__ int length, __UNUSED__ void *data)
-{
-   EINA_MAGIC_CHECK_STRINGSHARE_HEAD(ed, , 0);
-
-   return ed->hash - *hash;
-}
-
-static Eina_Rbtree_Direction
-_eina_stringshare_node(const Eina_Stringshare_Head *left, const Eina_Stringshare_Head *right, __UNUSED__ void *data)
-{
-   EINA_MAGIC_CHECK_STRINGSHARE_HEAD(left, , 0);
-   EINA_MAGIC_CHECK_STRINGSHARE_HEAD(right, , 0);
-
-   if (left->hash - right->hash < 0)
-     return EINA_RBTREE_LEFT;
-   return EINA_RBTREE_RIGHT;
-}
-
-static void
-_eina_stringshare_head_free(Eina_Stringshare_Head *ed, __UNUSED__ void *data)
-{
-   EINA_MAGIC_CHECK_STRINGSHARE_HEAD(ed, );
-
-   while (ed->head)
-     {
-       Eina_Stringshare_Node *el = ed->head;
-
-       ed->head = ed->head->next;
-       if (el != &ed->builtin_node)
-         MAGIC_FREE(el);
-     }
-   MAGIC_FREE(ed);
-}
-
 static inline int
-_eina_stringshare_small_cmp(const Eina_Stringshare_Small_Bucket *bucket, int i, const char *pstr, unsigned char plength)
+_eina_stringshare_small_cmp(const Eina_Stringshare_Small_Bucket *bucket,
+                            int i,
+                            const char *pstr,
+                            unsigned char plength)
 {
    /* pstr and plength are from second char and on, since the first is
     * always the same.
@@ -419,30 +172,33 @@ _eina_stringshare_small_cmp(const Eina_Stringshare_Small_Bucket *bucket, int i,
    const char *cur_pstr;
 
    if (cur_plength > plength)
-     return 1;
+      return 1;
    else if (cur_plength < plength)
-     return -1;
+      return -1;
 
    cur_pstr = bucket->strings[i] + 1;
 
    if (cur_pstr[0] > pstr[0])
-     return 1;
+      return 1;
    else if (cur_pstr[0] < pstr[0])
-     return -1;
+      return -1;
 
    if (plength == 1)
-     return 0;
+      return 0;
 
    if (cur_pstr[1] > pstr[1])
-     return 1;
+      return 1;
    else if (cur_pstr[1] < pstr[1])
-     return -1;
+      return -1;
 
    return 0;
 }
 
 static const char *
-_eina_stringshare_small_bucket_find(const Eina_Stringshare_Small_Bucket *bucket, const char *str, unsigned char length, int *idx)
+_eina_stringshare_small_bucket_find(const Eina_Stringshare_Small_Bucket *bucket,
+                                    const char *str,
+                                    unsigned char length,
+                                    int *idx)
 {
    const char *pstr = str + 1; /* skip first letter, it's always the same */
    unsigned char plength = length - 1;
@@ -450,8 +206,8 @@ _eina_stringshare_small_bucket_find(const Eina_Stringshare_Small_Bucket *bucket,
 
    if (bucket->count == 0)
      {
-       *idx = 0;
-       return NULL;
+        *idx = 0;
+        return NULL;
      }
 
    low = 0;
@@ -459,24 +215,20 @@ _eina_stringshare_small_bucket_find(const Eina_Stringshare_Small_Bucket *bucket,
 
    while (low < high)
      {
-       int r;
-
-       i = (low + high - 1) / 2;
-
-       r = _eina_stringshare_small_cmp(bucket, i, pstr, plength);
-       if (r > 0)
-         {
-            high = i;
-         }
-       else if (r < 0)
-         {
-            low = i + 1;
-         }
-       else
-         {
-            *idx = i;
-            return bucket->strings[i];
-         }
+        int r;
+
+        i = (low + high - 1) / 2;
+
+        r = _eina_stringshare_small_cmp(bucket, i, pstr, plength);
+        if (r > 0)
+           high = i;
+        else if (r < 0)
+           low = i + 1;
+        else
+          {
+             *idx = i;
+             return bucket->strings[i];
+          }
      }
 
    *idx = low;
@@ -484,32 +236,36 @@ _eina_stringshare_small_bucket_find(const Eina_Stringshare_Small_Bucket *bucket,
 }
 
 static Eina_Bool
-_eina_stringshare_small_bucket_resize(Eina_Stringshare_Small_Bucket *bucket, int size)
+_eina_stringshare_small_bucket_resize(Eina_Stringshare_Small_Bucket *bucket,
+                                      int size)
 {
    void *tmp;
 
-   tmp = realloc((void*)bucket->strings, size * sizeof(bucket->strings[0]));
+   tmp = realloc((void *)bucket->strings, size * sizeof(bucket->strings[0]));
    if (!tmp)
      {
-       eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
-       return 0;
+             eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+        return 0;
      }
+
    bucket->strings = tmp;
 
    tmp = realloc(bucket->lengths, size * sizeof(bucket->lengths[0]));
    if (!tmp)
      {
-       eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
-       return 0;
+             eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+        return 0;
      }
+
    bucket->lengths = tmp;
 
    tmp = realloc(bucket->references, size * sizeof(bucket->references[0]));
    if (!tmp)
      {
-       eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
-       return 0;
+             eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+        return 0;
      }
+
    bucket->references = tmp;
 
    bucket->size = size;
@@ -517,7 +273,11 @@ _eina_stringshare_small_bucket_resize(Eina_Stringshare_Small_Bucket *bucket, int
 }
 
 static const char *
-_eina_stringshare_small_bucket_insert_at(Eina_Stringshare_Small_Bucket **p_bucket, const char *str, unsigned char length, int idx)
+_eina_stringshare_small_bucket_insert_at(
+   Eina_Stringshare_Small_Bucket **p_bucket,
+   const char *str,
+   unsigned char length,
+   int idx)
 {
    Eina_Stringshare_Small_Bucket *bucket = *p_bucket;
    int todo, off;
@@ -525,27 +285,28 @@ _eina_stringshare_small_bucket_insert_at(Eina_Stringshare_Small_Bucket **p_bucke
 
    if (!bucket)
      {
-       *p_bucket = bucket = calloc(1, sizeof(*bucket));
-       if (!bucket)
-         {
-            eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
-            return NULL;
-         }
+        *p_bucket = bucket = calloc(1, sizeof(*bucket));
+        if (!bucket)
+          {
+             eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+             return NULL;
+          }
      }
 
    if (bucket->count + 1 >= bucket->size)
      {
-       int size = bucket->size + EINA_STRINGSHARE_SMALL_BUCKET_STEP;
-       if (!_eina_stringshare_small_bucket_resize(bucket, size))
-         return NULL;
+        int size = bucket->size + EINA_STRINGSHARE_SMALL_BUCKET_STEP;
+        if (!_eina_stringshare_small_bucket_resize(bucket, size))
+           return NULL;
      }
 
    snew = malloc(length + 1);
    if (!snew)
      {
-       eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
-       return NULL;
+             eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+        return NULL;
      }
+
    memcpy(snew, str, length);
    snew[length] = '\0';
 
@@ -553,12 +314,12 @@ _eina_stringshare_small_bucket_insert_at(Eina_Stringshare_Small_Bucket **p_bucke
    todo = bucket->count - idx;
    if (todo > 0)
      {
-       memmove((void *)(bucket->strings + off), bucket->strings + idx,
-               todo * sizeof(bucket->strings[0]));
-       memmove(bucket->lengths + off, bucket->lengths + idx,
-               todo * sizeof(bucket->lengths[0]));
-       memmove(bucket->references + off, bucket->references + idx,
-               todo * sizeof(bucket->references[0]));
+        memmove((void *)(bucket->strings + off), bucket->strings + idx,
+                todo * sizeof(bucket->strings[0]));
+        memmove(bucket->lengths + off,           bucket->lengths + idx,
+                todo * sizeof(bucket->lengths[0]));
+        memmove(bucket->references + off,        bucket->references + idx,
+                todo * sizeof(bucket->references[0]));
      }
 
    bucket->strings[idx] = snew;
@@ -570,48 +331,50 @@ _eina_stringshare_small_bucket_insert_at(Eina_Stringshare_Small_Bucket **p_bucke
 }
 
 static void
-_eina_stringshare_small_bucket_remove_at(Eina_Stringshare_Small_Bucket **p_bucket, int idx)
+_eina_stringshare_small_bucket_remove_at(
+   Eina_Stringshare_Small_Bucket **p_bucket,
+   int idx)
 {
    Eina_Stringshare_Small_Bucket *bucket = *p_bucket;
    int todo, off;
 
    if (bucket->references[idx] > 1)
      {
-       bucket->references[idx]--;
-       return;
+        bucket->references[idx]--;
+        return;
      }
 
-   free((char *)bucket->strings[idx]);
+        free((char *)bucket->strings[idx]);
 
    if (bucket->count == 1)
      {
-       free((void *)bucket->strings);
-       free(bucket->lengths);
-       free(bucket->references);
-       free(bucket);
-       *p_bucket = NULL;
-       return;
+        free((void *)bucket->strings);
+        free(bucket->lengths);
+        free(bucket->references);
+        free(bucket);
+        *p_bucket = NULL;
+        return;
      }
 
    bucket->count--;
    if (idx == bucket->count)
-     goto end;
+      goto end;
 
    off = idx + 1;
    todo = bucket->count - idx;
 
    memmove((void *)(bucket->strings + idx), bucket->strings + off,
-          todo * sizeof(bucket->strings[0]));
-   memmove(bucket->lengths + idx, bucket->lengths + off,
-          todo * sizeof(bucket->lengths[0]));
-   memmove(bucket->references + idx, bucket->references + off,
-          todo * sizeof(bucket->references[0]));
+           todo * sizeof(bucket->strings[0]));
+   memmove(bucket->lengths + idx,           bucket->lengths + off,
+           todo * sizeof(bucket->lengths[0]));
+   memmove(bucket->references + idx,        bucket->references + off,
+           todo * sizeof(bucket->references[0]));
 
- end:
+end:
    if (bucket->count + EINA_STRINGSHARE_SMALL_BUCKET_STEP < bucket->size)
      {
-       int size = bucket->size - EINA_STRINGSHARE_SMALL_BUCKET_STEP;
-       _eina_stringshare_small_bucket_resize(bucket, size);
+        int size = bucket->size - EINA_STRINGSHARE_SMALL_BUCKET_STEP;
+        _eina_stringshare_small_bucket_resize(bucket, size);
      }
 }
 
@@ -623,16 +386,16 @@ _eina_stringshare_small_add(const char *str, unsigned char length)
 
    bucket = _eina_small_share.buckets + (unsigned char)str[0];
    if (!*bucket)
-     i = 0;
+      i = 0;
    else
      {
-       const char *ret;
-       ret = _eina_stringshare_small_bucket_find(*bucket, str, length, &i);
-       if (ret)
-         {
-            (*bucket)->references[i]++;
-            return ret;
-         }
+        const char *ret;
+        ret = _eina_stringshare_small_bucket_find(*bucket, str, length, &i);
+        if (ret)
+          {
+             (*bucket)->references[i]++;
+             return ret;
+          }
      }
 
    return _eina_stringshare_small_bucket_insert_at(bucket, str, length, i);
@@ -647,16 +410,16 @@ _eina_stringshare_small_del(const char *str, unsigned char length)
 
    bucket = _eina_small_share.buckets + (unsigned char)str[0];
    if (!*bucket)
-     goto error;
+      goto error;
 
    ret = _eina_stringshare_small_bucket_find(*bucket, str, length, &i);
    if (!ret)
-     goto error;
+      goto error;
 
    _eina_stringshare_small_bucket_remove_at(bucket, i);
    return;
 
- error:
+error:
    CRITICAL("EEEK trying to del non-shared stringshare \"%s\"", str);
 }
 
@@ -676,179 +439,28 @@ _eina_stringshare_small_shutdown(void)
 
    for (; p_bucket < p_bucket_end; p_bucket++)
      {
-       Eina_Stringshare_Small_Bucket *bucket = *p_bucket;
-       char **s, **s_end;
-
-       if (!bucket)
-         continue;
-
-       s = (char **)bucket->strings;
-       s_end = s + bucket->count;
-       for (; s < s_end; s++)
-         free(*s);
-
-       free((void *)bucket->strings);
-       free(bucket->lengths);
-       free(bucket->references);
-       free(bucket);
-       *p_bucket = NULL;
-     }
-}
-
-static void
-_eina_stringshare_node_init(Eina_Stringshare_Node *node, const char *str, int slen)
-{
-   EINA_MAGIC_SET(node, EINA_MAGIC_STRINGSHARE_NODE);
-   node->references = 1;
-   node->length = slen;
-   memcpy(node->str, str, slen);
-   node->str[slen] = '\0';
-}
-
-static Eina_Stringshare_Head *
-_eina_stringshare_head_alloc(int slen)
-{
-   Eina_Stringshare_Head *head, t;
-   const size_t head_size = (char *)&(t.builtin_node.str) - (char *)&t;
-
-   head = malloc(head_size + slen + 1);
-   if (!head)
-     eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
-
-   return head;
-}
-
-static const char *
-_eina_stringshare_add_head(Eina_Stringshare_Head **p_bucket, int hash, const char *str, int slen)
-{
-   Eina_Rbtree **p_tree = (Eina_Rbtree **)p_bucket;
-   Eina_Stringshare_Head *head;
-
-   head = _eina_stringshare_head_alloc(slen);
-   if (!head)
-     return NULL;
-
-   EINA_MAGIC_SET(head, EINA_MAGIC_STRINGSHARE_HEAD);
-   head->hash = hash;
-   head->head = &head->builtin_node;
-   _eina_stringshare_node_init(head->head, str, slen);
-   head->head->next = NULL;
-
-   _eina_stringshare_population_head_init(head);
+        Eina_Stringshare_Small_Bucket *bucket = *p_bucket;
+        char **s, **s_end;
 
-   *p_tree = eina_rbtree_inline_insert
-     (*p_tree, EINA_RBTREE_GET(head),
-      EINA_RBTREE_CMP_NODE_CB(_eina_stringshare_node), NULL);
+        if (!bucket)
+           continue;
 
-   return head->head->str;
-}
-
-static void
-_eina_stringshare_del_head(Eina_Stringshare_Head **p_bucket, Eina_Stringshare_Head *head)
-{
-   Eina_Rbtree **p_tree = (Eina_Rbtree **)p_bucket;
-
-   *p_tree = eina_rbtree_inline_remove
-     (*p_tree, EINA_RBTREE_GET(head),
-      EINA_RBTREE_CMP_NODE_CB(_eina_stringshare_node), NULL);
-
-   MAGIC_FREE(head);
-}
-
-
-static inline Eina_Bool
-_eina_stringshare_node_eq(const Eina_Stringshare_Node *node, const char *str, unsigned int slen)
-{
-   return ((node->length == slen) &&
-          (memcmp(node->str, str, slen) == 0));
-}
-
-static Eina_Stringshare_Node *
-_eina_stringshare_head_find(Eina_Stringshare_Head *head, const char *str, unsigned int slen)
-{
-   Eina_Stringshare_Node *node, *prev;
-
-   node = head->head;
-   if (_eina_stringshare_node_eq(node, str, slen))
-     return node;
-
-   prev = node;
-   node = node->next;
-   for (; node != NULL; prev = node, node = node->next)
-     if (_eina_stringshare_node_eq(node, str, slen))
-       {
-         /* promote node, make hot items be at the beginning */
-         prev->next = node->next;
-         node->next = head->head;
-         head->head = node;
-         return node;
-       }
-
-   return NULL;
-}
-
-static Eina_Bool
-_eina_stringshare_head_remove_node(Eina_Stringshare_Head *head, const Eina_Stringshare_Node *node)
-{
-   Eina_Stringshare_Node *cur, *prev;
+        s = (char **)bucket->strings;
+        s_end = s + bucket->count;
+        for (; s < s_end; s++)
+           free(*s);
 
-   if (head->head == node)
-     {
-       head->head = node->next;
-       return 1;
+           free((void *)bucket->strings);
+           free(bucket->lengths);
+           free(bucket->references);
+           free(bucket);
+        *p_bucket = NULL;
      }
-
-   prev = head->head;
-   cur = head->head->next;
-   for (; cur != NULL; prev = cur, cur = cur->next)
-     if (cur == node)
-       {
-         prev->next = cur->next;
-         return 1;
-       }
-
-   return 0;
-}
-
-static Eina_Stringshare_Head *
-_eina_stringshare_find_hash(Eina_Stringshare_Head *bucket, int hash)
-{
-   return (Eina_Stringshare_Head*) eina_rbtree_inline_lookup
-     (EINA_RBTREE_GET(bucket), &hash, 0,
-      EINA_RBTREE_CMP_KEY_CB(_eina_stringshare_cmp), NULL);
-}
-
-static Eina_Stringshare_Node *
-_eina_stringshare_node_alloc(int slen)
-{
-   Eina_Stringshare_Node *node, t;
-   const size_t node_size = (char *)&(t.str) - (char *)&t;
-
-   node = malloc(node_size + slen + 1);
-   if (!node)
-     eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
-
-   return node;
-}
-
-static Eina_Stringshare_Node *
-_eina_stringshare_node_from_str(const char *str)
-{
-   Eina_Stringshare_Node *node, t;
-   const size_t offset = (char *)&(t.str) - (char *)&t;
-
-   node = (Eina_Stringshare_Node *)(str - offset);
-   EINA_MAGIC_CHECK_STRINGSHARE_NODE(node, );
-   return node;
 }
 
-struct dumpinfo
-{
-   int used, saved, dups, unique;
-};
-
 static void
-_eina_stringshare_small_bucket_dump(Eina_Stringshare_Small_Bucket *bucket, struct dumpinfo *di)
+_eina_stringshare_small_bucket_dump(Eina_Stringshare_Small_Bucket *bucket,
+                                    struct dumpinfo *di)
 {
    const char **s = bucket->strings;
    unsigned char *l = bucket->lengths;
@@ -863,14 +475,18 @@ _eina_stringshare_small_bucket_dump(Eina_Stringshare_Small_Bucket *bucket, struc
 
    for (i = 0; i < bucket->count; i++, s++, l++, r++)
      {
-       int dups;
-       printf("DDD: %5hhu %5hu '%s'\n", *l, *r, *s);
+        int dups;
+#ifdef _WIN32
+        printf("DDD: %5hu %5hu '%s'\n",  *l, *r, *s);
+#else
+        printf("DDD: %5hhu %5hu '%s'\n", *l, *r, *s);
+#endif
 
-       dups = (*r - 1);
+        dups = (*r - 1);
 
-       di->used += *l;
-       di->saved += *l * dups;
-       di->dups += dups;
+        di->used += *l;
+        di->saved += *l * dups;
+        di->dups += dups;
      }
 }
 
@@ -884,57 +500,27 @@ _eina_stringshare_small_dump(struct dumpinfo *di)
 
    for (; p_bucket < p_bucket_end; p_bucket++)
      {
-       Eina_Stringshare_Small_Bucket *bucket = *p_bucket;
+        Eina_Stringshare_Small_Bucket *bucket = *p_bucket;
 
-       if (!bucket)
-         continue;
+        if (!bucket)
+           continue;
 
-       _eina_stringshare_small_bucket_dump(bucket, di);
+        _eina_stringshare_small_bucket_dump(bucket, di);
      }
 }
 
-static Eina_Bool
-eina_iterator_array_check(const Eina_Rbtree *rbtree __UNUSED__, Eina_Stringshare_Head *head, struct dumpinfo *fdata)
-{
-   Eina_Stringshare_Node *node;
-
-   STRINGSHARE_LOCK_SMALL();
-   STRINGSHARE_LOCK_BIG();
-
-   fdata->used += sizeof(Eina_Stringshare_Head);
-   for (node = head->head; node; node = node->next)
-     {
-       printf("DDD: %5i %5i ", node->length, node->references);
-       printf("'%s'\n", ((char *)node) + sizeof(Eina_Stringshare_Node));
-       fdata->used += sizeof(Eina_Stringshare_Node);
-       fdata->used += node->length;
-       fdata->saved += (node->references - 1) * node->length;
-       fdata->dups += node->references - 1;
-       fdata->unique++;
-     }
-
-   STRINGSHARE_UNLOCK_BIG();
-   STRINGSHARE_UNLOCK_SMALL();
-
-   return EINA_TRUE;
-}
-
-/**
- * @endcond
- */
-
 
 /*============================================================================*
- *                                 Global                                     *
- *============================================================================*/
+*                                 Global                                     *
+*============================================================================*/
 
 /**
  * @internal
- * @brief Initialize the stringshare module.
+ * @brief Initialize the share_common module.
  *
  * @return #EINA_TRUE on success, #EINA_FALSE on failure.
  *
- * This function sets up the stringshare module of Eina. It is called by
+ * This function sets up the share_common module of Eina. It is called by
  * eina_init().
  *
  * @see eina_init()
@@ -942,111 +528,39 @@ eina_iterator_array_check(const Eina_Rbtree *rbtree __UNUSED__, Eina_Stringshare
 Eina_Bool
 eina_stringshare_init(void)
 {
-   _eina_stringshare_log_dom = eina_log_domain_register("eina_stringshare", EINA_LOG_COLOR_DEFAULT);
-   if (_eina_stringshare_log_dom < 0)
-     {
-       EINA_LOG_ERR("Could not register log domain: eina_stringshare");
-       return EINA_FALSE;
-     }
-
-   share = calloc(1, sizeof(Eina_Stringshare));
-   if (!share)
-     {
-       eina_log_domain_unregister(_eina_stringshare_log_dom);
-       _eina_stringshare_log_dom = -1;
-       return EINA_FALSE;
-     }
-
-#define EMS(n) eina_magic_string_static_set(n, n##_STR)
-   EMS(EINA_MAGIC_STRINGSHARE);
-   EMS(EINA_MAGIC_STRINGSHARE_HEAD);
-   EMS(EINA_MAGIC_STRINGSHARE_NODE);
-#undef EMS
-   EINA_MAGIC_SET(share, EINA_MAGIC_STRINGSHARE);
+   Eina_Bool ret;
+   ret = eina_share_common_init(&stringshare_share,
+                                EINA_MAGIC_STRINGSHARE_NODE,
+                                EINA_MAGIC_STRINGSHARE_NODE_STR);
+   if (ret)
+      _eina_stringshare_small_init();
 
-   _eina_stringshare_small_init();
-   _eina_stringshare_population_init();
-   return EINA_TRUE;
+   return ret;
 }
 
 /**
  * @internal
- * @brief Shut down the stringshare module.
+ * @brief Shut down the share_common module.
  *
  * @return #EINA_TRUE on success, #EINA_FALSE on failure.
  *
- * This function shuts down the stringshare module set up by
- * eina_stringshare_init(). It is called by eina_shutdown().
+ * This function shuts down the share_common module set up by
+ * eina_share_common_init(). It is called by eina_shutdown().
  *
  * @see eina_shutdown()
  */
 Eina_Bool
 eina_stringshare_shutdown(void)
 {
-   unsigned int i;
-
-   STRINGSHARE_LOCK_SMALL();
-   STRINGSHARE_LOCK_BIG();
-
-   _eina_stringshare_population_stats();
-
-   /* remove any string still in the table */
-   for (i = 0; i < EINA_STRINGSHARE_BUCKETS; i++)
-     {
-       eina_rbtree_delete(EINA_RBTREE_GET(share->buckets[i]), EINA_RBTREE_FREE_CB(_eina_stringshare_head_free), NULL);
-       share->buckets[i] = NULL;
-     }
-   MAGIC_FREE(share);
-
-   _eina_stringshare_population_shutdown();
+   Eina_Bool ret;
    _eina_stringshare_small_shutdown();
-   eina_log_domain_unregister(_eina_stringshare_log_dom);
-   _eina_stringshare_log_dom = -1;
-
-   STRINGSHARE_UNLOCK_BIG();
-   STRINGSHARE_UNLOCK_SMALL();
-
-
-   return EINA_TRUE;
-}
-
-#ifdef EFL_HAVE_PTHREAD
-
-/**
- * @internal
- * @brief Activate the stringshare mutexs.
- *
- * This function activate the mutexs in the eina stringshare module. It is called by
- * eina_thread_init().
- *
- * @see eina_thread_init()
- */
-void
-eina_stringshare_threads_init(void)
-{
-   _stringshare_threads_activated = EINA_TRUE;
-}
-
-/**
- * @internal
- * @brief Shut down the stringshare mutexs.
- *
- * This function shuts down the mutexs in the stringshare module.
- * It is called by eina_thread_shutdown().
- *
- * @see eina_thread_shutdown()
- */
-void
-eina_stringshare_threads_shutdown(void)
-{
-   _stringshare_threads_activated = EINA_FALSE;
+   ret = eina_share_common_shutdown(&stringshare_share);
+   return ret;
 }
 
-#endif
-
 /*============================================================================*
- *                                   API                                      *
- *============================================================================*/
+*                                   API                                      *
+*============================================================================*/
 
 /**
  * @addtogroup Eina_Stringshare_Group Stringshare
@@ -1073,6 +587,53 @@ eina_stringshare_threads_shutdown(void)
  */
 
 /**
+ * @brief Note that the given string has lost an instance.
+ *
+ * @param str string The given string.
+ *
+ * This function decreases the reference counter associated to @p str
+ * if it exists. If that counter reaches 0, the memory associated to
+ * @p str is freed. If @p str is NULL, the function returns
+ * immediatly.
+ *
+ * Note that if the given pointer is not shared or NULL, bad things
+ * will happen, likely a segmentation fault.
+ */
+EAPI void
+eina_stringshare_del(const char *str)
+{
+   int slen;
+   DBG("str=%p (%s)", str, str ? str : "");
+   if (!str)
+      return;
+
+   /* special cases */
+   if      (str[0] == '\0')
+      slen = 0;
+   else if (str[1] == '\0')
+      slen = 1;
+   else if (str[2] == '\0')
+      slen = 2;
+   else if (str[3] == '\0')
+      slen = 3;
+   else
+      slen = 4;  /* handled later */
+
+   if (slen < 2)
+      return;
+   else if (slen < 4)
+     {
+        eina_share_common_population_del(stringshare_share, slen);
+        STRINGSHARE_LOCK_SMALL();
+        _eina_stringshare_small_del(str, slen);
+        STRINGSHARE_UNLOCK_SMALL();
+        return;
+     }
+
+   eina_share_common_del(stringshare_share, str);
+}
+
+/**
  * @brief Retrieve an instance of a string for use in a program.
  *
  * @param   str The string to retrieve an instance of.
@@ -1086,82 +647,33 @@ eina_stringshare_threads_shutdown(void)
  * it is added to the strings to be searched and a duplicated string
  * of @p str is returned.
  *
- * This function does not check string size, but uses the give the
- * exact given size. This can be used to stringshare part of a larger
+ * This function does not check string size, but uses the
+ * exact given size. This can be used to share_common part of a larger
  * buffer or substring.
  *
- * @note it's not possible to have more than 65k references or strings
- * bigger than 65k since we use 'unsigned short' to save space.
- *
- * @see eina_stringshare_add()
+ * @see eina_share_common_add()
  */
 EAPI const char *
 eina_stringshare_add_length(const char *str, unsigned int slen)
 {
-   Eina_Stringshare_Head **p_bucket, *ed;
-   Eina_Stringshare_Node *el;
-   int hash_num, hash;
-
    DBG("str=%p (%.*s), slen=%u", str, slen, str ? str : "", slen);
-   if (!str) return NULL;
-
-   _eina_stringshare_population_add(slen);
 
    if (slen <= 0)
-     return "";
+      return "";
    else if (slen == 1)
-     return (const char *)_eina_stringshare_single + ((*str) << 1);
+      return (const char *)_eina_stringshare_single + ((*str) << 1);
    else if (slen < 4)
      {
-       const char *s;
+        const char *s;
 
-       STRINGSHARE_LOCK_SMALL();
-       s = _eina_stringshare_small_add(str, slen);
-       STRINGSHARE_UNLOCK_SMALL();
-       return s;
+        STRINGSHARE_LOCK_SMALL();
+        s = _eina_stringshare_small_add(str, slen);
+        STRINGSHARE_UNLOCK_SMALL();
+        return s;
      }
 
-   hash = eina_hash_superfast(str, slen);
-   hash_num = hash & 0xFF;
-   hash = (hash >> 8) & EINA_STRINGSHARE_MASK;
-
-   STRINGSHARE_LOCK_BIG();
-   p_bucket = share->buckets + hash_num;
-
-   ed = _eina_stringshare_find_hash(*p_bucket, hash);
-   if (!ed)
-     {
-       const char *s =  _eina_stringshare_add_head(p_bucket, hash, str, slen);
-       STRINGSHARE_UNLOCK_BIG();
-       return s;
-     }
-
-   EINA_MAGIC_CHECK_STRINGSHARE_HEAD(ed, STRINGSHARE_UNLOCK_BIG(), NULL);
-
-   el = _eina_stringshare_head_find(ed, str, slen);
-   if (el)
-     {
-       EINA_MAGIC_CHECK_STRINGSHARE_NODE(el, STRINGSHARE_UNLOCK_BIG());
-       el->references++;
-       STRINGSHARE_UNLOCK_BIG();
-       return el->str;
-     }
-
-   el = _eina_stringshare_node_alloc(slen);
-   if (!el)
-     {
-       STRINGSHARE_UNLOCK_BIG();
-       return NULL;
-     }
-
-   _eina_stringshare_node_init(el, str, slen);
-   el->next = ed->head;
-   ed->head = el;
-   _eina_stringshare_population_head_add(ed);
-
-   STRINGSHARE_UNLOCK_BIG();
-
-   return el->str;
+   return eina_share_common_add_length(stringshare_share, str, slen *
+                                       sizeof(char), sizeof(char));
 }
 
 /**
@@ -1181,176 +693,213 @@ eina_stringshare_add_length(const char *str, unsigned int slen)
  * length will be used. To use part of the string or non-null
  * terminated, use eina_stringshare_add_length() instead.
  *
- * @note it's not possible to have more than 65k references or strings
- * bigger than 65k since we use 'unsigned short' to save space.
- *
  * @see eina_stringshare_add_length()
  */
 EAPI const char *
 eina_stringshare_add(const char *str)
 {
    int slen;
-
-   if (!str) return NULL;
-
-   if      (str[0] == '\0') slen = 0;
-   else if (str[1] == '\0') slen = 1;
-   else if (str[2] == '\0') slen = 2;
-   else if (str[3] == '\0') slen = 3;
-   else                     slen = 3 + (int)strlen(str + 3);
+   if (!str)
+      return NULL;
+
+   if      (str[0] == '\0')
+      slen = 0;
+   else if (str[1] == '\0')
+      slen = 1;
+   else if (str[2] == '\0')
+      slen = 2;
+   else if (str[3] == '\0')
+      slen = 3;
+   else
+      slen = 3 + (int)strlen(str + 3);
 
    return eina_stringshare_add_length(str, slen);
 }
 
 /**
- * Increment references of the given shared string.
+ * @brief Retrieve an instance of a string for use in a program
+ * from a format string.
  *
- * @param str The shared string.
- * @return    A pointer to an instance of the string on success.
- *            @c NULL on failure.
+ * @param   fmt The NULL terminated format string to retrieve an instance of.
+ * @return  A pointer to an instance of the string on success.
+ *          @c NULL on failure.
  *
- * This is similar to eina_stringshare_add(), but it's faster since it will
- * avoid lookups if possible, but on the down side it requires the parameter
- * to be shared before, in other words, it must be the return of a previous
- * eina_stringshare_add().
+ * This function retrieves an instance of @p fmt. If @p fmt is
+ * @c NULL, then @c NULL is returned. If @p fmt is already stored, it
+ * is just returned and its reference counter is increased. Otherwise
+ * it is added to the strings to be searched and a duplicated string
+ * is returned.
+ *
+ * The format string @p fmt must be NULL terminated ('@\0') and its full
+ * length will be used. To use part of the format string or non-null
+ * terminated, use eina_stringshare_nprintf() instead.
  *
- * There is no unref since this is the work of eina_stringshare_del().
+ * @see eina_stringshare_nprintf()
  */
 EAPI const char *
-eina_stringshare_ref(const char *str)
+eina_stringshare_printf(const char *fmt, ...)
 {
-   Eina_Stringshare_Node *node;
-   int slen;
+   va_list args;
+   char *tmp;
+   const char *ret;
+   int len;
 
-   DBG("str=%p (%s)", str, str ? str : "");
-   if (!str) return NULL;
+   if (!fmt)
+      return NULL;
 
-   /* special cases */
-   if      (str[0] == '\0') slen = 0;
-   else if (str[1] == '\0') slen = 1;
-   else if (str[2] == '\0') slen = 2;
-   else if (str[3] == '\0') slen = 3;
-   else                     slen = 4; /* handled later */
+   va_start(args, fmt);
+   len = vasprintf(&tmp, fmt, args);
+   va_end(args);
 
-   if (slen < 2)
-     {
-       _eina_stringshare_population_add(slen);
+   if (len < 1)
+      return NULL;
 
-       return str;
-     }
-   else if (slen < 4)
-     {
-       const char *s;
-       _eina_stringshare_population_add(slen);
+   ret = eina_stringshare_add_length(tmp, len);
+   free(tmp);
 
-       STRINGSHARE_LOCK_SMALL();
-       s =  _eina_stringshare_small_add(str, slen);
-       STRINGSHARE_UNLOCK_SMALL();
+   return ret;
+}
 
-       return s;
-     }
+/**
+ * @brief Retrieve an instance of a string for use in a program
+ * from a format string.
+ *
+ * @param   fmt The NULL terminated format string to retrieve an instance of.
+ * @param   args The va_args for @p fmt
+ * @return  A pointer to an instance of the string on success.
+ *          @c NULL on failure.
+ *
+ * This function retrieves an instance of @p fmt with @p args. If @p fmt is
+ * @c NULL, then @c NULL is returned. If @p fmt with @p args is already stored, it
+ * is just returned and its reference counter is increased. Otherwise
+ * it is added to the strings to be searched and a duplicated string
+ * is returned.
+ *
+ * The format string @p fmt must be NULL terminated ('@\0') and its full
+ * length will be used. To use part of the format string or non-null
+ * terminated, use eina_stringshare_nprintf() instead.
+ *
+ * @see eina_stringshare_nprintf()
+ */
+EAPI const char *
+eina_stringshare_vprintf(const char *fmt, va_list args)
+{
+   char *tmp;
+   const char *ret;
+   int len;
 
-   STRINGSHARE_LOCK_BIG();
-   node = _eina_stringshare_node_from_str(str);
-   node->references++;
-   DBG("str=%p (%s) refs=%u", str, str, node->references);
+   if (!fmt)
+      return NULL;
 
-   STRINGSHARE_UNLOCK_BIG();
+   len = vasprintf(&tmp, fmt, args);
 
-   _eina_stringshare_population_add(node->length);
+   if (len < 1)
+      return NULL;
 
-   return str;
-}
+   ret = eina_stringshare_add_length(tmp, len);
+   free(tmp);
 
+   return ret;
+}
 
 /**
- * @brief Note that the given string has lost an instance.
+ * @brief Retrieve an instance of a string for use in a program
+ * from a format string with size limitation.
+ * @param   len The length of the format string to use
+ * @param   fmt The format string to retrieve an instance of.
+ * @return  A pointer to an instance of the string on success.
+ *          @c NULL on failure.
  *
- * @param str string The given string.
+ * This function retrieves an instance of @p fmt limited by @p len. If @p fmt is
+ * @c NULL or @p len is < 1, then @c NULL is returned. If the resulting string
+ * is already stored, it is returned and its reference counter is increased. Otherwise
+ * it is added to the strings to be searched and a duplicated string
+ * is returned.
  *
- * This function decreases the reference counter associated to @p str
- * if it exists. If that counter reaches 0, the memory associated to
- * @p str is freed. If @p str is NULL, the function returns
- * immediatly.
+ * @p len length of the format string will be used. To use the
+ * entire format string, use eina_stringshare_printf() instead.
  *
- * Note that if the given pointer is not shared or NULL, bad things
- * will happen, likely a segmentation fault.
+ * @see eina_stringshare_printf()
  */
-EAPI void
-eina_stringshare_del(const char *str)
+EAPI const char *
+eina_stringshare_nprintf(unsigned int len, const char *fmt, ...)
 {
-   Eina_Stringshare_Head *ed;
-   Eina_Stringshare_Head **p_bucket;
-   Eina_Stringshare_Node *node;
-   int hash_num, slen, hash;
-
-   DBG("str=%p (%s)", str, str ? str : "");
-   if (!str) return;
-
-   /* special cases */
-   if      (str[0] == '\0') slen = 0;
-   else if (str[1] == '\0') slen = 1;
-   else if (str[2] == '\0') slen = 2;
-   else if (str[3] == '\0') slen = 3;
-   else                     slen = 4; /* handled later */
+   va_list args;
+   char *tmp;
+   int size;
 
-   _eina_stringshare_population_del(slen);
+   if (!fmt)
+      return NULL;
 
-   if (slen < 2)
-     return;
-   else if (slen < 4)
-     {
-       STRINGSHARE_LOCK_SMALL();
-       _eina_stringshare_small_del(str, slen);
-       STRINGSHARE_UNLOCK_SMALL();
-       return;
-     }
+   if (len < 1)
+      return NULL;
 
-   STRINGSHARE_LOCK_BIG();
+   tmp = alloca(sizeof(char) * len + 1);
 
-   node = _eina_stringshare_node_from_str(str);
-   if (node->references > 1)
-     {
-       node->references--;
-       DBG("str=%p (%s) refs=%u", str, str, node->references);
-       STRINGSHARE_UNLOCK_BIG();
-       return;
-     }
+   va_start(args, fmt);
+   size = vsnprintf(tmp, len, fmt, args);
+   va_end(args);
 
-   DBG("str=%p (%s) refs=0, delete.", str, str);
-   node->references = 0;
-   slen = node->length;
+   if (size < 1)
+      return NULL;
 
-   hash = eina_hash_superfast(str, slen);
-   hash_num = hash & 0xFF;
-   hash = (hash >> 8) & EINA_STRINGSHARE_MASK;
+   return eina_stringshare_add_length(tmp, len);
+}
 
-   p_bucket = share->buckets + hash_num;
-   ed = _eina_stringshare_find_hash(*p_bucket, hash);
-   if (!ed)
-     goto on_error;
+/**
+ * Increment references of the given shared string.
+ *
+ * @param str The shared string.
+ * @return    A pointer to an instance of the string on success.
+ *            @c NULL on failure.
+ *
+ * This is similar to eina_share_common_add(), but it's faster since it will
+ * avoid lookups if possible, but on the down side it requires the parameter
+ * to be shared before, in other words, it must be the return of a previous
+ * eina_share_common_add().
+ *
+ * There is no unref since this is the work of eina_share_common_del().
+ */
+EAPI const char *
+eina_stringshare_ref(const char *str)
+{
+   int slen;
+   DBG("str=%p (%s)", str, str ? str : "");
 
-   EINA_MAGIC_CHECK_STRINGSHARE_HEAD(ed, STRINGSHARE_UNLOCK_BIG());
+   if (!str)
+      return eina_share_common_ref(stringshare_share, str);
 
-   if (!_eina_stringshare_head_remove_node(ed, node))
-     goto on_error;
+   /* special cases */
+   if      (str[0] == '\0')
+      slen = 0;
+   else if (str[1] == '\0')
+      slen = 1;
+   else if (str[2] == '\0')
+      slen = 2;
+   else if (str[3] == '\0')
+      slen = 3;
+   else
+      slen = 3 + (int)strlen(str + 3);
 
-   if (node != &ed->builtin_node)
-     MAGIC_FREE(node);
+   if (slen < 2)
+     {
+        eina_share_common_population_add(stringshare_share, slen);
 
-   if (!ed->head)
-     _eina_stringshare_del_head(p_bucket, ed);
-   else
-     _eina_stringshare_population_head_del(ed);
+        return str;
+     }
+   else if (slen < 4)
+     {
+        const char *s;
+        eina_share_common_population_add(stringshare_share, slen);
 
-   STRINGSHARE_UNLOCK_BIG();
+        STRINGSHARE_LOCK_SMALL();
+        s = _eina_stringshare_small_add(str, slen);
+        STRINGSHARE_UNLOCK_SMALL();
 
-   return;
+        return s;
+     }
 
- on_error:
-   STRINGSHARE_UNLOCK_BIG();
-   /* possible segfault happened before here, but... */
-   CRITICAL("EEEK trying to del non-shared stringshare \"%s\"", str);
+   return eina_share_common_ref(stringshare_share, str);
 }
 
 /**
@@ -1367,76 +916,37 @@ eina_stringshare_del(const char *str)
 EAPI int
 eina_stringshare_strlen(const char *str)
 {
-   const Eina_Stringshare_Node *node;
+   int len;
+   /* special cases */
+   if (str[0] == '\0')
+      return 0;
 
-   if (!str)
-     return -1;
+   if (str[1] == '\0')
+      return 1;
 
-   /* special cases */
-   if (str[0] == '\0') return 0;
-   if (str[1] == '\0') return 1;
-   if (str[2] == '\0') return 2;
-   if (str[3] == '\0') return 3;
+   if (str[2] == '\0')
+      return 2;
 
-   node = _eina_stringshare_node_from_str(str);
-   return node->length;
+   if (str[3] == '\0')
+      return 3;
+
+   len = eina_share_common_length(stringshare_share, (const char *)str);
+   len = (len > 0) ? len / (int)sizeof(char) : -1;
+   return len;
 }
 
 /**
- * @brief Dump the contents of the stringshare.
+ * @brief Dump the contents of the share_common.
  *
- * This function dumps all strings in the stringshare to stdout with a
+ * This function dumps all strings in the share_common to stdout with a
  * DDD: prefix per line and a memory usage summary.
  */
 EAPI void
 eina_stringshare_dump(void)
 {
-   Eina_Iterator *it;
-   unsigned int i;
-   struct dumpinfo di;
-
-   if (!share) return;
-   di.used = sizeof (_eina_stringshare_single);
-   di.saved = 0;
-   di.dups = 0;
-   di.unique = 0;
-   printf("DDD:   len   ref string\n");
-   printf("DDD:-------------------\n");
-
-   STRINGSHARE_LOCK_SMALL();
-   _eina_stringshare_small_dump(&di);
-   STRINGSHARE_UNLOCK_SMALL();
-
-   STRINGSHARE_LOCK_BIG();
-   for (i = 0; i < EINA_STRINGSHARE_BUCKETS; i++)
-     {
-       if (!share->buckets[i]) continue;
-//     printf("DDD: BUCKET # %i (HEAD=%i, NODE=%i)\n", i,
-//            sizeof(Eina_Stringshare_Head), sizeof(Eina_Stringshare_Node));
-       it = eina_rbtree_iterator_prefix((Eina_Rbtree *)share->buckets[i]);
-       eina_iterator_foreach(it, EINA_EACH(eina_iterator_array_check), &di);
-       eina_iterator_free(it);
-     }
-#ifdef EINA_STRINGSHARE_USAGE
-   /* One character strings are not counted in the hash. */
-   di.saved += population_group[0].count * sizeof(char);
-   di.saved += population_group[1].count * sizeof(char) * 2;
-#endif
-   printf("DDD:-------------------\n");
-   printf("DDD: usage (bytes) = %i, saved = %i (%3.0f%%)\n",
-         di.used, di.saved, di.used ? (di.saved * 100.0 / di.used) : 0.0);
-   printf("DDD: unique: %d, duplicates: %d (%3.0f%%)\n",
-         di.unique, di.dups, di.unique ? (di.dups * 100.0 / di.unique) : 0.0);
-
-#ifdef EINA_STRINGSHARE_USAGE
-   printf("DDD: Allocated strings: %i\n", population.count);
-   printf("DDD: Max allocated strings: %i\n", population.max);
-
-   for (i = 0; i < sizeof (population_group) / sizeof (population_group[0]); ++i)
-     fprintf(stderr, "DDD: %i strings of length %i, max strings: %i\n", population_group[i].count, i, population_group[i].max);
-#endif
-
-   STRINGSHARE_UNLOCK_BIG();
+   eina_share_common_dump(stringshare_share,
+                          _eina_stringshare_small_dump,
+                          sizeof(_eina_stringshare_single));
 }
 
 /**
index 0a4189e..9d3f4cb 100644 (file)
@@ -35,8 +35,8 @@
 #include "eina_error.h"
 
 /*============================================================================*
- *                                  Local                                     *
- *============================================================================*/
+*                                  Local                                     *
+*============================================================================*/
 
 /* The splitter data types */
 typedef struct list_node list_node_t;
@@ -46,43 +46,43 @@ typedef struct rect_node rect_node_t;
 
 struct list_node
 {
-       struct list_node *next;
+   struct list_node *next;
 };
 
 struct list
 {
-       struct list_node *head;
-       struct list_node *tail;
+   struct list_node *head;
+   struct list_node *tail;
 };
 
 struct rect
 {
-       short right;
-       short bottom;
-       short left;
-       short top;
-       short width;
-       short height;
-       int area;
+   short right;
+   short bottom;
+   short left;
+   short top;
+   short width;
+   short height;
+   int area;
 };
 
 struct rect_node
 {
-       struct list_node _lst;
-       struct rect rect;
+   struct list_node _lst;
+   struct rect rect;
 };
 
 typedef struct splitter
 {
-       Eina_Bool need_merge;
-       list_t rects;
+   Eina_Bool need_merge;
+   list_t rects;
 } splitter_t;
 
 typedef struct list_node_pool
 {
-       list_node_t *node;
-       int len;
-       int max;
+   list_node_t *node;
+   int len;
+   int max;
 } list_node_pool_t;
 
 
@@ -93,1111 +93,1134 @@ static list_node_pool_t list_node_pool = { NULL, 0, 1024 };
 
 typedef struct _Eina_Iterator_Tiler
 {
-       Eina_Iterator iterator;
-       const Eina_Tiler *tiler;
-       list_node_t *curr;
-       EINA_MAGIC
+   Eina_Iterator iterator;
+   const Eina_Tiler *tiler;
+   list_node_t *curr;
+   EINA_MAGIC
 } Eina_Iterator_Tiler;
 
 struct _Eina_Tiler
 {
-       struct
-       {
-               int w, h;
-       } tile;
-       Eina_Rectangle area;
-       EINA_MAGIC
-       splitter_t splitter;
+   struct
+   {
+      int w, h;
+   } tile;
+   Eina_Rectangle area;
+   EINA_MAGIC
+   splitter_t splitter;
 };
 
-#define EINA_MAGIC_CHECK_TILER(d, ...)                                 \
-       do {                                                            \
-               if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_TILER))             \
-               {                                                       \
-                       EINA_MAGIC_FAIL(d, EINA_MAGIC_TILER);           \
-                       return __VA_ARGS__;                             \
-               }                                                       \
-       } while(0)
-
-
-#define EINA_MAGIC_CHECK_TILER_ITERATOR(d, ...)                                \
-       do {                                                            \
-               if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_TILER_ITERATOR))    \
-               {                                                       \
-                       EINA_MAGIC_FAIL(d, EINA_MAGIC_TILER_ITERATOR);  \
-                       return __VA_ARGS__;                             \
-               }                                                       \
-       } while(0)
+#define EINA_MAGIC_CHECK_TILER(d, ...)                                  \
+   do {                                                            \
+        if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_TILER))             \
+          {                                                       \
+             EINA_MAGIC_FAIL(d, EINA_MAGIC_TILER);           \
+             return __VA_ARGS__;                             \
+          }                                                       \
+     } while(0)
+
+
+#define EINA_MAGIC_CHECK_TILER_ITERATOR(d, ...)                         \
+   do {                                                            \
+        if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_TILER_ITERATOR))    \
+          {                                                       \
+             EINA_MAGIC_FAIL(d, EINA_MAGIC_TILER_ITERATOR);  \
+             return __VA_ARGS__;                             \
+          }                                                       \
+     } while(0)
 
 /* The Splitter algorithm */
 static inline void rect_init(rect_t *r, int x, int y, int w, int h)
 {
-       r->area = w * h;
+   r->area = w * h;
 
-       r->left = x;
-       r->top = y;
+   r->left = x;
+   r->top = y;
 
-       r->right = x + w;
-       r->bottom = y + h;
+   r->right = x + w;
+   r->bottom = y + h;
 
-       r->width = w;
-       r->height = h;
+   r->width = w;
+   r->height = h;
 }
 
 static inline list_node_t *
 rect_list_node_pool_get(void)
 {
-       if (list_node_pool.node)
-       {
-               list_node_t *node;
-
-               node = list_node_pool.node;
-               list_node_pool.node = node->next;
-               list_node_pool.len--;
-
-               return node;
-       }
-       else
-               return malloc(sizeof(rect_node_t));
+   if (list_node_pool.node)
+     {
+        list_node_t *node;
+
+        node = list_node_pool.node;
+        list_node_pool.node = node->next;
+        list_node_pool.len--;
+
+        return node;
+     }
+   else
+      return malloc(sizeof(rect_node_t));
 }
 
 
 static inline void rect_list_concat(list_t *rects, list_t *other)
 {
-       if (!other->head)
-               return;
-
-       if (rects->tail)
-       {
-               rects->tail->next = other->head;
-               rects->tail = other->tail;
-       }
-       else
-       {
-               rects->head = other->head;
-               rects->tail = other->tail;
-       }
-       *other = list_zeroed;
+   if (!other->head)
+      return;
+
+   if (rects->tail)
+     {
+        rects->tail->next = other->head;
+        rects->tail = other->tail;
+     }
+   else
+     {
+        rects->head = other->head;
+        rects->tail = other->tail;
+     }
+
+   *other = list_zeroed;
 }
 
 static inline void rect_list_append_node(list_t *rects, list_node_t *node)
 {
-       if (rects->tail)
-       {
-               rects->tail->next = node;
-               rects->tail = node;
-       }
-       else
-       {
-               rects->head = node;
-               rects->tail = node;
-       }
+   if (rects->tail)
+     {
+        rects->tail->next = node;
+        rects->tail = node;
+     }
+   else
+     {
+        rects->head = node;
+        rects->tail = node;
+     }
 }
 
 static inline void rect_list_append(list_t *rects, const rect_t r)
 {
-       rect_node_t *rect_node;
+   rect_node_t *rect_node;
 
-       rect_node = (rect_node_t *) rect_list_node_pool_get();
-       rect_node->rect = r;
-       rect_node->_lst = list_node_zeroed;
+   rect_node = (rect_node_t *)rect_list_node_pool_get();
+   rect_node->rect = r;
+   rect_node->_lst = list_node_zeroed;
 
-       rect_list_append_node(rects, (list_node_t *) rect_node);
+   rect_list_append_node(rects, (list_node_t *)rect_node);
 }
 
-static inline void rect_list_append_xywh(list_t *rects, int x, int y, int w, int h)
+static inline void rect_list_append_xywh(list_t *rects,
+                                         int x,
+                                         int y,
+                                         int w,
+                                         int h)
 {
-       rect_t r;
+   rect_t r;
 
-       rect_init(&r, x, y, w, h);
-       rect_list_append(rects, r);
+   rect_init(&r, x, y, w, h);
+   rect_list_append(rects, r);
 }
 
 static inline void _calc_intra_rect_area(const rect_t a, const rect_t b,
-               int *width, int *height)
+                                         int *width, int *height)
 {
-       int max_left, min_right, max_top, min_bottom;
+   int max_left, min_right, max_top, min_bottom;
 
-       if (a.left < b.left)
-               max_left = b.left;
-       else
-               max_left = a.left;
+   if (a.left < b.left)
+      max_left = b.left;
+   else
+      max_left = a.left;
 
-       if (a.right < b.right)
-               min_right = a.right;
-       else
-               min_right = b.right;
+   if (a.right < b.right)
+      min_right = a.right;
+   else
+      min_right = b.right;
 
-       *width = min_right - max_left;
+   *width = min_right - max_left;
 
-       if (a.top < b.top)
-               max_top = b.top;
-       else
-               max_top = a.top;
+   if (a.top < b.top)
+      max_top = b.top;
+   else
+      max_top = a.top;
 
-       if (a.bottom < b.bottom)
-               min_bottom = a.bottom;
-       else
-               min_bottom = b.bottom;
+   if (a.bottom < b.bottom)
+      min_bottom = a.bottom;
+   else
+      min_bottom = b.bottom;
 
-       *height = min_bottom - max_top;
+   *height = min_bottom - max_top;
 }
 
 static inline void _split_strict(list_t *dirty, const rect_t current, rect_t r)
 {
-       int h_1, h_2, w_1, w_2;
-
-       h_1 = current.top - r.top;
-       h_2 = r.bottom - current.bottom;
-       w_1 = current.left - r.left;
-       w_2 = r.right - current.right;
-
-       if (h_1 > 0)
-       {
-               /*    .--.r (b)                .---.r2
-                *    |  |                     |   |
-                *  .-------.cur (a) .---.r    '---'
-                *  | |  |  |     -> |   |   +
-                *  | `--'  |        `---'
-                *  `-------'
-                */
-               rect_list_append_xywh(dirty, r.left, r.top, r.width, h_1);
-               r.height -= h_1;
-               r.top = current.top;
-       }
-
-       if (h_2 > 0)
-       {
-               /*  .-------.cur (a)
-                *  | .---. |        .---.r
-                *  | |   | |    ->  |   |
-                *  `-------'        `---'   +  .---.r2
-                *    |   |                     |   |
-                *    `---'r (b)                `---'
-                */
-               rect_list_append_xywh(dirty, r.left, current.bottom, r.width,
-                               h_2);
-               r.height -= h_2;
-       }
-
-       if (w_1 > 0)
-       {
-               /* (b) r  .----.cur (a)
-                *     .--|-.  |      .--.r2   .-.r
-                *     |  | |  |  ->  |  |   + | |
-                *     `--|-'  |      `--'     `-'
-                *        `----'
-                */
-               rect_list_append_xywh(dirty, r.left, r.top, w_1, r.height);
-               /* not necessary to keep these, r (b) will be destroyed */
-               /* r.width -= w_1; */
-               /* r.left = current.left; */
-       }
-
-       if (w_2 > 0)
-       {
-               /*  .----.cur (a)
-                *  |    |
-                *  |  .-|--.r (b)  .-.r   .--.r2
-                *  |  | |  |    -> | |  + |  |
-                *  |  `-|--'       `-'    `--'
-                *  `----'
-                */
-               rect_list_append_xywh(dirty, current.right, r.top, w_2,
-                               r.height);
-               /* not necessary to keep this, r (b) will be destroyed */
-               /* r.width -= w_2; */
-       }
+   int h_1, h_2, w_1, w_2;
+
+   h_1 = current.top - r.top;
+   h_2 = r.bottom - current.bottom;
+   w_1 = current.left - r.left;
+   w_2 = r.right - current.right;
+
+   if (h_1 > 0)
+     {
+        /*    .--.r (b)                .---.r2
+         *    |  |                     |   |
+         *  .-------.cur (a) .---.r    '---'
+         *  | |  |  |     -> |   |   +
+         *  | `--'  |        `---'
+         *  `-------'
+         */
+        rect_list_append_xywh(dirty, r.left, r.top, r.width, h_1);
+        r.height -= h_1;
+        r.top = current.top;
+     }
+
+   if (h_2 > 0)
+     {
+        /*  .-------.cur (a)
+         *  | .---. |        .---.r
+         *  | |   | |    ->  |   |
+         *  `-------'        `---'   +  .---.r2
+         *    |   |                     |   |
+         *    `---'r (b)                `---'
+         */
+        rect_list_append_xywh(dirty, r.left, current.bottom, r.width,
+                              h_2);
+        r.height -= h_2;
+     }
+
+   if (w_1 > 0)
+      /* (b) r  .----.cur (a)
+       *     .--|-.  |      .--.r2   .-.r
+       *     |  | |  |  ->  |  |   + | |
+       *     `--|-'  |      `--'     `-'
+       *        `----'
+       */
+        rect_list_append_xywh(dirty, r.left, r.top, w_1, r.height);  /* not necessary to keep these, r (b) will be destroyed */
+
+   /* r.width -= w_1; */
+   /* r.left = current.left; */
+
+   if (w_2 > 0)
+      /*  .----.cur (a)
+       *  |    |
+       *  |  .-|--.r (b)  .-.r   .--.r2
+       *  |  | |  |    -> | |  + |  |
+       *  |  `-|--'       `-'    `--'
+       *  `----'
+       */
+        rect_list_append_xywh(dirty, current.right, r.top, w_2,
+                            r.height);  /* not necessary to keep this, r (b) will be destroyed */
+
+   /* r.width -= w_2; */
 }
 
 static inline void _calc_intra_outer_rect_area(const rect_t a, const rect_t b,
-               rect_t *intra, rect_t *outer)
+                                               rect_t *intra, rect_t *outer)
 {
-       int min_left, max_left, min_right, max_right;
-       int min_top, max_top, min_bottom, max_bottom;
-
-       if (a.left < b.left)
-       {
-               max_left = b.left;
-               min_left = a.left;
-       }
-       else
-       {
-               max_left = a.left;
-               min_left = b.left;
-       }
-
-       if (a.right < b.right)
-       {
-               min_right = a.right;
-               max_right = b.right;
-       }
-       else
-       {
-               min_right = b.right;
-               max_right = a.right;
-       }
-
-       intra->left = max_left;
-       intra->right = min_right;
-       intra->width = min_right - max_left;
-
-       outer->left = min_left;
-       outer->right = max_right;
-       outer->width = max_right - min_left;
-
-       if (a.top < b.top)
-       {
-               max_top = b.top;
-               min_top = a.top;
-       }
-       else
-       {
-               max_top = a.top;
-               min_top = b.top;
-       }
-
-       if (a.bottom < b.bottom)
-       {
-               min_bottom = a.bottom;
-               max_bottom = b.bottom;
-       }
-       else
-       {
-               min_bottom = b.bottom;
-               max_bottom = a.bottom;
-       }
-
-       intra->top = max_top;
-       intra->bottom = min_bottom;
-       intra->height = min_bottom - max_top;
-       if ((intra->width > 0) && (intra->height > 0))
-               intra->area = intra->width * intra->height;
-       else
-               intra->area = 0;
-
-       outer->top = min_top;
-       outer->bottom = max_bottom;
-       outer->height = max_bottom - min_top;
-       outer->area = outer->width * outer->height;
+   int min_left, max_left, min_right, max_right;
+   int min_top, max_top, min_bottom, max_bottom;
+
+   if (a.left < b.left)
+     {
+        max_left = b.left;
+        min_left = a.left;
+     }
+   else
+     {
+        max_left = a.left;
+        min_left = b.left;
+     }
+
+   if (a.right < b.right)
+     {
+        min_right = a.right;
+        max_right = b.right;
+     }
+   else
+     {
+        min_right = b.right;
+        max_right = a.right;
+     }
+
+   intra->left = max_left;
+   intra->right = min_right;
+   intra->width = min_right - max_left;
+
+   outer->left = min_left;
+   outer->right = max_right;
+   outer->width = max_right - min_left;
+
+   if (a.top < b.top)
+     {
+        max_top = b.top;
+        min_top = a.top;
+     }
+   else
+     {
+        max_top = a.top;
+        min_top = b.top;
+     }
+
+   if (a.bottom < b.bottom)
+     {
+        min_bottom = a.bottom;
+        max_bottom = b.bottom;
+     }
+   else
+     {
+        min_bottom = b.bottom;
+        max_bottom = a.bottom;
+     }
+
+   intra->top = max_top;
+   intra->bottom = min_bottom;
+   intra->height = min_bottom - max_top;
+   if ((intra->width > 0) && (intra->height > 0))
+      intra->area = intra->width * intra->height;
+   else
+      intra->area = 0;
+
+   outer->top = min_top;
+   outer->bottom = max_bottom;
+   outer->height = max_bottom - min_top;
+   outer->area = outer->width * outer->height;
 }
 
 enum
 {
-       SPLIT_FUZZY_ACTION_NONE,
-       SPLIT_FUZZY_ACTION_SPLIT,
-       SPLIT_FUZZY_ACTION_MERGE
+   SPLIT_FUZZY_ACTION_NONE,
+   SPLIT_FUZZY_ACTION_SPLIT,
+   SPLIT_FUZZY_ACTION_MERGE
 };
 
 static inline int _split_fuzzy(list_t *dirty, const rect_t a, rect_t *b)
 {
-       int h_1, h_2, w_1, w_2, action;
-
-       h_1 = a.top - b->top;
-       h_2 = b->bottom - a.bottom;
-       w_1 = a.left - b->left;
-       w_2 = b->right - a.right;
-
-       action = SPLIT_FUZZY_ACTION_NONE;
-
-       if (h_1 > 0)
-       {
-               /*    .--.r (b)                .---.r2
-                *    |  |                     |   |
-                *  .-------.cur (a) .---.r    '---'
-                *  | |  |  |     -> |   |   +
-                *  | `--'  |        `---'
-                *  `-------'
-                */
-               rect_list_append_xywh(dirty, b->left, b->top, b->width, h_1);
-               b->height -= h_1;
-               b->top = a.top;
-               action = SPLIT_FUZZY_ACTION_SPLIT;
-       }
-
-       if (h_2 > 0)
-       {
-               /*  .-------.cur (a)
-                *  | .---. |        .---.r
-                *  | |   | |    ->  |   |
-                *  `-------'        `---'   +  .---.r2
-                *    |   |                     |   |
-                *    `---'r (b)                `---'
-                */
-               rect_list_append_xywh(dirty, b->left, a.bottom, b->width, h_2);
-               b->height -= h_2;
-               action = SPLIT_FUZZY_ACTION_SPLIT;
-       }
-
-       if (((w_1 > 0) || (w_2 > 0)) && (a.height == b->height))
-               return SPLIT_FUZZY_ACTION_MERGE;
-
-       if (w_1 > 0)
-       {
-               /* (b)  r  .----.cur (a)
-                *      .--|-.  |      .--.r2   .-.r
-                *      |  | |  |  ->  |  |   + | |
-                *      `--|-'  |      `--'     `-'
-                *         `----'
-                */
-               rect_list_append_xywh(dirty, b->left, b->top, w_1, b->height);
-               /* not necessary to keep these, r (b) will be destroyed */
-               /* b->width -= w_1; */
-               /* b->left = a.left; */
-               action = SPLIT_FUZZY_ACTION_SPLIT;
-       }
-
-       if (w_2 > 0)
-       {
-               /* .----.cur (a)
-                * |    |
-                * |  .-|--.r (b)  .-.r   .--.r2
-                * |  | |  |    -> | |  + |  |
-                * |  `-|--'       `-'    `--'
-                * `----'
-                */
-               rect_list_append_xywh(dirty, a.right, b->top, w_2, b->height);
-               /* not necessary to keep these, r (b) will be destroyed */
-               /* b->width -= w_2; */
-               action = SPLIT_FUZZY_ACTION_SPLIT;
-       }
-
-       return action;
+   int h_1, h_2, w_1, w_2, action;
+
+   h_1 = a.top - b->top;
+   h_2 = b->bottom - a.bottom;
+   w_1 = a.left - b->left;
+   w_2 = b->right - a.right;
+
+   action = SPLIT_FUZZY_ACTION_NONE;
+
+   if (h_1 > 0)
+     {
+        /*    .--.r (b)                .---.r2
+         *    |  |                     |   |
+         *  .-------.cur (a) .---.r    '---'
+         *  | |  |  |     -> |   |   +
+         *  | `--'  |        `---'
+         *  `-------'
+         */
+        rect_list_append_xywh(dirty, b->left, b->top, b->width, h_1);
+        b->height -= h_1;
+        b->top = a.top;
+        action = SPLIT_FUZZY_ACTION_SPLIT;
+     }
+
+   if (h_2 > 0)
+     {
+        /*  .-------.cur (a)
+         *  | .---. |        .---.r
+         *  | |   | |    ->  |   |
+         *  `-------'        `---'   +  .---.r2
+         *    |   |                     |   |
+         *    `---'r (b)                `---'
+         */
+        rect_list_append_xywh(dirty, b->left, a.bottom, b->width, h_2);
+        b->height -= h_2;
+        action = SPLIT_FUZZY_ACTION_SPLIT;
+     }
+
+   if (((w_1 > 0) || (w_2 > 0)) && (a.height == b->height))
+      return SPLIT_FUZZY_ACTION_MERGE;
+
+   if (w_1 > 0)
+     {
+        /* (b)  r  .----.cur (a)
+         *      .--|-.  |      .--.r2   .-.r
+         *      |  | |  |  ->  |  |   + | |
+         *      `--|-'  |      `--'     `-'
+         *         `----'
+         */
+        rect_list_append_xywh(dirty, b->left, b->top, w_1, b->height);
+        /* not necessary to keep these, r (b) will be destroyed */
+        /* b->width -= w_1; */
+        /* b->left = a.left; */
+        action = SPLIT_FUZZY_ACTION_SPLIT;
+     }
+
+   if (w_2 > 0)
+     {
+        /* .----.cur (a)
+         * |    |
+         * |  .-|--.r (b)  .-.r   .--.r2
+         * |  | |  |    -> | |  + |  |
+         * |  `-|--'       `-'    `--'
+         * `----'
+         */
+        rect_list_append_xywh(dirty, a.right, b->top, w_2, b->height);
+        /* not necessary to keep these, r (b) will be destroyed */
+        /* b->width -= w_2; */
+        action = SPLIT_FUZZY_ACTION_SPLIT;
+     }
+
+   return action;
 }
 
 #if 0
 static void rect_list_node_pool_set_max(int max)
 {
-       int diff;
+   int diff;
 
-       diff = list_node_pool.len - max;
-       for (; diff > 0 && list_node_pool.node != NULL; diff--)
-       {
-               list_node_t *node;
+   diff = list_node_pool.len - max;
+   for (; diff > 0 && list_node_pool.node != NULL; diff--)
+     {
+        list_node_t *node;
 
-               node = list_node_pool.node;
-               list_node_pool.node = node->next;
-               list_node_pool.len--;
+        node = list_node_pool.node;
+        list_node_pool.node = node->next;
+        list_node_pool.len--;
 
-               free(node);
-       }
+        free(node);
+     }
 
-       list_node_pool.max = max;
+   list_node_pool.max = max;
 }
 #endif
 
 static void rect_list_node_pool_flush(void)
 {
-       while (list_node_pool.node)
-       {
-               list_node_t *node;
+   while (list_node_pool.node)
+     {
+        list_node_t *node;
 
-               node = list_node_pool.node;
-               list_node_pool.node = node->next;
-               list_node_pool.len--;
+        node = list_node_pool.node;
+        list_node_pool.node = node->next;
+        list_node_pool.len--;
 
-               free(node);
-       }
+        free(node);
+     }
 }
 
 
 
 static inline void rect_list_node_pool_put(list_node_t *node)
 {
-       if (list_node_pool.len < list_node_pool.max)
-       {
-               node->next = list_node_pool.node;
-               list_node_pool.node = node;
-               list_node_pool.len++;
-       }
-       else
-               free(node);
+   if (list_node_pool.len < list_node_pool.max)
+     {
+        node->next = list_node_pool.node;
+        list_node_pool.node = node;
+        list_node_pool.len++;
+     }
+   else
+        free(node);
 }
 
 #if 0
 static void rect_print(const rect_t r)
 {
-       printf("<rect(%d, %d, %d, %d)>", r.left, r.top, r.width, r.height);
+        printf("<rect(%d, %d, %d, %d)>", r.left, r.top, r.width, r.height);
 }
 
 static void rect_list_print(const list_t rects)
 {
-       list_node_t *node;
-       int len;
-
-       len = 0;
-       for (node = rects.head; node != NULL; node = node->next)
-               len++;
-
-       printf("[");
-       for (node = rects.head; node != NULL; node = node->next)
-       {
-               rect_print(((rect_node_t *) node)->rect);
-               if (node->next)
-               {
-                       putchar(',');
-                       if (len < 4)
-                               putchar(' ');
-                       else
-                       {
-                               putchar('\n');
-                               putchar(' ');
-                       }
-               }
-       }
-       printf("]\n");
+   list_node_t *node;
+   int len;
+
+   len = 0;
+   for (node = rects.head; node != NULL; node = node->next)
+      len++;
+
+        printf("[");
+   for (node = rects.head; node != NULL; node = node->next)
+     {
+        rect_print(((rect_node_t *)node)->rect);
+        if (node->next)
+          {
+                  putchar(',');
+             if (len < 4)
+                  putchar(' ');
+             else
+               {
+                  putchar('\n');
+                  putchar(' ');
+               }
+          }
+     }
+   printf("]\n");
 }
 #endif
 
 static inline list_node_t *
 rect_list_unlink_next(list_t *rects, list_node_t *parent_node)
 {
-       list_node_t *node;
-
-       if (parent_node)
-       {
-               node = parent_node->next;
-               parent_node->next = node->next;
-       }
-       else
-       {
-               node = rects->head;
-               rects->head = node->next;
-       }
-
-       if (rects->tail == node)
-               rects->tail = parent_node;
-       *node = list_node_zeroed;
-       return node;
+   list_node_t *node;
+
+   if (parent_node)
+     {
+        node = parent_node->next;
+        parent_node->next = node->next;
+     }
+   else
+     {
+        node = rects->head;
+        rects->head = node->next;
+     }
+
+   if (rects->tail == node)
+      rects->tail = parent_node;
+
+   *node = list_node_zeroed;
+   return node;
 }
 
 static inline void rect_list_del_next(list_t *rects, list_node_t *parent_node)
 {
-       list_node_t *node;
+   list_node_t *node;
 
-       node = rect_list_unlink_next(rects, parent_node);
-       rect_list_node_pool_put(node);
+   node = rect_list_unlink_next(rects, parent_node);
+        rect_list_node_pool_put(node);
 }
 
 static void rect_list_clear(list_t *rects)
 {
-       list_node_t *node;
-
-       node = rects->head;
-       while (node)
-       {
-               list_node_t *aux;
-
-               aux = node->next;
-               rect_list_node_pool_put(node);
-               node = aux;
-       }
-       *rects = list_zeroed;
+   list_node_t *node;
+
+   node = rects->head;
+   while (node)
+     {
+        list_node_t *aux;
+
+        aux = node->next;
+        rect_list_node_pool_put(node);
+        node = aux;
+     }
+   *rects = list_zeroed;
 }
 
 static void rect_list_del_split_strict(list_t *rects, const rect_t del_r)
 {
-       list_t modified = list_zeroed;
-       list_node_t *cur_node, *prev_node;
-
-       prev_node = NULL;
-       cur_node = rects->head;
-       while (cur_node)
-       {
-               int intra_width, intra_height;
-               rect_t current;
-
-               current = ((rect_node_t*) cur_node)->rect;
-
-               _calc_intra_rect_area(del_r, current, &intra_width,
-                               &intra_height);
-               if ((intra_width <= 0) || (intra_height <= 0))
-               {
-                       /*  .---.current      .---.del_r
-                        *  |   |             |   |
-                        *  `---+---.del_r    `---+---.current
-                        *      |   |             |   |
-                        *      `---'             `---'
-                        * no intersection, nothing to do
-                        */
-                       prev_node = cur_node;
-                       cur_node = cur_node->next;
-               }
-               else if ((intra_width == current.width) && (intra_height
-                               == current.height))
-               {
-                       /*  .-------.del_r
-                        *  | .---. |
-                        *  | |   | |
-                        *  | `---'current
-                        *  `-------'
-                        * current is contained, remove from rects
-                        */
-                       cur_node = cur_node->next;
-                       rect_list_del_next(rects, prev_node);
-               }
-               else
-               {
-                       _split_strict(&modified, del_r, current);
-                       cur_node = cur_node->next;
-                       rect_list_del_next(rects, prev_node);
-               }
-       }
-
-       rect_list_concat(rects, &modified);
+   list_t modified = list_zeroed;
+   list_node_t *cur_node, *prev_node;
+
+   prev_node = NULL;
+   cur_node = rects->head;
+   while (cur_node)
+     {
+        int intra_width, intra_height;
+        rect_t current;
+
+        current = ((rect_node_t *)cur_node)->rect;
+
+        _calc_intra_rect_area(del_r, current, &intra_width,
+                              &intra_height);
+        if ((intra_width <= 0) || (intra_height <= 0))
+          {
+             /*  .---.current      .---.del_r
+              *  |   |             |   |
+              *  `---+---.del_r    `---+---.current
+              *      |   |             |   |
+              *      `---'             `---'
+              * no intersection, nothing to do
+              */
+             prev_node = cur_node;
+             cur_node = cur_node->next;
+          }
+        else if ((intra_width == current.width) && (intra_height
+                                                    == current.height))
+          {
+             /*  .-------.del_r
+              *  | .---. |
+              *  | |   | |
+              *  | `---'current
+              *  `-------'
+              * current is contained, remove from rects
+              */
+             cur_node = cur_node->next;
+             rect_list_del_next(rects, prev_node);
+          }
+        else
+          {
+             _split_strict(&modified, del_r, current);
+             cur_node = cur_node->next;
+             rect_list_del_next(rects, prev_node);
+          }
+     }
+
+   rect_list_concat(rects, &modified);
 }
 
 #if 0
 static void rect_list_add_split_strict(list_t *rects, list_node_t *node)
 {
-       list_t dirty = list_zeroed;
-       list_t new_dirty = list_zeroed;
-       list_node_t *cur_node;
-
-       if (!rects->head)
-       {
-               rect_list_append_node(rects, node);
-               return;
-       }
-
-       rect_list_append_node(&dirty, node);
-
-       cur_node = rects->head;
-       while (dirty.head)
-       {
-               rect_t current;
-
-               if (!cur_node)
-               {
-                       rect_list_concat(rects, &dirty);
-                       break;
-               }
-
-               current = ((rect_node_t*) cur_node)->rect;
-
-               while (dirty.head)
-               {
-                       int intra_width, intra_height;
-                       rect_t r;
-
-                       r = ((rect_node_t *) dirty.head)->rect;
-                       _calc_intra_rect_area(r, current, &intra_width,
-                                       &intra_height);
-                       if ((intra_width == r.width) && (intra_height
-                                       == r.height))
-                               /*  .-------.cur
-                                *  | .---.r|
-                                *  | |   | |
-                                *  | `---' |
-                                *  `-------'
-                                */
-                               rect_list_del_next(&dirty, NULL);
-                       else if ((intra_width <= 0) || (intra_height <= 0))
-                       {
-                               /*  .---.cur     .---.r
-                                *  |   |        |   |
-                                *  `---+---.r   `---+---.cur
-                                *      |   |        |   |
-                                *      `---'        `---'
-                                */
-                               list_node_t *tmp;
-                               tmp = rect_list_unlink_next(&dirty, NULL);
-                               rect_list_append_node(&new_dirty, tmp);
-                       }
-                       else
-                       {
-                               _split_strict(&new_dirty, current, r);
-                               rect_list_del_next(&dirty, NULL);
-                       }
-               }
-               dirty = new_dirty;
-               new_dirty = list_zeroed;
-
-               cur_node = cur_node->next;
-       }
+   list_t dirty = list_zeroed;
+   list_t new_dirty = list_zeroed;
+   list_node_t *cur_node;
+
+   if (!rects->head)
+     {
+        rect_list_append_node(rects, node);
+        return;
+     }
+
+        rect_list_append_node(&dirty, node);
+
+   cur_node = rects->head;
+   while (dirty.head)
+     {
+        rect_t current;
+
+        if (!cur_node)
+          {
+             rect_list_concat(rects, &dirty);
+             break;
+          }
+
+        current = ((rect_node_t *)cur_node)->rect;
+
+        while (dirty.head)
+          {
+             int intra_width, intra_height;
+             rect_t r;
+
+             r = ((rect_node_t *)dirty.head)->rect;
+             _calc_intra_rect_area(r, current, &intra_width,
+                                   &intra_height);
+             if ((intra_width == r.width) && (intra_height
+                                              == r.height))
+                /*  .-------.cur
+                 *  | .---.r|
+                 *  | |   | |
+                 *  | `---' |
+                 *  `-------'
+                 */
+                rect_list_del_next(&dirty, NULL);
+             else if ((intra_width <= 0) || (intra_height <= 0))
+               {
+                  /*  .---.cur     .---.r
+                   *  |   |        |   |
+                   *  `---+---.r   `---+---.cur
+                   *      |   |        |   |
+                   *      `---'        `---'
+                   */
+                  list_node_t *tmp;
+                  tmp = rect_list_unlink_next(&dirty, NULL);
+                  rect_list_append_node(&new_dirty, tmp);
+               }
+             else
+               {
+                  _split_strict(&new_dirty, current, r);
+                  rect_list_del_next(&dirty, NULL);
+               }
+          }
+        dirty = new_dirty;
+        new_dirty = list_zeroed;
+
+        cur_node = cur_node->next;
+     }
 }
 #endif
 
 static list_node_t *
 rect_list_add_split_fuzzy(list_t *rects, list_node_t *node, int accepted_error)
 {
-       list_t dirty = list_zeroed;
-       list_node_t *old_last;
-
-       old_last = rects->tail;
-
-       if (!rects->head)
-       {
-               rect_list_append_node(rects, node);
-               return old_last;
-       }
-
-       rect_list_append_node(&dirty, node);
-       while (dirty.head)
-       {
-               list_node_t *d_node, *cur_node, *prev_cur_node;
-               int keep_dirty;
-               rect_t r;
-
-               d_node = rect_list_unlink_next(&dirty, NULL);
-               r = ((rect_node_t *) d_node)->rect;
-
-               prev_cur_node = NULL;
-               cur_node = rects->head;
-               keep_dirty = 1;
-               while (cur_node)
-               {
-                       int area, action;
-                       rect_t current, intra, outer;
-
-                       current = ((rect_node_t *) cur_node)->rect;
-
-                       _calc_intra_outer_rect_area(r, current, &intra, &outer);
-                       area = current.area + r.area - intra.area;
-
-                       if ((intra.width == r.width) && (intra.height
-                                       == r.height))
-                       {
-                               /*  .-------.cur
-                                *  | .---.r|
-                                *  | |   | |
-                                *  | `---' |
-                                *  `-------'
-                                */
-                               keep_dirty = 0;
-                               break;
-                       }
-                       else if ((intra.width == current.width)
-                                       && (intra.height == current.height))
-                       {
-                               /* .-------.r
-                                * | .---.cur
-                                * | |   | |
-                                * | `---' |
-                                * `-------'
-                                */
-                               if (old_last == cur_node)
-                                       old_last = prev_cur_node;
-                               cur_node = cur_node->next;
-                               rect_list_del_next(rects, prev_cur_node);
-                       }
-                       else if ((outer.area - area) <= accepted_error)
-                       {
-                               /* .-----------. bounding box (outer)
-                                * |.---. .---.|
-                                * ||cur| |r  ||
-                                * ||   | |   ||
-                                * |`---' `---'|
-                                * `-----------'
-                                * merge them, remove both and add merged
-                                */
-                               rect_node_t *n;
-
-                               if (old_last == cur_node)
-                                       old_last = prev_cur_node;
-
-                               n = (rect_node_t *) rect_list_unlink_next(
-                                               rects, prev_cur_node);
-                               n->rect = outer;
-                               rect_list_append_node(&dirty, (list_node_t *) n);
-
-                               keep_dirty = 0;
-                               break;
-                       }
-                       else if (intra.area <= accepted_error)
-                       {
-                               /*  .---.cur     .---.r
-                                *  |   |        |   |
-                                *  `---+---.r   `---+---.cur
-                                *      |   |        |   |
-                                *      `---'        `---'
-                                *  no split, no merge
-                                */
-                               prev_cur_node = cur_node;
-                               cur_node = cur_node->next;
-                       }
-                       else
-                       {
-                               /* split is required */
-                               action = _split_fuzzy(&dirty, current, &r);
-                               if (action == SPLIT_FUZZY_ACTION_MERGE)
-                               {
-                                       /* horizontal merge is possible: remove both, add merged */
-                                       rect_node_t *n;
-
-                                       if (old_last == cur_node)
-                                               old_last = prev_cur_node;
-
-                                       n
-                                                       = (rect_node_t *) rect_list_unlink_next(
-                                                                       rects,
-                                                                       prev_cur_node);
-
-                                       n->rect.left = outer.left;
-                                       n->rect.width = outer.width;
-                                       n->rect.right = outer.right;
-                                       n->rect.area = outer.width * r.height;
-                                       rect_list_append_node(&dirty,
-                                                       (list_node_t *) n);
-                               }
-                               else if (action == SPLIT_FUZZY_ACTION_NONE)
-                               {
-                                       /*
-                                        * this rect check was totally useless,
-                                        * should never happen
-                                        */
-                                       /* prev_cur_node = cur_node; */
-                                       /* cur_node = cur_node->next; */
-                                       printf("Should not get here!\n");
-                                       abort();
-                               }
-
-                               keep_dirty = 0;
-                               break;
-                       }
-               }
-               if (EINA_UNLIKELY(keep_dirty))
-               {
-                       rect_list_append_node(rects, d_node);
-               }
-               else
-                       rect_list_node_pool_put(d_node);
-       }
-
-       return old_last;
+   list_t dirty = list_zeroed;
+   list_node_t *old_last;
+
+   old_last = rects->tail;
+
+   if (!rects->head)
+     {
+        rect_list_append_node(rects, node);
+        return old_last;
+     }
+
+        rect_list_append_node(&dirty, node);
+   while (dirty.head)
+     {
+        list_node_t *d_node, *cur_node, *prev_cur_node;
+        int keep_dirty;
+        rect_t r;
+
+        d_node = rect_list_unlink_next(&dirty, NULL);
+        r = ((rect_node_t *)d_node)->rect;
+
+        prev_cur_node = NULL;
+        cur_node = rects->head;
+        keep_dirty = 1;
+        while (cur_node)
+          {
+             int area, action;
+             rect_t current, intra, outer;
+
+             current = ((rect_node_t *)cur_node)->rect;
+
+             _calc_intra_outer_rect_area(r, current, &intra, &outer);
+             area = current.area + r.area - intra.area;
+
+             if ((intra.width == r.width) && (intra.height
+                                              == r.height))
+               {
+                  /*  .-------.cur
+                   *  | .---.r|
+                   *  | |   | |
+                   *  | `---' |
+                   *  `-------'
+                   */
+                  keep_dirty = 0;
+                  break;
+               }
+             else if ((intra.width == current.width)
+                      && (intra.height == current.height))
+               {
+                  /* .-------.r
+                   * | .---.cur
+                   * | |   | |
+                   * | `---' |
+                   * `-------'
+                   */
+                  if (old_last == cur_node)
+                     old_last = prev_cur_node;
+
+                  cur_node = cur_node->next;
+                  rect_list_del_next(rects, prev_cur_node);
+               }
+             else if ((outer.area - area) <= accepted_error)
+               {
+                  /* .-----------. bounding box (outer)
+                   * |.---. .---.|
+                   * ||cur| |r  ||
+                   * ||   | |   ||
+                   * |`---' `---'|
+                   * `-----------'
+                   * merge them, remove both and add merged
+                   */
+                  rect_node_t *n;
+
+                  if (old_last == cur_node)
+                     old_last = prev_cur_node;
+
+                  n = (rect_node_t *)rect_list_unlink_next(
+                        rects, prev_cur_node);
+                  n->rect = outer;
+                       rect_list_append_node(&dirty, (list_node_t *)n);
+
+                  keep_dirty = 0;
+                  break;
+               }
+             else if (intra.area <= accepted_error)
+               {
+                  /*  .---.cur     .---.r
+                   *  |   |        |   |
+                   *  `---+---.r   `---+---.cur
+                   *      |   |        |   |
+                   *      `---'        `---'
+                   *  no split, no merge
+                   */
+                  prev_cur_node = cur_node;
+                  cur_node = cur_node->next;
+               }
+             else
+               {
+                  /* split is required */
+                  action = _split_fuzzy(&dirty, current, &r);
+                  if (action == SPLIT_FUZZY_ACTION_MERGE)
+                    {
+/* horizontal merge is possible: remove both, add merged */
+                       rect_node_t *n;
+
+                       if (old_last == cur_node)
+                          old_last = prev_cur_node;
+
+                       n
+                          = (rect_node_t *)rect_list_unlink_next(
+                                rects,
+                                prev_cur_node);
+
+                       n->rect.left = outer.left;
+                       n->rect.width = outer.width;
+                       n->rect.right = outer.right;
+                       n->rect.area = outer.width * r.height;
+                       rect_list_append_node(&dirty,
+                                             (list_node_t *)n);
+                    }
+                  else if (action == SPLIT_FUZZY_ACTION_NONE)
+                    {
+/*
+ * this rect check was totally useless,
+ * should never happen
+ */
+/* prev_cur_node = cur_node; */
+/* cur_node = cur_node->next; */
+                       printf("Should not get here!\n");
+                       abort();
+                    }
+
+                  keep_dirty = 0;
+                  break;
+               }
+          }
+        if (EINA_UNLIKELY(keep_dirty))
+           rect_list_append_node(rects, d_node);
+        else
+           rect_list_node_pool_put(d_node);
+     }
+
+   return old_last;
 }
 
 static inline void _calc_outer_rect_area(const rect_t a, const rect_t b,
-               rect_t *outer)
+                                         rect_t *outer)
 {
-       int min_left, max_right;
-       int min_top, max_bottom;
-
-       if (a.left < b.left)
-               min_left = a.left;
-       else
-               min_left = b.left;
-
-       if (a.right < b.right)
-               max_right = b.right;
-       else
-               max_right = a.right;
-
-       outer->left = min_left;
-       outer->right = max_right;
-       outer->width = max_right - min_left;
-
-       if (a.top < b.top)
-               min_top = a.top;
-       else
-               min_top = b.top;
-
-       if (a.bottom < b.bottom)
-               max_bottom = b.bottom;
-       else
-               max_bottom = a.bottom;
-
-       outer->top = min_top;
-       outer->bottom = max_bottom;
-       outer->height = max_bottom - min_top;
-
-       outer->area = outer->width * outer->height;
+   int min_left, max_right;
+   int min_top, max_bottom;
+
+   if (a.left < b.left)
+      min_left = a.left;
+   else
+      min_left = b.left;
+
+   if (a.right < b.right)
+      max_right = b.right;
+   else
+      max_right = a.right;
+
+   outer->left = min_left;
+   outer->right = max_right;
+   outer->width = max_right - min_left;
+
+   if (a.top < b.top)
+      min_top = a.top;
+   else
+      min_top = b.top;
+
+   if (a.bottom < b.bottom)
+      max_bottom = b.bottom;
+   else
+      max_bottom = a.bottom;
+
+   outer->top = min_top;
+   outer->bottom = max_bottom;
+   outer->height = max_bottom - min_top;
+
+   outer->area = outer->width * outer->height;
 }
 
-static void rect_list_merge_rects(list_t *rects, list_t *to_merge, int accepted_error)
+static void rect_list_merge_rects(list_t *rects,
+                                  list_t *to_merge,
+                                  int accepted_error)
 {
-       while (to_merge->head)
-       {
-               list_node_t *node, *parent_node;
-               rect_t r1;
-               int merged;
-
-               r1 = ((rect_node_t *) to_merge->head)->rect;
-
-               merged = 0;
-               parent_node = NULL;
-               node = rects->head;
-               while (node != NULL)
-               {
-                       rect_t r2, outer;
-                       int area;
-
-                       r2 = ((rect_node_t *) node)->rect;
-
-                       _calc_outer_rect_area(r1, r2, &outer);
-                       area = r1.area + r2.area; /* intra area is taken as 0 */
-                       if (outer.area - area <= accepted_error)
-                       {
-                               /*
-                                * remove both r1 and r2, create r3
-                                * actually r3 uses r2 instance, saves memory
-                                */
-                               rect_node_t *n;
-
-                               n = (rect_node_t *) rect_list_unlink_next(
-                                               rects, parent_node);
-                               n->rect = outer;
-                               rect_list_append_node(to_merge,
-                                               (list_node_t *) n);
-                               merged = 1;
-                               break;
-                       }
-
-                       parent_node = node;
-                       node = node->next;
-               }
-
-               if (!merged)
-               {
-                       list_node_t *n;
-                       n = rect_list_unlink_next(to_merge, NULL);
-                       rect_list_append_node(rects, n);
-               }
-               else
-                       rect_list_del_next(to_merge, NULL);
-       }
+   while (to_merge->head)
+     {
+        list_node_t *node, *parent_node;
+        rect_t r1;
+        int merged;
+
+        r1 = ((rect_node_t *)to_merge->head)->rect;
+
+        merged = 0;
+        parent_node = NULL;
+        node = rects->head;
+        while (node != NULL)
+          {
+             rect_t r2, outer;
+             int area;
+
+             r2 = ((rect_node_t *)node)->rect;
+
+             _calc_outer_rect_area(r1, r2, &outer);
+             area = r1.area + r2.area; /* intra area is taken as 0 */
+             if (outer.area - area <= accepted_error)
+               {
+                  /*
+                   * remove both r1 and r2, create r3
+                   * actually r3 uses r2 instance, saves memory
+                   */
+                  rect_node_t *n;
+
+                  n = (rect_node_t *)rect_list_unlink_next(
+                        rects, parent_node);
+                  n->rect = outer;
+                  rect_list_append_node(to_merge,
+                                        (list_node_t *)n);
+                  merged = 1;
+                  break;
+               }
+
+             parent_node = node;
+             node = node->next;
+          }
+
+        if (!merged)
+          {
+             list_node_t *n;
+             n = rect_list_unlink_next(to_merge, NULL);
+                  rect_list_append_node(rects, n);
+          }
+        else
+                  rect_list_del_next(to_merge, NULL);
+     }
 }
 
-static void rect_list_add_split_fuzzy_and_merge(list_t *rects, list_node_t *node,
-               int split_accepted_error, int merge_accepted_error)
+static void rect_list_add_split_fuzzy_and_merge(list_t *rects,
+                                                list_node_t *node,
+                                                int split_accepted_error,
+                                                int merge_accepted_error)
 {
-       list_node_t *n;
+   list_node_t *n;
 
-       n = rect_list_add_split_fuzzy(rects, node, split_accepted_error);
-       if (n && n->next)
-       {
-               list_t to_merge;
+   n = rect_list_add_split_fuzzy(rects, node, split_accepted_error);
+   if (n && n->next)
+     {
+        list_t to_merge;
 
-               /* split list into 2 segments, already merged and to merge */
-               to_merge.head = n->next;
-               to_merge.tail = rects->tail;
-               rects->tail = n;
-               n->next = NULL;
+        /* split list into 2 segments, already merged and to merge */
+        to_merge.head = n->next;
+        to_merge.tail = rects->tail;
+        rects->tail = n;
+        n->next = NULL;
 
-               rect_list_merge_rects(rects, &to_merge, merge_accepted_error);
-       }
+        rect_list_merge_rects(rects, &to_merge, merge_accepted_error);
+     }
 }
 
 static inline void _splitter_new(Eina_Tiler *t)
 {
-       t->splitter.rects = list_zeroed;
-       t->splitter.need_merge = EINA_FALSE;
+   t->splitter.rects = list_zeroed;
+   t->splitter.need_merge = EINA_FALSE;
 }
 
 static inline void _splitter_del(Eina_Tiler *t)
 {
-       rect_list_clear(&t->splitter.rects);
-       rect_list_node_pool_flush();
+   rect_list_clear(&t->splitter.rects);
+   rect_list_node_pool_flush();
 }
 
-static inline void _splitter_tile_size_set(Eina_Tiler *t, int w __UNUSED__, int h __UNUSED__)
+static inline void _splitter_tile_size_set(Eina_Tiler *t,
+                                           int w __UNUSED__,
+                                           int h __UNUSED__)
 {
-       /* TODO are w and h used for something? */
-       t->splitter.rects = list_zeroed;
+   /* TODO are w and h used for something? */
+   t->splitter.rects = list_zeroed;
 }
 
 static inline Eina_Bool _splitter_rect_add(Eina_Tiler *t, Eina_Rectangle *rect)
 {
-       rect_node_t *rn;
-
-       //printf("ACCOUNTING[1]: add_redraw: %4d,%4d %3dx%3d\n", x, y, w, h);
-       rect->x >>= 1;
-       rect->y >>= 1;
-       rect->w += 2;
-       rect->w >>= 1;
-       rect->h += 2;
-       rect->h >>= 1;
-
-       rn = (rect_node_t *) rect_list_node_pool_get();
-       rn->_lst = list_node_zeroed;
-       rect_init(&rn->rect, rect->x, rect->y, rect->w, rect->h);
-       //printf("ACCOUNTING[2]: add_redraw: %4d,%4d %3dx%3d\n", x, y, w, h);
-       //testing on my core2 duo desktop - fuzz of 32 or 48 is best.
+   rect_node_t *rn;
+
+   //printf("ACCOUNTING[1]: add_redraw: %4d,%4d %3dx%3d\n", x, y, w, h);
+   rect->x >>= 1;
+   rect->y >>= 1;
+   rect->w += 2;
+   rect->w >>= 1;
+   rect->h += 2;
+   rect->h >>= 1;
+
+   rn = (rect_node_t *)rect_list_node_pool_get();
+   rn->_lst = list_node_zeroed;
+   rect_init(&rn->rect, rect->x, rect->y, rect->w, rect->h);
+   //printf("ACCOUNTING[2]: add_redraw: %4d,%4d %3dx%3d\n", x, y, w, h);
+   //testing on my core2 duo desktop - fuzz of 32 or 48 is best.
 #define FUZZ 32
-       rect_list_add_split_fuzzy_and_merge(&t->splitter.rects,
-                       (list_node_t *) rn, FUZZ * FUZZ, FUZZ * FUZZ);
-       return EINA_TRUE;
+   rect_list_add_split_fuzzy_and_merge(&t->splitter.rects,
+                                       (list_node_t *)rn,
+                                       FUZZ * FUZZ,
+                                       FUZZ * FUZZ);
+   return EINA_TRUE;
 }
 
 static inline void _splitter_rect_del(Eina_Tiler *t, Eina_Rectangle *rect)
 {
-       rect_t r;
-
-       if (!t->splitter.rects.head)
-               return;
-       rect->x += 1;
-       rect->y += 1;
-       rect->x >>= 1;
-       rect->y >>= 1;
-       rect->w -= 1;
-       rect->w >>= 1;
-       rect->h -= 1;
-       rect->h >>= 1;
-
-       if ((rect->w <= 0) || (rect->h <= 0))
-               return;
-
-       rect_init(&r, rect->x, rect->y, rect->w, rect->h);
-       //fprintf(stderr, "ACCOUNTING: del_redraw: %4d,%4d %3dx%3d\n", x, y, w, h);
-
-       rect_list_del_split_strict(&t->splitter.rects, r);
-       t->splitter.need_merge = EINA_TRUE;
-       return;
+   rect_t r;
+
+   if (!t->splitter.rects.head)
+      return;
+
+   rect->x += 1;
+   rect->y += 1;
+   rect->x >>= 1;
+   rect->y >>= 1;
+   rect->w -= 1;
+   rect->w >>= 1;
+   rect->h -= 1;
+   rect->h >>= 1;
+
+   if ((rect->w <= 0) || (rect->h <= 0))
+      return;
+
+   rect_init(&r, rect->x, rect->y, rect->w, rect->h);
+   //fprintf(stderr, "ACCOUNTING: del_redraw: %4d,%4d %3dx%3d\n", x, y, w, h);
+
+   rect_list_del_split_strict(&t->splitter.rects, r);
+   t->splitter.need_merge = EINA_TRUE;
+   return;
 }
 
 static inline void _splitter_clear(Eina_Tiler *t)
 {
-       rect_list_clear(&t->splitter.rects);
-       t->splitter.need_merge = EINA_FALSE;
+   rect_list_clear(&t->splitter.rects);
+   t->splitter.need_merge = EINA_FALSE;
 }
 /* end of splitter algorithm */
 
 static Eina_Bool _iterator_next(Eina_Iterator_Tiler *it, void **data)
 {
-       Eina_Rectangle *rect = (Eina_Rectangle *)data;
-       list_node_t *n;
+   Eina_Rectangle *rect = (Eina_Rectangle *)data;
+   list_node_t *n;
+
+   for (n = it->curr; n != NULL; n = n->next)
+     {
+        rect_t cur;
 
-       for (n = it->curr; n != NULL; n = n->next)
-       {
-               rect_t cur;
+        cur = ((rect_node_t *)n)->rect;
 
-               cur = ((rect_node_t *) n)->rect;
+        rect->x = cur.left << 1;
+        rect->y = cur.top << 1;
+        rect->w = cur.width << 1;
+        rect->h = cur.height << 1;
 
-               rect->x = cur.left << 1;
-               rect->y = cur.top << 1;
-               rect->w = cur.width << 1;
-               rect->h = cur.height << 1;
+        if (eina_rectangle_intersection(rect, &it->tiler->area) == EINA_FALSE)
+           continue;
 
-               if (eina_rectangle_intersection(rect, &it->tiler->area) == EINA_FALSE)
-                       continue;
-               if ((rect->w <= 0) || (rect->h <= 0))
-                       continue;
+        if ((rect->w <= 0) || (rect->h <= 0))
+           continue;
 
-               it->curr = n->next;
-               return EINA_TRUE;
-       }
-       return EINA_FALSE;
+        it->curr = n->next;
+        return EINA_TRUE;
+     }
+   return EINA_FALSE;
 }
 
-static void * _iterator_get_container(Eina_Iterator_Tiler *it)
+static void *_iterator_get_container(Eina_Iterator_Tiler *it)
 {
-       EINA_MAGIC_CHECK_TILER_ITERATOR(it, NULL);
-       return (void *)it->tiler;
+   EINA_MAGIC_CHECK_TILER_ITERATOR(it, NULL);
+   return (void *)it->tiler;
 }
 
 static void _iterator_free(Eina_Iterator_Tiler *it)
 {
-       EINA_MAGIC_CHECK_TILER_ITERATOR(it);
-       free(it);
+   EINA_MAGIC_CHECK_TILER_ITERATOR(it);
+   free(it);
 }
 
 /*============================================================================*
- *                                 Global                                     *
- *============================================================================*/
+*                                 Global                                     *
+*============================================================================*/
 
 /*============================================================================*
- *                                   API                                      *
- *============================================================================*/
+*                                   API                                      *
+*============================================================================*/
 
 EAPI Eina_Tiler *eina_tiler_new(int w, int h)
 {
-       Eina_Tiler *t;
-
-       t = calloc(1, sizeof(Eina_Tiler));
-       t->area.w = w;
-       t->area.h = h;
-       t->tile.w = w;
-       t->tile.h = h;
-       EINA_MAGIC_SET(t, EINA_MAGIC_TILER);
-       _splitter_new(t);
-       return t;
+   Eina_Tiler *t;
+
+   t = calloc(1, sizeof(Eina_Tiler));
+   t->area.w = w;
+   t->area.h = h;
+   t->tile.w = w;
+   t->tile.h = h;
+   EINA_MAGIC_SET(t, EINA_MAGIC_TILER);
+   _splitter_new(t);
+   return t;
 }
 
 EAPI void eina_tiler_free(Eina_Tiler *t)
 {
-       EINA_MAGIC_CHECK_TILER(t);
-       _splitter_del(t);
-       free(t);
+   EINA_MAGIC_CHECK_TILER(t);
+   _splitter_del(t);
+   free(t);
 }
 
 EAPI void eina_tiler_tile_size_set(Eina_Tiler *t, int w, int h)
 {
-       EINA_MAGIC_CHECK_TILER(t);
-       if ((w <= 0) || (h <= 0)) return;
+   EINA_MAGIC_CHECK_TILER(t);
+   if ((w <= 0) || (h <= 0))
+      return;
 
-       t->tile.w = w;
-       t->tile.h = h;
-       _splitter_tile_size_set(t, w, h);
+   t->tile.w = w;
+   t->tile.h = h;
+   _splitter_tile_size_set(t, w, h);
 }
 
 EAPI Eina_Bool eina_tiler_rect_add(Eina_Tiler *t, const Eina_Rectangle *r)
 {
-       Eina_Rectangle tmp;
-
-       EINA_MAGIC_CHECK_TILER(t, EINA_FALSE);
-       if ((r->w <= 0) || (r->h <= 0))
-               return EINA_FALSE;
-       tmp = *r;
-       if (eina_rectangle_intersection(&tmp, &t->area) == EINA_FALSE)
-               return EINA_FALSE;
-       if ((tmp.w <= 0) || (tmp.h <= 0))
-               return EINA_FALSE;
-       return _splitter_rect_add(t, &tmp);
+   Eina_Rectangle tmp;
+
+   EINA_MAGIC_CHECK_TILER(t, EINA_FALSE);
+   if ((r->w <= 0) || (r->h <= 0))
+      return EINA_FALSE;
+
+   tmp = *r;
+   if (eina_rectangle_intersection(&tmp, &t->area) == EINA_FALSE)
+      return EINA_FALSE;
+
+   if ((tmp.w <= 0) || (tmp.h <= 0))
+      return EINA_FALSE;
+
+   return _splitter_rect_add(t, &tmp);
 }
 
 EAPI void eina_tiler_rect_del(Eina_Tiler *t, const Eina_Rectangle *r)
 {
-       Eina_Rectangle tmp;
-
-       EINA_MAGIC_CHECK_TILER(t);
-       if ((r->w <= 0) || (r->h <= 0))
-               return;
-       tmp = *r;
-       if (eina_rectangle_intersection(&tmp, &t->area) == EINA_FALSE)
-               return;
-       if ((tmp.w <= 0) || (tmp.h <= 0))
-               return;
-       _splitter_rect_del(t, &tmp);
+   Eina_Rectangle tmp;
+
+   EINA_MAGIC_CHECK_TILER(t);
+   if ((r->w <= 0) || (r->h <= 0))
+      return;
+
+   tmp = *r;
+   if (eina_rectangle_intersection(&tmp, &t->area) == EINA_FALSE)
+      return;
+
+   if ((tmp.w <= 0) || (tmp.h <= 0))
+      return;
+
+   _splitter_rect_del(t, &tmp);
 }
 
 EAPI void eina_tiler_clear(Eina_Tiler *t)
 {
-       EINA_MAGIC_CHECK_TILER(t);
-       _splitter_clear(t);
+   EINA_MAGIC_CHECK_TILER(t);
+   _splitter_clear(t);
 }
 
 
-EAPI Eina_Iterator * eina_tiler_iterator_new(const Eina_Tiler *t)
+EAPI Eina_Iterator *eina_tiler_iterator_new(const Eina_Tiler *t)
 {
-       Eina_Iterator_Tiler *it;
+   Eina_Iterator_Tiler *it;
 
-       EINA_MAGIC_CHECK_TILER(t, NULL);
-       it = calloc(1, sizeof (Eina_Iterator_Tiler));
-       if (!it) return NULL;
+   EINA_MAGIC_CHECK_TILER(t, NULL);
+
+   it = calloc(1, sizeof (Eina_Iterator_Tiler));
+   if (!it)
+      return NULL;
 
-       it->tiler = t;
+   it->tiler = t;
 
-       if (t->splitter.need_merge == EINA_TRUE)
-       {
-               list_t to_merge;
-               splitter_t *sp;
+   if (t->splitter.need_merge == EINA_TRUE)
+     {
+        list_t to_merge;
+        splitter_t *sp;
+
+        sp = (splitter_t *)&(t->splitter);
+        to_merge = t->splitter.rects;
+        sp->rects = list_zeroed;
+        rect_list_merge_rects(&sp->rects, &to_merge, FUZZ * FUZZ);
+        sp->need_merge = 0;
+     }
 
-               sp = (splitter_t *)&(t->splitter);
-               to_merge = t->splitter.rects;
-               sp->rects = list_zeroed;
-               rect_list_merge_rects(&sp->rects, &to_merge, FUZZ * FUZZ);
-               sp->need_merge = 0;
-       }
+   it->curr = it->tiler->splitter.rects.head;
 
-       it->curr = it->tiler->splitter.rects.head;
-       it->iterator.next = FUNC_ITERATOR_NEXT(_iterator_next);
-       it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(_iterator_get_container);
-       it->iterator.free = FUNC_ITERATOR_FREE(_iterator_free);
+   it->iterator.version = EINA_ITERATOR_VERSION;
+   it->iterator.next = FUNC_ITERATOR_NEXT(_iterator_next);
+   it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
+         _iterator_get_container);
+   it->iterator.free = FUNC_ITERATOR_FREE(_iterator_free);
 
-       EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
-       EINA_MAGIC_SET(it, EINA_MAGIC_TILER_ITERATOR);
+   EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
+   EINA_MAGIC_SET(it,            EINA_MAGIC_TILER_ITERATOR);
 
-       return &it->iterator;
+   return &it->iterator;
 }
 
 struct _Eina_Tile_Grid_Slicer_Iterator
@@ -1216,10 +1239,11 @@ eina_tile_grid_slicer_iterator_free(Eina_Tile_Grid_Slicer_Iterator *it)
 }
 
 static Eina_Bool
-eina_tile_grid_slicer_iterator_next(Eina_Tile_Grid_Slicer_Iterator *it, void **data)
+eina_tile_grid_slicer_iterator_next(Eina_Tile_Grid_Slicer_Iterator *it,
+                                    void **data)
 {
    return eina_tile_grid_slicer_next
-     (&it->priv, (const Eina_Tile_Grid_Info **)data);
+             (&it->priv, (const Eina_Tile_Grid_Info **)data);
 }
 
 /**
@@ -1243,19 +1267,25 @@ eina_tile_grid_slicer_iterator_next(Eina_Tile_Grid_Slicer_Iterator *it, void **d
  *     is set.
  */
 EAPI Eina_Iterator *
-eina_tile_grid_slicer_iterator_new(int x, int y, int w, int h, int tile_w, int tile_h)
+eina_tile_grid_slicer_iterator_new(int x,
+                                   int y,
+                                   int w,
+                                   int h,
+                                   int tile_w,
+                                   int tile_h)
 {
    Eina_Tile_Grid_Slicer_Iterator *it;
 
    it = calloc(1, sizeof(*it));
    if (!it)
      {
-       eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
-       return NULL;
+        eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+        return NULL;
      }
 
    EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
 
+   it->iterator.version = EINA_ITERATOR_VERSION;
    it->iterator.next = FUNC_ITERATOR_NEXT(eina_tile_grid_slicer_iterator_next);
    it->iterator.free = FUNC_ITERATOR_FREE(eina_tile_grid_slicer_iterator_free);
 
diff --git a/src/lib/eina_unicode.c b/src/lib/eina_unicode.c
new file mode 100644 (file)
index 0000000..cef07fb
--- /dev/null
@@ -0,0 +1,176 @@
+/* EINA - EFL data type library
+ * Copyright (C) 2010 Tom Hacohen,
+ *             Brett Nash
+ *
+ * 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/>.
+
+ */
+
+#include <Eina.h>
+#include "eina_unicode.h"
+
+/* FIXME: check if sizeof(wchar_t) == sizeof(Eina_Unicode) if so,
+ * probably better to use the standard functions */
+
+/* Maybe I'm too tired, but this is the only thing that actually worked. */
+const Eina_Unicode _EINA_UNICODE_EMPTY_STRING[1] = {0};
+EAPI const Eina_Unicode *EINA_UNICODE_EMPTY_STRING = _EINA_UNICODE_EMPTY_STRING;
+/**
+ * @brief Same as the standard strcmp just with Eina_Unicode instead of char.
+ */
+EAPI int
+eina_unicode_strcmp(const Eina_Unicode *a, const Eina_Unicode *b)
+{
+   for (; *a && *a == *b; a++, b++)
+      ;
+   if (*a == *b)
+      return 0;
+   else if (*a < *b)
+      return -1;
+   else
+      return 1;
+}
+
+/**
+ * @brief Same as the standard strcpy just with Eina_Unicode instead of char.
+ */
+EAPI Eina_Unicode *
+eina_unicode_strcpy(Eina_Unicode *dest, const Eina_Unicode *source)
+{
+   Eina_Unicode *ret = dest;
+
+   while (*source)
+      *dest++ = *source++;
+   *dest = 0;
+   return ret;
+}
+
+/**
+ * @brief Same as the standard strncpy just with Eina_Unicode instead of char.
+ */
+EAPI Eina_Unicode *
+eina_unicode_strncpy(Eina_Unicode *dest, const Eina_Unicode *source, size_t n)
+{
+   Eina_Unicode *ret = dest;
+
+   for ( ; n && *source ; n--)
+      *dest++ = *source++;
+   for (; n; n--)
+      *dest++ = 0;
+   return ret;
+}
+
+/**
+ * @brief Same as the standard strlen just with Eina_Unicode instead of char.
+ */
+EAPI size_t
+eina_unicode_strlen(const Eina_Unicode *ustr)
+{
+   const Eina_Unicode *end;
+   for (end = ustr; *end; end++)
+      ;
+   return end - ustr;
+}
+
+/**
+ * @brief Returns the length of a Eina_Unicode string, up to a limit.
+ *
+ * This function returns the number of characters in string, up to a maximum
+ * of n.  If the terminating character is not found in the string, it returns
+ * n.
+ *
+ * @param ustr String to search
+ * @param n Max length to search
+ * @return Number of characters or n.
+ */
+EAPI size_t
+eina_unicode_strnlen(const Eina_Unicode *ustr, int n)
+{
+   const Eina_Unicode *end;
+   const Eina_Unicode *last = ustr + n; /* technically not portable ;-) */
+   for (end = ustr; end < last && *end; end++)
+      ;
+   return end - ustr;
+}
+
+
+
+
+/**
+ * @brief Same as the standard strdup just with Eina_Unicode instead of char.
+ */
+EAPI Eina_Unicode *
+eina_unicode_strdup(const Eina_Unicode *text)
+{
+   Eina_Unicode *ustr;
+   int len;
+
+   len = eina_unicode_strlen(text);
+   ustr = (Eina_Unicode *)calloc(len + 1, sizeof(Eina_Unicode));
+   memcpy(ustr, text, len * sizeof(Eina_Unicode));
+
+   return ustr;
+}
+
+/**
+ * @brief Same as the standard strdup just with Eina_Unicode instead of char.
+ */
+EAPI Eina_Unicode *
+eina_unicode_strstr(const Eina_Unicode *haystack, const Eina_Unicode *needle)
+{
+   const Eina_Unicode *i, *j;
+
+   for (i = haystack; *i; i++)
+     {
+        haystack = i; /* set this location as the base position */
+        for (j = needle; *j && *i && *j == *i; j++, i++)
+           ;
+
+        if (!*j) /*if we got to the end of j this means we got a full match */
+          {
+             return (Eina_Unicode *)haystack; /* return the new base position */
+          }
+     }
+
+   return NULL;
+}
+
+/**
+ * @see eina_str_escape()
+ */
+EAPI Eina_Unicode *
+eina_unicode_escape(const Eina_Unicode *str)
+{
+   Eina_Unicode *s2, *d;
+   const Eina_Unicode *s;
+
+   s2 = malloc((eina_unicode_strlen(str) * 2) + 1);
+   if (!s2)
+      return NULL;
+
+   for (s = str, d = s2; *s != 0; s++, d++)
+     {
+        if ((*s == ' ') || (*s == '\\') || (*s == '\''))
+          {
+             *d = '\\';
+             d++;
+          }
+
+        *d = *s;
+     }
+   *d = 0;
+   return s2;
+}
+
diff --git a/src/lib/eina_ustrbuf.c b/src/lib/eina_ustrbuf.c
new file mode 100644 (file)
index 0000000..7df5b16
--- /dev/null
@@ -0,0 +1,89 @@
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include "eina_strbuf_common.h"
+#include "eina_unicode.h"
+#include "eina_ustrbuf.h"
+
+/*============================================================================*
+ *                                  Local                                     *
+ *============================================================================*/
+
+/**
+ * @cond LOCAL
+ */
+
+#ifdef _STRBUF_DATA_TYPE
+# undef _STRBUF_DATA_TYPE
+#endif
+
+#ifdef _STRBUF_CSIZE
+# undef _STRBUF_CSIZE
+#endif
+
+#ifdef _STRBUF_STRUCT_NAME
+# undef _STRBUF_STRUCT_NAME
+#endif
+
+#ifdef _STRBUF_STRLEN_FUNC
+# undef _STRBUF_STRLEN_FUNC
+#endif
+
+#ifdef _STRBUF_STRESCAPE_FUNC
+# undef _STRBUF_STRESCAPE_FUNC
+#endif
+
+#ifdef _STRBUF_MAGIC
+# undef _STRBUF_MAGIC
+#endif
+
+#ifdef _STRBUF_MAGIC_STR
+# undef _STRBUF_MAGIC_STR
+#endif
+
+#ifdef _FUNC_EXPAND
+# undef _FUNC_EXPAND
+#endif
+
+#define _STRBUF_DATA_TYPE         Eina_Unicode
+#define _STRBUF_CSIZE             sizeof(_STRBUF_DATA_TYPE)
+#define _STRBUF_STRUCT_NAME       Eina_UStrbuf
+#define _STRBUF_STRLEN_FUNC(x)    eina_unicode_strlen(x)
+#define _STRBUF_STRESCAPE_FUNC(x) eina_unicode_escape(x)
+#define _STRBUF_MAGIC             EINA_MAGIC_USTRBUF
+#define _STRBUF_MAGIC_STR         __USTRBUF_MAGIC_STR
+static const char __USTRBUF_MAGIC_STR[] = "Eina UStrbuf";
+
+#define _FUNC_EXPAND(y) eina_ustrbuf_ ## y
+
+/**
+ * @endcond
+ */
+
+
+/*============================================================================*
+ *                                 Global                                     *
+ *============================================================================*/
+
+
+/*============================================================================*
+ *                                   API                                      *
+ *============================================================================*/
+
+/**
+ * @addtogroup Eina_Unicode_String_Buffer_Group Unicode String Buffer
+ *
+ * @brief These functions provide unicode string buffers management.
+ *
+ * The Unicode String Buffer data type is designed to be a mutable string,
+ * allowing to append, prepend or insert a string to a buffer.
+ *
+ * @{
+ */
+
+#include "eina_strbuf_template_c.x"
+
+/**
+ * @}
+ */
diff --git a/src/lib/eina_ustringshare.c b/src/lib/eina_ustringshare.c
new file mode 100644 (file)
index 0000000..142472e
--- /dev/null
@@ -0,0 +1,243 @@
+/* EINA - EFL data type library
+ * Copyright (C) 2002-2008 Carsten Haitzler,
+ *                         Jorge Luis Zapata Muga,
+ *                         Cedric Bail,
+ *                         Gustavo Sverzut Barbieri
+ *                         Tom Hacohen
+ *
+ * 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/>.
+
+ */
+/**
+ * @page tutorial_ustringshare_page UStringshare Tutorial
+ *
+ * to be written...
+ *
+ */
+
+#include "eina_share_common.h"
+#include "eina_unicode.h"
+#include "eina_private.h"
+#include "eina_ustringshare.h"
+
+/* The actual share */
+static Eina_Share *ustringshare_share;
+static const char EINA_MAGIC_USTRINGSHARE_NODE_STR[] = "Eina UStringshare Node";
+
+/*============================================================================*
+*                                 Global                                     *
+*============================================================================*/
+
+/**
+ * @internal
+ * @brief Initialize the share_common module.
+ *
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function sets up the share_common module of Eina. It is called by
+ * eina_init().
+ *
+ * @see eina_init()
+ */
+Eina_Bool
+eina_ustringshare_init(void)
+{
+   return eina_share_common_init(&ustringshare_share,
+                                 EINA_MAGIC_USTRINGSHARE_NODE,
+                                 EINA_MAGIC_USTRINGSHARE_NODE_STR);
+}
+
+/**
+ * @internal
+ * @brief Shut down the share_common module.
+ *
+ * @return #EINA_TRUE on success, #EINA_FALSE on failure.
+ *
+ * This function shuts down the share_common module set up by
+ * eina_share_common_init(). It is called by eina_shutdown().
+ *
+ * @see eina_shutdown()
+ */
+Eina_Bool
+eina_ustringshare_shutdown(void)
+{
+   Eina_Bool ret;
+   ret = eina_share_common_shutdown(&ustringshare_share);
+   return ret;
+}
+
+/*============================================================================*
+*                                   API                                      *
+*============================================================================*/
+/**
+ * @addtogroup Eina_UStringshare_Group Unicode Stringshare
+ *
+ * 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.
+ *
+ * For more information, you can look at the @ref tutorial_ustringshare_page.
+ *
+ * @{
+ */
+
+/**
+ * @brief Note that the given string has lost an instance.
+ *
+ * @param str string The given string.
+ *
+ * This function decreases the reference counter associated to @p str
+ * if it exists. If that counter reaches 0, the memory associated to
+ * @p str is freed. If @p str is NULL, the function returns
+ * immediatly.
+ *
+ * Note that if the given pointer is not shared or NULL, bad things
+ * will happen, likely a segmentation fault.
+ */
+EAPI void
+eina_ustringshare_del(const Eina_Unicode *str)
+{
+   if (!str)
+      return;
+
+   eina_share_common_del(ustringshare_share,(const char *)str);
+}
+
+/**
+ * @brief Retrieve an instance of a string for use in a program.
+ *
+ * @param   str The string to retrieve an instance of.
+ * @param   slen The string size (<= strlen(str)).
+ * @return  A pointer to an instance of the string on success.
+ *          @c NULL on failure.
+ *
+ * This function retrieves an instance of @p str. If @p str is
+ * @c NULL, then @c NULL is returned. If @p str is already stored, it
+ * is just returned and its reference counter is increased. Otherwise
+ * it is added to the strings to be searched and a duplicated string
+ * of @p str is returned.
+ *
+ * This function does not check string size, but uses the
+ * exact given size. This can be used to share_common part of a larger
+ * buffer or substring.
+ *
+ * @see eina_ustringshare_add()
+ */
+EAPI const Eina_Unicode *
+eina_ustringshare_add_length(const Eina_Unicode *str, unsigned int slen)
+{
+   return (const Eina_Unicode *)eina_share_common_add_length(ustringshare_share,
+                                                             (const char *)str,
+                                                             slen *
+                                                             sizeof(
+                                                                Eina_Unicode),
+                                                             sizeof(
+                                                                Eina_Unicode));
+}
+
+/**
+ * @brief Retrieve an instance of a string for use in a program.
+ *
+ * @param   str The NULL terminated string to retrieve an instance of.
+ * @return  A pointer to an instance of the string on success.
+ *          @c NULL on failure.
+ *
+ * This function retrieves an instance of @p str. If @p str is
+ * @c NULL, then @c NULL is returned. If @p str is already stored, it
+ * is just returned and its reference counter is increased. Otherwise
+ * it is added to the strings to be searched and a duplicated string
+ * of @p str is returned.
+ *
+ * The string @p str must be NULL terminated ('@\0') and its full
+ * length will be used. To use part of the string or non-null
+ * terminated, use eina_stringshare_add_length() instead.
+ *
+ * @see eina_ustringshare_add_length()
+ */
+EAPI const Eina_Unicode *
+eina_ustringshare_add(const Eina_Unicode *str)
+{
+   int slen = (str) ? (int)eina_unicode_strlen(str) : -1;
+   return eina_ustringshare_add_length(str, slen);
+}
+
+/**
+ * Increment references of the given shared string.
+ *
+ * @param str The shared string.
+ * @return    A pointer to an instance of the string on success.
+ *            @c NULL on failure.
+ *
+ * This is similar to eina_share_common_add(), but it's faster since it will
+ * avoid lookups if possible, but on the down side it requires the parameter
+ * to be shared before, in other words, it must be the return of a previous
+ * eina_ustringshare_add().
+ *
+ * There is no unref since this is the work of eina_ustringshare_del().
+ */
+EAPI const Eina_Unicode *
+eina_ustringshare_ref(const Eina_Unicode *str)
+{
+   return (const Eina_Unicode *)eina_share_common_ref(ustringshare_share,
+                                                      (const char *)str);
+}
+
+/**
+ * @brief Note that the given string @b must be shared.
+ *
+ * @param str the shared string to know the length. It is safe to
+ *        give NULL, in that case -1 is returned.
+ *
+ * This function is a cheap way to known the length of a shared
+ * string. Note that if the given pointer is not shared, bad
+ * things will happen, likely a segmentation fault. If in doubt, try
+ * strlen().
+ */
+EAPI int
+eina_ustringshare_strlen(const Eina_Unicode *str)
+{
+   int len = eina_share_common_length(ustringshare_share, (const char *)str);
+   len = (len > 0) ? len / (int)sizeof(Eina_Unicode) : -1;
+   return len;
+}
+
+/**
+ * @brief Dump the contents of the share_common.
+ *
+ * This function dumps all strings in the share_common to stdout with a
+ * DDD: prefix per line and a memory usage summary.
+ */
+EAPI void
+eina_ustringshare_dump(void)
+{
+   eina_share_common_dump(ustringshare_share, NULL, 0);
+}
+
+/**
+ * @}
+ */
+
index 901bc6b..554f907 100644 (file)
@@ -1,28 +1,28 @@
 /* eina_value.c
 
-Copyright (C) 2001 Christopher Rosendahl    <smugg@fatelabs.com>
+   Copyright (C) 2001 Christopher Rosendahl    <smugg@fatelabs.com>
                    Nathan Ingersoll         <ningerso@d.umn.edu>
 
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to
-deal in the Software without restriction, including without limitation the
-rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-sell copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
+   Permission is hereby granted, free of charge, to any person obtaining a copy
+   of this software and associated documentation files (the "Software"), to
+   deal in the Software without restriction, including without limitation the
+   rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+   sell copies of the Software, and to permit persons to whom the Software is
+   furnished to do so, subject to the following conditions:
 
-The above copyright notice and this permission notice shall be included in
-all copies of the Software and its documentation and acknowledgment shall be
-given in the documentation and software packages that this Software was
-used.
+   The above copyright notice and this permission notice shall be included in
+   all copies of the Software and its documentation and acknowledgment shall be
+   given in the documentation and software packages that this Software was
+   used.
 
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+   THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+   IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
-*/
+ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -32,16 +32,16 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "eina_private.h"
 
 /*============================================================================*
- *                                 Global                                     *
- *============================================================================*/
+*                                 Global                                     *
+*============================================================================*/
 
 /*============================================================================*
- *                                   API                                      *
- *============================================================================*/
+*                                   API                                      *
+*============================================================================*/
 
 EAPI const unsigned int eina_prime_table[] =
 {
    17, 31, 61, 127, 257, 509, 1021,
-     2053, 4093, 8191, 16381, 32771, 65537, 131071, 262147, 524287, 1048573,
-     2097143, 4194301, 8388617, 16777213
+   2053, 4093, 8191, 16381, 32771, 65537, 131071, 262147, 524287, 1048573,
+   2097143, 4194301, 8388617, 16777213
 };
index fd093b9..2d7f8d0 100644 (file)
@@ -1,4 +1,10 @@
-SUBDIRS = chained_pool ememoa_fixed pass_through ememoa_unknown fixed_bitmap buddy
+SUBDIRS = chained_pool \
+       ememoa_fixed \
+       pass_through \
+       ememoa_unknown \
+       fixed_bitmap \
+       buddy \
+       one_big
 
 MAINTAINERCLEANFILES = \
 Makefile.in
index 76835b5..722528f 100644 (file)
 
 typedef struct _Block
 {
-       EINA_INLIST;
-       Eina_Bool available : 1;
-       unsigned short int order : 7; /* final order is order + min_order */
+   EINA_INLIST;
+   Eina_Bool available : 1;
+   unsigned short int order : 7; /* final order is order + min_order */
 } Block;
 
 typedef struct _Buddy
 {
-       void *heap; /* start address of the heap */
-       size_t size; /* total size in bytes of the heap */
-       unsigned int min_order; /* minimum size is 1 << min_order */
-       unsigned int max_order; /* maximum size is 1 << max_order */
-       unsigned int num_order; /* number of orders */
-       Eina_Inlist **areas; /* one area per order */
-       Block *blocks; /* the allocated block information */
+   void *heap; /* start address of the heap */
+   size_t size; /* total size in bytes of the heap */
+   unsigned int min_order; /* minimum size is 1 << min_order */
+   unsigned int max_order; /* maximum size is 1 << max_order */
+   unsigned int num_order; /* number of orders */
+   Eina_Inlist **areas; /* one area per order */
+   Block *blocks; /* the allocated block information */
 } Buddy;
 
 /* get the minimum order greater or equal to size */
 static inline unsigned int _get_order(Buddy *b, size_t size)
 {
-       unsigned int i;
-       size_t bytes;
-
-       bytes = 1 << b->min_order;
-       for (i = 0; bytes < size && i < b->num_order; i++)
-       {
-               bytes += bytes;
-       }
-       //printf("order for size %d is %d\n", size, i + b->min_order);
-       return i;
+   unsigned int i;
+   size_t bytes;
+
+   bytes = 1 << b->min_order;
+   for (i = 0; bytes < size && i < b->num_order; i++)
+     {
+        bytes += bytes;
+     }
+   //printf("order for size %d is %d\n", size, i + b->min_order);
+   return i;
 }
 
-static inline void * _get_offset(Buddy *b, Block *block)
+static inline void *_get_offset(Buddy *b, Block *block)
 {
-       void *ret;
+   void *ret;
 
-       ret = (char *)b->heap + ((block - &b->blocks[0]) << b->min_order);
-       return ret;
+   ret = (char *)b->heap + ((block - &b->blocks[0]) << b->min_order);
+   return ret;
 }
 
-static void *_init(__UNUSED__ const char *context, __UNUSED__ const char *options, va_list args)
+static void *_init(__UNUSED__ const char *context,
+                   __UNUSED__ const char *options,
+                   va_list args)
 {
-       Buddy *b;
-       int i;
-       size_t bytes;
-       size_t size;
-       size_t min_order;
-       void *heap;
-
-       heap = va_arg(args, void *);
-       size = va_arg(args, size_t);
-       min_order = va_arg(args, int);
-       /* the minimum order we support is 15 (32K) */
-       min_order = min_order < 15 ? 15 : min_order;
-       bytes = 1 << min_order;
-       for (i = 0; bytes <= size; i++)
-       {
-               bytes += bytes;
-       }
-       if (!i)
-       {
-               return NULL;
-       }
-       b = malloc(sizeof(Buddy));
-       b->heap = heap;
-       b->size = size;
-       b->min_order = min_order;
-       b->max_order = min_order + i - 1;
-       b->num_order = i;
-       b->areas = calloc(b->num_order, sizeof(Eina_Inlist *));
-       b->blocks = calloc(1 << (b->num_order - 1), sizeof(Block));
-       /* setup the initial free area */
-       b->blocks[0].available = EINA_TRUE;
-       b->areas[b->num_order - 1] = EINA_INLIST_GET(&(b->blocks[0]));
-
-       return b;
+   Buddy *b;
+   int i;
+   size_t bytes;
+   size_t size;
+   size_t min_order;
+   void *heap;
+
+   heap = va_arg(args, void *);
+   size = va_arg(args, size_t);
+   min_order = va_arg(args, int);
+   /* the minimum order we support is 15 (32K) */
+   min_order = min_order < 15 ? 15 : min_order;
+   bytes = 1 << min_order;
+   for (i = 0; bytes <= size; i++)
+     {
+        bytes += bytes;
+     }
+   if (!i)
+      return NULL;
+
+   b = malloc(sizeof(Buddy));
+   b->heap = heap;
+   b->size = size;
+   b->min_order = min_order;
+   b->max_order = min_order + i - 1;
+   b->num_order = i;
+   b->areas = calloc(b->num_order, sizeof(Eina_Inlist *));
+   b->blocks = calloc(1 << (b->num_order - 1), sizeof(Block));
+   /* setup the initial free area */
+   b->blocks[0].available = EINA_TRUE;
+   b->areas[b->num_order - 1] = EINA_INLIST_GET(&(b->blocks[0]));
+
+   return b;
 }
 
 static void _shutdown(void *data)
 {
-       Buddy *b = data;
+   Buddy *b = data;
 
-       free(b->blocks);
-       free(b->areas);
-       free(b);
+   free(b->blocks);
+   free(b->areas);
+   free(b);
 }
 
 static void _free(void *data, void *element)
 {
-       Buddy *b = data;
-       Block *block, *buddy;
-       unsigned int offset;
-       unsigned int index;
-
-       offset = (unsigned char *)element - (unsigned char *)b->heap;
-       if (offset > b->size)
-               return;
-       index = offset >> b->min_order;
-       block = &b->blocks[index];
-
-       //printf("free %x index = %d order = %d buddy = %d\n", offset, index, block->order, index ^ (1 << block->order));
-       /* we should always work with the buddy at right */
-       if (index & (1 << block->order))
-       {
-               Block *left;
-
-               index = index ^ (1 << block->order);
-               left = &b->blocks[index];
-               if (!left->available)
-                       goto end;
-               else
-               {
-                       buddy = block;
-                       block = left;
-                       b->areas[block->order] = eina_inlist_remove(b->areas[block->order], EINA_INLIST_GET(block));
-                       block->order++;
-               }
-       }
+   Buddy *b = data;
+   Block *block, *buddy;
+   unsigned int offset;
+   unsigned int index;
+
+   offset = (unsigned char *)element - (unsigned char *)b->heap;
+   if (offset > b->size)
+      return;
+
+   index = offset >> b->min_order;
+   block = &b->blocks[index];
+
+   //printf("free %x index = %d order = %d buddy = %d\n", offset, index, block->order, index ^ (1 << block->order));
+   /* we should always work with the buddy at right */
+   if (index & (1 << block->order))
+     {
+        Block *left;
+
+        index = index ^ (1 << block->order);
+        left = &b->blocks[index];
+        if (!left->available)
+           goto end;
+        else
+          {
+             buddy = block;
+             block = left;
+             b->areas[block->order] = eina_inlist_remove(b->areas[block->order],
+                                                         EINA_INLIST_GET(block));
+             block->order++;
+          }
+     }
+
 check:
-       /* already on the last order */
-       if (block->order + b->min_order == b->max_order)
-               goto end;
-       /* get the buddy */
-       buddy = &b->blocks[index ^ (1 << block->order)];
-       if (!buddy->available)
-               goto end;
-       /* merge two blocks */
-       b->areas[block->order] = eina_inlist_remove(b->areas[block->order], EINA_INLIST_GET(buddy));
-       block->order++;
-       goto check;
+   /* already on the last order */
+   if (block->order + b->min_order == b->max_order)
+     {
+        goto end; /* get the buddy */
+
+     }
+
+   buddy = &b->blocks[index ^ (1 << block->order)];
+   if (!buddy->available)
+     {
+        goto end; /* merge two blocks */
+
+     }
+
+   b->areas[block->order] = eina_inlist_remove(b->areas[block->order],
+                                                         EINA_INLIST_GET(buddy));
+   block->order++;
+   goto check;
 end:
-       /* add the block to the free list */
-       block->available = EINA_TRUE;
-       b->areas[block->order] = eina_inlist_append(b->areas[block->order], EINA_INLIST_GET(block));
+   /* add the block to the free list */
+   block->available = EINA_TRUE;
+   b->areas[block->order] = eina_inlist_append(b->areas[block->order],
+                                                         EINA_INLIST_GET(block));
 }
 
 static void *_alloc(void *data, unsigned int size)
 {
-       Buddy *b = data;
-       Block *block, *buddy;
-       unsigned int k, j;
-
-       k = j = _get_order(b, size);
-       /* get a free list of order k where k <= j <= max_order */
-       while ((j < b->num_order) && !b->areas[j])
-               j++;
-       /* check that the order is on our range */
-       if (j + b->min_order > b->max_order)
-               return NULL;
-
-       /* get a free element on this order, if not, go splitting until we find one */
-       //printf("getting order %d (%d) for size %d\n", j, k, size);
+   Buddy *b = data;
+   Block *block, *buddy;
+   unsigned int k, j;
+
+   k = j = _get_order(b, size);
+   /* get a free list of order k where k <= j <= max_order */
+   while ((j < b->num_order) && !b->areas[j])
+      j++;
+   /* check that the order is on our range */
+   if (j + b->min_order > b->max_order)
+      return NULL;
+
+   /* get a free element on this order, if not, go splitting until we find one */
+   //printf("getting order %d (%d) for size %d\n", j, k, size);
 found:
-       if (j == k)
-       {
-               void *ret;
-
-               block = EINA_INLIST_CONTAINER_GET(b->areas[j], Block);
-               block->available = EINA_FALSE;
-               block->order = j;
-               /* remove the block from the list */
-               b->areas[j] = eina_inlist_remove(b->areas[j], EINA_INLIST_GET(block));
-               ret = _get_offset(b, block);
-
-               return ret;
-       }
-       block = EINA_INLIST_CONTAINER_GET(b->areas[j], Block);
-       /* split */
-       b->areas[j] = eina_inlist_remove(b->areas[j], EINA_INLIST_GET(block));
-       j--;
-       b->areas[j] = eina_inlist_append(b->areas[j], EINA_INLIST_GET(block));
-       buddy = block + (1 << j);
-       buddy->order = j;
-       buddy->available = EINA_TRUE;
-       b->areas[j] = eina_inlist_append(b->areas[j], EINA_INLIST_GET(buddy));
-
-       goto found;
+   if (j == k)
+     {
+        void *ret;
+
+        block = EINA_INLIST_CONTAINER_GET(b->areas[j], Block);
+        block->available = EINA_FALSE;
+        block->order = j;
+        /* remove the block from the list */
+        b->areas[j] = eina_inlist_remove(b->areas[j], EINA_INLIST_GET(block));
+        ret = _get_offset(b, block);
+
+        return ret;
+     }
+
+   block = EINA_INLIST_CONTAINER_GET(b->areas[j], Block);
+   /* split */
+   b->areas[j] = eina_inlist_remove(b->areas[j], EINA_INLIST_GET(block));
+   j--;
+   b->areas[j] = eina_inlist_append(b->areas[j], EINA_INLIST_GET(block));
+   buddy = block + (1 << j);
+   buddy->order = j;
+   buddy->available = EINA_TRUE;
+   b->areas[j] = eina_inlist_append(b->areas[j], EINA_INLIST_GET(buddy));
+
+   goto found;
 }
 
 static void _statistics(void *data)
 {
-       Buddy *b = data;
-       unsigned int i;
-
-       printf("Information:\n");
-       printf("size = %li, min_order = %d, max_order = %d, num_order = %d, num_blocks = %d (%luKB)\n", b->size, b->min_order, b->max_order, b->num_order, 1 << b->num_order, ((1 << (b->num_order)) * sizeof(Block)) / 1024);
-       printf("Area dumping:");
-       /* iterate over the free lists and dump the maps */
-       for (i = 0; i < b->num_order; i++)
-       {
-               Block *block;
-
-               printf("\n2^%d:", b->min_order + i);
-               EINA_INLIST_FOREACH(b->areas[i], block)
-               {
-                       printf(" %li", (block - &b->blocks[0]));
-               }
-       }
-       printf("\nBlocks dumping:\n");
+   Buddy *b = data;
+   unsigned int i;
+
+        printf("Information:\n");
+        printf(
+      "size = %li, min_order = %d, max_order = %d, num_order = %d, num_blocks = %d (%luKB)\n",
+      b->size,
+      b->min_order,
+      b->max_order,
+      b->num_order,
+      1 << b->num_order,
+      ((1 << (b->num_order)) * sizeof(Block)) / 1024);
+        printf("Area dumping:");
+   /* iterate over the free lists and dump the maps */
+   for (i = 0; i < b->num_order; i++)
+     {
+        Block *block;
+
+        printf("\n2^%d:", b->min_order + i);
+        EINA_INLIST_FOREACH(b->areas[i], block)
+        {
+           printf(" %li", (block - &b->blocks[0]));
+        }
+     }
+           printf("\nBlocks dumping:\n");
 }
 
 static Eina_Mempool_Backend _backend = {
-       "buddy",
-       &_init,
-       &_free,
-       &_alloc,
-       NULL, /* realloc */
-       NULL, /* garbage collect */
-       &_statistics,
-       &_shutdown
+   "buddy",
+   &_init,
+   &_free,
+   &_alloc,
+   NULL, /* realloc */
+   NULL, /* garbage collect */
+   &_statistics,
+   &_shutdown
 };
 
 Eina_Bool buddy_init(void)
 {
-       return eina_mempool_register(&_backend);
+   return eina_mempool_register(&_backend);
 }
 
 void buddy_shutdown(void)
 {
-       eina_mempool_unregister(&_backend);
+   eina_mempool_unregister(&_backend);
 }
 
 
index 4f9e42b..f178cac 100644 (file)
@@ -1,8 +1,5 @@
-/*
- * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
- */
 /* EINA - EFL data type library
- * Copyright (C) 2008 Cedric BAIL
+ * Copyright (C) 2008-2010 Cedric BAIL, Vincent Torri
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
 #include <stdlib.h>
 #include <string.h>
 
-#ifdef EFL_HAVE_PTHREAD
+#ifdef EFL_HAVE_POSIX_THREADS
 #include <pthread.h>
 #endif
 
+#ifdef EFL_HAVE_WIN32_THREADS
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+# undef WIN32_LEAN_AND_MEAN
+#endif
+
 #include "eina_inlist.h"
 #include "eina_error.h"
 #include "eina_module.h"
@@ -52,13 +55,19 @@ static int _eina_mempool_log_dom = -1;
 typedef struct _Chained_Mempool Chained_Mempool;
 struct _Chained_Mempool
 {
-   Eina_Inlist  *first;
+   Eina_Inlist *first;
    const char *name;
-   int item_size;
+   int item_alloc;
    int pool_size;
+   int alloc_size;
+   int group_size;
    int usage;
-#ifdef EFL_HAVE_PTHREAD
+#ifdef EFL_HAVE_THREADS
+# ifdef EFL_HAVE_POSIX_THREADS
    pthread_mutex_t mutex;
+# else
+   HANDLE mutex;
+# endif
 #endif
 };
 
@@ -75,15 +84,21 @@ _eina_chained_mp_pool_new(Chained_Mempool *pool)
 {
    Chained_Pool *p;
    unsigned char *ptr;
-   int item_alloc, i;
+   int i;
 
-   item_alloc = ((pool->item_size + sizeof(void *) - 1) / sizeof(void *)) * sizeof(void *);
-   p = malloc(sizeof(Chained_Pool) + (pool->pool_size * item_alloc));
-   ptr = (unsigned char *) (p + 1);
+   eina_error_set(0);
+   p = malloc(pool->alloc_size);
+   if (!p)
+     {
+        eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+        return NULL;
+     }
+
+   ptr = (unsigned char *)p + eina_mempool_alignof(sizeof(Chained_Pool));
    p->usage = 0;
    p->base = NULL;
-   for (i = 0; i < pool->pool_size; ++i, ptr += item_alloc)
-     eina_trash_push(&p->base, ptr);
+   for (i = 0; i < pool->pool_size; ++i, ptr += pool->item_alloc)
+      eina_trash_push(&p->base, ptr);
    return p;
 }
 
@@ -100,47 +115,61 @@ eina_chained_mempool_malloc(void *data, __UNUSED__ unsigned int size)
    Chained_Pool *p = NULL;
    void *mem;
 
-#ifdef EFL_HAVE_PTHREAD
+#ifdef EFL_HAVE_THREADS
+# ifdef EFL_HAVE_POSIX_THREADS
    pthread_mutex_lock(&pool->mutex);
+# else
+   WaitForSingleObject(pool->mutex, INFINITE);
+# endif
 #endif
 
    // look 4 pool from 2nd bucket on
    EINA_INLIST_FOREACH(pool->first, p)
-     {
-       // base is not NULL - has a free slot
-       if (p->base)
-         {
-            pool->first = eina_inlist_demote(pool->first, EINA_INLIST_GET(p));
-            break;
-         }
-     }
+   {
+      // base is not NULL - has a free slot
+      if (p->base)
+        {
+           pool->first = eina_inlist_demote(pool->first, EINA_INLIST_GET(p));
+           break;
+        }
+   }
 
    // we have reached the end of the list - no free pools
    if (!p)
      {
-       p = _eina_chained_mp_pool_new(pool);
-       if (!p)
-         {
+        p = _eina_chained_mp_pool_new(pool);
+        if (!p)
+          {
 #ifdef EFL_HAVE_PTHREAD
-            pthread_mutex_unlock(&pool->mutex);
+# ifdef EFL_HAVE_POSIX_THREADS
+             pthread_mutex_unlock(&pool->mutex);
+# else
+             ReleaseMutex(pool->mutex);
+# endif
 #endif
-            return NULL;
-         }
-       pool->first = eina_inlist_prepend(pool->first, EINA_INLIST_GET(p));
+             return NULL;
+          }
+
+        pool->first = eina_inlist_prepend(pool->first, EINA_INLIST_GET(p));
      }
+
    // Request a free pointer
    mem = eina_trash_pop(&p->base);
    // move to end - it just filled up
    if (!p->base)
-     {
-       pool->first = eina_inlist_demote(pool->first, EINA_INLIST_GET(p));
-     }
+      pool->first = eina_inlist_demote(pool->first, EINA_INLIST_GET(p));
+
    p->usage++;
    pool->usage++;
 
-#ifdef EFL_HAVE_PTHREAD
+#ifdef EFL_HAVE_THREADS
+# ifdef EFL_HAVE_POSIX_THREADS
    pthread_mutex_unlock(&pool->mutex);
+# else
+   ReleaseMutex(pool->mutex);
+# endif
 #endif
+
    return mem;
 }
 
@@ -150,76 +179,97 @@ eina_chained_mempool_free(void *data, void *ptr)
    Chained_Mempool *pool = data;
    Chained_Pool *p;
    void *pmem;
-   int item_alloc, psize;
+   int psize;
 
-   item_alloc = ((pool->item_size + sizeof(void *) - 1) / sizeof(void *)) * sizeof(void *);
-   psize = item_alloc * pool->pool_size;
+   psize = pool->group_size;
    // look 4 pool
 
-#ifdef EFL_HAVE_PTHREAD
+#ifdef EFL_HAVE_THREADS
+# ifdef EFL_HAVE_POSIX_THREADS
    pthread_mutex_lock(&pool->mutex);
+# else
+   WaitForSingleObject(pool->mutex, INFINITE);
+# endif
 #endif
 
    EINA_INLIST_FOREACH(pool->first, p)
-     {
-       // pool mem base
-       pmem = (void *)(((unsigned char *)p) + sizeof(Chained_Pool));
-       // is it in pool mem?
-       if ((ptr >= pmem) && ((unsigned char *)ptr < (((unsigned char *)pmem) + psize)))
-         {
-            // freed node points to prev free node
-            eina_trash_push(&p->base, ptr);
-            // next free node is now the one we freed
-            p->usage--;
-            pool->usage--;
-            if (p->usage == 0)
-              {
-                 // free bucket
-                 pool->first = eina_inlist_remove(pool->first, EINA_INLIST_GET(p));
-                 _eina_chained_mp_pool_free(p);
-              }
-            else
-              {
-                 // move to front
-                 pool->first = eina_inlist_promote(pool->first, EINA_INLIST_GET(p));
-              }
-            break;
-         }
-     }
-
-#ifdef EFL_HAVE_PTHREAD
+   {
+      // pool mem base
+      pmem = (void *)(((unsigned char *)p) + sizeof(Chained_Pool));
+      // is it in pool mem?
+      if ((ptr >= pmem) &&
+          ((unsigned char *)ptr < (((unsigned char *)pmem) + psize)))
+        {
+           // freed node points to prev free node
+           eina_trash_push(&p->base, ptr);
+           // next free node is now the one we freed
+           p->usage--;
+           pool->usage--;
+           if (p->usage == 0)
+             {
+                // free bucket
+                pool->first = eina_inlist_remove(pool->first, EINA_INLIST_GET(p));
+                _eina_chained_mp_pool_free(p);
+             }
+           else
+              // move to front
+              pool->first = eina_inlist_promote(pool->first, EINA_INLIST_GET(p));
+
+           break;
+        }
+   }
+
+#ifdef EFL_HAVE_THREADS
+# ifdef EFL_HAVE_POSIX_THREADS
    pthread_mutex_unlock(&pool->mutex);
+# else
+   ReleaseMutex(pool->mutex);
+# endif
 #endif
 }
 
-static void*
-eina_chained_mempool_realloc(__UNUSED__ void *data, __UNUSED__ void *element, __UNUSED__ unsigned int size)
+static void *
+eina_chained_mempool_realloc(__UNUSED__ void *data,
+                             __UNUSED__ void *element,
+                             __UNUSED__ unsigned int size)
 {
    return NULL;
 }
 
-static void*
-eina_chained_mempool_init(const char *context, __UNUSED__ const char *option, va_list args)
+static void *
+eina_chained_mempool_init(const char *context,
+                          __UNUSED__ const char *option,
+                          va_list args)
 {
    Chained_Mempool *mp;
+   int item_size;
    size_t length;
 
    length = context ? strlen(context) + 1 : 0;
 
    mp = calloc(1, sizeof(Chained_Mempool) + length);
-   if (!mp) return NULL;
+   if (!mp)
+      return NULL;
 
-   mp->item_size = va_arg(args, int);
+   item_size = va_arg(args, int);
    mp->pool_size = va_arg(args, int);
 
    if (length)
      {
-       mp->name = (const char*) (mp + 1);
-       memcpy((char*) mp->name, context, length);
+        mp->name = (const char *)(mp + 1);
+        memcpy((char *)mp->name, context, length);
      }
 
-#ifdef EFL_HAVE_PTHREAD
+   mp->item_alloc = eina_mempool_alignof(item_size);
+   mp->group_size = mp->item_alloc * mp->pool_size;
+   mp->alloc_size = mp->group_size + eina_mempool_alignof(sizeof(Chained_Pool));
+
+#ifdef EFL_HAVE_THREADS
+# ifdef EFL_HAVE_POSIX_THREADS
    pthread_mutex_init(&mp->mutex, NULL);
+# else
+   mp->mutex = CreateMutex(NULL, FALSE, NULL);
+# endif
 #endif
 
    return mp;
@@ -230,23 +280,29 @@ eina_chained_mempool_shutdown(void *data)
 {
    Chained_Mempool *mp;
 
-   mp = (Chained_Mempool *) data;
+   mp = (Chained_Mempool *)data;
 
    while (mp->first)
      {
-       Chained_Pool *p = (Chained_Pool *) mp->first;
+        Chained_Pool *p = (Chained_Pool *)mp->first;
 
 #ifdef DEBUG
-       if (p->usage > 0)
-         INF("Bad news we are destroying not an empty mempool [%s]\n", mp->name);
+        if (p->usage > 0)
+           INF("Bad news we are destroying not an empty mempool [%s]\n",
+               mp->name);
+
 #endif
 
-       mp->first = eina_inlist_remove(mp->first, mp->first);
-       _eina_chained_mp_pool_free(p);
+        mp->first = eina_inlist_remove(mp->first, mp->first);
+        _eina_chained_mp_pool_free(p);
      }
 
-#ifdef EFL_HAVE_PTHREAD
+#ifdef EFL_HAVE_THREADS
+# ifdef EFL_HAVE_POSIX_THREADS
    pthread_mutex_destroy(&mp->mutex);
+# else
+   CloseHandle(mp->mutex);
+# endif
 #endif
 
    free(mp);
@@ -266,12 +322,14 @@ static Eina_Mempool_Backend _eina_chained_mp_backend = {
 Eina_Bool chained_init(void)
 {
 #ifdef DEBUG
-   _eina_mempool_log_dom = eina_log_domain_register("eina_mempool", EINA_LOG_COLOR_DEFAULT);
+   _eina_mempool_log_dom = eina_log_domain_register("eina_mempool",
+                                                    EINA_LOG_COLOR_DEFAULT);
    if (_eina_mempool_log_dom < 0)
      {
-       EINA_LOG_ERR("Could not register log domain: eina_mempool");
-       return EINA_FALSE;
+        EINA_LOG_ERR("Could not register log domain: eina_mempool");
+        return EINA_FALSE;
      }
+
 #endif
    return eina_mempool_register(&_eina_chained_mp_backend);
 }
index 9b787f0..5b635fb 100644 (file)
@@ -1,6 +1,3 @@
-/*
- * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
- */
 /* EINA - EFL data type library
  * Copyright (C) 2008 Cedric BAIL
  *
@@ -57,8 +54,10 @@ eina_ememoa_fixed_free(void *data, void *ptr)
    ememoa_mempool_fixed_push_object(efm->pool, ptr);
 }
 
-static void*
-eina_ememoa_fixed_realloc(__UNUSED__ void *data, __UNUSED__ void *element, __UNUSED__ unsigned int size)
+static void *
+eina_ememoa_fixed_realloc(__UNUSED__ void *data,
+                          __UNUSED__ void *element,
+                          __UNUSED__ unsigned int size)
 {
    return NULL;
 }
@@ -77,11 +76,13 @@ eina_ememoa_fixed_statistics(void *data)
    Eina_Ememoa_Fixed_Mempool *efm = data;
 
    ememoa_mempool_fixed_display_statistic(efm->pool);
-   (void) efm;
+   (void)efm;
 }
 
-static void*
-eina_ememoa_fixed_init(const char *context, __UNUSED__ const char *option, va_list args)
+static void *
+eina_ememoa_fixed_init(const char *context,
+                       __UNUSED__ const char *option,
+                       va_list args)
 {
    struct ememoa_mempool_desc_s *desc = NULL;
    Eina_Ememoa_Fixed_Mempool *efm = NULL;
@@ -92,13 +93,14 @@ eina_ememoa_fixed_init(const char *context, __UNUSED__ const char *option, va_li
 
    if (context)
      {
-       context_length = strlen(context) + 1;
+        context_length = strlen(context) + 1;
 
-       desc = calloc(1, sizeof (struct ememoa_mempool_desc_s) + context_length);
-       if (!desc) goto on_error;
+        desc = calloc(1, sizeof (struct ememoa_mempool_desc_s) + context_length);
+        if (!desc)
+           goto on_error;
 
-       desc->name = (char*) (desc + 1);
-       memcpy((char*) desc->name, context, context_length);
+        desc->name = (char *)(desc + 1);
+        memcpy((char *)desc->name, context, context_length);
      }
 
    item_size = va_arg(args, int);
@@ -106,20 +108,28 @@ eina_ememoa_fixed_init(const char *context, __UNUSED__ const char *option, va_li
    thread_protect = va_arg(args, int);
 
    efm = malloc(sizeof (Eina_Ememoa_Fixed_Mempool));
-   if (!efm) goto on_error;
+   if (!efm)
+      goto on_error;
 
    efm->desc = desc;
-   efm->pool = ememoa_mempool_fixed_init(item_size,
-                                        pool_size,
-                                        thread_protect ? EMEMOA_THREAD_PROTECTION : 0,
-                                        efm->desc);
-   if (efm->pool < 0) goto on_error;
+   efm->pool = ememoa_mempool_fixed_init(
+         item_size,
+         pool_size,
+         thread_protect ?
+         EMEMOA_THREAD_PROTECTION : 0,
+         efm->desc);
+   if (efm->pool < 0)
+      goto on_error;
 
    return efm;
 
- on_error:
-   if (desc) free(desc);
-   if (efm) free(efm);
+on_error:
+   if (desc)
+      free(desc);
+
+   if (efm)
+      free(efm);
+
    return NULL;
 }
 
@@ -128,30 +138,32 @@ eina_ememoa_fixed_shutdown(void *data)
 {
    Eina_Ememoa_Fixed_Mempool *efm = data;
 
-   if (efm->desc) free(efm->desc);
-   ememoa_mempool_fixed_clean(efm->pool);
+   if (efm->desc)
+      free(efm->desc);
+
+      ememoa_mempool_fixed_clean(efm->pool);
    free(efm);
 }
 
 static Eina_Mempool_Backend _eina_ememoa_mp_backend = {
-  .name = "ememoa_fixed",
-  .init = &eina_ememoa_fixed_init,
-  .shutdown = &eina_ememoa_fixed_shutdown,
-  .realloc = &eina_ememoa_fixed_realloc,
-  .alloc = &eina_ememoa_fixed_malloc,
-  .free = &eina_ememoa_fixed_free,
-  .garbage_collect = &eina_ememoa_fixed_gc,
-  .statistics = &eina_ememoa_fixed_statistics
+   .name = "ememoa_fixed",
+   .init = &eina_ememoa_fixed_init,
+   .shutdown = &eina_ememoa_fixed_shutdown,
+   .realloc = &eina_ememoa_fixed_realloc,
+   .alloc = &eina_ememoa_fixed_malloc,
+   .free = &eina_ememoa_fixed_free,
+   .garbage_collect = &eina_ememoa_fixed_gc,
+   .statistics = &eina_ememoa_fixed_statistics
 };
 
 Eina_Bool ememoa_fixed_init(void)
 {
-       return eina_mempool_register(&_eina_ememoa_mp_backend);
+   return eina_mempool_register(&_eina_ememoa_mp_backend);
 }
 
 void ememoa_fixed_shutdown(void)
 {
-       eina_mempool_unregister(&_eina_ememoa_mp_backend);
+   eina_mempool_unregister(&_eina_ememoa_mp_backend);
 }
 
 
index fb4295e..43a595d 100644 (file)
@@ -1,6 +1,3 @@
-/*
- * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
- */
 /* EINA - EFL data type library
  * Copyright (C) 2008 Cedric BAIL
  *
@@ -33,7 +30,8 @@
 #include "eina_private.h"
 #include "eina_mempool.h"
 
-typedef struct _Eina_Ememoa_Unknown_Size_Mempool Eina_Ememoa_Unknown_Size_Mempool;
+typedef struct _Eina_Ememoa_Unknown_Size_Mempool
+Eina_Ememoa_Unknown_Size_Mempool;
 struct _Eina_Ememoa_Unknown_Size_Mempool
 {
    struct ememoa_mempool_desc_s *desc;
@@ -56,7 +54,7 @@ eina_ememoa_unknown_size_free(void *data, void *ptr)
    ememoa_mempool_unknown_size_push_object(efm->pool, ptr);
 }
 
-static void*
+static void *
 eina_ememoa_unknown_size_realloc(void *data, void *element, unsigned int size)
 {
    Eina_Ememoa_Unknown_Size_Mempool *efm = data;
@@ -80,8 +78,10 @@ eina_ememoa_unknown_size_statistics(void *data)
    ememoa_mempool_unknown_size_display_statistic(efm->pool);
 }
 
-static void*
-eina_ememoa_unknown_size_init(const char *context, __UNUSED__ const char *option, va_list args)
+static void *
+eina_ememoa_unknown_size_init(const char *context,
+                              __UNUSED__ const char *option,
+                              va_list args)
 {
    struct ememoa_mempool_desc_s *desc = NULL;
    Eina_Ememoa_Unknown_Size_Mempool *efm = NULL;
@@ -93,13 +93,14 @@ eina_ememoa_unknown_size_init(const char *context, __UNUSED__ const char *option
 
    if (context)
      {
-       context_length = strlen(context) + 1;
+        context_length = strlen(context) + 1;
 
-       desc = calloc(1, sizeof (struct ememoa_mempool_desc_s) + context_length);
-       if (!desc) goto on_error;
+        desc = calloc(1, sizeof (struct ememoa_mempool_desc_s) + context_length);
+        if (!desc)
+           goto on_error;
 
-       desc->name = (char*) (desc + 1);
-       memcpy((char*) desc->name, context, context_length);
+        desc->name = (char *)(desc + 1);
+        memcpy((char *)desc->name, context, context_length);
      }
 
    thread_protect = va_arg(args, int);
@@ -108,23 +109,31 @@ eina_ememoa_unknown_size_init(const char *context, __UNUSED__ const char *option
    items_map = malloc(sizeof (unsigned int) * 2 * items_count);
 
    for (i = 0; i < (items_count << 1); ++i)
-     items_map[i] = va_arg(args, unsigned int);
+      items_map[i] = va_arg(args, unsigned int);
 
    efm = malloc(sizeof (Eina_Ememoa_Unknown_Size_Mempool));
-   if (!efm) goto on_error;
+   if (!efm)
+      goto on_error;
 
    efm->desc = desc;
-   efm->pool = ememoa_mempool_unknown_size_init(items_count,
-                                               items_map,
-                                               thread_protect ? EMEMOA_THREAD_PROTECTION : 0,
-                                               efm->desc);
-   if (efm->pool < 0) goto on_error;
+   efm->pool = ememoa_mempool_unknown_size_init(
+         items_count,
+         items_map,
+         thread_protect ?
+         EMEMOA_THREAD_PROTECTION : 0,
+         efm->desc);
+   if (efm->pool < 0)
+      goto on_error;
 
    return efm;
 
- on_error:
-   if (desc) free(desc);
-   if (efm) free(efm);
+on_error:
+   if (desc)
+      free(desc);
+
+   if (efm)
+      free(efm);
+
    return NULL;
 }
 
@@ -133,30 +142,32 @@ eina_ememoa_unknown_size_shutdown(void *data)
 {
    Eina_Ememoa_Unknown_Size_Mempool *efm = data;
 
-   if (efm->desc) free(efm->desc);
-   ememoa_mempool_unknown_size_clean(efm->pool);
+   if (efm->desc)
+      free(efm->desc);
+
+      ememoa_mempool_unknown_size_clean(efm->pool);
    free(efm);
 }
 
 static Eina_Mempool_Backend _eina_ememoa_unknown_mp_backend = {
-  .name = "ememoa_unknown",
-  .init = &eina_ememoa_unknown_size_init,
-  .shutdown = &eina_ememoa_unknown_size_shutdown,
-  .realloc = &eina_ememoa_unknown_size_realloc,
-  .alloc = &eina_ememoa_unknown_size_malloc,
-  .free = &eina_ememoa_unknown_size_free,
-  .garbage_collect = &eina_ememoa_unknown_size_gc,
-  .statistics = &eina_ememoa_unknown_size_statistics
+   .name = "ememoa_unknown",
+   .init = &eina_ememoa_unknown_size_init,
+   .shutdown = &eina_ememoa_unknown_size_shutdown,
+   .realloc = &eina_ememoa_unknown_size_realloc,
+   .alloc = &eina_ememoa_unknown_size_malloc,
+   .free = &eina_ememoa_unknown_size_free,
+   .garbage_collect = &eina_ememoa_unknown_size_gc,
+   .statistics = &eina_ememoa_unknown_size_statistics
 };
 
 Eina_Bool ememoa_unknown_init(void)
 {
-       return eina_mempool_register(&_eina_ememoa_unknown_mp_backend);
+   return eina_mempool_register(&_eina_ememoa_unknown_mp_backend);
 }
 
 void ememoa_unknown_shutdown(void)
 {
-       eina_mempool_unregister(&_eina_ememoa_unknown_mp_backend);
+   eina_mempool_unregister(&_eina_ememoa_unknown_mp_backend);
 }
 
 #ifndef EINA_STATIC_BUILD_EMEMOA_UNKNOWN
index fdc4f8a..967a4ad 100644 (file)
@@ -1,6 +1,3 @@
-/*
- * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
- */
 /* EINA - EFL data type library
  * Copyright (C) 2008 Cedric BAIL
  *
@@ -71,15 +68,21 @@ _eina_rbtree_inlist_delta(void)
 }
 
 static Eina_Rbtree_Direction
-_eina_fixed_cmp(const Eina_Rbtree *left, const Eina_Rbtree *right, __UNUSED__ void *data)
+_eina_fixed_cmp(const Eina_Rbtree *left,
+                const Eina_Rbtree *right,
+                __UNUSED__ void *data)
 {
    if (left - right < 0)
-     return EINA_RBTREE_LEFT;
+      return EINA_RBTREE_LEFT;
+
    return EINA_RBTREE_RIGHT;
 }
 
 static int
-_eina_fixed_cmp_key(const Eina_Rbtree *node, const void *key, __UNUSED__ int length, Eina_Fixed_Bitmap *mp)
+_eina_fixed_cmp_key(const Eina_Rbtree *node,
+                    const void *key,
+                    __UNUSED__ int length,
+                    Eina_Fixed_Bitmap *mp)
 {
    const void *a = node;
    const void *b = key;
@@ -90,14 +93,17 @@ _eina_fixed_cmp_key(const Eina_Rbtree *node, const void *key, __UNUSED__ int len
    delta = (char *)a - (char *)b;
 
    if (delta > 0)
-     return 1;
+      return 1;
+
    if (delta + limit < 0)
-     return -1;
+      return -1;
+
    return 0;
 }
 
 static void
-_eina_fixed_bitmap_pool_free(Eina_Fixed_Bitmap_Pool *pool, __UNUSED__ void *data)
+_eina_fixed_bitmap_pool_free(Eina_Fixed_Bitmap_Pool *pool,
+                             __UNUSED__ void *data)
 {
    free(pool);
 }
@@ -112,33 +118,39 @@ eina_fixed_bitmap_malloc(void *data, __UNUSED__ unsigned int size)
 
    if (mp->head)
      {
-       pool = (Eina_Fixed_Bitmap_Pool*) ((unsigned char*) mp->head + _eina_rbtree_inlist_delta());
+        pool =
+           (Eina_Fixed_Bitmap_Pool *)((unsigned char *)mp->head +
+                                      _eina_rbtree_inlist_delta());
 
-       if (pool->bitmask == 0) pool = NULL;
+        if (pool->bitmask == 0)
+           pool = NULL;
      }
 
    if (!pool)
      {
-       eina_error_set(0);
-       pool = malloc(sizeof (Eina_Fixed_Bitmap_Pool) + mp->item_size * 32);
-       if (!pool)
-         {
-            eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
-            return NULL;
-         }
-
-       pool->bitmask = 0xFFFFFFFF;
-
-       mp->head = eina_inlist_prepend(mp->head, EINA_INLIST_GET(pool));
-       mp->lookup = eina_rbtree_inline_insert(mp->lookup, EINA_RBTREE_GET(pool), EINA_RBTREE_CMP_NODE_CB(_eina_fixed_cmp), NULL);
+             eina_error_set(0);
+        pool = malloc(sizeof (Eina_Fixed_Bitmap_Pool) + mp->item_size * 32);
+        if (!pool)
+          {
+             eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+             return NULL;
+          }
+
+        pool->bitmask = 0xFFFFFFFF;
+
+        mp->head = eina_inlist_prepend(mp->head, EINA_INLIST_GET(pool));
+        mp->lookup = eina_rbtree_inline_insert(mp->lookup, EINA_RBTREE_GET(
+                                                  pool),
+                                               EINA_RBTREE_CMP_NODE_CB(
+                                                  _eina_fixed_cmp), NULL);
      }
 
    idx = ffs(pool->bitmask) - 1;
    pool->bitmask &= ~(1 << idx);
-   ptr = (unsigned char*) (pool + 1) + idx * mp->item_size;
+   ptr = (unsigned char *)(pool + 1) + idx * mp->item_size;
 
    if (pool->bitmask == 0)
-     mp->head = eina_inlist_demote(mp->head, EINA_INLIST_GET(pool));
+      mp->head = eina_inlist_demote(mp->head, EINA_INLIST_GET(pool));
 
    return ptr;
 }
@@ -152,14 +164,23 @@ eina_fixed_bitmap_free(void *data, void *ptr)
    Eina_Bool push_front = EINA_FALSE;
    ssize_t delta;
 
-   pool = (Eina_Fixed_Bitmap_Pool*) eina_rbtree_inline_lookup(mp->lookup,
-                                                             ptr, 0,
-                                                             EINA_RBTREE_CMP_KEY_CB(_eina_fixed_cmp_key), mp);
-   if (!pool) return ;
-   if (pool->bitmask != 0xFFFFFFFF) push_front = EINA_TRUE;
+   pool = (Eina_Fixed_Bitmap_Pool *)eina_rbtree_inline_lookup(
+         mp->lookup,
+         ptr,
+         0,
+         EINA_RBTREE_CMP_KEY_CB(
+            _eina_fixed_cmp_key),
+         mp);
+   if (!pool)
+      return;
+
+   if (pool->bitmask != 0xFFFFFFFF)
+      push_front = EINA_TRUE;
 
    a = pool;
-   delta = ((char *)ptr - (char *)a - sizeof (Eina_Fixed_Bitmap_Pool)) / mp->item_size;
+   delta =
+      ((char *)ptr - (char *)a -
+       sizeof (Eina_Fixed_Bitmap_Pool)) / mp->item_size;
 
    assert(delta >= 0 && delta < 32);
 
@@ -167,29 +188,41 @@ eina_fixed_bitmap_free(void *data, void *ptr)
 
    if (pool->bitmask == 0xFFFFFFFF)
      {
-       mp->head = eina_inlist_remove(mp->head, EINA_INLIST_GET(pool));
-       mp->lookup = eina_rbtree_inline_remove(mp->lookup, EINA_RBTREE_GET(pool), EINA_RBTREE_CMP_NODE_CB(_eina_fixed_cmp), NULL);
-       free(pool);
+        mp->head = eina_inlist_remove(mp->head, EINA_INLIST_GET(pool));
+        mp->lookup = eina_rbtree_inline_remove(mp->lookup, EINA_RBTREE_GET(
+                                                  pool),
+                                               EINA_RBTREE_CMP_NODE_CB(
+                                                  _eina_fixed_cmp), NULL);
+        free(pool);
      }
    else if (push_front)
-     mp->head = eina_inlist_promote(mp->head, EINA_INLIST_GET(pool));
+      mp->head = eina_inlist_promote(mp->head, EINA_INLIST_GET(pool));
 }
 
 static void *
-eina_fixed_bitmap_realloc(__UNUSED__ void *data, __UNUSED__ void *element, __UNUSED__ unsigned int size)
+eina_fixed_bitmap_realloc(__UNUSED__ void *data,
+                          __UNUSED__ void *element,
+                          __UNUSED__ unsigned int size)
 {
    return NULL;
 }
 
-static void*
-eina_fixed_bitmap_init(__UNUSED__ const char *context, __UNUSED__ const char *option, va_list args)
+static void *
+eina_fixed_bitmap_init(__UNUSED__ const char *context,
+                       __UNUSED__ const char *option,
+                       va_list args)
 {
    Eina_Fixed_Bitmap *mp;
+   int item_size;
 
    mp = malloc(sizeof (Eina_Fixed_Bitmap));
-   if (!mp) return NULL;
+   if (!mp)
+      return NULL;
+
+   item_size = va_arg(args, int);
+
+   mp->item_size = eina_mempool_alignof(item_size);
 
-   mp->item_size = va_arg(args, int);
    mp->lookup = NULL;
    mp->head = NULL;
 
@@ -201,7 +234,8 @@ eina_fixed_bitmap_shutdown(void *data)
 {
    Eina_Fixed_Bitmap *mp = data;
 
-   eina_rbtree_delete(mp->lookup, EINA_RBTREE_FREE_CB(_eina_fixed_bitmap_pool_free), NULL);
+   eina_rbtree_delete(mp->lookup,
+                      EINA_RBTREE_FREE_CB(_eina_fixed_bitmap_pool_free), NULL);
    free(mp);
 }
 
diff --git a/src/modules/mp/one_big/Makefile.am b/src/modules/mp/one_big/Makefile.am
new file mode 100644 (file)
index 0000000..cee0761
--- /dev/null
@@ -0,0 +1,28 @@
+MAINTAINERCLEANFILES = Makefile.in
+
+AM_CPPFLAGS = \
+-I. \
+-I$(top_srcdir)/src/include \
+-I$(top_builddir)/src/include \
+@EINA_CPPFLAGS@ \
+@EFL_EINA_BUILD@
+
+if EINA_BUILD_ONE_BIG
+if !EINA_STATIC_BUILD_ONE_BIG
+
+controllerdir = $(libdir)/eina/modules/mp/one_big/$(MODULE_ARCH)
+controller_LTLIBRARIES = module.la
+
+module_la_SOURCES = \
+eina_one_big.c
+
+module_la_CFLAGS = @EINA_CFLAGS@ @EFL_PTHREAD_CFLAGS@
+module_la_LIBADD = $(top_builddir)/src/lib/libeina.la @EINA_LIBS@
+module_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -module -avoid-version @EFL_PTHREAD_LIBS@
+module_la_LIBTOOLFLAGS = --tag=disable-static
+
+endif
+endif
+
+clean-local:
+       rm -rf *.gcno
diff --git a/src/modules/mp/one_big/eina_one_big.c b/src/modules/mp/one_big/eina_one_big.c
new file mode 100644 (file)
index 0000000..4867037
--- /dev/null
@@ -0,0 +1,275 @@
+/* EINA - EFL data type library
+ * Copyright (C) 2010 Cedric BAIL, Vincent Torri
+ *
+ * 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
+
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef EFL_HAVE_POSIX_THREADS
+#include <pthread.h>
+#endif
+
+#ifdef EFL_HAVE_WIN32_THREADS
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+# undef WIN32_LEAN_AND_MEAN
+#endif
+
+#include "eina_mempool.h"
+#include "eina_trash.h"
+
+#ifdef DEBUG
+#include "eina_private.h"
+#include "eina_log.h"
+
+static int _eina_mempool_log_dom = -1;
+
+#ifdef INF
+#undef INF
+#endif
+#define INF(...) EINA_LOG_DOM_INFO(_eina_mempool_log_dom, __VA_ARGS__)
+#endif
+
+typedef struct _One_Big One_Big;
+struct _One_Big
+{
+   const char *name;
+
+   int item_size;
+
+   int usage;
+   int over;
+
+   int served;
+   int max;
+   unsigned char *base;
+
+   Eina_Trash *empty;
+
+#ifdef EFL_HAVE_THREADS
+# ifdef EFL_HAVE_POSIX_THREADS
+   pthread_mutex_t mutex;
+# else
+   HANDLE mutex;
+# endif
+#endif
+};
+
+static void *
+eina_one_big_malloc(void *data, __UNUSED__ unsigned int size)
+{
+   One_Big *pool = data;
+   unsigned char *mem = NULL;
+
+#ifdef EFL_HAVE_THREADS
+# ifdef EFL_HAVE_POSIX_THREADS
+   pthread_mutex_lock(&pool->mutex);
+# else
+   WaitForSingleObject(pool->mutex, INFINITE);
+# endif
+#endif
+
+   if (pool->empty)
+     {
+        mem = eina_trash_pop(&pool->empty);
+        pool->usage++;
+        goto on_exit;
+     }
+
+   if (pool->served < pool->max)
+     {
+        mem = pool->base + (pool->served++ *pool->item_size);
+        pool->usage++;
+        goto on_exit;
+     }
+
+      eina_error_set(0);
+   mem = malloc(pool->item_size);
+   if (!mem)
+      eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+   else
+      pool->over++;
+
+on_exit:
+#ifdef EFL_HAVE_THREADS
+# ifdef EFL_HAVE_POSIX_THREADS
+   pthread_mutex_unlock(&pool->mutex);
+# else
+   ReleaseMutex(pool->mutex);
+# endif
+#endif
+   return mem;
+}
+
+static void
+eina_one_big_free(void *data, void *ptr)
+{
+   One_Big *pool = data;
+
+#ifdef EFL_HAVE_THREADS
+# ifdef EFL_HAVE_POSIX_THREADS
+   pthread_mutex_lock(&pool->mutex);
+# else
+   WaitForSingleObject(pool->mutex, INFINITE);
+# endif
+#endif
+
+   if ((void *)pool->base <= ptr
+       && ptr < (void *)(pool->base + (pool->max * pool->item_size)))
+     {
+        eina_trash_push(&pool->empty, ptr);
+        pool->usage--;
+     }
+   else
+     {
+        free(ptr);
+        pool->over--;
+     }
+
+#ifdef EFL_HAVE_THREADS
+# ifdef EFL_HAVE_POSIX_THREADS
+   pthread_mutex_unlock(&pool->mutex);
+# else
+   ReleaseMutex(pool->mutex);
+# endif
+#endif
+}
+
+static void *
+eina_one_big_realloc(__UNUSED__ void *data,
+                     __UNUSED__ void *element,
+                     __UNUSED__ unsigned int size)
+{
+   return NULL;
+}
+
+static void *
+eina_one_big_init(const char *context,
+                  __UNUSED__ const char *option,
+                  va_list args)
+{
+   One_Big *pool;
+   int item_size;
+   size_t length;
+
+   length = context ? strlen(context) + 1 : 0;
+
+   pool = calloc(1, sizeof (One_Big) + length);
+   if (!pool)
+      return NULL;
+
+   item_size = va_arg(args, int);
+
+   pool->item_size = eina_mempool_alignof(item_size);
+   pool->max = va_arg(args, int);
+
+   if (length)
+     {
+        pool->name = (const char *)(pool + 1);
+        memcpy((char *)pool->name, context, length);
+     }
+
+   pool->base = malloc(pool->item_size * pool->max);
+   if (!pool->base)
+     {
+        free(pool);
+        return NULL;
+     }
+
+#ifdef EFL_HAVE_THREADS
+# ifdef EFL_HAVE_POSIX_THREADS
+   pthread_mutex_init(&pool->mutex, NULL);
+# else
+   pool->mutex = CreateMutex(NULL, FALSE, NULL);
+# endif
+#endif
+
+   return pool;
+}
+
+static void
+eina_one_big_shutdown(void *data)
+{
+   One_Big *pool;
+
+   pool = data;
+
+   if (!pool) return ;
+
+#ifdef DEBUG
+   if (pool->usage > 0)
+      INF(
+         "Bad news we are destroying memory still referenced in mempool [%s]\n",
+         pool->name);
+
+   if (pool->over > 0)
+      INF("Bad news we are loosing track of pointer from mempool [%s]\n",
+          pool->name);
+
+#endif
+
+   free(pool->base);
+   free(pool);
+}
+
+
+static Eina_Mempool_Backend _eina_one_big_mp_backend = {
+   "one_big",
+   &eina_one_big_init,
+   &eina_one_big_free,
+   &eina_one_big_malloc,
+   &eina_one_big_realloc,
+   NULL,
+   NULL,
+   &eina_one_big_shutdown
+};
+
+Eina_Bool one_big_init(void)
+{
+#ifdef DEBUG
+   _eina_mempool_log_dom = eina_log_domain_register("eina_one_big_mempool",
+                                                    EINA_LOG_COLOR_DEFAULT);
+   if (_eina_mempool_log_dom < 0)
+     {
+        EINA_LOG_ERR("Could not register log domain: eina_one_big_mempool");
+        return EINA_FALSE;
+     }
+
+#endif
+   return eina_mempool_register(&_eina_one_big_mp_backend);
+}
+
+void one_big_shutdown(void)
+{
+   eina_mempool_unregister(&_eina_one_big_mp_backend);
+#ifdef DEBUG
+   eina_log_domain_unregister(_eina_mempool_log_dom);
+   _eina_mempool_log_dom = -1;
+#endif
+}
+
+#ifndef EINA_STATIC_BUILD_ONE_BIG
+
+EINA_MODULE_INIT(one_big_init);
+EINA_MODULE_SHUTDOWN(one_big_shutdown);
+
+#endif /* ! EINA_STATIC_BUILD_ONE_BIG */
+
index ef8fcb3..0acd978 100644 (file)
@@ -1,6 +1,3 @@
-/*
- * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
- */
 /* EINA - EFL data type library
  * Copyright (C) 2008 Cedric BAIL
  *
@@ -42,16 +39,18 @@ eina_pass_through_free(__UNUSED__ void *data, void *ptr)
    free(ptr);
 }
 
-static void*
+static void *
 eina_pass_through_realloc(__UNUSED__ void *data, void *ptr, unsigned int size)
 {
    return realloc(ptr, size);
 }
 
-static void*
-eina_pass_through_init(__UNUSED__ const char *context, __UNUSED__ const char *option, __UNUSED__ va_list args)
+static void *
+eina_pass_through_init(__UNUSED__ const char *context,
+                       __UNUSED__ const char *option,
+                       __UNUSED__ va_list args)
 {
-   return (void*) 0x1;
+   return (void *)0x1;
 }
 
 static void
@@ -73,12 +72,12 @@ static Eina_Mempool_Backend _eina_pass_through_mp_backend = {
 
 Eina_Bool pass_through_init(void)
 {
-       return eina_mempool_register(&_eina_pass_through_mp_backend);
+   return eina_mempool_register(&_eina_pass_through_mp_backend);
 }
 
 void pass_through_shutdown(void)
 {
-       eina_mempool_unregister(&_eina_pass_through_mp_backend);
+   eina_mempool_unregister(&_eina_pass_through_mp_backend);
 }
 
 #ifndef EINA_STATIC_BUILD_PASS_THROUGH
index 532403b..50d42f1 100644 (file)
@@ -57,36 +57,36 @@ extern "C" {
 #ifdef IF_FREE
 # undef IF_FREE
 #endif
-#define IF_FREE(ptr) if (ptr) free(ptr); ptr = NULL;
+#define IF_FREE(ptr) if (ptr) {free(ptr); } ptr = NULL;
 
 /* convenience macros for checking pointer parameters for non-NULL */
 #undef CHECK_PARAM_POINTER_RETURN
 #define CHECK_PARAM_POINTER_RETURN(sparam, param, ret) \
-     if (!(param)) \
-        { \
-           printf("***** 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(); \
-           return ret; \
-        }
+   if (!(param)) \
+     { \
+        printf("***** 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(); } \
+        return ret; \
+     }
 
 #undef CHECK_PARAM_POINTER
 #define CHECK_PARAM_POINTER(sparam, param) \
-     if (!(param)) \
-        { \
-           printf("***** 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(); \
-           return; \
-        }
+   if (!(param)) \
+     { \
+        printf("***** 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(); } \
+        return; \
+     }
 
 
 # ifdef __sgi
@@ -95,412 +95,463 @@ extern "C" {
 #   define inline
 #  endif
 # endif
-   
+
 # define ECORE_SORT_MIN 0
 # define ECORE_SORT_MAX 1
 
-   typedef void (*Ecore_For_Each) (void *value, void *user_data);
+typedef void (*Ecore_For_Each)(void *value, void *user_data);
 # define ECORE_FOR_EACH(function) ((Ecore_For_Each)function)
-   
-   typedef void (*Ecore_Free_Cb) (void *data);
+
+typedef void (*Ecore_Free_Cb)(void *data);
 # define ECORE_FREE_CB(func) ((Ecore_Free_Cb)func)
-   
-   typedef unsigned int (*Ecore_Hash_Cb) (const void *key);
+
+typedef unsigned int (*Ecore_Hash_Cb)(const void *key);
 # define ECORE_HASH_CB(function) ((Ecore_Hash_Cb)function)
-   
-   typedef int (*Ecore_Compare_Cb) (const void *data1, const void *data2);
+
+typedef int (*Ecore_Compare_Cb)(const void *data1, const void *data2);
 # define ECORE_COMPARE_CB(function) ((Ecore_Compare_Cb)function)
-   
-   typedef struct _ecore_list Ecore_List;
+
+typedef struct _ecore_list Ecore_List;
 # define ECORE_LIST(list) ((Ecore_List *)list)
-   
-   typedef struct _ecore_list_node Ecore_List_Node;
+
+typedef struct _ecore_list_node Ecore_List_Node;
 # define ECORE_LIST_NODE(node) ((Ecore_List_Node *)node)
 
-   typedef struct _ecore_strbuf Ecore_Strbuf;
+typedef struct _ecore_strbuf Ecore_Strbuf;
 # define ECORE_STRBUF(buf) ((Ecore_Strbuf *)buf)
-   
-   struct _ecore_list_node {
-      void *data;
-      struct _ecore_list_node *next;
-   };
-   
-   struct _ecore_list {
-      Ecore_List_Node *first;  /* The first node in the list */
-      Ecore_List_Node *last;   /* The last node in the list */
-      Ecore_List_Node *current;        /* The current node in the list */
-      
-      Ecore_Free_Cb free_func;  /* The callback to free data in nodes */
-      
-      int nodes;               /* The number of nodes in the list */
-      int index;               /* The position from the front of the
-                                list of current node */
-   };
-   
-   EAPI int ecore_direct_compare(const void *key1, const void *key2);
-   EAPI int ecore_str_compare(const void *key1, const void *key2);
-   
-   EAPI unsigned int ecore_direct_hash(const void *key);
-   EAPI unsigned int ecore_str_hash(const void *key);
-   
-   /* Creating and initializing new list structures */
-   EAPI Ecore_List *ecore_list_new(void);
-   EAPI int ecore_list_init(Ecore_List *list);
-   
-   /* Adding items to the list */
-   EAPI int ecore_list_append(Ecore_List * list, void *_data);
-   EAPI int ecore_list_prepend(Ecore_List * list, void *_data);
-   EAPI int ecore_list_insert(Ecore_List * list, void *_data);
-   EAPI int ecore_list_append_list(Ecore_List * list, Ecore_List * append);
-   EAPI int ecore_list_prepend_list(Ecore_List * list, Ecore_List * prepend);
-   
-   /* Removing items from the list */
-   EAPI int ecore_list_remove_destroy(Ecore_List *list);
-   EAPI void *ecore_list_remove(Ecore_List * list);
-   EAPI void *ecore_list_first_remove(Ecore_List * list);
-   EAPI void *ecore_list_last_remove(Ecore_List * list);
-   
-   /* Retrieve the current position in the list */
-   EAPI void *ecore_list_current(Ecore_List * list);
-   EAPI void *ecore_list_first(Ecore_List * list);
-   EAPI void *ecore_list_last(Ecore_List * list);
-   EAPI int ecore_list_index(Ecore_List * list);
-   EAPI int ecore_list_count(Ecore_List * list);
-   
-   /* Traversing the list */
-   EAPI int ecore_list_for_each(Ecore_List *list, Ecore_For_Each function,
-                               void *user_data);
-   EAPI void *ecore_list_first_goto(Ecore_List * list);
-   EAPI void *ecore_list_last_goto(Ecore_List * list);
-   EAPI void *ecore_list_index_goto(Ecore_List * list, int index);
-   EAPI void *ecore_list_goto(Ecore_List * list, const void *_data);
-   
-   /* Traversing the list and returning data */
-   EAPI void *ecore_list_next(Ecore_List * list);
-   EAPI void *ecore_list_find(Ecore_List *list, Ecore_Compare_Cb function,
-        const void *user_data);
-
-   /* Sorting the list */
-   EAPI int ecore_list_sort(Ecore_List *list, Ecore_Compare_Cb compare,
-                                  char order);
-   EAPI int ecore_list_mergesort(Ecore_List *list, Ecore_Compare_Cb compare,
-                                  char order);
-   EAPI int ecore_list_heapsort(Ecore_List *list, Ecore_Compare_Cb compare,
-                                  char order);
-   EAPI void ecore_list_merge(Ecore_List *list, Ecore_List *l2, 
-                                  Ecore_Compare_Cb, char order);
-   
-   /* Check to see if there is any data in the list */
-   EAPI int ecore_list_empty_is(Ecore_List * list);
-   
-   /* Remove every node in the list without freeing the list itself */
-   EAPI int ecore_list_clear(Ecore_List * list);
-   /* Free the list and it's contents */
-   EAPI void ecore_list_destroy(Ecore_List *list);
-   
-   /* Creating and initializing list nodes */
-   EAPI Ecore_List_Node *ecore_list_node_new(void);
-   EAPI int ecore_list_node_init(Ecore_List_Node *newNode);
-   
-   /* Destroying nodes */
-   EAPI int ecore_list_node_destroy(Ecore_List_Node * _e_node, Ecore_Free_Cb free_func);
-   
-   EAPI int ecore_list_free_cb_set(Ecore_List * list, Ecore_Free_Cb free_func);
-   
-   typedef Ecore_List Ecore_DList;
+
+struct _ecore_list_node
+{
+   void *data;
+   struct _ecore_list_node *next;
+};
+
+struct _ecore_list
+{
+   Ecore_List_Node *first; /* The first node in the list */
+   Ecore_List_Node *last; /* The last node in the list */
+   Ecore_List_Node *current; /* The current node in the list */
+
+   Ecore_Free_Cb free_func; /* The callback to free data in nodes */
+
+   int nodes; /* The number of nodes in the list */
+   int index; /* The position from the front of the
+                 list of current node */
+};
+
+EAPI int              ecore_direct_compare(const void *key1, const void *key2);
+EAPI int              ecore_str_compare(const void *key1, const void *key2);
+
+EAPI unsigned int     ecore_direct_hash(const void *key);
+EAPI unsigned int     ecore_str_hash(const void *key);
+
+/* Creating and initializing new list structures */
+EAPI Ecore_List *     ecore_list_new(void);
+EAPI int              ecore_list_init(Ecore_List *list);
+
+/* Adding items to the list */
+EAPI int              ecore_list_append(Ecore_List *list, void *_data);
+EAPI int              ecore_list_prepend(Ecore_List *list, void *_data);
+EAPI int              ecore_list_insert(Ecore_List *list, void *_data);
+EAPI int              ecore_list_append_list(Ecore_List *list,
+                                             Ecore_List *append);
+EAPI int              ecore_list_prepend_list(Ecore_List *list,
+                                              Ecore_List *prepend);
+
+/* Removing items from the list */
+EAPI int              ecore_list_remove_destroy(Ecore_List *list);
+EAPI void *           ecore_list_remove(Ecore_List *list);
+EAPI void *           ecore_list_first_remove(Ecore_List *list);
+EAPI void *           ecore_list_last_remove(Ecore_List *list);
+
+/* Retrieve the current position in the list */
+EAPI void *           ecore_list_current(Ecore_List *list);
+EAPI void *           ecore_list_first(Ecore_List *list);
+EAPI void *           ecore_list_last(Ecore_List *list);
+EAPI int              ecore_list_index(Ecore_List *list);
+EAPI int              ecore_list_count(Ecore_List *list);
+
+/* Traversing the list */
+EAPI int              ecore_list_for_each(Ecore_List *list,
+                                          Ecore_For_Each function,
+                                          void *user_data);
+EAPI void *           ecore_list_first_goto(Ecore_List *list);
+EAPI void *           ecore_list_last_goto(Ecore_List *list);
+EAPI void *           ecore_list_index_goto(Ecore_List *list, int index);
+EAPI void *           ecore_list_goto(Ecore_List *list, const void *_data);
+
+/* Traversing the list and returning data */
+EAPI void *           ecore_list_next(Ecore_List *list);
+EAPI void *           ecore_list_find(Ecore_List *list,
+                                      Ecore_Compare_Cb function,
+                                      const void *user_data);
+
+/* Sorting the list */
+EAPI int              ecore_list_sort(Ecore_List *list,
+                                      Ecore_Compare_Cb compare,
+                                      char order);
+EAPI int              ecore_list_mergesort(Ecore_List *list,
+                                           Ecore_Compare_Cb compare,
+                                           char order);
+EAPI int              ecore_list_heapsort(Ecore_List *list,
+                                          Ecore_Compare_Cb compare,
+                                          char order);
+EAPI void             ecore_list_merge(Ecore_List *list, Ecore_List *l2,
+                                       Ecore_Compare_Cb, char order);
+
+/* Check to see if there is any data in the list */
+EAPI int              ecore_list_empty_is(Ecore_List *list);
+
+/* Remove every node in the list without freeing the list itself */
+EAPI int              ecore_list_clear(Ecore_List *list);
+/* Free the list and it's contents */
+EAPI void             ecore_list_destroy(Ecore_List *list);
+
+/* Creating and initializing list nodes */
+EAPI Ecore_List_Node *ecore_list_node_new(void);
+EAPI int              ecore_list_node_init(Ecore_List_Node *newNode);
+
+/* Destroying nodes */
+EAPI int              ecore_list_node_destroy(Ecore_List_Node *_e_node,
+                                              Ecore_Free_Cb free_func);
+
+EAPI int              ecore_list_free_cb_set(Ecore_List *list,
+                                             Ecore_Free_Cb free_func);
+
+typedef Ecore_List Ecore_DList;
 # define ECORE_DLIST(dlist) ((Ecore_DList *)dlist)
-   
-   typedef struct _ecore_dlist_node Ecore_DList_Node;
+
+typedef struct _ecore_dlist_node Ecore_DList_Node;
 # define ECORE_DLIST_NODE(dlist) ((Ecore_DList_Node *)dlist)
-   
-   struct _ecore_dlist_node {
-      Ecore_List_Node single;
-      Ecore_DList_Node *previous;
-   };
-   
-   /* Creating and initializing new list structures */
-   EAPI Ecore_DList *ecore_dlist_new(void);
-   EAPI int ecore_dlist_init(Ecore_DList *list);
-   EAPI void ecore_dlist_destroy(Ecore_DList *list);
-   
-   /* Adding items to the list */
-   EAPI int ecore_dlist_append(Ecore_DList * _e_dlist, void *_data);
-   EAPI int ecore_dlist_prepend(Ecore_DList * _e_dlist, void *_data);
-   EAPI int ecore_dlist_insert(Ecore_DList * _e_dlist, void *_data);
-   EAPI int ecore_dlist_append_list(Ecore_DList * _e_dlist, Ecore_DList * append);
-   EAPI int ecore_dlist_prepend_list(Ecore_DList * _e_dlist, Ecore_DList * prepend);
-   
-   /* Info about list's state */
+
+struct _ecore_dlist_node
+{
+   Ecore_List_Node single;
+   Ecore_DList_Node *previous;
+};
+
+/* Creating and initializing new list structures */
+EAPI Ecore_DList *ecore_dlist_new(void);
+EAPI int          ecore_dlist_init(Ecore_DList *list);
+EAPI void         ecore_dlist_destroy(Ecore_DList *list);
+
+/* Adding items to the list */
+EAPI int          ecore_dlist_append(Ecore_DList *_e_dlist, void *_data);
+EAPI int          ecore_dlist_prepend(Ecore_DList *_e_dlist, void *_data);
+EAPI int          ecore_dlist_insert(Ecore_DList *_e_dlist, void *_data);
+EAPI int          ecore_dlist_append_list(Ecore_DList *_e_dlist,
+                                          Ecore_DList *append);
+EAPI int          ecore_dlist_prepend_list(Ecore_DList *_e_dlist,
+                                           Ecore_DList *prepend);
+
+/* Info about list's state */
 # define ecore_dlist_first(list) ecore_list_first(list)
 # define ecore_dlist_last(list) ecore_list_last(list)
-   EAPI void *ecore_dlist_current(Ecore_DList *list);
-   EAPI int ecore_dlist_index(Ecore_DList *list);
+EAPI void *            ecore_dlist_current(Ecore_DList *list);
+EAPI int               ecore_dlist_index(Ecore_DList *list);
 # define ecore_dlist_count(list) ecore_list_count(list)
-   
-   /* Removing items from the list */
-   EAPI void *ecore_dlist_remove(Ecore_DList * _e_dlist);
-   EAPI void *ecore_dlist_first_remove(Ecore_DList * _e_dlist);
-   EAPI int ecore_dlist_remove_destroy(Ecore_DList *list);
-   EAPI void *ecore_dlist_last_remove(Ecore_DList * _e_dlist);
-   
-   /* Traversing the list */
+
+/* Removing items from the list */
+EAPI void *            ecore_dlist_remove(Ecore_DList *_e_dlist);
+EAPI void *            ecore_dlist_first_remove(Ecore_DList *_e_dlist);
+EAPI int               ecore_dlist_remove_destroy(Ecore_DList *list);
+EAPI void *            ecore_dlist_last_remove(Ecore_DList *_e_dlist);
+
+/* Traversing the list */
 # define ecore_dlist_for_each(list, function, user_data) \
    ecore_list_for_each(list, function, user_data)
-   EAPI void *ecore_dlist_first_goto(Ecore_DList * _e_dlist);
-   EAPI void *ecore_dlist_last_goto(Ecore_DList * _e_dlist);
-   EAPI void *ecore_dlist_index_goto(Ecore_DList * _e_dlist, int index);
-   EAPI void *ecore_dlist_goto(Ecore_DList * _e_dlist, void *_data);
-   
-   /* Traversing the list and returning data */
-   EAPI void *ecore_dlist_next(Ecore_DList * list);
-   EAPI void *ecore_dlist_previous(Ecore_DList * list);
-   
-   /* Sorting the list */
-   EAPI int ecore_dlist_sort(Ecore_DList *list, Ecore_Compare_Cb compare,
-                                  char order);
-   EAPI int ecore_dlist_mergesort(Ecore_DList *list, Ecore_Compare_Cb compare,
-                                  char order);
+EAPI void *            ecore_dlist_first_goto(Ecore_DList *_e_dlist);
+EAPI void *            ecore_dlist_last_goto(Ecore_DList *_e_dlist);
+EAPI void *            ecore_dlist_index_goto(Ecore_DList *_e_dlist, int index);
+EAPI void *            ecore_dlist_goto(Ecore_DList *_e_dlist, void *_data);
+
+/* Traversing the list and returning data */
+EAPI void *            ecore_dlist_next(Ecore_DList *list);
+EAPI void *            ecore_dlist_previous(Ecore_DList *list);
+
+/* Sorting the list */
+EAPI int               ecore_dlist_sort(Ecore_DList *list,
+                                        Ecore_Compare_Cb compare,
+                                        char order);
+EAPI int               ecore_dlist_mergesort(Ecore_DList *list,
+                                             Ecore_Compare_Cb compare,
+                                             char order);
 # define ecore_dlist_heapsort(list, compare, order) \
    ecore_list_heapsort(list, compare, order)
-   EAPI void ecore_dlist_merge(Ecore_DList *list, Ecore_DList *l2, 
-                                  Ecore_Compare_Cb, char order);
-   
-   /* Check to see if there is any data in the list */
-   EAPI int ecore_dlist_empty_is(Ecore_DList * _e_dlist);
-   
-   /* Remove every node in the list without free'ing it */
-   EAPI int ecore_dlist_clear(Ecore_DList * _e_dlist);
-   
-   /* Creating and initializing list nodes */
-   EAPI int ecore_dlist_node_init(Ecore_DList_Node * node);
-   EAPI Ecore_DList_Node *ecore_dlist_node_new(void);
-   
-   /* Destroying nodes */
-   EAPI int ecore_dlist_node_destroy(Ecore_DList_Node * node, Ecore_Free_Cb free_func);
-   
-   EAPI int ecore_dlist_free_cb_set(Ecore_DList * dlist, Ecore_Free_Cb free_func);
-   
-   
-   
-   /*
-    * Hash Table Implementation:
-    * 
-    * Traditional hash table implementation. I had tried a list of tables
-    * approach to save on the realloc's but it ended up being much slower than
-    * the traditional approach.
-    */
-   
-   typedef struct _ecore_hash_node Ecore_Hash_Node;
+EAPI void              ecore_dlist_merge(Ecore_DList *list, Ecore_DList *l2,
+                                         Ecore_Compare_Cb, char order);
+
+/* Check to see if there is any data in the list */
+EAPI int               ecore_dlist_empty_is(Ecore_DList *_e_dlist);
+
+/* Remove every node in the list without free'ing it */
+EAPI int               ecore_dlist_clear(Ecore_DList *_e_dlist);
+
+/* Creating and initializing list nodes */
+EAPI int               ecore_dlist_node_init(Ecore_DList_Node *node);
+EAPI Ecore_DList_Node *ecore_dlist_node_new(void);
+
+/* Destroying nodes */
+EAPI int               ecore_dlist_node_destroy(Ecore_DList_Node *node,
+                                                Ecore_Free_Cb free_func);
+
+EAPI int               ecore_dlist_free_cb_set(Ecore_DList *dlist,
+                                               Ecore_Free_Cb free_func);
+
+
+
+/*
+ * Hash Table Implementation:
+ *
+ * Traditional hash table implementation. I had tried a list of tables
+ * approach to save on the realloc's but it ended up being much slower than
+ * the traditional approach.
+ */
+
+typedef struct _ecore_hash_node Ecore_Hash_Node;
 # define ECORE_HASH_NODE(hash) ((Ecore_Hash_Node *)hash)
-   
-   struct _ecore_hash_node {
-      Ecore_Hash_Node *next; /* Pointer to the next node in the bucket list */
-      void *key;            /* The key for the data node */
-      void *value;          /* The value associated with this node */
-   };
-   
-   typedef struct _ecore_hash Ecore_Hash;
+
+struct _ecore_hash_node
+{
+   Ecore_Hash_Node *next; /* Pointer to the next node in the bucket list */
+   void *key; /* The key for the data node */
+   void *value; /* The value associated with this node */
+};
+
+typedef struct _ecore_hash Ecore_Hash;
 # define ECORE_HASH(hash) ((Ecore_Hash *)hash)
-   
-   struct _ecore_hash {
-      Ecore_Hash_Node **buckets;
-      int size;                /* An index into the table of primes to
-                        determine size */
-      int nodes;               /* The number of nodes currently in the hash */
-
-      int index;    /* The current index into the bucket table */
-      
-      Ecore_Compare_Cb compare;        /* The function used to compare node values */
-      Ecore_Hash_Cb hash_func; /* The callback function to determine hash */
-      
-      Ecore_Free_Cb free_key;  /* The callback function to free key */
-      Ecore_Free_Cb free_value;        /* The callback function to free value */
-   };
-   
-   /* Create and initialize a hash */
-   EAPI Ecore_Hash *ecore_hash_new(Ecore_Hash_Cb hash_func, Ecore_Compare_Cb compare);
-   EAPI int ecore_hash_init(Ecore_Hash *hash, Ecore_Hash_Cb hash_func, Ecore_Compare_Cb compare);
-   
-   /* Functions related to freeing the data in the hash table */
-   EAPI int ecore_hash_free_key_cb_set(Ecore_Hash *hash, Ecore_Free_Cb function);
-   EAPI int ecore_hash_free_value_cb_set(Ecore_Hash *hash, Ecore_Free_Cb function);
-   EAPI void ecore_hash_destroy(Ecore_Hash *hash);
-
-   EAPI int ecore_hash_count(Ecore_Hash *hash);
-   EAPI int ecore_hash_for_each_node(Ecore_Hash *hash, Ecore_For_Each for_each_func,
-                                    void *user_data);
-   EAPI Ecore_List *ecore_hash_keys(Ecore_Hash *hash);
-   
-   /* Retrieve and store data into the hash */
-   EAPI void *ecore_hash_get(Ecore_Hash *hash, const void *key);
-   EAPI int ecore_hash_set(Ecore_Hash *hash, void *key, void *value);
-   EAPI int ecore_hash_hash_set(Ecore_Hash *hash, Ecore_Hash *set);
-   EAPI void *ecore_hash_remove(Ecore_Hash *hash, const void *key);
-   EAPI void *ecore_hash_find(Ecore_Hash *hash, Ecore_Compare_Cb compare, const void *value);
-   EAPI void ecore_hash_dump_graph(Ecore_Hash *hash);
-   EAPI void ecore_hash_dump_stats(Ecore_Hash *hash);
-
-
-   typedef struct _ecore_heap Ecore_Sheap;
+
+struct _ecore_hash
+{
+   Ecore_Hash_Node **buckets;
+   int size; /* An index into the table of primes to
+                determine size */
+   int nodes; /* The number of nodes currently in the hash */
+
+   int index; /* The current index into the bucket table */
+
+   Ecore_Compare_Cb compare; /* The function used to compare node values */
+   Ecore_Hash_Cb hash_func; /* The callback function to determine hash */
+
+   Ecore_Free_Cb free_key; /* The callback function to free key */
+   Ecore_Free_Cb free_value; /* The callback function to free value */
+};
+
+/* Create and initialize a hash */
+EAPI Ecore_Hash *ecore_hash_new(Ecore_Hash_Cb hash_func,
+                                Ecore_Compare_Cb compare);
+EAPI int         ecore_hash_init(Ecore_Hash *hash,
+                                 Ecore_Hash_Cb hash_func,
+                                 Ecore_Compare_Cb compare);
+
+/* Functions related to freeing the data in the hash table */
+EAPI int         ecore_hash_free_key_cb_set(Ecore_Hash *hash,
+                                            Ecore_Free_Cb function);
+EAPI int         ecore_hash_free_value_cb_set(Ecore_Hash *hash,
+                                              Ecore_Free_Cb function);
+EAPI void        ecore_hash_destroy(Ecore_Hash *hash);
+
+EAPI int         ecore_hash_count(Ecore_Hash *hash);
+EAPI int         ecore_hash_for_each_node(Ecore_Hash *hash,
+                                          Ecore_For_Each for_each_func,
+                                          void *user_data);
+EAPI Ecore_List *ecore_hash_keys(Ecore_Hash *hash);
+
+/* Retrieve and store data into the hash */
+EAPI void *      ecore_hash_get(Ecore_Hash *hash, const void *key);
+EAPI int         ecore_hash_set(Ecore_Hash *hash, void *key, void *value);
+EAPI int         ecore_hash_hash_set(Ecore_Hash *hash, Ecore_Hash *set);
+EAPI void *      ecore_hash_remove(Ecore_Hash *hash, const void *key);
+EAPI void *      ecore_hash_find(Ecore_Hash *hash,
+                                 Ecore_Compare_Cb compare,
+                                 const void *value);
+EAPI void        ecore_hash_dump_graph(Ecore_Hash *hash);
+EAPI void        ecore_hash_dump_stats(Ecore_Hash *hash);
+
+
+typedef struct _ecore_heap Ecore_Sheap;
 # define ECORE_HEAP(heap) ((Ecore_Sheap *)heap)
-   
-   struct _ecore_heap {
-      void **data;
-      int size;
-      int space;
-      
-      char order, sorted;
-      
-      /* Callback for comparing node values, default is direct comparison */
-      Ecore_Compare_Cb compare;
-
-      /* Callback for freeing node data, default is NULL */
-      Ecore_Free_Cb free_func;
-   };
-   
-   EAPI Ecore_Sheap *ecore_sheap_new(Ecore_Compare_Cb compare, int size);
-   EAPI void ecore_sheap_destroy(Ecore_Sheap *heap);
-   EAPI int ecore_sheap_init(Ecore_Sheap *heap, Ecore_Compare_Cb compare, int size);
-   EAPI int ecore_sheap_free_cb_set(Ecore_Sheap *heap, Ecore_Free_Cb free_func);
-   EAPI int ecore_sheap_insert(Ecore_Sheap *heap, void *data);
-   EAPI void *ecore_sheap_extract(Ecore_Sheap *heap);
-   EAPI void *ecore_sheap_extreme(Ecore_Sheap *heap);
-   EAPI int ecore_sheap_change(Ecore_Sheap *heap, void *item, void *newval);
-   EAPI int ecore_sheap_compare_set(Ecore_Sheap *heap, Ecore_Compare_Cb compare);
-   EAPI void ecore_sheap_order_set(Ecore_Sheap *heap, char order);
-   EAPI void ecore_sheap_sort(Ecore_Sheap *heap);
-   
-   EAPI void *ecore_sheap_item(Ecore_Sheap *heap, int i);
-   
-  
-   typedef struct _ecore_string Ecore_String; 
-   struct _ecore_string { 
-      char *string; 
-      int references; 
-   }; 
-
-   EAPI int ecore_string_init();
-   EAPI void ecore_string_shutdown();
-   EAPI const char *ecore_string_instance(const char *string);
-   EAPI void ecore_string_release(const char *string);
-   
-   typedef struct _Ecore_Tree_Node Ecore_Tree_Node;
+
+struct _ecore_heap
+{
+   void **data;
+   int size;
+   int space;
+
+   char order, sorted;
+
+   /* Callback for comparing node values, default is direct comparison */
+   Ecore_Compare_Cb compare;
+
+   /* Callback for freeing node data, default is NULL */
+   Ecore_Free_Cb free_func;
+};
+
+EAPI Ecore_Sheap *ecore_sheap_new(Ecore_Compare_Cb compare, int size);
+EAPI void         ecore_sheap_destroy(Ecore_Sheap *heap);
+EAPI int          ecore_sheap_init(Ecore_Sheap *heap,
+                                   Ecore_Compare_Cb compare,
+                                   int size);
+EAPI int          ecore_sheap_free_cb_set(Ecore_Sheap *heap,
+                                          Ecore_Free_Cb free_func);
+EAPI int          ecore_sheap_insert(Ecore_Sheap *heap, void *data);
+EAPI void *       ecore_sheap_extract(Ecore_Sheap *heap);
+EAPI void *       ecore_sheap_extreme(Ecore_Sheap *heap);
+EAPI int          ecore_sheap_change(Ecore_Sheap *heap,
+                                     void *item,
+                                     void *newval);
+EAPI int          ecore_sheap_compare_set(Ecore_Sheap *heap,
+                                          Ecore_Compare_Cb compare);
+EAPI void         ecore_sheap_order_set(Ecore_Sheap *heap, char order);
+EAPI void         ecore_sheap_sort(Ecore_Sheap *heap);
+
+EAPI void *       ecore_sheap_item(Ecore_Sheap *heap, int i);
+
+
+typedef struct _ecore_string Ecore_String;
+struct _ecore_string
+{
+   char *string;
+   int references;
+};
+
+EAPI int         ecore_string_init();
+EAPI void        ecore_string_shutdown();
+EAPI const char *ecore_string_instance(const char *string);
+EAPI void        ecore_string_release(const char *string);
+
+typedef struct _Ecore_Tree_Node Ecore_Tree_Node;
 # define ECORE_TREE_NODE(object) ((Ecore_Tree_Node *)object)
-   struct _Ecore_Tree_Node {
-      
-      /* The actual data for each node */
-      void *key;
-      void *value;
-      
-      /* Pointers to surrounding nodes */
-      Ecore_Tree_Node *parent;
-      Ecore_Tree_Node *left_child;
-      Ecore_Tree_Node *right_child;
-      
-      /* Book keeping information for quicker balancing of the tree */
-      int max_right;
-      int max_left;
-   };
-   
-   typedef struct _Ecore_Tree Ecore_Tree;
+struct _Ecore_Tree_Node
+{
+
+   /* The actual data for each node */
+   void *key;
+   void *value;
+
+   /* Pointers to surrounding nodes */
+   Ecore_Tree_Node *parent;
+   Ecore_Tree_Node *left_child;
+   Ecore_Tree_Node *right_child;
+
+   /* Book keeping information for quicker balancing of the tree */
+   int max_right;
+   int max_left;
+};
+
+typedef struct _Ecore_Tree Ecore_Tree;
 # define ECORE_TREE(object) ((Ecore_Tree *)object)
-   struct _Ecore_Tree {
-      /* Nodes of the tree */
-      Ecore_Tree_Node *tree;
-      
-      /* Callback for comparing node values, default is direct comparison */
-      Ecore_Compare_Cb compare_func;
-      
-      /* Callback for freeing node data, default is NULL */
-      Ecore_Free_Cb free_value;
-      /* Callback for freeing node key, default is NULL */
-      Ecore_Free_Cb free_key;
-   };
-   
-   /* Some basic tree functions */
-   /* Allocate and initialize a new tree */
-   EAPI Ecore_Tree *ecore_tree_new(Ecore_Compare_Cb compare_func);
-   /* Initialize a new tree */
-   EAPI int ecore_tree_init(Ecore_Tree * tree, Ecore_Compare_Cb compare_func);
-   
-   /* Free the tree */
-   EAPI int ecore_tree_destroy(Ecore_Tree * tree);
-   /* Check to see if the tree has any nodes in it */
-   EAPI int ecore_tree_empty_is(Ecore_Tree * tree);
-   
-   /* Retrieve the value associated with key */
-   EAPI void *ecore_tree_get(Ecore_Tree * tree, const void *key);
-   EAPI Ecore_Tree_Node *ecore_tree_get_node(Ecore_Tree * tree, const void *key);
-   /* Retrieve the value of node with key greater than or equal to key */
-   EAPI void *ecore_tree_closest_larger_get(Ecore_Tree * tree, const void *key);
-   /* Retrieve the value of node with key less than or equal to key */
-   EAPI void *ecore_tree_closest_smaller_get(Ecore_Tree * tree, const void *key);
-   
-   /* Set the value associated with key to value */
-   EAPI int ecore_tree_set(Ecore_Tree * tree, void *key, void *value);
-   /* Remove the key from the tree */
-   EAPI int ecore_tree_remove(Ecore_Tree * tree, const void *key);
-   
-   /* Add a node to the tree */
-   EAPI int ecore_tree_node_add(Ecore_Tree * tree, Ecore_Tree_Node * node);
-   /* Remove a node from the tree */
-   EAPI int ecore_tree_node_remove(Ecore_Tree * tree, Ecore_Tree_Node * node);
-   
-   /* For each node in the tree perform the for_each_func function */
-   /* For this one pass in the node */
-   EAPI int ecore_tree_for_each_node(Ecore_Tree * tree, Ecore_For_Each for_each_func,
-                                    void *user_data);
-   /* And here pass in the node's value */
-   EAPI int ecore_tree_for_each_node_value(Ecore_Tree * tree,
-                                          Ecore_For_Each for_each_func,
-                                          void *user_data);
-   
-   /* Some basic node functions */
-   /* Initialize a node */
-   EAPI int ecore_tree_node_init(Ecore_Tree_Node * new_node);
-   /* Allocate and initialize a new node */
-   EAPI Ecore_Tree_Node *ecore_tree_node_new(void);
-   /* Free the desired node */
-   EAPI int ecore_tree_node_destroy(Ecore_Tree_Node * node, 
-                  Ecore_Free_Cb free_value, Ecore_Free_Cb free_key);
-   
-   /* Set the node's key to key */
-   EAPI int ecore_tree_node_key_set(Ecore_Tree_Node * node, void *key);
-   /* Retrieve the key in node */
-   EAPI void *ecore_tree_node_key_get(Ecore_Tree_Node * node);
-   
-   /* Set the node's value to value */
-   EAPI int ecore_tree_node_value_set(Ecore_Tree_Node * node, void *value);
-   /* Retrieve the value in node */
-   EAPI void *ecore_tree_node_value_get(Ecore_Tree_Node * node);
-   
-   /* Add a function to free the data stored in nodes */
-   EAPI int ecore_tree_free_value_cb_set(Ecore_Tree * tree, Ecore_Free_Cb free_value);
-   /* Add a function to free the keys stored in nodes */
-   EAPI int ecore_tree_free_key_cb_set(Ecore_Tree * tree, Ecore_Free_Cb free_key);
-
-
-   EAPI Ecore_Strbuf * ecore_strbuf_new(void);
-   EAPI void ecore_strbuf_free(Ecore_Strbuf *buf);
-   EAPI void ecore_strbuf_append(Ecore_Strbuf *buf, const char *str);
-   EAPI void ecore_strbuf_append_char(Ecore_Strbuf *buf, char c);
-   EAPI void ecore_strbuf_insert(Ecore_Strbuf *buf, const char *str, 
-                                 size_t pos);
+struct _Ecore_Tree
+{
+   /* Nodes of the tree */
+   Ecore_Tree_Node *tree;
+
+   /* Callback for comparing node values, default is direct comparison */
+   Ecore_Compare_Cb compare_func;
+
+   /* Callback for freeing node data, default is NULL */
+   Ecore_Free_Cb free_value;
+   /* Callback for freeing node key, default is NULL */
+   Ecore_Free_Cb free_key;
+};
+
+/* Some basic tree functions */
+/* Allocate and initialize a new tree */
+EAPI Ecore_Tree *     ecore_tree_new(Ecore_Compare_Cb compare_func);
+/* Initialize a new tree */
+EAPI int              ecore_tree_init(Ecore_Tree *tree,
+                                      Ecore_Compare_Cb compare_func);
+
+/* Free the tree */
+EAPI int              ecore_tree_destroy(Ecore_Tree *tree);
+/* Check to see if the tree has any nodes in it */
+EAPI int              ecore_tree_empty_is(Ecore_Tree *tree);
+
+/* Retrieve the value associated with key */
+EAPI void *           ecore_tree_get(Ecore_Tree *tree, const void *key);
+EAPI Ecore_Tree_Node *ecore_tree_get_node(Ecore_Tree *tree, const void *key);
+/* Retrieve the value of node with key greater than or equal to key */
+EAPI void *           ecore_tree_closest_larger_get(Ecore_Tree *tree,
+                                                    const void *key);
+/* Retrieve the value of node with key less than or equal to key */
+EAPI void *           ecore_tree_closest_smaller_get(Ecore_Tree *tree,
+                                                     const void *key);
+
+/* Set the value associated with key to value */
+EAPI int              ecore_tree_set(Ecore_Tree *tree, void *key, void *value);
+/* Remove the key from the tree */
+EAPI int              ecore_tree_remove(Ecore_Tree *tree, const void *key);
+
+/* Add a node to the tree */
+EAPI int              ecore_tree_node_add(Ecore_Tree *tree,
+                                          Ecore_Tree_Node *node);
+/* Remove a node from the tree */
+EAPI int              ecore_tree_node_remove(Ecore_Tree *tree,
+                                             Ecore_Tree_Node *node);
+
+/* For each node in the tree perform the for_each_func function */
+/* For this one pass in the node */
+EAPI int              ecore_tree_for_each_node(Ecore_Tree *tree,
+                                               Ecore_For_Each for_each_func,
+                                               void *user_data);
+/* And here pass in the node's value */
+EAPI int              ecore_tree_for_each_node_value(
+   Ecore_Tree *tree,
+   Ecore_For_Each
+   for_each_func,
+   void *user_data);
+
+/* Some basic node functions */
+/* Initialize a node */
+EAPI int              ecore_tree_node_init(Ecore_Tree_Node *new_node);
+/* Allocate and initialize a new node */
+EAPI Ecore_Tree_Node *ecore_tree_node_new(void);
+/* Free the desired node */
+EAPI int              ecore_tree_node_destroy(Ecore_Tree_Node *node,
+                                              Ecore_Free_Cb free_value,
+                                              Ecore_Free_Cb free_key);
+
+/* Set the node's key to key */
+EAPI int              ecore_tree_node_key_set(Ecore_Tree_Node *node, void *key);
+/* Retrieve the key in node */
+EAPI void *           ecore_tree_node_key_get(Ecore_Tree_Node *node);
+
+/* Set the node's value to value */
+EAPI int              ecore_tree_node_value_set(Ecore_Tree_Node *node,
+                                                void *value);
+/* Retrieve the value in node */
+EAPI void *           ecore_tree_node_value_get(Ecore_Tree_Node *node);
+
+/* Add a function to free the data stored in nodes */
+EAPI int              ecore_tree_free_value_cb_set(Ecore_Tree *tree,
+                                                   Ecore_Free_Cb free_value);
+/* Add a function to free the keys stored in nodes */
+EAPI int              ecore_tree_free_key_cb_set(Ecore_Tree *tree,
+                                                 Ecore_Free_Cb free_key);
+
+
+EAPI Ecore_Strbuf *   ecore_strbuf_new(void);
+EAPI void             ecore_strbuf_free(Ecore_Strbuf *buf);
+EAPI void             ecore_strbuf_append(Ecore_Strbuf *buf, const char *str);
+EAPI void             ecore_strbuf_append_char(Ecore_Strbuf *buf, char c);
+EAPI void             ecore_strbuf_insert(Ecore_Strbuf *buf, const char *str,
+                                          size_t pos);
 # define ecore_strbuf_prepend(buf, str) ecore_strbuf_insert(buf, str, 0)
-   EAPI const char * ecore_strbuf_string_get(Ecore_Strbuf *buf);
-   EAPI size_t ecore_strbuf_length_get(Ecore_Strbuf *buf);
-   EAPI int ecore_strbuf_replace(Ecore_Strbuf *buf, const char *str, 
-                                 const char *with, unsigned int n);
+EAPI const char *     ecore_strbuf_string_get(Ecore_Strbuf *buf);
+EAPI size_t           ecore_strbuf_length_get(Ecore_Strbuf *buf);
+EAPI int              ecore_strbuf_replace(Ecore_Strbuf *buf, const char *str,
+                                           const char *with, unsigned int n);
 # define ecore_strbuf_replace_first(buf, str, with) \
-       ecore_strbuf_replace(buf, str, with, 1)
-   EAPI int ecore_strbuf_replace_all(Ecore_Strbuf *buf, const char *str,
-                                     const char *with);
+   ecore_strbuf_replace(buf, str, with, 1)
+EAPI int              ecore_strbuf_replace_all(Ecore_Strbuf *buf,
+                                               const char *str,
+                                               const char *with);
 
-   extern int ecore_str_compare(const void *key1, const void *key2);
-   extern int ecore_direct_compare(const void *key1, const void *key2);
-   extern unsigned int ecore_str_hash(const void *key);
+extern int            ecore_str_compare(const void *key1, const void *key2);
+extern int            ecore_direct_compare(const void *key1, const void *key2);
+extern unsigned int   ecore_str_hash(const void *key);
 
 #ifdef __cplusplus
 }
 #endif
-#endif                         /* _ECORE_DATA_H */
+#endif /* _ECORE_DATA_H */
index 21e1131..9784892 100644 (file)
 
 typedef unsigned char Evas_Bool;
 
-typedef struct _Evas_Array_Hash  Evas_Array_Hash;
-typedef struct _Evas_Hash        Evas_Hash;              /**< A Hash table handle */
-typedef struct _Evas_List        Evas_List;              /**< A generic linked list node handle */
+typedef struct _Evas_Array_Hash Evas_Array_Hash;
+typedef struct _Evas_Hash Evas_Hash; /**< A Hash table handle */
+typedef struct _Evas_List Evas_List; /**< A generic linked list node handle */
 typedef struct _Evas_Object_List Evas_Object_List;
 
 struct _Evas_Hash
 {
-   int               population;
+   int population;
    Evas_Object_List *buckets[256];
 };
 
-struct _Evas_List                             /** A linked list node */
+struct _Evas_List /** A linked list node */
 {
-   void      *data;                           /**< Pointer to list element payload */
-   Evas_List *next;                           /**< Next member in the list */
-   Evas_List *prev;                           /**< Previous member in the list */
-   struct _Evas_List_Accounting *accounting;  /**< Private list accounting info - don't touch */
+   void *data; /**< Pointer to list element payload */
+   Evas_List *next; /**< Next member in the list */
+   Evas_List *prev; /**< Previous member in the list */
+   struct _Evas_List_Accounting *accounting; /**< Private list accounting info - don't touch */
 };
 
 struct _Evas_Object_List
 {
-   Evas_Object_List  *next, *prev;
-   Evas_Object_List  *last;
+   Evas_Object_List *next, *prev;
+   Evas_Object_List *last;
 };
 
 
@@ -64,85 +64,129 @@ struct _Evas_Object_List
 extern "C" {
 #endif
 
-  /*
-   * Evas Array Hash functions
-   */
-
-   EAPI Evas_Array_Hash *evas_array_hash_new        (void);
-   EAPI void             evas_array_hash_free       (Evas_Array_Hash *hash);
-   EAPI void             evas_array_hash_add        (Evas_Array_Hash *hash, int key, int data);
-   EAPI int              evas_array_hash_search     (Evas_Array_Hash *hash, int key);
-
-
-  /*
-   * Evas Hash functions
-   */
-
-   /* FIXME: add:
-    * api to add find, del members by data, size not just string and also
-    * provide hash generation functions settable by the app
-    *
-    * do we really need this? hmmm - let me think... there may be a better way
-    */
-   EAPI Evas_Hash  *evas_hash_add                   (Evas_Hash *hash, const char *key, const void *data);
-   EAPI Evas_Hash  *evas_hash_direct_add            (Evas_Hash *hash, const char *key, const void *data);
-   EAPI Evas_Hash  *evas_hash_del                   (Evas_Hash *hash, const char *key, const void *data);
-   EAPI void       *evas_hash_find                  (const Evas_Hash *hash, const char *key);
-   EAPI void       *evas_hash_modify                (Evas_Hash *hash, const char *key, const void *data);
-   EAPI int         evas_hash_size                  (const Evas_Hash *hash);
-   EAPI void        evas_hash_free                  (Evas_Hash *hash);
-   EAPI void        evas_hash_foreach               (const Evas_Hash *hash, Evas_Bool (*func) (const Evas_Hash *hash, const char *key, void *data, void *fdata), const void *fdata);
-   EAPI int         evas_hash_alloc_error           (void);
-
-
-  /*
-   * Evas List functions
-   */
-
-   EAPI Evas_List  *evas_list_append                (Evas_List *list, const void *data);
-   EAPI Evas_List  *evas_list_prepend               (Evas_List *list, const void *data);
-   EAPI Evas_List  *evas_list_append_relative       (Evas_List *list, const void *data, const void *relative);
-   EAPI Evas_List  *evas_list_append_relative_list  (Evas_List *list, const void *data, Evas_List *relative);
-   EAPI Evas_List  *evas_list_prepend_relative      (Evas_List *list, const void *data, const void *relative);
-   EAPI Evas_List  *evas_list_prepend_relative_list (Evas_List *list, const void *data, Evas_List *relative);
-   EAPI Evas_List  *evas_list_remove                (Evas_List *list, const void *data);
-   EAPI Evas_List  *evas_list_remove_list           (Evas_List *list, Evas_List *remove_list);
-   EAPI Evas_List  *evas_list_promote_list          (Evas_List *list, Evas_List *move_list);
-   EAPI void       *evas_list_find                  (const Evas_List *list, const void *data);
-   EAPI Evas_List  *evas_list_find_list             (const Evas_List *list, const void *data);
-   EAPI Evas_List  *evas_list_free                  (Evas_List *list);
-   EAPI Evas_List  *evas_list_last                  (const Evas_List *list);
-   EAPI Evas_List  *evas_list_next                  (const Evas_List *list);
-   EAPI Evas_List  *evas_list_prev                  (const Evas_List *list);
-   EAPI void       *evas_list_data                  (const Evas_List *list);
-   EAPI int         evas_list_count                 (const Evas_List *list);
-   EAPI void       *evas_list_nth                   (const Evas_List *list, int n);
-   EAPI Evas_List  *evas_list_nth_list              (const Evas_List *list, int n);
-   EAPI Evas_List  *evas_list_reverse               (Evas_List *list);
-   EAPI Evas_List  *evas_list_sort                  (Evas_List *list, int size, int(*func)(void*,void*));
-   EAPI int         evas_list_alloc_error           (void);
-
-
-  /*
-   * Evas Object List functions
-   */
-
-   EAPI void *evas_object_list_append               (void *in_list, void *in_item);
-   EAPI void *evas_object_list_prepend              (void *in_list, void *in_item);
-   EAPI void *evas_object_list_append_relative      (void *in_list, void *in_item, void *in_relative);
-   EAPI void *evas_object_list_prepend_relative     (void *in_list, void *in_item, void *in_relative);
-   EAPI void *evas_object_list_remove               (void *in_list, void *in_item);
-   EAPI void *evas_object_list_find                 (void *in_list, void *in_item);
-
-
-  /*
-   * Evas Stringshare functions
-   */
-
-   EAPI void        evas_stringshare_init           (void);           /* not implemented */
-   EAPI void        evas_stringshare_shutdown       (void);           /* not implemented */
-   EAPI const char *evas_stringshare_add            (const char *str);
-   EAPI void        evas_stringshare_del            (const char *str);
+/*
+ * Evas Array Hash functions
+ */
+
+EAPI Evas_Array_Hash *evas_array_hash_new        (void);
+EAPI void             evas_array_hash_free       (Evas_Array_Hash *hash);
+EAPI void             evas_array_hash_add        (Evas_Array_Hash *hash,
+                                                  int key,
+                                                  int data);
+EAPI int              evas_array_hash_search     (Evas_Array_Hash *hash,
+                                                  int key);
+
+
+/*
+ * Evas Hash functions
+ */
+
+/* FIXME: add:
+ * api to add find, del members by data, size not just string and also
+ * provide hash generation functions settable by the app
+ *
+ * do we really need this? hmmm - let me think... there may be a better way
+ */
+EAPI Evas_Hash *evas_hash_add                   (Evas_Hash *hash,
+                                                 const char *key,
+                                                 const void *data);
+EAPI Evas_Hash *evas_hash_direct_add            (Evas_Hash *hash,
+                                                 const char *key,
+                                                 const void *data);
+EAPI Evas_Hash *evas_hash_del                   (Evas_Hash *hash,
+                                                 const char *key,
+                                                 const void *data);
+EAPI void *     evas_hash_find                  (const Evas_Hash *hash,
+                                                 const char *key);
+EAPI void *     evas_hash_modify                (Evas_Hash *hash,
+                                                 const char *key,
+                                                 const void *data);
+EAPI int        evas_hash_size                  (const Evas_Hash *hash);
+EAPI void       evas_hash_free                  (Evas_Hash *hash);
+EAPI void       evas_hash_foreach               (const Evas_Hash *hash,
+                                                 Evas_Bool (*func)(
+                                                    const Evas_Hash *hash,
+                                                    const char *
+                                                    key,
+                                                    void *data,
+                                                    void *fdata),
+                                                 const void *fdata);
+EAPI int        evas_hash_alloc_error           (void);
+
+
+/*
+ * Evas List functions
+ */
+
+EAPI Evas_List *evas_list_append                (Evas_List *list,
+                                                 const void *data);
+EAPI Evas_List *evas_list_prepend               (Evas_List *list,
+                                                 const void *data);
+EAPI Evas_List *evas_list_append_relative       (Evas_List *list,
+                                                 const void *data,
+                                                 const void *relative);
+EAPI Evas_List *evas_list_append_relative_list  (Evas_List *list,
+                                                 const void *data,
+                                                 Evas_List *relative);
+EAPI Evas_List *evas_list_prepend_relative      (Evas_List *list,
+                                                 const void *data,
+                                                 const void *relative);
+EAPI Evas_List *evas_list_prepend_relative_list (Evas_List *list,
+                                                 const void *data,
+                                                 Evas_List *relative);
+EAPI Evas_List *evas_list_remove                (Evas_List *list,
+                                                 const void *data);
+EAPI Evas_List *evas_list_remove_list           (Evas_List *list,
+                                                 Evas_List *remove_list);
+EAPI Evas_List *evas_list_promote_list          (Evas_List *list,
+                                                 Evas_List *move_list);
+EAPI void *     evas_list_find                  (const Evas_List *list,
+                                                 const void *data);
+EAPI Evas_List *evas_list_find_list             (const Evas_List *list,
+                                                 const void *data);
+EAPI Evas_List *evas_list_free                  (Evas_List *list);
+EAPI Evas_List *evas_list_last                  (const Evas_List *list);
+EAPI Evas_List *evas_list_next                  (const Evas_List *list);
+EAPI Evas_List *evas_list_prev                  (const Evas_List *list);
+EAPI void *     evas_list_data                  (const Evas_List *list);
+EAPI int        evas_list_count                 (const Evas_List *list);
+EAPI void *     evas_list_nth                   (const Evas_List *list, int n);
+EAPI Evas_List *evas_list_nth_list              (const Evas_List *list, int n);
+EAPI Evas_List *evas_list_reverse               (Evas_List *list);
+EAPI Evas_List *evas_list_sort                  (Evas_List *list,
+                                                 int size,
+                                                 int (*func)(void *,void *));
+EAPI int        evas_list_alloc_error           (void);
+
+
+/*
+ * Evas Object List functions
+ */
+
+EAPI void *     evas_object_list_append               (void *in_list,
+                                                       void *in_item);
+EAPI void *     evas_object_list_prepend              (void *in_list,
+                                                       void *in_item);
+EAPI void *     evas_object_list_append_relative      (void *in_list,
+                                                       void *in_item,
+                                                       void *in_relative);
+EAPI void *     evas_object_list_prepend_relative     (void *in_list,
+                                                       void *in_item,
+                                                       void *in_relative);
+EAPI void *     evas_object_list_remove               (void *in_list,
+                                                       void *in_item);
+EAPI void *     evas_object_list_find                 (void *in_list,
+                                                       void *in_item);
+
+
+/*
+ * Evas Stringshare functions
+ */
+
+EAPI void        evas_stringshare_init           (void); /* not implemented */
+EAPI void        evas_stringshare_shutdown       (void); /* not implemented */
+EAPI const char *evas_stringshare_add            (const char *str);
+EAPI void        evas_stringshare_del            (const char *str);
 
 #ifdef __cplusplus
 }
index 4c3f8c0..a414348 100644 (file)
@@ -34,6 +34,9 @@ eina_suite_SOURCES =  \
 eina_suite.c           \
 eina_test_fp.c         \
 eina_test_stringshare.c \
+eina_test_ustringshare.c\
+eina_test_ustr.c       \
+eina_test_binshare.c    \
 eina_test_array.c      \
 eina_test_error.c      \
 eina_test_log.c        \
@@ -67,6 +70,12 @@ module_dummy_LTLIBRARIES = module_dummy.la
 module_dummy_la_SOURCES = \
 eina_test_module_dummy.c
 
+module_dummy_la_CPPFLAGS =                     \
+-I$(top_srcdir)/src/lib                        \
+-I$(top_srcdir)/src/include                    \
+-I$(top_builddir)/src/include                  \
+-I$(top_builddir)/src/lib                      \
+@EFL_EINA_BUILD@
 module_dummy_la_LIBADD       = $(top_builddir)/src/lib/libeina.la @EINA_LIBS@
 module_dummy_la_LDFLAGS      = -no-undefined @lt_enable_auto_import@ -module -avoid-version
 module_dummy_la_LIBTOOLFLAGS = --tag=disable-static
@@ -103,4 +112,3 @@ eina_bench_LDADD = @GLIB_LIBS@ $(top_builddir)/src/lib/libeina.la
 endif
 
 EXTRA_DIST = eina_bench.h eina_suite.h Ecore_Data.h Evas_Data.h evas_mempool.h
-
index 56caa3e..f957d52 100644 (file)
@@ -1,7 +1,3 @@
-/*
- * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
- */
-
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
 #define ECORE_HASH_CHAIN_MAX 3
 
 #define ECORE_COMPUTE_HASH(hash, key) hash->hash_func(key) % \
-                                       ecore_prime_table[hash->size];
+   ecore_prime_table[hash->size];
 
-#define ECORE_HASH_INCREASE(hash) ((hash && ecore_prime_table[hash->size] < PRIME_MAX) ? \
-               (hash->nodes / ecore_prime_table[hash->size]) > \
-               ECORE_HASH_CHAIN_MAX : FALSE)
-#define ECORE_HASH_REDUCE(hash) ((hash && ecore_prime_table[hash->size] > PRIME_MIN) ? \
-               (double)hash->nodes / (double)ecore_prime_table[hash->size-1] \
-               < ((double)ECORE_HASH_CHAIN_MAX * 0.375) : FALSE)
+#define ECORE_HASH_INCREASE(hash) ((hash && ecore_prime_table[hash->size] < \
+                                    PRIME_MAX) ? \
+                                   (hash->nodes / \
+                                    ecore_prime_table[hash->size]) > \
+                                   ECORE_HASH_CHAIN_MAX : FALSE)
+#define ECORE_HASH_REDUCE(hash) ((hash && ecore_prime_table[hash->size] > \
+                                  PRIME_MIN) ? \
+                                 (double)hash->nodes / \
+                                 (double)ecore_prime_table[hash->size - 1] \
+                                 < ((double)ECORE_HASH_CHAIN_MAX * \
+                                    0.375) : FALSE)
 
 
 static const unsigned int ecore_prime_table[] =
 {
    17, 31, 61, 127, 257, 509, 1021,
-     2053, 4093, 8191, 16381, 32771, 65537, 131071, 262147, 524287, 1048573,
-     2097143, 4194301, 8388617, 16777213
+   2053, 4093, 8191, 16381, 32771, 65537, 131071, 262147, 524287, 1048573,
+   2097143, 4194301, 8388617, 16777213
 };
 
 
 /* Private hash manipulation functions */
-static int _ecore_hash_node_add(Ecore_Hash *hash, Ecore_Hash_Node *node);
-static Ecore_Hash_Node * _ecore_hash_node_get(Ecore_Hash *hash, const void *key);
-static int _ecore_hash_increase(Ecore_Hash *hash);
-static int _ecore_hash_decrease(Ecore_Hash *hash);
-static inline int _ecore_hash_rehash(Ecore_Hash *hash, Ecore_Hash_Node **old_table, int old_size);
-static int _ecore_hash_bucket_destroy(Ecore_Hash_Node *list, Ecore_Free_Cb keyd,
-                                     Ecore_Free_Cb valued);
-static inline Ecore_Hash_Node * _ecore_hash_bucket_get(Ecore_Hash *hash,
-                                               Ecore_Hash_Node *bucket, const void *key);
-
-static Ecore_Hash_Node *_ecore_hash_node_new(void *key, void *value);
-static int _ecore_hash_node_init(Ecore_Hash_Node *node, void *key, void *value);
-static int _ecore_hash_node_destroy(Ecore_Hash_Node *node, Ecore_Free_Cb keyd,
-                                   Ecore_Free_Cb valued);
+static int                     _ecore_hash_node_add(Ecore_Hash *hash,
+                                                    Ecore_Hash_Node *node);
+static Ecore_Hash_Node *       _ecore_hash_node_get(Ecore_Hash *hash,
+                                                    const void *key);
+static int                     _ecore_hash_increase(Ecore_Hash *hash);
+static int                     _ecore_hash_decrease(Ecore_Hash *hash);
+static inline int              _ecore_hash_rehash(Ecore_Hash *hash,
+                                                  Ecore_Hash_Node **old_table,
+                                                  int old_size);
+static int                     _ecore_hash_bucket_destroy(Ecore_Hash_Node *list,
+                                                          Ecore_Free_Cb keyd,
+                                                          Ecore_Free_Cb valued);
+static inline Ecore_Hash_Node *_ecore_hash_bucket_get(Ecore_Hash *hash,
+                                                      Ecore_Hash_Node *bucket,
+                                                      const void *key);
+
+static Ecore_Hash_Node *       _ecore_hash_node_new(void *key, void *value);
+static int                     _ecore_hash_node_init(Ecore_Hash_Node *node,
+                                                     void *key,
+                                                     void *value);
+static int                     _ecore_hash_node_destroy(Ecore_Hash_Node *node,
+                                                        Ecore_Free_Cb keyd,
+                                                        Ecore_Free_Cb valued);
 
 /**
  * @defgroup Ecore_Data_Hash_ADT_Creation_Group Hash Creation Functions
@@ -71,12 +81,12 @@ ecore_hash_new(Ecore_Hash_Cb hash_func, Ecore_Compare_Cb compare)
 {
    Ecore_Hash *new_hash = (Ecore_Hash *)malloc(sizeof(Ecore_Hash));
    if (!new_hash)
-     return NULL;
+      return NULL;
 
    if (!ecore_hash_init(new_hash, hash_func, compare))
      {
-       FREE(new_hash);
-       return NULL;
+        FREE(new_hash);
+        return NULL;
      }
 
    return new_hash;
@@ -91,7 +101,9 @@ ecore_hash_new(Ecore_Hash_Cb hash_func, Ecore_Compare_Cb compare)
  * @ingroup Ecore_Data_Hash_ADT_Creation_Group
  */
 EAPI int
-ecore_hash_init(Ecore_Hash *hash, Ecore_Hash_Cb hash_func, Ecore_Compare_Cb compare)
+ecore_hash_init(Ecore_Hash *hash,
+                Ecore_Hash_Cb hash_func,
+                Ecore_Compare_Cb compare)
 {
    CHECK_PARAM_POINTER_RETURN("hash", hash, FALSE);
 
@@ -101,7 +113,7 @@ ecore_hash_init(Ecore_Hash *hash, Ecore_Hash_Cb hash_func, Ecore_Compare_Cb comp
    hash->compare = compare;
 
    hash->buckets = (Ecore_Hash_Node **)calloc(ecore_prime_table[0],
-                                             sizeof(Ecore_Hash_Node *));
+                                              sizeof(Ecore_Hash_Node *));
 
    return TRUE;
 }
@@ -173,16 +185,20 @@ ecore_hash_set(Ecore_Hash *hash, void *key, void *value)
    node = _ecore_hash_node_get(hash, key);
    if (node)
      {
-       if (hash->free_key) hash->free_key(key);
-       if (node->value && hash->free_value) hash->free_value(node->value);
-       node->value = value;
-       ret = TRUE;
+        if (hash->free_key)
+           hash->free_key(key);
+
+        if (node->value && hash->free_value)
+           hash->free_value(node->value);
+
+        node->value = value;
+        ret = TRUE;
      }
    else
      {
-       node = _ecore_hash_node_new(key, value);
-       if (node)
-         ret = _ecore_hash_node_add(hash, node);
+        node = _ecore_hash_node_new(key, value);
+        if (node)
+           ret = _ecore_hash_node_add(hash, node);
      }
 
    return ret;
@@ -202,29 +218,33 @@ ecore_hash_hash_set(Ecore_Hash *hash, Ecore_Hash *set)
    Ecore_Hash_Node *node, *old;
 
    CHECK_PARAM_POINTER_RETURN("hash", hash, FALSE);
-   CHECK_PARAM_POINTER_RETURN("set", set, FALSE);
+   CHECK_PARAM_POINTER_RETURN("set",  set,  FALSE);
 
    for (i = 0; i < ecore_prime_table[set->size]; i++)
      {
-       /* Hash into a new list to avoid loops of rehashing the same nodes */
-       while ((old = set->buckets[i]))
-         {
-            set->buckets[i] = old->next;
-            old->next = NULL;
-            node = _ecore_hash_node_get(hash, old->key);
-            if (node)
-              {
-                 /* This key already exists. Delete the old and add the new
-                  * value */
-                 if (hash->free_key) hash->free_key(node->key);
-                 if (hash->free_value) hash->free_key(node->value);
-                 node->key = old->key;
-                 node->value = old->value;
-                 free(old);
-              }
-            else
-              _ecore_hash_node_add(hash, old);
-         }
+        /* Hash into a new list to avoid loops of rehashing the same nodes */
+        while ((old = set->buckets[i]))
+          {
+             set->buckets[i] = old->next;
+             old->next = NULL;
+             node = _ecore_hash_node_get(hash, old->key);
+             if (node)
+               {
+                  /* This key already exists. Delete the old and add the new
+                   * value */
+                  if (hash->free_key)
+                     hash->free_key(node->key);
+
+                  if (hash->free_value)
+                     hash->free_key(node->value);
+
+                  node->key = old->key;
+                  node->value = old->value;
+                  free(old);
+               }
+             else
+                _ecore_hash_node_add(hash, old);
+          }
      }
    FREE(set->buckets);
    ecore_hash_init(set, set->hash_func, set->compare);
@@ -246,28 +266,30 @@ ecore_hash_destroy(Ecore_Hash *hash)
 
    if (hash->buckets)
      {
-       while (i < ecore_prime_table[hash->size])
-         {
-            if (hash->buckets[i])
-              {
-                 Ecore_Hash_Node *bucket;
-
-                               /*
-                                * Remove the bucket list to avoid possible recursion
-                                * on the free callbacks.
-                                */
-                 bucket = hash->buckets[i];
-                 hash->buckets[i] = NULL;
-                 _ecore_hash_bucket_destroy(bucket,
-                                            hash->free_key,
-                                            hash->free_value);
-              }
-            i++;
-         }
-
-       FREE(hash->buckets);
+        while (i < ecore_prime_table[hash->size])
+          {
+             if (hash->buckets[i])
+               {
+                  Ecore_Hash_Node *bucket;
+
+                  /*
+                   * Remove the bucket list to avoid possible recursion
+                   * on the free callbacks.
+                   */
+                  bucket = hash->buckets[i];
+                  hash->buckets[i] = NULL;
+                  _ecore_hash_bucket_destroy(bucket,
+                                             hash->free_key,
+                                             hash->free_value);
+               }
+
+             i++;
+          }
+
+        FREE(hash->buckets);
      }
-   FREE(hash);
+
+        FREE(hash);
 
    return;
 }
@@ -301,25 +323,28 @@ ecore_hash_count(Ecore_Hash *hash)
  * @ingroup Ecore_Data_Hash_ADT_Traverse_Group
  */
 EAPI int
-ecore_hash_for_each_node(Ecore_Hash *hash, Ecore_For_Each for_each_func, void *user_data)
+ecore_hash_for_each_node(Ecore_Hash *hash,
+                         Ecore_For_Each for_each_func,
+                         void *user_data)
 {
    unsigned int i = 0;
 
-   CHECK_PARAM_POINTER_RETURN("hash", hash, FALSE);
+   CHECK_PARAM_POINTER_RETURN("hash",          hash,          FALSE);
    CHECK_PARAM_POINTER_RETURN("for_each_func", for_each_func, FALSE);
 
    while (i < ecore_prime_table[hash->size])
      {
-       if (hash->buckets[i])
-         {
-            Ecore_Hash_Node *node;
-
-            for (node = hash->buckets[i]; node; node = node->next)
-              {
-                 for_each_func(node, user_data);
-              }
-         }
-       i++;
+        if (hash->buckets[i])
+          {
+             Ecore_Hash_Node *node;
+
+             for (node = hash->buckets[i]; node; node = node->next)
+               {
+                  for_each_func(node, user_data);
+               }
+          }
+
+        i++;
      }
 
    return TRUE;
@@ -342,16 +367,17 @@ ecore_hash_keys(Ecore_Hash *hash)
    keys = ecore_list_new();
    while (i < ecore_prime_table[hash->size])
      {
-       if (hash->buckets[i])
-         {
-            Ecore_Hash_Node *node;
-
-            for (node = hash->buckets[i]; node; node = node->next)
-              {
-                 ecore_list_append(keys, node->key);
-              }
-         }
-       i++;
+        if (hash->buckets[i])
+          {
+             Ecore_Hash_Node *node;
+
+             for (node = hash->buckets[i]; node; node = node->next)
+               {
+                  ecore_list_append(keys, node->key);
+               }
+          }
+
+        i++;
      }
    ecore_list_first_goto(keys);
 
@@ -368,16 +394,17 @@ ecore_hash_dump_graph(Ecore_Hash *hash)
    unsigned int i;
 
    for (i = 0; i < ecore_prime_table[hash->size]; i++)
-     if (hash->buckets[i])
-       {
-         int n = 0;
-         Ecore_Hash_Node *node;
-         for (node = hash->buckets[i]; node; node = node->next)
-           n++;
-         printf("%d\t%u", i, n);
-       }
-   else
-     printf("%d\t0", i);
+      if (hash->buckets[i])
+        {
+           int n = 0;
+           Ecore_Hash_Node *node;
+           for (node = hash->buckets[i]; node; node = node->next)
+              n++;
+           printf("%d\t%u", i, n);
+        }
+      else
+           printf("%d\t0",  i);
+
 }
 
 /**
@@ -392,23 +419,25 @@ ecore_hash_dump_stats(Ecore_Hash *hash)
 
    for (i = 0; i < ecore_prime_table[hash->size]; i++)
      {
-       if (hash->buckets[i])
-         {
-            int n = 0;
-            Ecore_Hash_Node *node;
-            for (node = hash->buckets[i]; node; node = node->next)
-              n++;
-            sum_n_2 += ((double)n * (double)n);
-            sum_n += (double)n;
-         }
+        if (hash->buckets[i])
+          {
+             int n = 0;
+             Ecore_Hash_Node *node;
+             for (node = hash->buckets[i]; node; node = node->next)
+                n++;
+             sum_n_2 += ((double)n * (double)n);
+             sum_n += (double)n;
+          }
      }
    variance = (sum_n_2 - ((sum_n * sum_n) / (double)i)) / (double)i;
-   printf("Average length: %f\n\tvariance^2: %f", (sum_n / (double)i),
-         variance);
+           printf("Average length: %f\n\tvariance^2: %f", (sum_n / (double)i),
+          variance);
 }
 
 static int
-_ecore_hash_bucket_destroy(Ecore_Hash_Node *list, Ecore_Free_Cb keyd, Ecore_Free_Cb valued)
+_ecore_hash_bucket_destroy(Ecore_Hash_Node *list,
+                           Ecore_Free_Cb keyd,
+                           Ecore_Free_Cb valued)
 {
    Ecore_Hash_Node *node;
 
@@ -416,8 +445,8 @@ _ecore_hash_bucket_destroy(Ecore_Hash_Node *list, Ecore_Free_Cb keyd, Ecore_Free
 
    for (node = list; node; node = list)
      {
-       list = list->next;
-       _ecore_hash_node_destroy(node, keyd, valued);
+        list = list->next;
+        _ecore_hash_node_destroy(node, keyd, valued);
      }
 
    return TRUE;
@@ -439,13 +468,13 @@ _ecore_hash_node_add(Ecore_Hash *hash, Ecore_Hash_Node *node)
 
    /* Check to see if the hash needs to be resized */
    if (ECORE_HASH_INCREASE(hash))
-     _ecore_hash_increase(hash);
+      _ecore_hash_increase(hash);
 
    /* Compute the position in the table */
    if (!hash->hash_func)
-     hash_val = (unsigned long)node->key % ecore_prime_table[hash->size];
+      hash_val = (unsigned long)node->key % ecore_prime_table[hash->size];
    else
-     hash_val = ECORE_COMPUTE_HASH(hash, node->key);
+      hash_val = ECORE_COMPUTE_HASH(hash, node->key);
 
    /* Prepend the node to the list at the index position */
    node->next = hash->buckets[hash_val];
@@ -473,7 +502,7 @@ ecore_hash_get(Ecore_Hash *hash, const void *key)
 
    node = _ecore_hash_node_get(hash, key);
    if (!node)
-     return NULL;
+      return NULL;
 
    data = node->value;
 
@@ -501,9 +530,9 @@ ecore_hash_remove(Ecore_Hash *hash, const void *key)
 
    /* Compute the position in the table */
    if (!hash->hash_func)
-     hash_val = (unsigned long )key % ecore_prime_table[hash->size];
+      hash_val = (unsigned long )key % ecore_prime_table[hash->size];
    else
-     hash_val = ECORE_COMPUTE_HASH(hash, key);
+      hash_val = ECORE_COMPUTE_HASH(hash, key);
 
    /*
     * If their is a list that could possibly hold the key/value pair
@@ -511,47 +540,44 @@ ecore_hash_remove(Ecore_Hash *hash, const void *key)
     */
    if (hash->buckets[hash_val])
      {
-       list = hash->buckets[hash_val];
-
-       /*
-        * Traverse the list to find the specified key
-        */
-       node = list;
-       if (hash->compare)
-         {
-            while ((node) && (hash->compare(node->key, key) != 0))
-              {
-                 list = node;
-                 node = node->next;
-              }
-         }
-       else
-         {
-            while ((node) && (node->key != key))
-              {
-                 list = node;
-                 node = node->next;
-              }
-         }
-
-       /*
-        * Remove the node with the matching key and free it's memory
-        */
-       if (node)
-         {
-            if (list == node)
-              hash->buckets[hash_val] = node->next;
-            else
-              list->next = node->next;
-            ret = node->value;
-            node->value = NULL;
-            _ecore_hash_node_destroy(node, hash->free_key, NULL);
-            hash->nodes--;
-         }
+        list = hash->buckets[hash_val];
+
+        /*
+         * Traverse the list to find the specified key
+         */
+        node = list;
+        if (hash->compare)
+           while ((node) && (hash->compare(node->key, key) != 0))
+             {
+                list = node;
+                node = node->next;
+             }
+        else
+           while ((node) && (node->key != key))
+             {
+                list = node;
+                node = node->next;
+             }
+
+        /*
+         * Remove the node with the matching key and free it's memory
+         */
+        if (node)
+          {
+             if (list == node)
+                hash->buckets[hash_val] = node->next;
+             else
+                list->next = node->next;
+
+             ret = node->value;
+             node->value = NULL;
+             _ecore_hash_node_destroy(node, hash->free_key, NULL);
+             hash->nodes--;
+          }
      }
 
    if (ECORE_HASH_REDUCE(hash))
-     _ecore_hash_decrease(hash);
+      _ecore_hash_decrease(hash);
 
    return ret;
 }
@@ -569,22 +595,24 @@ ecore_hash_find(Ecore_Hash *hash, Ecore_Compare_Cb compare, const void *value)
 {
    unsigned int i = 0;
 
-   CHECK_PARAM_POINTER_RETURN("hash", hash, NULL);
+   CHECK_PARAM_POINTER_RETURN("hash",    hash,    NULL);
    CHECK_PARAM_POINTER_RETURN("compare", compare, NULL);
-   CHECK_PARAM_POINTER_RETURN("value", value, NULL);
+   CHECK_PARAM_POINTER_RETURN("value",   value,   NULL);
 
    while (i < ecore_prime_table[hash->size])
      {
-       if (hash->buckets[i])
-         {
-            Ecore_Hash_Node *node;
-
-            for (node = hash->buckets[i]; node; node = node->next)
-              {
-                 if (!compare(node->value, value)) return node->value;
-              }
-         }
-       i++;
+        if (hash->buckets[i])
+          {
+             Ecore_Hash_Node *node;
+
+             for (node = hash->buckets[i]; node; node = node->next)
+               {
+                  if (!compare(node->value, value))
+                     return node->value;
+               }
+          }
+
+        i++;
      }
 
    return NULL;
@@ -605,29 +633,27 @@ _ecore_hash_node_get(Ecore_Hash *hash, const void *key)
    CHECK_PARAM_POINTER_RETURN("hash", hash, NULL);
 
    if (!hash->buckets)
-     {
-       return NULL;
-     }
+      return NULL;
 
    /* Compute the position in the table */
    if (!hash->hash_func)
-     hash_val = (unsigned long)key % ecore_prime_table[hash->size];
+      hash_val = (unsigned long)key % ecore_prime_table[hash->size];
    else
-     hash_val = ECORE_COMPUTE_HASH(hash, key);
+      hash_val = ECORE_COMPUTE_HASH(hash, key);
 
    /* Grab the bucket at the specified position */
    if (hash->buckets[hash_val])
      {
-       node = _ecore_hash_bucket_get(hash, hash->buckets[hash_val], key);
-       /*
-        * Move matched node to the front of the list as it's likely
-        * to be searched for again soon.
-        */
-       if (node && node != hash->buckets[hash_val])
-         {
-            node->next = hash->buckets[hash_val];
-            hash->buckets[hash_val] = node;
-         }
+        node = _ecore_hash_bucket_get(hash, hash->buckets[hash_val], key);
+        /*
+         * Move matched node to the front of the list as it's likely
+         * to be searched for again soon.
+         */
+        if (node && node != hash->buckets[hash_val])
+          {
+             node->next = hash->buckets[hash_val];
+             hash->buckets[hash_val] = node;
+          }
      }
 
    return node;
@@ -641,7 +667,9 @@ _ecore_hash_node_get(Ecore_Hash *hash, const void *key)
  * @return Returns NULL on error or not found, the found node on success
  */
 static inline Ecore_Hash_Node *
-_ecore_hash_bucket_get(Ecore_Hash *hash, Ecore_Hash_Node *bucket, const void *key)
+_ecore_hash_bucket_get(Ecore_Hash *hash,
+                       Ecore_Hash_Node *bucket,
+                       const void *key)
 {
    Ecore_Hash_Node *prev = NULL;
    Ecore_Hash_Node *node = NULL;
@@ -651,31 +679,29 @@ _ecore_hash_bucket_get(Ecore_Hash *hash, Ecore_Hash_Node *bucket, const void *ke
     * list, then return the node.
     */
    if (hash->compare)
-     {
-       for (node = bucket; node; node = node->next)
-         {
-            if (hash->compare(node->key, key) == 0)
-              break;
-            prev = node;
-         }
-     }
+      for (node = bucket; node; node = node->next)
+        {
+           if (hash->compare(node->key, key) == 0)
+              break;
+
+           prev = node;
+        }
    else
-     {
-       for (node = bucket; node; node = node->next)
-         {
-            if (node->key == key)
-              break;
-            prev = node;
-         }
-     }
+      for (node = bucket; node; node = node->next)
+        {
+           if (node->key == key)
+              break;
+
+           prev = node;
+        }
 
    /*
     * Remove node from the list to replace it at the beginning.
     */
    if (node && prev)
      {
-       prev->next = node->next;
-       node->next = NULL;
+        prev->next = node->next;
+        node->next = NULL;
      }
 
    return node;
@@ -694,8 +720,9 @@ _ecore_hash_increase(Ecore_Hash *hash)
    CHECK_PARAM_POINTER_RETURN("hash", hash, FALSE);
 
    /* Max size reached so return FALSE */
-   if ((ecore_prime_table[hash->size] == PRIME_MAX) || (hash->size == PRIME_TABLE_MAX))
-     return FALSE;
+   if ((ecore_prime_table[hash->size] == PRIME_MAX) ||
+       (hash->size == PRIME_TABLE_MAX))
+      return FALSE;
 
    /*
     * Increase the size of the hash and save a pointer to the old data
@@ -706,7 +733,8 @@ _ecore_hash_increase(Ecore_Hash *hash)
    /*
     * Allocate a new bucket area, of the new larger size
     */
-   hash->buckets = calloc(ecore_prime_table[hash->size], sizeof(Ecore_Hash_Node *));
+   hash->buckets =
+      calloc(ecore_prime_table[hash->size], sizeof(Ecore_Hash_Node *));
 
    /*
     * Make sure the allocation succeeded, if not replace the old data and
@@ -714,10 +742,11 @@ _ecore_hash_increase(Ecore_Hash *hash)
     */
    if (!hash->buckets)
      {
-       hash->buckets = old;
-       hash->size--;
-       return FALSE;
+        hash->buckets = old;
+        hash->size--;
+        return FALSE;
      }
+
    hash->nodes = 0;
 
    /*
@@ -725,14 +754,14 @@ _ecore_hash_increase(Ecore_Hash *hash)
     */
    if (_ecore_hash_rehash(hash, old, hash->size - 1))
      {
-       FREE(old);
-       return TRUE;
+        FREE(old);
+        return TRUE;
      }
 
    /*
     * Free the old buckets regardless of success.
     */
-   FREE(old);
+        FREE(old);
 
    return FALSE;
 }
@@ -750,7 +779,7 @@ _ecore_hash_decrease(Ecore_Hash *hash)
    CHECK_PARAM_POINTER_RETURN("hash", hash, FALSE);
 
    if (ecore_prime_table[hash->size] == PRIME_MIN)
-     return FALSE;
+      return FALSE;
 
    /*
     * Decrease the hash size and store a pointer to the old data
@@ -762,7 +791,7 @@ _ecore_hash_decrease(Ecore_Hash *hash)
     * Allocate a new area to store the data
     */
    hash->buckets = (Ecore_Hash_Node **)calloc(ecore_prime_table[hash->size],
-                                             sizeof(Ecore_Hash_Node *));
+                                              sizeof(Ecore_Hash_Node *));
 
    /*
     * Make sure allocation succeeded otherwise rreturn to the previous
@@ -770,17 +799,17 @@ _ecore_hash_decrease(Ecore_Hash *hash)
     */
    if (!hash->buckets)
      {
-       hash->buckets = old;
-       hash->size++;
-       return FALSE;
+        hash->buckets = old;
+        hash->size++;
+        return FALSE;
      }
 
    hash->nodes = 0;
 
    if (_ecore_hash_rehash(hash, old, hash->size + 1))
      {
-       FREE(old);
-       return TRUE;
+        FREE(old);
+        return TRUE;
      }
 
    return FALSE;
@@ -798,18 +827,18 @@ _ecore_hash_rehash(Ecore_Hash *hash, Ecore_Hash_Node **old_table, int old_size)
    unsigned int i;
    Ecore_Hash_Node *old;
 
-   CHECK_PARAM_POINTER_RETURN("hash", hash, FALSE);
+   CHECK_PARAM_POINTER_RETURN("hash",      hash,      FALSE);
    CHECK_PARAM_POINTER_RETURN("old_table", old_table, FALSE);
 
    for (i = 0; i < ecore_prime_table[old_size]; i++)
      {
-       /* Hash into a new list to avoid loops of rehashing the same nodes */
-       while ((old = old_table[i]))
-         {
-            old_table[i] = old->next;
-            old->next = NULL;
-            _ecore_hash_node_add(hash, old);
-         }
+        /* Hash into a new list to avoid loops of rehashing the same nodes */
+        while ((old = old_table[i]))
+          {
+             old_table[i] = old->next;
+             old->next = NULL;
+             _ecore_hash_node_add(hash, old);
+          }
      }
 
    return TRUE;
@@ -828,12 +857,12 @@ _ecore_hash_node_new(void *key, void *value)
 
    node = (Ecore_Hash_Node *)malloc(sizeof(Ecore_Hash_Node));
    if (!node)
-     return NULL;
+      return NULL;
 
    if (!_ecore_hash_node_init(node, key, value))
      {
-       FREE(node);
-       return NULL;
+        FREE(node);
+        return NULL;
      }
 
    return node;
@@ -849,7 +878,7 @@ _ecore_hash_node_new(void *key, void *value)
 static int
 _ecore_hash_node_init(Ecore_Hash_Node *node, void *key, void *value)
 {
-   CHECK_PARAM_POINTER_RETURN("node", node, FALSE);
+      CHECK_PARAM_POINTER_RETURN("node", node, FALSE);
 
    node->key = key;
    node->value = value;
@@ -865,15 +894,17 @@ _ecore_hash_node_init(Ecore_Hash_Node *node, void *key, void *value)
  * @return Returns TRUE on success, FALSE on error
  */
 static int
-_ecore_hash_node_destroy(Ecore_Hash_Node *node, Ecore_Free_Cb keyd, Ecore_Free_Cb valued)
+_ecore_hash_node_destroy(Ecore_Hash_Node *node,
+                         Ecore_Free_Cb keyd,
+                         Ecore_Free_Cb valued)
 {
-   CHECK_PARAM_POINTER_RETURN("node", node, FALSE);
+      CHECK_PARAM_POINTER_RETURN("node", node, FALSE);
 
    if (keyd)
-     keyd(node->key);
+      keyd(node->key);
 
    if (valued)
-     valued(node->value);
+      valued(node->value);
 
    FREE(node);
 
@@ -886,9 +917,9 @@ ecore_str_compare(const void *key1, const void *key2)
    const char *k1, *k2;
 
    if (!key1 || !key2)
-     return ecore_direct_compare(key1, key2);
+      return ecore_direct_compare(key1, key2);
    else if (key1 == key2)
-     return 0;
+      return 0;
 
    k1 = key1;
    k2 = key2;
@@ -905,13 +936,13 @@ ecore_str_hash(const void *key)
    const char *k = key;
 
    if (!k)
-     return 0;
+      return 0;
 
    mask = (sizeof(unsigned int) * 8) - 1;
 
    for (i = 0; k[i] != '\0'; i++)
      {
-       value ^= ((unsigned int) k[i] << ((i * 5) & mask));
+        value ^= ((unsigned int)k[i] << ((i * 5) & mask));
      }
 
    return value;
index 5b7229c..f6ac49c 100644 (file)
@@ -1,7 +1,3 @@
-/*
- * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
- */
-
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
 #define ECORE_MERGESORT_LIMIT 40000
 
 /* Return information about the list */
-static void *_ecore_list_current(Ecore_List * list);
+static void *           _ecore_list_current(Ecore_List *list);
 
 /* Adding functions */
-static int _ecore_list_insert(Ecore_List * list, Ecore_List_Node *node);
-static int _ecore_list_append_0(Ecore_List * list, Ecore_List_Node *node);
-static int _ecore_list_prepend_0(Ecore_List * list, Ecore_List_Node *node);
+static int              _ecore_list_insert(Ecore_List *list,
+                                           Ecore_List_Node *node);
+static int              _ecore_list_append_0(Ecore_List *list,
+                                             Ecore_List_Node *node);
+static int              _ecore_list_prepend_0(Ecore_List *list,
+                                              Ecore_List_Node *node);
 
 /* Remove functions */
-static void *_ecore_list_remove_0(Ecore_List * list);
-static void *_ecore_list_first_remove(Ecore_List * list);
-static void *_ecore_list_last_remove(Ecore_List * list);
+static void *           _ecore_list_remove_0(Ecore_List *list);
+static void *           _ecore_list_first_remove(Ecore_List *list);
+static void *           _ecore_list_last_remove(Ecore_List *list);
 
 /* Basic traversal functions */
-static void *_ecore_list_next(Ecore_List * list);
-static void *_ecore_list_last_goto(Ecore_List * list);
-static void *_ecore_list_first_goto(Ecore_List * list);
-static void *_ecore_list_goto(Ecore_List * list, const void *data);
-static void *_ecore_list_index_goto(Ecore_List *list, int idx);
+static void *           _ecore_list_next(Ecore_List *list);
+static void *           _ecore_list_last_goto(Ecore_List *list);
+static void *           _ecore_list_first_goto(Ecore_List *list);
+static void *           _ecore_list_goto(Ecore_List *list, const void *data);
+static void *           _ecore_list_index_goto(Ecore_List *list, int idx);
 
 /* Iterative functions */
-static int _ecore_list_for_each(Ecore_List *list, Ecore_For_Each function,
-                                void *user_data);
-static void *_ecore_list_find(Ecore_List *list, Ecore_Compare_Cb function,
-                              const void *user_data);
+static int              _ecore_list_for_each(Ecore_List *list,
+                                             Ecore_For_Each function,
+                                             void *user_data);
+static void *           _ecore_list_find(Ecore_List *list,
+                                         Ecore_Compare_Cb function,
+                                         const void *user_data);
 
 /* Sorting functions */
 static Ecore_List_Node *_ecore_list_node_mergesort(Ecore_List_Node *first,
-                                  int n, Ecore_Compare_Cb compare, int order);
+                                                   int n,
+                                                   Ecore_Compare_Cb compare,
+                                                   int order);
 static Ecore_List_Node *_ecore_list_node_merge(Ecore_List_Node *first,
                                                Ecore_List_Node *second,
                                                Ecore_Compare_Cb compare,
                                                int order);
 static Ecore_List_Node *_ecore_dlist_node_mergesort(Ecore_List_Node *first,
-                                  int n, Ecore_Compare_Cb compare, int order);
+                                                    int n,
+                                                    Ecore_Compare_Cb compare,
+                                                    int order);
 static Ecore_List_Node *_ecore_dlist_node_merge(Ecore_List_Node *first,
-                                               Ecore_List_Node *second,
-                                               Ecore_Compare_Cb compare,
-                                               int order);
+                                                Ecore_List_Node *second,
+                                                Ecore_Compare_Cb compare,
+                                                int order);
 
 /* Private double linked list functions */
-static void *_ecore_dlist_previous(Ecore_DList * list);
+static void *_ecore_dlist_previous(Ecore_DList *list);
 static void *_ecore_dlist_first_remove(Ecore_DList *list);
 static void *_ecore_dlist_index_goto(Ecore_DList *list, int idx);
 
 /**
-@defgroup Ecore_Data_List_Creation_Group List Creation/Destruction Functions
+   @defgroup Ecore_Data_List_Creation_Group List Creation/Destruction Functions
 
-Functions that create, initialize and destroy Ecore_Lists.
-*/
+   Functions that create, initialize and destroy Ecore_Lists.
+ */
 
 /**
  * Create and initialize a new list.
@@ -79,12 +84,12 @@ ecore_list_new(void)
 
    list = (Ecore_List *)malloc(sizeof(Ecore_List));
    if (!list)
-     return NULL;
+      return NULL;
 
    if (!ecore_list_init(list))
      {
-       FREE(list);
-       return NULL;
+        FREE(list);
+        return NULL;
      }
 
    return list;
@@ -120,9 +125,9 @@ ecore_list_destroy(Ecore_List *list)
 
    while (list->first)
      {
-       data = _ecore_list_first_remove(list);
-       if (list->free_func)
-         list->free_func(data);
+        data = _ecore_list_first_remove(list);
+        if (list->free_func)
+           list->free_func(data);
      }
 
    FREE(list);
@@ -158,7 +163,7 @@ ecore_list_empty_is(Ecore_List *list)
    CHECK_PARAM_POINTER_RETURN("list", list, TRUE);
 
    if (list->nodes)
-     ret = FALSE;
+      ret = FALSE;
 
    return ret;
 }
@@ -198,10 +203,10 @@ ecore_list_count(Ecore_List *list)
 }
 
 /**
-@defgroup Ecore_Data_List_Add_Item_Group List Item Adding Functions
+   @defgroup Ecore_Data_List_Add_Item_Group List Item Adding Functions
 
-Functions that are used to add nodes to an Ecore_List.
-*/
+   Functions that are used to add nodes to an Ecore_List.
+ */
 
 /**
  * Append data to the list.
@@ -231,19 +236,19 @@ static int
 _ecore_list_append_0(Ecore_List *list, Ecore_List_Node *end)
 {
    if (list->last)
-     list->last->next = end;
+      list->last->next = end;
 
    list->last = end;
 
    if (list->first == NULL)
      {
-       list->first = end;
-       list->index = 0;
-       list->current = NULL;
+        list->first = end;
+        list->index = 0;
+        list->current = NULL;
      }
 
    if (list->index >= list->nodes)
-     list->index++;
+      list->index++;
 
    list->nodes++;
 
@@ -284,7 +289,7 @@ _ecore_list_prepend_0(Ecore_List *list, Ecore_List_Node *start)
 
    /* If no last node, then the first node is the last node */
    if (list->last == NULL)
-     list->last = list->first;
+      list->last = list->first;
 
    list->nodes++;
    list->index++;
@@ -324,16 +329,16 @@ _ecore_list_insert(Ecore_List *list, Ecore_List_Node *new_node)
     * same as prepending it to the list.
     */
    if (list->current == list->first)
-     return _ecore_list_prepend_0(list, new_node);
+      return _ecore_list_prepend_0(list, new_node);
 
    if (list->current == NULL)
      {
-       int ret_value;
+        int ret_value;
 
-       ret_value = _ecore_list_append_0(list, new_node);
-       list->current = list->last;
+        ret_value = _ecore_list_append_0(list, new_node);
+        list->current = list->last;
 
-       return ret_value;
+        return ret_value;
      }
 
    /* Setup the fields of the new node */
@@ -361,24 +366,26 @@ _ecore_list_insert(Ecore_List *list, Ecore_List_Node *new_node)
 EAPI int
 ecore_list_append_list(Ecore_List *list, Ecore_List *append)
 {
-   CHECK_PARAM_POINTER_RETURN("list", list, FALSE);
+   CHECK_PARAM_POINTER_RETURN("list",   list,   FALSE);
    CHECK_PARAM_POINTER_RETURN("append", append, FALSE);
 
-   if (ecore_list_empty_is(append)) return TRUE;
+   if (ecore_list_empty_is(append))
+      return TRUE;
 
    if (ecore_list_empty_is(list))
      {
-       list->first = append->first;
-       list->current = list->first;
-       list->last = append->last;
-       list->nodes = append->nodes;
+        list->first = append->first;
+        list->current = list->first;
+        list->last = append->last;
+        list->nodes = append->nodes;
      }
    else
      {
-       list->last->next = append->first;
-       list->last = append->last;
-       list->nodes += append->nodes;
+        list->last->next = append->first;
+        list->last = append->last;
+        list->nodes += append->nodes;
      }
+
    ecore_list_init(append);
    return TRUE;
 }
@@ -393,34 +400,36 @@ ecore_list_append_list(Ecore_List *list, Ecore_List *append)
 EAPI int
 ecore_list_prepend_list(Ecore_List *list, Ecore_List *prepend)
 {
-   CHECK_PARAM_POINTER_RETURN("list", list, FALSE);
+   CHECK_PARAM_POINTER_RETURN("list",    list,    FALSE);
    CHECK_PARAM_POINTER_RETURN("prepend", prepend, FALSE);
 
-   if (ecore_list_empty_is(prepend)) return TRUE;
+   if (ecore_list_empty_is(prepend))
+      return TRUE;
 
    if (ecore_list_empty_is(list))
      {
-       list->first = prepend->first;
-       list->current = NULL;
-       list->last = prepend->last;
-       list->nodes = prepend->nodes;
+        list->first = prepend->first;
+        list->current = NULL;
+        list->last = prepend->last;
+        list->nodes = prepend->nodes;
      }
    else
      {
-       prepend->last->next = list->first;
-       list->first = prepend->first;
-       list->nodes += prepend->nodes;
-       list->index += prepend->nodes;
+        prepend->last->next = list->first;
+        list->first = prepend->first;
+        list->nodes += prepend->nodes;
+        list->index += prepend->nodes;
      }
+
    ecore_list_init(prepend);
    return TRUE;
 }
 
 /**
-@defgroup Ecore_Data_List_Remove_Item_Group List Item Removing Functions
+   @defgroup Ecore_Data_List_Remove_Item_Group List Item Removing Functions
 
-Functions that remove nodes from an Ecore_List.
-*/
+   Functions that remove nodes from an Ecore_List.
+ */
 
 /**
  * Remove the current item from the list.
@@ -448,19 +457,19 @@ _ecore_list_remove_0(Ecore_List *list)
    Ecore_List_Node *old;
 
    if (!list)
-     return NULL;
+      return NULL;
 
    if (ecore_list_empty_is(list))
-     return NULL;
+      return NULL;
 
    if (!list->current)
-     return NULL;
+      return NULL;
 
    if (list->current == list->first)
-     return _ecore_list_first_remove(list);
+      return _ecore_list_first_remove(list);
 
    if (list->current == list->last)
-     return _ecore_list_last_remove(list);
+      return _ecore_list_last_remove(list);
 
    old = list->current;
 
@@ -494,7 +503,7 @@ ecore_list_remove_destroy(Ecore_List *list)
 
    data = _ecore_list_remove_0(list);
    if (list->free_func)
-     list->free_func(data);
+      list->free_func(data);
 
    return TRUE;
 }
@@ -526,22 +535,22 @@ _ecore_list_first_remove(Ecore_List *list)
    Ecore_List_Node *old;
 
    if (!list)
-     return NULL;
+      return NULL;
 
    if (ecore_list_empty_is(list))
-     return NULL;
+      return NULL;
 
    old = list->first;
 
    list->first = list->first->next;
 
    if (list->current == old)
-     list->current = list->first;
+      list->current = list->first;
    else
-     (list->index ? list->index-- : 0);
+      (list->index ? list->index-- : 0);
 
    if (list->last == old)
-     list->last = list->first;
+      list->last = list->first;
 
    ret = old->data;
    old->data = NULL;
@@ -578,21 +587,22 @@ _ecore_list_last_remove(Ecore_List *list)
    Ecore_List_Node *old, *prev;
 
    if (!list)
-     return NULL;
+      return NULL;
 
    if (ecore_list_empty_is(list))
-     return NULL;
+      return NULL;
 
    old = list->last;
    if (list->current == old)
-     list->current = NULL;
+      list->current = NULL;
 
    if (list->first == old)
-     list->first = NULL;
-   for (prev = list->first; prev && prev->next != old; prev = prev->next);
+      list->first = NULL;
+
+   for (prev = list->first; prev && prev->next != old; prev = prev->next) ;
    list->last = prev;
    if (prev)
-     prev->next = NULL;
+      prev->next = NULL;
 
    old->next = NULL;
    ret = old->data;
@@ -605,10 +615,10 @@ _ecore_list_last_remove(Ecore_List *list)
 }
 
 /**
-@defgroup Ecore_Data_List_Traverse_Group List Traversal Functions
+   @defgroup Ecore_Data_List_Traverse_Group List Traversal Functions
 
-Functions that can be used to traverse an Ecore_List.
-*/
+   Functions that can be used to traverse an Ecore_List.
+ */
 
 /**
  * Make the current item the item with the given index number.
@@ -637,26 +647,26 @@ _ecore_list_index_goto(Ecore_List *list, int idx)
    int i;
 
    if (!list)
-     return NULL;
+      return NULL;
 
    if (ecore_list_empty_is(list))
-     return NULL;
+      return NULL;
 
    if (idx > ecore_list_count(list) || idx < 0)
-     return NULL;
+      return NULL;
 
    if (idx < list->index)
      {
-       _ecore_list_first_goto(list);
-       i = 0;
+        _ecore_list_first_goto(list);
+        i = 0;
      }
    else
-     i = list->index;
+      i = list->index;
 
-   for (; i < idx && _ecore_list_next(list); i++);
+   for (; i < idx && _ecore_list_next(list); i++) ;
 
    if (i >= list->nodes)
-     return NULL;
+      return NULL;
 
    list->index = i;
 
@@ -675,7 +685,7 @@ ecore_list_goto(Ecore_List *list, const void *data)
 {
    void *ret;
 
-   CHECK_PARAM_POINTER_RETURN("list", list, NULL);
+      CHECK_PARAM_POINTER_RETURN("list", list, NULL);
 
    ret = _ecore_list_goto(list, data);
 
@@ -690,27 +700,27 @@ _ecore_list_goto(Ecore_List *list, const void *data)
    Ecore_List_Node *node;
 
    if (!list)
-     return NULL;
+      return NULL;
 
    idx = 0;
 
    node = list->first;
    while (node && node->data)
      {
-       Ecore_List_Node *next;
+        Ecore_List_Node *next;
 
-       if (node->data == data)
-         break;
+        if (node->data == data)
+           break;
 
-       next = node->next;
+        next = node->next;
 
-       node = next;
+        node = next;
 
-       idx++;
+        idx++;
      }
 
    if (!node)
-     return NULL;
+      return NULL;
 
    list->current = node;
    list->index = idx;
@@ -729,7 +739,7 @@ ecore_list_first_goto(Ecore_List *list)
 {
    void *ret;
 
-   CHECK_PARAM_POINTER_RETURN("list", list, NULL);
+      CHECK_PARAM_POINTER_RETURN("list", list, NULL);
 
    ret = _ecore_list_first_goto(list);
 
@@ -741,7 +751,7 @@ static void *
 _ecore_list_first_goto(Ecore_List *list)
 {
    if (!list || !list->first)
-     return NULL;
+      return NULL;
 
    list->current = list->first;
    list->index = 0;
@@ -760,7 +770,7 @@ ecore_list_last_goto(Ecore_List *list)
 {
    void *ret;
 
-   CHECK_PARAM_POINTER_RETURN("list", list, NULL);
+      CHECK_PARAM_POINTER_RETURN("list", list, NULL);
 
    ret = _ecore_list_last_goto(list);
 
@@ -772,7 +782,7 @@ static void *
 _ecore_list_last_goto(Ecore_List *list)
 {
    if (!list || !list->last)
-     return NULL;
+      return NULL;
 
    list->current = list->last;
    list->index = (list->nodes - 1);
@@ -806,7 +816,8 @@ ecore_list_first(Ecore_List *list)
    void *ret;
 
    if (!list->first)
-     return NULL;
+      return NULL;
+
    ret = list->first->data;
 
    return ret;
@@ -823,7 +834,8 @@ ecore_list_last(Ecore_List *list)
    void *ret;
 
    if (!list->last)
-     return NULL;
+      return NULL;
+
    ret = list->last->data;
 
    return ret;
@@ -836,7 +848,7 @@ _ecore_list_current(Ecore_List *list)
    void *ret;
 
    if (!list->current)
-     return NULL;
+      return NULL;
 
    ret = list->current->data;
 
@@ -854,7 +866,7 @@ ecore_list_next(Ecore_List *list)
 {
    void *data;
 
-   CHECK_PARAM_POINTER_RETURN("list", list, NULL);
+      CHECK_PARAM_POINTER_RETURN("list", list, NULL);
 
    data = _ecore_list_next(list);
 
@@ -870,7 +882,7 @@ _ecore_list_next(Ecore_List *list)
    Ecore_List_Node *next;
 
    if (!list->current)
-     return NULL;
+      return NULL;
 
    ret = list->current;
    next = list->current->next;
@@ -893,10 +905,10 @@ _ecore_list_next(Ecore_List *list)
 EAPI int
 ecore_list_clear(Ecore_List *list)
 {
-   CHECK_PARAM_POINTER_RETURN("list", list, FALSE);
+      CHECK_PARAM_POINTER_RETURN("list", list, FALSE);
 
    while (!ecore_list_empty_is(list))
-     _ecore_list_first_remove(list);
+      _ecore_list_first_remove(list);
 
    return TRUE;
 }
@@ -927,11 +939,11 @@ _ecore_list_for_each(Ecore_List *list, Ecore_For_Each function, void *user_data)
    void *value;
 
    if (!list || !function)
-     return FALSE;
+      return FALSE;
 
    _ecore_list_first_goto(list);
    while ((value = _ecore_list_next(list)) != NULL)
-     function(value, user_data);
+      function(value, user_data);
 
    return TRUE;
 }
@@ -944,28 +956,35 @@ _ecore_list_for_each(Ecore_List *list, Ecore_For_Each function, void *user_data)
  * @return the first matching data node, or NULL if none match
  */
 EAPI void *
-ecore_list_find(Ecore_List *list, Ecore_Compare_Cb function, const void *user_data)
+ecore_list_find(Ecore_List *list,
+                Ecore_Compare_Cb function,
+                const void *user_data)
 {
-  CHECK_PARAM_POINTER_RETURN("list", list, NULL);
+   CHECK_PARAM_POINTER_RETURN("list", list, NULL);
 
-  return _ecore_list_find(list, function, user_data);
+   return _ecore_list_find(list, function, user_data);
 }
 
 /* The real meat of finding a node via a compare cb */
 static void *
-_ecore_list_find(Ecore_List *list, Ecore_Compare_Cb function, const void *user_data)
+_ecore_list_find(Ecore_List *list,
+                 Ecore_Compare_Cb function,
+                 const void *user_data)
 {
-  void *value;
-  if (!list || !function) return NULL;
+   void *value;
+   if (!list || !function)
+      return NULL;
 
-  _ecore_list_first_goto(list);
-  while ((value = _ecore_list_current(list)) != NULL)
-  {
-    if (!function(value, user_data)) return value;
-    ecore_list_next(list);
-  }
+   _ecore_list_first_goto(list);
+   while ((value = _ecore_list_current(list)) != NULL)
+     {
+        if (!function(value, user_data))
+           return value;
 
-  return NULL;
+        ecore_list_next(list);
+     }
+
+   return NULL;
 }
 
 /**
@@ -986,11 +1005,13 @@ ecore_list_sort(Ecore_List *list, Ecore_Compare_Cb compare, char order)
    CHECK_PARAM_POINTER_RETURN("list", list, 0);
 
    if (list->nodes < 2)
-     return 1;
+      return 1;
+
    if (list->nodes < ECORE_MERGESORT_LIMIT)
-     return ecore_list_mergesort(list, compare, order);
+      return ecore_list_mergesort(list, compare, order);
+
    if (!ecore_list_heapsort(list, compare, order))
-     return ecore_list_mergesort(list, compare, order);
+      return ecore_list_mergesort(list, compare, order);
 
    return 1;
 }
@@ -1012,19 +1033,19 @@ ecore_list_mergesort(Ecore_List *list, Ecore_Compare_Cb compare, char order)
 
    CHECK_PARAM_POINTER_RETURN("list", list, 0);
    if (list->nodes < 2)
-     return 1;
+      return 1;
 
    if (order == ECORE_SORT_MIN)
-     order = 1;
+      order = 1;
    else
-     order = -1;
+      order = -1;
 
    node = _ecore_list_node_mergesort(list->first, list->nodes, compare, order);
    list->first = node;
 
    /* maybe there is a better way to do that but our last node has changed */
    while (node->next)
-     node = node->next;
+      node = node->next;
    list->last = node;
 
    _ecore_list_first_goto(list);
@@ -1042,28 +1063,32 @@ ecore_list_mergesort(Ecore_List *list, Ecore_Compare_Cb compare, char order)
  *                  ECORE_SORT_MAX
  */
 EAPI void
-ecore_list_merge(Ecore_List *list, Ecore_List *l2, Ecore_Compare_Cb compare, char order)
+ecore_list_merge(Ecore_List *list,
+                 Ecore_List *l2,
+                 Ecore_Compare_Cb compare,
+                 char order)
 {
    CHECK_PARAM_POINTER("list", list);
-   CHECK_PARAM_POINTER("l2", l2);
+   CHECK_PARAM_POINTER("l2",   l2);
 
-   if (ecore_list_empty_is(l2)) return;
+   if (ecore_list_empty_is(l2))
+      return;
 
    if (ecore_list_empty_is(list))
      {
-       ecore_list_append_list(list, l2);
-       return;
+        ecore_list_append_list(list, l2);
+        return;
      }
 
    if (order == ECORE_SORT_MIN)
-     order = 1;
+      order = 1;
    else
-     order = -1;
+      order = -1;
 
    list->first = _ecore_list_node_merge(list->first, l2->first, compare, order);
 
    if ((order * compare(list->last->data, l2->last->data)) < 0)
-     list->last = l2->last;
+      list->last = l2->last;
 
    list->nodes += l2->nodes;
    ecore_list_init(l2);
@@ -1082,23 +1107,24 @@ _ecore_list_node_mergesort(Ecore_List_Node *first, int n,
    mid = n / 2;
 
    if (n < 2)
-     return first;
+      return first;
    else if (n == 2)
      {
-       if (compare(first->data, first->next->data) * order > 0)
+        if (compare(first->data, first->next->data) * order > 0)
           {
-               /* swap the data */
-               void *data;
-               data = first->next->data;
-               first->next->data = first->data;
-               first->data = data;
-         }
-      return first;
-    }
+             /* swap the data */
+             void *data;
+             data = first->next->data;
+             first->next->data = first->data;
+             first->data = data;
+          }
+
+        return first;
+     }
 
    /* first find the premiddle node*/
    for (premid = first, i = 0; i < mid - 1; i++)
-     premid = premid->next;
+      premid = premid->next;
 
    /* split the list */
    middle = premid->next;
@@ -1123,37 +1149,37 @@ _ecore_list_node_merge(Ecore_List_Node *first, Ecore_List_Node *second,
     * a pointer to it */
    if (compare(first->data, second->data) * order > 0)
      {
-       list = l = second;
-       second = second->next;
+        list = l = second;
+        second = second->next;
      }
    else
      {
-       list = l = first;
-       first = first->next;
+        list = l = first;
+        first = first->next;
      }
 
    /* and now start the merging */
    while (first && second)
      {
-       if (compare(first->data, second->data) * order > 0)
-         {
-               l = l->next = second;
-               second = second->next;
-         }
-       else
-         {
-               l = l->next = first;
-               first = first->next;
-         }
+        if (compare(first->data, second->data) * order > 0)
+          {
+             l = l->next = second;
+             second = second->next;
+          }
+        else
+          {
+             l = l->next = first;
+             first = first->next;
+          }
      }
 
    /* append the rest or set it to NULL */
    if (first)
-     l->next = first;
+      l->next = first;
    else if (second)
-     l->next = second;
+      l->next = second;
    else
-     l->next = NULL;
+      l->next = NULL;
 
    return list;
 }
@@ -1182,13 +1208,13 @@ ecore_list_heapsort(Ecore_List *list, Ecore_Compare_Cb compare, char order)
     */
    heap = ecore_sheap_new(compare, list->nodes);
    if (!heap)
-     return 0;
+      return 0;
 
    ecore_sheap_order_set(heap, order);
    _ecore_list_first_goto(list);
    while ((data = _ecore_list_next(list)))
      {
-       ecore_sheap_insert(heap, data);
+        ecore_sheap_insert(heap, data);
      }
 
    /*
@@ -1197,8 +1223,8 @@ ecore_list_heapsort(Ecore_List *list, Ecore_Compare_Cb compare, char order)
    node = list->first;
    while (node)
      {
-       node->data = ecore_sheap_extract(heap);
-       node = node->next;
+        node->data = ecore_sheap_extract(heap);
+        node = node->next;
      }
 
    ecore_sheap_destroy(heap);
@@ -1220,11 +1246,11 @@ ecore_list_node_init(Ecore_List_Node *node)
 }
 
 /**
-@defgroup Ecore_Data_List_Node_Group List Node Functions
+   @defgroup Ecore_Data_List_Node_Group List Node Functions
 
-Functions that are used in the creation, maintenance and destruction of
-Ecore_List nodes.
-*/
+   Functions that are used in the creation, maintenance and destruction of
+   Ecore_List nodes.
+ */
 
 /**
  * Allocates and initializes a new list node.
@@ -1240,8 +1266,8 @@ ecore_list_node_new()
 
    if (!ecore_list_node_init(new_node))
      {
-       FREE(new_node);
-       return NULL;
+        FREE(new_node);
+        return NULL;
      }
 
    return new_node;
@@ -1260,7 +1286,7 @@ ecore_list_node_destroy(Ecore_List_Node *node, Ecore_Free_Cb free_func)
    CHECK_PARAM_POINTER_RETURN("node", node, FALSE);
 
    if (free_func && node->data)
-     free_func(node->data);
+      free_func(node->data);
 
    FREE(node);
 
@@ -1286,12 +1312,12 @@ ecore_dlist_new()
 
    list = (Ecore_DList *)malloc(sizeof(Ecore_DList));
    if (!list)
-     return NULL;
+      return NULL;
 
    if (!ecore_dlist_init(list))
      {
-       IF_FREE(list);
-       return NULL;
+        IF_FREE(list);
+        return NULL;
      }
 
    return list;
@@ -1326,9 +1352,9 @@ ecore_dlist_destroy(Ecore_DList *list)
 
    while (list->first)
      {
-       data = _ecore_dlist_first_remove(list);
-       if (list->free_func)
-         list->free_func(data);
+        data = _ecore_dlist_first_remove(list);
+        if (list->free_func)
+           list->free_func(data);
      }
 
    FREE(list);
@@ -1404,7 +1430,7 @@ ecore_dlist_append(Ecore_DList *list, void *data)
    prev = ECORE_DLIST_NODE(ECORE_LIST(list)->last);
    ret = _ecore_list_append_0(ECORE_LIST(list), ECORE_LIST_NODE(node));
    if (ret)
-     node->previous = prev;
+      node->previous = prev;
 
    return ret;
 }
@@ -1431,7 +1457,7 @@ ecore_dlist_prepend(Ecore_DList *list, void *data)
    prev = ECORE_DLIST_NODE(ECORE_LIST(list)->first);
    ret = _ecore_list_prepend_0(ECORE_LIST(list), ECORE_LIST_NODE(node));
    if (ret && prev)
-     prev->previous = node;
+      prev->previous = node;
 
    return ret;
 }
@@ -1456,9 +1482,10 @@ ecore_dlist_insert(Ecore_DList *list, void *data)
     * Identify and shortcut the end cases.
     */
    if (!ECORE_LIST(list)->current)
-     return ecore_dlist_append(list, data);
+      return ecore_dlist_append(list, data);
+
    if (ECORE_LIST(list)->current == ECORE_LIST(list)->first)
-     return ecore_dlist_prepend(list, data);
+      return ecore_dlist_prepend(list, data);
 
    node = ecore_dlist_node_new();
    ECORE_LIST_NODE(node)->data = data;
@@ -1489,25 +1516,27 @@ ecore_dlist_insert(Ecore_DList *list, void *data)
 EAPI int
 ecore_dlist_append_list(Ecore_DList *list, Ecore_DList *append)
 {
-   CHECK_PARAM_POINTER_RETURN("list", list, FALSE);
+   CHECK_PARAM_POINTER_RETURN("list",   list,   FALSE);
    CHECK_PARAM_POINTER_RETURN("append", append, FALSE);
 
-   if (ecore_dlist_empty_is(append)) return TRUE;
+   if (ecore_dlist_empty_is(append))
+      return TRUE;
 
    if (ecore_dlist_empty_is(list))
      {
-       list->first = append->first;
-       list->current = NULL;
-       list->last = append->last;
-       list->nodes = append->nodes;
+        list->first = append->first;
+        list->current = NULL;
+        list->last = append->last;
+        list->nodes = append->nodes;
      }
    else
      {
-       list->last->next = append->first;
-       ECORE_DLIST_NODE(append->first)->previous = ECORE_DLIST_NODE(list->last);
-       list->last = append->last;
-       list->nodes += append->nodes;
+        list->last->next = append->first;
+        ECORE_DLIST_NODE(append->first)->previous = ECORE_DLIST_NODE(list->last);
+        list->last = append->last;
+        list->nodes += append->nodes;
      }
+
    ecore_dlist_init(append);
    return TRUE;
 }
@@ -1522,26 +1551,29 @@ ecore_dlist_append_list(Ecore_DList *list, Ecore_DList *append)
 EAPI int
 ecore_dlist_prepend_list(Ecore_DList *list, Ecore_DList *prepend)
 {
-   CHECK_PARAM_POINTER_RETURN("list", list, FALSE);
+   CHECK_PARAM_POINTER_RETURN("list",    list,    FALSE);
    CHECK_PARAM_POINTER_RETURN("prepend", prepend, FALSE);
 
-   if (ecore_dlist_empty_is(prepend)) return TRUE;
+   if (ecore_dlist_empty_is(prepend))
+      return TRUE;
 
    if (ecore_dlist_empty_is(list))
      {
-       list->first = prepend->first;
-       list->current = NULL;
-       list->last = prepend->last;
-       list->nodes = prepend->nodes;
+        list->first = prepend->first;
+        list->current = NULL;
+        list->last = prepend->last;
+        list->nodes = prepend->nodes;
      }
    else
      {
-       prepend->last->next = list->first;
-       ECORE_DLIST_NODE(list->first)->previous = ECORE_DLIST_NODE(prepend->last);
-       list->first = prepend->first;
-       list->nodes += prepend->nodes;
-       list->index += prepend->nodes;
+        prepend->last->next = list->first;
+        ECORE_DLIST_NODE(list->first)->previous = ECORE_DLIST_NODE(
+              prepend->last);
+        list->first = prepend->first;
+        list->nodes += prepend->nodes;
+        list->index += prepend->nodes;
      }
+
    ecore_dlist_init(prepend);
    return TRUE;
 }
@@ -1569,10 +1601,11 @@ ecore_dlist_remove(Ecore_DList *list)
 
    if (l2->current)
      {
-       node = ECORE_DLIST_NODE(list->current->next);
-       if (node)
-         node->previous = ECORE_DLIST_NODE(l2->current)->previous;
+        node = ECORE_DLIST_NODE(list->current->next);
+        if (node)
+           node->previous = ECORE_DLIST_NODE(l2->current)->previous;
      }
+
    ret = _ecore_list_remove_0(list);
 
    return ret;
@@ -1612,10 +1645,10 @@ ecore_dlist_remove_destroy(Ecore_DList *list)
 
    data = ecore_dlist_remove(list);
    if (!data)
-     return FALSE;
+      return FALSE;
 
    if (list->free_func)
-     list->free_func(data);
+      list->free_func(data);
 
    return TRUE;
 }
@@ -1626,11 +1659,11 @@ _ecore_dlist_first_remove(Ecore_DList *list)
    void *ret;
 
    if (!list)
-     return NULL;
+      return NULL;
 
    ret = _ecore_list_first_remove(list);
    if (ret && ECORE_LIST(list)->first)
-     ECORE_DLIST_NODE(ECORE_LIST(list)->first)->previous = NULL;
+      ECORE_DLIST_NODE(ECORE_LIST(list)->first)->previous = NULL;
 
    return ret;
 }
@@ -1650,23 +1683,25 @@ ecore_dlist_last_remove(Ecore_DList *list)
    CHECK_PARAM_POINTER_RETURN("list", list, NULL);
 
    if (ecore_list_empty_is(list))
-     return NULL;
+      return NULL;
 
    node = list->last;
    list->last = ECORE_LIST_NODE(ECORE_DLIST_NODE(node)->previous);
    if (list->last)
-     list->last->next = NULL;
+      list->last->next = NULL;
+
    if (list->first == node)
-     list->first = NULL;
+      list->first = NULL;
+
    if (list->current == node)
-     list->current = NULL;
+      list->current = NULL;
 
    ret = node->data;
    ecore_list_node_destroy(node, NULL);
 
    list->nodes--;
    if (list->index >= list->nodes)
-     list->index--;
+      list->index--;
 
    return ret;
 }
@@ -1697,28 +1732,28 @@ _ecore_dlist_index_goto(Ecore_DList *list, int idx)
    int i, increment;
 
    if (!list)
-     return NULL;
+      return NULL;
 
    if (ecore_list_empty_is(ECORE_LIST(list)))
-     return NULL;
+      return NULL;
 
    if (idx > ecore_list_count(ECORE_LIST(list)) || idx < 0)
-     return NULL;
+      return NULL;
 
    if (ECORE_LIST(list)->index >= ECORE_LIST(list)->nodes)
-     _ecore_list_last_goto(ECORE_LIST(list));
+      _ecore_list_last_goto(ECORE_LIST(list));
 
    if (idx < ECORE_LIST(list)->index)
-     increment = -1;
+      increment = -1;
    else
-     increment = 1;
+      increment = 1;
 
    for (i = ECORE_LIST(list)->index; i != idx; i += increment)
      {
-       if (increment > 0)
-         _ecore_list_next(list);
-       else
-         _ecore_dlist_previous(list);
+        if (increment > 0)
+           _ecore_list_next(list);
+        else
+           _ecore_dlist_previous(list);
      }
 
    return _ecore_list_current(list);
@@ -1829,17 +1864,21 @@ _ecore_dlist_previous(Ecore_DList *list)
    void *data = NULL;
 
    if (!list)
-     return NULL;
+      return NULL;
 
    if (ECORE_LIST(list)->current)
      {
-       data = ECORE_LIST(list)->current->data;
-       ECORE_LIST(list)->current = ECORE_LIST_NODE(ECORE_DLIST_NODE(
-                                                                    ECORE_LIST(list)->current)->previous);
-       ECORE_LIST(list)->index--;
+        data = ECORE_LIST(list)->current->data;
+                                     ECORE_LIST(list)->
+        current = ECORE_LIST_NODE(ECORE_DLIST_NODE(
+                                     ECORE_LIST(list)->
+                                     current)->previous);
+                                     ECORE_LIST(list)->index
+        --;
      }
    else
-     _ecore_list_last_goto(ECORE_LIST(list));
+      _ecore_list_last_goto(
+         ECORE_LIST(list));
 
    return data;
 }
@@ -1878,11 +1917,13 @@ ecore_dlist_sort(Ecore_List *list, Ecore_Compare_Cb compare, char order)
    CHECK_PARAM_POINTER_RETURN("list", list, 0);
 
    if (list->nodes < 2)
-     return 1;
+      return 1;
+
    if (list->nodes < ECORE_MERGESORT_LIMIT)
-     return ecore_dlist_mergesort(list, compare, order);
+      return ecore_dlist_mergesort(list, compare, order);
+
    if (!ecore_dlist_heapsort(list, compare, order))
-     return ecore_dlist_mergesort(list, compare, order);
+      return ecore_dlist_mergesort(list, compare, order);
 
    return 1;
 }
@@ -1904,19 +1945,19 @@ ecore_dlist_mergesort(Ecore_DList *list, Ecore_Compare_Cb compare, char order)
 
    CHECK_PARAM_POINTER_RETURN("list", list, 0);
    if (list->nodes < 2)
-     return 1;
+      return 1;
 
    if (order == ECORE_SORT_MIN)
-     order = 1;
+      order = 1;
    else
-     order = -1;
+      order = -1;
 
    node = _ecore_dlist_node_mergesort(list->first, list->nodes, compare, order);
    list->first = node;
 
    /* maybe there is a better way to do that but our last node has changed */
    while (node->next)
-     node = node->next;
+      node = node->next;
    list->last = node;
 
    _ecore_list_first_goto(list);
@@ -1934,28 +1975,32 @@ ecore_dlist_mergesort(Ecore_DList *list, Ecore_Compare_Cb compare, char order)
  *                  ECORE_SORT_MAX
  */
 EAPI void
-ecore_dlist_merge(Ecore_DList *list, Ecore_DList *l2, Ecore_Compare_Cb compare, char order)
+ecore_dlist_merge(Ecore_DList *list,
+                  Ecore_DList *l2,
+                  Ecore_Compare_Cb compare,
+                  char order)
 {
    CHECK_PARAM_POINTER("list", list);
-   CHECK_PARAM_POINTER("l2", l2);
+   CHECK_PARAM_POINTER("l2",   l2);
 
-   if (ecore_dlist_empty_is(l2)) return;
+   if (ecore_dlist_empty_is(l2))
+      return;
 
    if (ecore_dlist_empty_is(list))
      {
-       ecore_dlist_append_list(list, l2);
-       return;
+        ecore_dlist_append_list(list, l2);
+        return;
      }
 
    if (order == ECORE_SORT_MIN)
-     order = 1;
+      order = 1;
    else
-     order = -1;
+      order = -1;
 
    list->first = _ecore_dlist_node_merge(list->first, l2->first, compare, order);
 
    if ((order * compare(list->last->data, l2->last->data)) < 0)
-     list->last = l2->last;
+      list->last = l2->last;
 
    list->nodes += l2->nodes;
    ecore_dlist_init(l2);
@@ -1964,38 +2009,39 @@ ecore_dlist_merge(Ecore_DList *list, Ecore_DList *l2, Ecore_Compare_Cb compare,
 /* this is the internal recrusive function for the merge sort */
 static Ecore_List_Node *
 _ecore_dlist_node_mergesort(Ecore_List_Node *first, int n,
-                           Ecore_Compare_Cb compare, int order)
+                            Ecore_Compare_Cb compare, int order)
 {
    Ecore_List_Node *middle;
    Ecore_List_Node *premid;
    int mid;
    int i;
 
-   mid = n/2;
+   mid = n / 2;
 
    if (n < 2)
-     return first;
+      return first;
    else if (n == 2)
      {
-       if (compare(first->data, first->next->data) * order > 0)
+        if (compare(first->data, first->next->data) * order > 0)
           {
-               /* swap the data */
-               void *data;
-               data = first->next->data;
-               first->next->data = first->data;
-               first->data = data;
-         }
-      return first;
-    }
+             /* swap the data */
+             void *data;
+             data = first->next->data;
+             first->next->data = first->data;
+             first->data = data;
+          }
+
+        return first;
+     }
 
    /* first find the premiddle node*/
    for (premid = first, i = 0; i < mid - 1; i++)
-     premid = premid->next;
+      premid = premid->next;
 
    /* split the list */
    middle = premid->next;
    premid->next = NULL;
-   ECORE_DLIST_NODE(middle)->previous = NULL;
+             ECORE_DLIST_NODE(middle)->previous = NULL;
 
    /* sort the the partial lists */
    first = _ecore_dlist_node_mergesort(first, mid, compare, order);
@@ -2007,7 +2053,7 @@ _ecore_dlist_node_mergesort(Ecore_List_Node *first, int n,
 /* this function is used to merge the partial sorted lists */
 static Ecore_List_Node *
 _ecore_dlist_node_merge(Ecore_List_Node *first, Ecore_List_Node *second,
-                       Ecore_Compare_Cb compare, int order)
+                        Ecore_Compare_Cb compare, int order)
 {
    Ecore_List_Node *list;
    Ecore_List_Node *l;
@@ -2016,45 +2062,45 @@ _ecore_dlist_node_merge(Ecore_List_Node *first, Ecore_List_Node *second,
     * a pointer to it */
    if (compare(first->data, second->data) * order > 0)
      {
-       list = l = second;
-       second = second->next;
+        list = l = second;
+        second = second->next;
      }
    else
      {
-       list = l = first;
-       first = first->next;
+        list = l = first;
+        first = first->next;
      }
 
    /* and now start the merging */
    while (first && second)
      {
-       if (compare(first->data, second->data) * order > 0)
-         {
-               ECORE_DLIST_NODE(second)->previous = ECORE_DLIST_NODE(l);
-               l = l->next = second;
-               second = second->next;
-         }
-       else
-         {
-               ECORE_DLIST_NODE(first)->previous = ECORE_DLIST_NODE(l);
-               l = l->next = first;
-               first = first->next;
-         }
+        if (compare(first->data, second->data) * order > 0)
+          {
+             ECORE_DLIST_NODE(second)->previous = ECORE_DLIST_NODE(l);
+             l = l->next = second;
+             second = second->next;
+          }
+        else
+          {
+             ECORE_DLIST_NODE(first)->previous = ECORE_DLIST_NODE(l);
+             l = l->next = first;
+             first = first->next;
+          }
      }
 
    /* append the rest or set it to NULL */
    if (first)
      {
-       ECORE_DLIST_NODE(first)->previous = ECORE_DLIST_NODE(l);
+             ECORE_DLIST_NODE(first)->previous = ECORE_DLIST_NODE(l);
         l->next = first;
      }
    else if (second)
      {
-       ECORE_DLIST_NODE(second)->previous = ECORE_DLIST_NODE(l);
-       l->next = second;
+             ECORE_DLIST_NODE(second)->previous = ECORE_DLIST_NODE(l);
+        l->next = second;
      }
    else
-     l->next = NULL;
+      l->next = NULL;
 
    return list;
 }
@@ -2073,7 +2119,7 @@ ecore_dlist_node_init(Ecore_DList_Node *node)
 
    ret = ecore_list_node_init(ECORE_LIST_NODE(node));
    if (ret)
-     node->previous = NULL;
+      node->previous = NULL;
 
    return ret;
 }
@@ -2090,12 +2136,12 @@ ecore_dlist_node_new()
    new_node = malloc(sizeof(Ecore_DList_Node));
 
    if (!new_node)
-     return NULL;
+      return NULL;
 
    if (!ecore_dlist_node_init(new_node))
      {
-       FREE(new_node);
-       return NULL;
+        FREE(new_node);
+        return NULL;
      }
 
    return new_node;
@@ -2108,7 +2154,7 @@ ecore_dlist_node_new()
  * @return Returns TRUE on success, FALSE on error
  */
 EAPI int
-ecore_dlist_node_destroy(Ecore_DList_Node * node, Ecore_Free_Cb free_func)
+ecore_dlist_node_destroy(Ecore_DList_Node *node, Ecore_Free_Cb free_func)
 {
    CHECK_PARAM_POINTER_RETURN("node", node, FALSE);
 
index a39d358..448be97 100644 (file)
@@ -1,7 +1,3 @@
-/*
- * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
- */
-
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
@@ -34,13 +30,14 @@ ecore_sheap_new(Ecore_Compare_Cb compare, int size)
 
    heap = (Ecore_Sheap *)malloc(sizeof(Ecore_Sheap));
    if (!heap)
-     return NULL;
+      return NULL;
+
    memset(heap, 0, sizeof(Ecore_Sheap));
 
    if (!ecore_sheap_init(heap, compare, size))
      {
-       FREE(heap);
-       return NULL;
+        FREE(heap);
+        return NULL;
      }
 
    return heap;
@@ -60,14 +57,16 @@ ecore_sheap_init(Ecore_Sheap *heap, Ecore_Compare_Cb compare, int size)
 
    heap->space = size;
    if (!compare)
-     heap->compare = ecore_direct_compare;
+      heap->compare = ecore_direct_compare;
    else
-     heap->compare = compare;
+      heap->compare = compare;
+
    heap->order = ECORE_SORT_MIN;
 
    heap->data = (void **)malloc(heap->space * sizeof(void *));
    if (!heap->data)
-     return FALSE;
+      return FALSE;
+
    memset(heap->data, 0, heap->space * sizeof(void *));
 
    return TRUE;
@@ -92,8 +91,8 @@ ecore_sheap_destroy(Ecore_Sheap *heap)
     * Free data in heap
     */
    if (heap->free_func)
-     for (i = 0; i < heap->size; i++)
-       heap->free_func(heap->data[i]);
+      for (i = 0; i < heap->size; i++)
+         heap->free_func(heap->data[i]);
 
    FREE(heap->data);
 
@@ -139,7 +138,7 @@ ecore_sheap_insert(Ecore_Sheap *heap, void *data)
     * space available to add this data
     */
    if (heap->size >= heap->space)
-     return FALSE;
+      return FALSE;
 
    heap->sorted = FALSE;
 
@@ -159,53 +158,49 @@ ecore_sheap_insert(Ecore_Sheap *heap, void *data)
     * number of branching decisions that must be predicted.
     */
    if (heap->order == ECORE_SORT_MIN)
-     {
-       while ((position > 0) && heap->compare(heap->data[parent],
-                                              heap->data[position]) > 0)
-         {
-
-            /*
-             * Swap the data with it's parents to move it up in
-             * the heap.
-             */
-            temp = heap->data[position];
-            heap->data[position] = heap->data[parent];
-            heap->data[parent] = temp;
-
-            /*
-             * Now determine the new position for the next
-             * iteration of the loop, as well as it's parents
-             * position.
-             */
-            i = PARENT(i);
-            position = i - 1;
-            parent = PARENT(i) - 1;
-         }
-     }
+      while ((position > 0) && heap->compare(heap->data[parent],
+                                             heap->data[position]) > 0)
+        {
+
+           /*
+            * Swap the data with it's parents to move it up in
+            * the heap.
+            */
+           temp = heap->data[position];
+           heap->data[position] = heap->data[parent];
+           heap->data[parent] = temp;
+
+           /*
+            * Now determine the new position for the next
+            * iteration of the loop, as well as it's parents
+            * position.
+            */
+           i = PARENT(i);
+           position = i - 1;
+           parent = PARENT(i) - 1;
+        }
    else
-     {
-       while ((position > 0) && heap->compare(heap->data[parent],
-                                              heap->data[position]) < 0)
-         {
-
-            /*
-             * Swap the data with it's parents to move it up in
-             * the heap.
-             */
-            temp = heap->data[position];
-            heap->data[position] = heap->data[PARENT(i) - 1];
-            heap->data[PARENT(i) - 1] = temp;
-
-            /*
-             * Now determine the new position for the next
-             * iteration of the loop, as well as it's parents
-             * position.
-             */
-            i = PARENT(i);
-            position = i - 1;
-            parent = PARENT(i) - 1;
-         }
-     }
+      while ((position > 0) && heap->compare(heap->data[parent],
+                                             heap->data[position]) < 0)
+        {
+
+           /*
+            * Swap the data with it's parents to move it up in
+            * the heap.
+            */
+           temp = heap->data[position];
+           heap->data[position] = heap->data[PARENT(i) - 1];
+           heap->data[PARENT(i) - 1] = temp;
+
+           /*
+            * Now determine the new position for the next
+            * iteration of the loop, as well as it's parents
+            * position.
+            */
+           i = PARENT(i);
+           position = i - 1;
+           parent = PARENT(i) - 1;
+        }
 
    return TRUE;
 }
@@ -223,7 +218,7 @@ ecore_sheap_extract(Ecore_Sheap *heap)
    void *extreme;
 
    if (heap->size < 1)
-     return NULL;
+      return NULL;
 
    heap->sorted = FALSE;
 
@@ -246,7 +241,7 @@ EAPI void *
 ecore_sheap_extreme(Ecore_Sheap *heap)
 {
    if (heap->size < 1)
-     return NULL;
+      return NULL;
 
    return heap->data[0];
 }
@@ -267,12 +262,12 @@ ecore_sheap_change(Ecore_Sheap *heap, void *item, void *newval)
 
    CHECK_PARAM_POINTER_RETURN("heap", heap, FALSE);
 
-   for (i = 0; i < heap->size && heap->compare(heap->data[i], item); i++);
+   for (i = 0; i < heap->size && heap->compare(heap->data[i], item); i++) ;
 
    if (i < heap->size)
-     heap->data[i] = newval;
+      heap->data[i] = newval;
    else
-     return FALSE;
+      return FALSE;
 
    /*
     * FIXME: This is not the correct procedure when a change occurs.
@@ -297,9 +292,9 @@ ecore_sheap_compare_set(Ecore_Sheap *heap, Ecore_Compare_Cb compare)
    CHECK_PARAM_POINTER_RETURN("heap", heap, FALSE);
 
    if (!compare)
-     heap->compare = ecore_direct_compare;
+      heap->compare = ecore_direct_compare;
    else
-     heap->compare = compare;
+      heap->compare = compare;
 
    _ecore_sheap_update_data(heap);
 
@@ -345,7 +340,7 @@ ecore_sheap_sort(Ecore_Sheap *heap)
     * Extract the heap and insert into the new data array in order.
     */
    while (heap->size > 0)
-     new_data[i++] = ecore_sheap_extract(heap);
+      new_data[i++] = ecore_sheap_extract(heap);
 
    /*
     * Free the old data array and update the heap with the new data, also
@@ -369,13 +364,13 @@ EAPI inline void *
 ecore_sheap_item(Ecore_Sheap *heap, int i)
 {
    if (i >= heap->size)
-     return NULL;
+      return NULL;
 
    /*
     * Make sure the data is sorted so we return the correct value.
     */
    if (!heap->sorted)
-     ecore_sheap_sort(heap);
+      ecore_sheap_sort(heap);
 
    return heap->data[i];
 }
@@ -394,27 +389,27 @@ _ecore_sheap_heapify(Ecore_Sheap *heap, int i)
 
    if (heap->order == ECORE_SORT_MIN)
      {
-       if (left <= heap->size && heap->compare(heap->data[left - 1],
-                                               heap->data[i - 1]) < 0)
-         extreme = left;
-       else
-         extreme = i;
-
-       if (right <= heap->size && heap->compare(heap->data[right - 1],
-                                                heap->data[extreme - 1]) < 0)
-         extreme = right;
+        if (left <= heap->size && heap->compare(heap->data[left - 1],
+                                                heap->data[i - 1]) < 0)
+           extreme = left;
+        else
+           extreme = i;
+
+        if (right <= heap->size && heap->compare(heap->data[right - 1],
+                                                 heap->data[extreme - 1]) < 0)
+           extreme = right;
      }
    else
      {
-       if (left <= heap->size && heap->compare(heap->data[left - 1],
-                                               heap->data[i - 1]) > 0)
-         extreme = left;
-       else
-         extreme = i;
-
-       if (right <= heap->size && heap->compare(heap->data[right - 1],
-                                                heap->data[extreme - 1]) > 0)
-         extreme = right;
+        if (left <= heap->size && heap->compare(heap->data[left - 1],
+                                                heap->data[i - 1]) > 0)
+           extreme = left;
+        else
+           extreme = i;
+
+        if (right <= heap->size && heap->compare(heap->data[right - 1],
+                                                 heap->data[extreme - 1]) > 0)
+           extreme = right;
      }
 
    /*
@@ -423,13 +418,13 @@ _ecore_sheap_heapify(Ecore_Sheap *heap, int i)
     */
    if (extreme != i)
      {
-       void *temp;
+        void *temp;
 
-       temp = heap->data[extreme - 1];
-       heap->data[extreme - 1] = heap->data[i - 1];
-       heap->data[i - 1] = temp;
+        temp = heap->data[extreme - 1];
+        heap->data[extreme - 1] = heap->data[i - 1];
+        heap->data[i - 1] = temp;
 
-       _ecore_sheap_heapify(heap, extreme);
+        _ecore_sheap_heapify(heap, extreme);
      }
 }
 
@@ -449,7 +444,7 @@ _ecore_sheap_update_data(Ecore_Sheap *heap)
    heap->data = malloc(heap->space * sizeof(void *));
 
    for (i = 0; i < old_size; i++)
-     ecore_sheap_insert(heap, data[i]);
+      ecore_sheap_insert(heap, data[i]);
 
    FREE(data);
 }
@@ -459,14 +454,14 @@ ecore_direct_compare(const void *key1, const void *key2)
 {
    unsigned long k1, k2;
 
-   k1 = (unsigned long) key1;
-   k2 = (unsigned long) key2;
+   k1 = (unsigned long)key1;
+   k2 = (unsigned long)key2;
 
    if (k1 > k2)
-     return 1;
+      return 1;
 
    if (k1 < k2)
-     return -1;
+      return -1;
 
    return 0;
 }
index 7395e00..d76e4c5 100644 (file)
@@ -41,11 +41,13 @@ ecore_string_init()
     */
    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_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;
@@ -72,21 +74,22 @@ ecore_string_instance(const char *string)
    str = ecore_hash_get(ecore_strings, string);
    if (!str)
      {
-       int length;
+        int length;
 
-       /*
-        * Allocate and initialize a new string reference.
-        */
-       length = strlen(string) + 1;
+        /*
+         * Allocate and initialize a new string reference.
+         */
+        length = strlen(string) + 1;
 
-       str = (Ecore_String *)malloc(sizeof(Ecore_String) + length * sizeof(char));
+        str =
+           (Ecore_String *)malloc(sizeof(Ecore_String) + length * sizeof(char));
 
-       str->string = (char*)(str + 1);
-       str->references = 0;
+        str->string = (char *)(str + 1);
+        str->references = 0;
 
-       memcpy(str->string, string, length);
+        memcpy(str->string, string, length);
 
-       ecore_hash_set(ecore_strings, str->string, str);
+        ecore_hash_set(ecore_strings, str->string, str);
      }
 
    str->references++;
@@ -111,26 +114,26 @@ ecore_string_release(const char *string)
 
    str = ecore_hash_get(ecore_strings, (char *)string);
    if (!str)
-     return;
+      return;
 
    str->references--;
    if (str->references < 1)
      {
-       ecore_hash_remove(ecore_strings, (char *)string);
-       FREE(str);
+        ecore_hash_remove(ecore_strings, (char *)string);
+        FREE(str);
      }
 }
 
 EAPI void
 ecore_string_hash_dump_graph(void)
 {
-       ecore_hash_dump_graph(ecore_strings);
+   ecore_hash_dump_graph(ecore_strings);
 }
 
 EAPI void
 ecore_string_hash_dump_stats(void)
 {
-       ecore_hash_dump_stats(ecore_strings);
+   ecore_hash_dump_stats(ecore_strings);
 }
 
 /**
@@ -142,8 +145,8 @@ ecore_string_shutdown()
    --ecore_string_init_count;
    if (!ecore_string_init_count)
      {
-       ecore_hash_destroy(ecore_strings);
-       ecore_strings = NULL;
+        ecore_hash_destroy(ecore_strings);
+        ecore_strings = NULL;
      }
 }
 
index 4479f8f..e971873 100644 (file)
@@ -35,15 +35,15 @@ struct _Eina_Benchmark_Case
 };
 
 static const Eina_Benchmark_Case etc[] = {
-  /* { "Hash", eina_bench_hash }, */
-  /* { "Array vs List vs Inlist", eina_bench_array }, */
-  /* { "Stringshare", eina_bench_stringshare }, */
-  /* { "Convert", eina_bench_convert }, */
-  /* { "Sort", eina_bench_sort }, */
-  /* { "Mempool", eina_bench_mempool }, */
-  /* { "Rectangle_Pool", eina_bench_rectangle_pool }, */
-  { "Render Loop", eina_bench_quadtree },
-  { NULL, NULL }
+   /* { "Hash", eina_bench_hash }, */
+   /* { "Array vs List vs Inlist", eina_bench_array }, */
+   /* { "Stringshare", eina_bench_stringshare }, */
+   /* { "Convert", eina_bench_convert }, */
+   /* { "Sort", eina_bench_sort }, */
+   /* { "Mempool", eina_bench_mempool }, */
+   /* { "Rectangle_Pool", eina_bench_rectangle_pool }, */
+   { "Render Loop", eina_bench_quadtree },
+   { NULL, NULL }
 };
 
 /* FIXME this is a copy from eina_test_mempool
@@ -52,10 +52,14 @@ static const Eina_Benchmark_Case etc[] = {
 static Eina_Array *_modules;
 static void _mempool_init(void)
 {
-    eina_init();
-    /* force modules to be loaded in case they are not installed */
-    _modules = eina_module_list_get(NULL, PACKAGE_BUILD_DIR"/src/modules", 1, NULL, NULL);
-    eina_module_list_load(_modules);
+   eina_init();
+   /* force modules to be loaded in case they are not installed */
+   _modules = eina_module_list_get(NULL,
+                                   PACKAGE_BUILD_DIR "/src/modules",
+                                   1,
+                                   NULL,
+                                   NULL);
+   eina_module_list_load(_modules);
 }
 
 static void _mempool_shutdown(void)
@@ -72,7 +76,8 @@ main(int argc, char **argv)
    Eina_Array *ea;
    unsigned int i;
 
-   if (argc != 2) return -1;
+   if (argc != 2)
+      return -1;
 
    _mempool_init();
 
@@ -80,14 +85,15 @@ main(int argc, char **argv)
 
    for (i = 0; etc[i].bench_case != NULL; ++i)
      {
-       test = eina_benchmark_new(etc[i].bench_case, argv[1]);
-       if (!test) continue ;
+        test = eina_benchmark_new(etc[i].bench_case, argv[1]);
+        if (!test)
+           continue;
 
-       etc[i].build(test);
+        etc[i].build(test);
 
-       ea = eina_benchmark_run(test);
+        ea = eina_benchmark_run(test);
 
-       eina_benchmark_free(test);
+        eina_benchmark_free(test);
      }
 
    eina_bench_e17();
index 8ff134e..90667bb 100644 (file)
@@ -51,7 +51,9 @@ static Eina_Bool keep(void *data, __UNUSED__ void *gdata)
 {
    Eina_Bench_Object *bo = data;
 
-   if (bo->keep == EINA_TRUE) return EINA_TRUE;
+   if (bo->keep == EINA_TRUE)
+      return EINA_TRUE;
+
    free(bo);
    return EINA_FALSE;
 }
@@ -73,31 +75,36 @@ eina_bench_array_4evas_render_inline(int request)
 
    for (i = 0; i < 1000; ++i)
      {
-       for (j = 0; j < (unsigned int) request; ++j)
-         {
-            ebo = malloc(sizeof (Eina_Bench_Object));
-            if (!ebo) continue ;
-
-            ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
-
-            eina_array_push(array, ebo);
-         }
-
-       if (i == 500)
-         {
-            EINA_ARRAY_ITER_NEXT(array, j, ebo, it)
-              free(ebo);
-
-            eina_array_clean(array);
-         }
-       else if (i % 30 == 0) eina_array_remove(array, keep, NULL);
-
-       EINA_ARRAY_ITER_NEXT(array, j, ebo, it)
-         ebo->keep = rand() < (RAND_MAX / 2) ? ebo->keep : EINA_FALSE;
+        for (j = 0; j < (unsigned int)request; ++j)
+          {
+             ebo = malloc(sizeof (Eina_Bench_Object));
+             if (!ebo)
+                continue;
+
+             ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
+
+             eina_array_push(array, ebo);
+          }
+
+        if (i == 500)
+          {
+             EINA_ARRAY_THREADSAFE_ITER_NEXT(array, j, ebo, it,
+               free(ebo);
+             );
+
+             eina_array_clean(array);
+          }
+        else if (i % 30 == 0)
+           eina_array_remove(array, keep, NULL);
+
+        EINA_ARRAY_THREADSAFE_ITER_NEXT(array, j, ebo, it,
+          ebo->keep = rand() < (RAND_MAX / 2) ? ebo->keep : EINA_FALSE;
+        );
      }
 
-   EINA_ARRAY_ITER_NEXT(array, j, ebo, it)
-     free(ebo);
+        EINA_ARRAY_THREADSAFE_ITER_NEXT(array, j, ebo, it,
+          free(ebo);
+        );
 
    eina_array_free(array);
 
@@ -106,7 +113,7 @@ eina_bench_array_4evas_render_inline(int request)
 
 static Eina_Bool
 eina_iterator_ebo_free(__UNUSED__ const Eina_Array *array,
-                      Eina_Bench_Object *ebo,  __UNUSED__ void *fdata)
+                       Eina_Bench_Object *ebo,  __UNUSED__ void *fdata)
 {
    free(ebo);
    return EINA_TRUE;
@@ -114,7 +121,7 @@ eina_iterator_ebo_free(__UNUSED__ const Eina_Array *array,
 
 static Eina_Bool
 eina_iterator_ebo_rand(__UNUSED__ const void *container,
-                      Eina_Bench_Object *ebo,  __UNUSED__ void *fdata)
+                       Eina_Bench_Object *ebo,  __UNUSED__ void *fdata)
 {
    ebo->keep = rand() < (RAND_MAX / 2) ? ebo->keep : EINA_FALSE;
    return EINA_TRUE;
@@ -137,33 +144,35 @@ eina_bench_array_4evas_render_iterator(int request)
 
    for (i = 0; i < 1000; ++i)
      {
-       for (j = 0; j < (unsigned int) request; ++j)
-         {
-            ebo = malloc(sizeof (Eina_Bench_Object));
-            if (!ebo) continue ;
-
-            ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
-
-            eina_array_push(array, ebo);
-         }
-
-       if (i == 500)
-         {
-            it = eina_array_iterator_new(array);
-            eina_iterator_foreach(it, EINA_EACH(eina_iterator_ebo_free), NULL);
-            eina_iterator_free(it);
-
-            eina_array_clean(array);
-         }
-       else if (i % 30 == 0) eina_array_remove(array, keep, NULL);
-
-       it = eina_array_iterator_new(array);
-       eina_iterator_foreach(it, EINA_EACH(eina_iterator_ebo_rand), NULL);
-       eina_iterator_free(it);
+        for (j = 0; j < (unsigned int)request; ++j)
+          {
+             ebo = malloc(sizeof (Eina_Bench_Object));
+             if (!ebo)
+                continue;
+
+             ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
+
+             eina_array_push(array, ebo);
+          }
+
+        if (i == 500)
+          {
+             it = eina_array_iterator_new(array);
+             eina_iterator_foreach(it, EINA_EACH_CB(eina_iterator_ebo_free), NULL);
+             eina_iterator_free(it);
+
+             eina_array_clean(array);
+          }
+        else if (i % 30 == 0)
+           eina_array_remove(array, keep, NULL);
+
+        it = eina_array_iterator_new(array);
+        eina_iterator_foreach(it, EINA_EACH_CB(eina_iterator_ebo_rand), NULL);
+        eina_iterator_free(it);
      }
 
    it = eina_array_iterator_new(array);
-   eina_iterator_foreach(it, EINA_EACH(eina_iterator_ebo_free), NULL);
+   eina_iterator_foreach(it, EINA_EACH_CB(eina_iterator_ebo_free), NULL);
    eina_iterator_free(it);
 
    eina_array_free(array);
@@ -184,57 +193,53 @@ eina_bench_list_4evas_render(int request)
 
    for (i = 0; i < 1000; ++i)
      {
-       for (j = 0; j < request; ++j)
-         {
-            ebo = malloc(sizeof (Eina_Bench_Object));
-            if (!ebo) continue ;
-
-            ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
-
-            list = eina_list_prepend(list, ebo);
-         }
-
-       if (i == 500)
-         {
-            while (list)
-              {
-                 free(eina_list_data_get(list));
-                 list = eina_list_remove_list(list, list);
-              }
-         }
-       else
-         {
-            if (i % 30 == 0)
-              {
-                 tmp = list;
-                 while (tmp)
-                   {
-                      Eina_List *reminder = tmp;
-
-                      ebo = eina_list_data_get(reminder);
-                      tmp = eina_list_next(tmp);
-
-                      if (ebo->keep == EINA_FALSE)
-                        {
-                           list = eina_list_remove_list(list, reminder);
-                           free(ebo);
-                        }
-                   }
-              }
-         }
-
-       for (tmp = list; tmp; tmp = eina_list_next(tmp))
-         {
-            ebo = eina_list_data_get(tmp);
-
-            ebo->keep = rand() < (RAND_MAX / 2) ? ebo->keep : EINA_FALSE;
-         }
+        for (j = 0; j < request; ++j)
+          {
+             ebo = malloc(sizeof (Eina_Bench_Object));
+             if (!ebo)
+                continue;
+
+             ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
+
+             list = eina_list_prepend(list, ebo);
+          }
+
+        if (i == 500)
+           while (list)
+             {
+                       free(eina_list_data_get(list));
+                list = eina_list_remove_list(list, list);
+             }
+        else if (i % 30 == 0)
+          {
+             tmp = list;
+             while (tmp)
+               {
+                  Eina_List *reminder = tmp;
+
+                  ebo = eina_list_data_get(reminder);
+                  tmp = eina_list_next(tmp);
+
+                  if (ebo->keep == EINA_FALSE)
+                    {
+                       list = eina_list_remove_list(list, reminder);
+                       free(ebo);
+                    }
+               }
+          }
+
+        for (tmp = list; tmp; tmp = eina_list_next(tmp))
+          {
+             ebo = eina_list_data_get(tmp);
+
+             ebo->keep = rand() < (RAND_MAX / 2) ? ebo->keep : EINA_FALSE;
+          }
      }
 
    while (list)
      {
-       free(eina_list_data_get(list));
-       list = eina_list_remove_list(list, list);
+                       free(eina_list_data_get(list));
+        list = eina_list_remove_list(list, list);
      }
 
    eina_shutdown();
@@ -254,54 +259,50 @@ eina_bench_list_4evas_render_iterator(int request)
 
    for (i = 0; i < 1000; ++i)
      {
-       for (j = 0; j < request; ++j)
-         {
-            ebo = malloc(sizeof (Eina_Bench_Object));
-            if (!ebo) continue ;
-
-            ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
-
-            list = eina_list_prepend(list, ebo);
-         }
-
-       if (i == 500)
-         {
-            while (list)
-              {
-                 free(eina_list_data_get(list));
-                 list = eina_list_remove_list(list, list);
-              }
-         }
-       else
-         {
-            if (i % 30 == 0)
-              {
-                 tmp = list;
-                 while (tmp)
-                   {
-                      Eina_List *reminder = tmp;
-
-                      ebo = eina_list_data_get(reminder);
-                      tmp = eina_list_next(tmp);
-
-                      if (ebo->keep == EINA_FALSE)
-                        {
-                           list = eina_list_remove_list(list, reminder);
-                           free(ebo);
-                        }
-                   }
-              }
-         }
-
-       it = eina_list_iterator_new(list);
-       eina_iterator_foreach(it, EINA_EACH(eina_iterator_ebo_rand), NULL);
-       eina_iterator_free(it);
+        for (j = 0; j < request; ++j)
+          {
+             ebo = malloc(sizeof (Eina_Bench_Object));
+             if (!ebo)
+                continue;
+
+             ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
+
+             list = eina_list_prepend(list, ebo);
+          }
+
+        if (i == 500)
+           while (list)
+             {
+                       free(eina_list_data_get(list));
+                list = eina_list_remove_list(list, list);
+             }
+        else if (i % 30 == 0)
+          {
+             tmp = list;
+             while (tmp)
+               {
+                  Eina_List *reminder = tmp;
+
+                  ebo = eina_list_data_get(reminder);
+                  tmp = eina_list_next(tmp);
+
+                  if (ebo->keep == EINA_FALSE)
+                    {
+                       list = eina_list_remove_list(list, reminder);
+                       free(ebo);
+                    }
+               }
+          }
+
+        it = eina_list_iterator_new(list);
+        eina_iterator_foreach(it, EINA_EACH_CB(eina_iterator_ebo_rand), NULL);
+        eina_iterator_free(it);
      }
 
    while (list)
      {
-       free(eina_list_data_get(list));
-       list = eina_list_remove_list(list, list);
+        free(eina_list_data_get(list));
+        list = eina_list_remove_list(list, list);
      }
 
    eina_shutdown();
@@ -318,53 +319,49 @@ eina_bench_inlist_4evas_render(int request)
 
    for (i = 0; i < 1000; ++i)
      {
-       for (j = 0; j < request; ++j)
-         {
-            ebo = malloc(sizeof (Eina_Bench_Object));
-            if (!ebo) continue ;
-
-            ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
-
-            head = eina_inlist_prepend(head, EINA_INLIST_GET(ebo));
-         }
-
-       if (i == 500)
-         {
-            while (head)
-              {
-                 tmp = head;
-                 head = head->next;
-                 free(tmp);
-              }
-         }
-       else
-         {
-            if (i % 30 == 0)
-              {
-                 tmp = head;
-                 while(tmp)
-                   {
-                      ebo = (Eina_Bench_Object *) tmp;
-
-                      tmp = tmp->next;
-                      if (ebo->keep == EINA_FALSE)
-                        {
-                           head = eina_inlist_remove(head, EINA_INLIST_GET(ebo));
-                           free(ebo);
-                        }
-                   }
-              }
-         }
-
-       EINA_INLIST_FOREACH(head, ebo)
-         ebo->keep = rand() < (RAND_MAX / 2) ? ebo->keep : EINA_FALSE;
+        for (j = 0; j < request; ++j)
+          {
+             ebo = malloc(sizeof (Eina_Bench_Object));
+             if (!ebo)
+                continue;
+
+             ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
+
+             head = eina_inlist_prepend(head, EINA_INLIST_GET(ebo));
+          }
+
+        if (i == 500)
+           while (head)
+             {
+                tmp = head;
+                head = head->next;
+                       free(tmp);
+             }
+        else if (i % 30 == 0)
+          {
+             tmp = head;
+             while(tmp)
+               {
+                  ebo = (Eina_Bench_Object *)tmp;
+
+                  tmp = tmp->next;
+                  if (ebo->keep == EINA_FALSE)
+                    {
+                       head = eina_inlist_remove(head, EINA_INLIST_GET(ebo));
+                       free(ebo);
+                    }
+               }
+          }
+
+        EINA_INLIST_FOREACH(head, ebo)
+        ebo->keep = rand() < (RAND_MAX / 2) ? ebo->keep : EINA_FALSE;
      }
 
    while (head)
      {
-       tmp = head;
-       head = head->next;
-       free(tmp);
+        tmp = head;
+        head = head->next;
+                       free(tmp);
      }
 }
 
@@ -380,54 +377,50 @@ eina_bench_inlist_4evas_render_iterator(int request)
 
    for (i = 0; i < 1000; ++i)
      {
-       for (j = 0; j < request; ++j)
-         {
-            ebo = malloc(sizeof (Eina_Bench_Object));
-            if (!ebo) continue ;
-
-            ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
-
-            head = eina_inlist_prepend(head, EINA_INLIST_GET(ebo));
-         }
-
-       if (i == 500)
-         {
-            while (head)
-              {
-                 tmp = head;
-                 head = head->next;
-                 free(tmp);
-              }
-         }
-       else
-         {
-            if (i % 30 == 0)
-              {
-                 tmp = head;
-                 while(tmp)
-                   {
-                      ebo = (Eina_Bench_Object *) tmp;
-
-                      tmp = tmp->next;
-                      if (ebo->keep == EINA_FALSE)
-                        {
-                           head = eina_inlist_remove(head, EINA_INLIST_GET(ebo));
-                           free(ebo);
-                        }
-                   }
-              }
-         }
-
-       it = eina_inlist_iterator_new(head);
-       eina_iterator_foreach(it, EINA_EACH(eina_iterator_ebo_rand), NULL);
-       eina_iterator_free(it);
+        for (j = 0; j < request; ++j)
+          {
+             ebo = malloc(sizeof (Eina_Bench_Object));
+             if (!ebo)
+                continue;
+
+             ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
+
+             head = eina_inlist_prepend(head, EINA_INLIST_GET(ebo));
+          }
+
+        if (i == 500)
+           while (head)
+             {
+                tmp = head;
+                head = head->next;
+                       free(tmp);
+             }
+        else if (i % 30 == 0)
+          {
+             tmp = head;
+             while(tmp)
+               {
+                  ebo = (Eina_Bench_Object *)tmp;
+
+                  tmp = tmp->next;
+                  if (ebo->keep == EINA_FALSE)
+                    {
+                       head = eina_inlist_remove(head, EINA_INLIST_GET(ebo));
+                       free(ebo);
+                    }
+               }
+          }
+
+        it = eina_inlist_iterator_new(head);
+        eina_iterator_foreach(it, EINA_EACH_CB(eina_iterator_ebo_rand), NULL);
+        eina_iterator_free(it);
      }
 
    while (head)
      {
-       tmp = head;
-       head = head->next;
-       free(tmp);
+        tmp = head;
+        head = head->next;
+                       free(tmp);
      }
 }
 
@@ -443,57 +436,53 @@ eina_bench_glist_4evas_render(int request)
 
    for (i = 0; i < 1000; ++i)
      {
-       for (j = 0; j < request; ++j)
-         {
-            ebo = malloc(sizeof (Eina_Bench_Object));
-            if (!ebo) continue ;
-
-            ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
-
-            list = g_list_prepend(list, ebo);
-         }
-
-       if (i == 500)
-         {
-            while (list)
-              {
-                 free(list->data);
-                 list = g_list_delete_link(list, list);
-              }
-         }
-       else
-         {
-            if (i % 30 == 0)
-              {
-                 tmp = list;
-                 while (tmp)
-                   {
-                      GList *reminder = tmp;
-
-                      ebo = reminder->data;
-                      tmp = g_list_next(tmp);
-
-                      if (ebo->keep == EINA_FALSE)
-                        {
-                           list = g_list_delete_link(list, reminder);
-                           free(ebo);
-                        }
-                   }
-              }
-         }
-
-       for (tmp = list; tmp; tmp = g_list_next(tmp))
-         {
-            ebo = tmp->data;
-
-            ebo->keep = rand() < (RAND_MAX / 2) ? ebo->keep : EINA_FALSE;
-         }
+        for (j = 0; j < request; ++j)
+          {
+             ebo = malloc(sizeof (Eina_Bench_Object));
+             if (!ebo)
+                continue;
+
+             ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
+
+             list = g_list_prepend(list, ebo);
+          }
+
+        if (i == 500)
+           while (list)
+             {
+                       free(list->data);
+                list = g_list_delete_link(list, list);
+             }
+        else if (i % 30 == 0)
+          {
+             tmp = list;
+             while (tmp)
+               {
+                  GList *reminder = tmp;
+
+                  ebo = reminder->data;
+                  tmp = g_list_next(tmp);
+
+                  if (ebo->keep == EINA_FALSE)
+                    {
+                       list = g_list_delete_link(list, reminder);
+                       free(ebo);
+                    }
+               }
+          }
+
+        for (tmp = list; tmp; tmp = g_list_next(tmp))
+          {
+             ebo = tmp->data;
+
+             ebo->keep = rand() < (RAND_MAX / 2) ? ebo->keep : EINA_FALSE;
+          }
      }
 
    while (list)
      {
-       free(list->data);
-       list = g_list_delete_link(list, list);
+                       free(list->data);
+        list = g_list_delete_link(list, list);
      }
 }
 
@@ -509,49 +498,45 @@ eina_bench_gptrarray_4evas_render(int request)
 
    for (i = 0; i < 1000; ++i)
      {
-       for (j = 0; j < (unsigned int) request; ++j)
-         {
-            ebo = malloc(sizeof (Eina_Bench_Object));
-            if (!ebo) continue ;
-
-            ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
-
-            g_ptr_array_add(array, ebo);
-         }
-
-       if (i == 500)
-         {
-            for (j = 0; j < array->len; ++j)
-              free(g_ptr_array_index(array, j));
-            g_ptr_array_remove_range(array, 0, array->len);
-         }
-       else
-         {
-            if (i % 30 == 0)
-              {
-                 for (j = 0; j < array->len; )
-                   {
-                      ebo = g_ptr_array_index(array, j);
-
-                      if (ebo->keep == EINA_FALSE)
-                        free(g_ptr_array_remove_index_fast(array, j));
-                      else
-                        j++;
-                   }
-              }
-         }
-
-       for (j = 0; j < array->len; ++j)
-         {
-            ebo = g_ptr_array_index(array, j);
-
-            ebo->keep = rand() < (RAND_MAX / 2) ? ebo->keep : EINA_FALSE;
-         }
+        for (j = 0; j < (unsigned int)request; ++j)
+          {
+             ebo = malloc(sizeof (Eina_Bench_Object));
+             if (!ebo)
+                continue;
+
+             ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
+
+             g_ptr_array_add(array, ebo);
+          }
+
+        if (i == 500)
+          {
+             for (j = 0; j < array->len; ++j)
+                free(g_ptr_array_index(array, j));
+             g_ptr_array_remove_range(array, 0, array->len);
+          }
+        else if (i % 30 == 0)
+           for (j = 0; j < array->len; )
+             {
+                ebo = g_ptr_array_index(array, j);
+
+                if (ebo->keep == EINA_FALSE)
+                   free(g_ptr_array_remove_index_fast(array, j));
+                else
+                   j++;
+             }
+
+        for (j = 0; j < array->len; ++j)
+          {
+             ebo = g_ptr_array_index(array, j);
+
+             ebo->keep = rand() < (RAND_MAX / 2) ? ebo->keep : EINA_FALSE;
+          }
      }
 
    for (j = 0; j < array->len; ++j)
-     free(g_ptr_array_index(array, j));
-   g_ptr_array_free(array, TRUE);
+                   free(g_ptr_array_index(array, j));
+                   g_ptr_array_free(array, TRUE);
 }
 #endif
 
@@ -566,57 +551,53 @@ eina_bench_evas_list_4evas_render(int request)
 
    for (i = 0; i < 1000; ++i)
      {
-       for (j = 0; j < request; ++j)
-         {
-            ebo = malloc(sizeof (Eina_Bench_Object));
-            if (!ebo) continue ;
-
-            ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
-
-            list = evas_list_prepend(list, ebo);
-         }
-
-       if (i == 500)
-         {
-            while (list)
-              {
-                 free(evas_list_data(list));
-                 list = evas_list_remove_list(list, list);
-              }
-         }
-       else
-         {
-            if (i % 30 == 0)
-              {
-                 tmp = list;
-                 while (tmp)
-                   {
-                      Evas_List *reminder = tmp;
-
-                      ebo = evas_list_data(reminder);
-                      tmp = evas_list_next(tmp);
-
-                      if (ebo->keep == EINA_FALSE)
-                        {
-                           list = evas_list_remove_list(list, reminder);
-                           free(ebo);
-                        }
-                   }
-              }
-         }
-
-       for (tmp = list; tmp; tmp = evas_list_next(tmp))
-         {
-            ebo = evas_list_data(tmp);
-
-            ebo->keep = rand() < (RAND_MAX / 2) ? ebo->keep : EINA_FALSE;
-         }
+        for (j = 0; j < request; ++j)
+          {
+             ebo = malloc(sizeof (Eina_Bench_Object));
+             if (!ebo)
+                continue;
+
+             ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
+
+             list = evas_list_prepend(list, ebo);
+          }
+
+        if (i == 500)
+           while (list)
+             {
+                       free(evas_list_data(list));
+                list = evas_list_remove_list(list, list);
+             }
+        else if (i % 30 == 0)
+          {
+             tmp = list;
+             while (tmp)
+               {
+                  Evas_List *reminder = tmp;
+
+                  ebo = evas_list_data(reminder);
+                  tmp = evas_list_next(tmp);
+
+                  if (ebo->keep == EINA_FALSE)
+                    {
+                       list = evas_list_remove_list(list, reminder);
+                       free(ebo);
+                    }
+               }
+          }
+
+        for (tmp = list; tmp; tmp = evas_list_next(tmp))
+          {
+             ebo = evas_list_data(tmp);
+
+             ebo->keep = rand() < (RAND_MAX / 2) ? ebo->keep : EINA_FALSE;
+          }
      }
 
    while (list)
      {
-       free(evas_list_data(list));
-       list = evas_list_remove_list(list, list);
+                       free(evas_list_data(list));
+        list = evas_list_remove_list(list, list);
      }
 }
 
@@ -627,7 +608,7 @@ _eina_ecore_for_each_remove(void *value, void *user_data)
    Ecore_List *list = user_data;
 
    if (ebo->keep == EINA_FALSE)
-     ecore_list_remove_destroy(list);
+      ecore_list_remove_destroy(list);
 }
 
 static void
@@ -651,47 +632,71 @@ eina_bench_ecore_list_4evas_render(int request)
 
    for (i = 0; i < 1000; ++i)
      {
-       for (j = 0; j < request; ++j)
-         {
-            ebo = malloc(sizeof (Eina_Bench_Object));
-            if (!ebo) continue ;
-
-            ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
-
-            ecore_list_prepend(list, ebo);
-         }
-
-       if (i == 500)
-         {
-            ecore_list_clear(list);
-         }
-       else
-         {
-            if (i % 30 == 0)
-              {
-                 ecore_list_for_each(list, _eina_ecore_for_each_remove, list);
-              }
-         }
-
-       ecore_list_for_each(list, _eina_ecore_for_each_rand, list);
+        for (j = 0; j < request; ++j)
+          {
+             ebo = malloc(sizeof (Eina_Bench_Object));
+             if (!ebo)
+                continue;
+
+             ebo->keep = rand() < (RAND_MAX / 2) ? EINA_TRUE : EINA_FALSE;
+
+             ecore_list_prepend(list, ebo);
+          }
+
+        if (i == 500)
+           ecore_list_clear(list);
+        else if (i % 30 == 0)
+           ecore_list_for_each(list, _eina_ecore_for_each_remove, list);
+
+           ecore_list_for_each(list, _eina_ecore_for_each_rand,   list);
      }
 
-   ecore_list_destroy(list);
+           ecore_list_destroy(list);
 }
 
 void eina_bench_array(Eina_Benchmark *bench)
 {
-   eina_benchmark_register(bench, "array-inline", EINA_BENCHMARK(eina_bench_array_4evas_render_inline), 200, 4000, 100);
-   eina_benchmark_register(bench, "array-iterator", EINA_BENCHMARK(eina_bench_array_4evas_render_iterator), 200, 4000, 100);
-   eina_benchmark_register(bench, "list", EINA_BENCHMARK(eina_bench_list_4evas_render), 200, 4000, 100);
-   eina_benchmark_register(bench, "list-iterator", EINA_BENCHMARK(eina_bench_list_4evas_render_iterator), 200, 4000, 100);
-   eina_benchmark_register(bench, "inlist", EINA_BENCHMARK(eina_bench_inlist_4evas_render), 200, 4000, 100);
-   eina_benchmark_register(bench, "inlist-iterator", EINA_BENCHMARK(eina_bench_inlist_4evas_render_iterator), 200, 4000, 100);
+   eina_benchmark_register(bench, "array-inline",
+                           EINA_BENCHMARK(
+                              eina_bench_array_4evas_render_inline),    200,
+                           4000, 100);
+   eina_benchmark_register(bench, "array-iterator",
+                           EINA_BENCHMARK(
+                              eina_bench_array_4evas_render_iterator),  200,
+                           4000, 100);
+   eina_benchmark_register(bench, "list",
+                           EINA_BENCHMARK(
+                              eina_bench_list_4evas_render),            200,
+                           4000, 100);
+   eina_benchmark_register(bench, "list-iterator",
+                           EINA_BENCHMARK(
+                              eina_bench_list_4evas_render_iterator),   200,
+                           4000, 100);
+   eina_benchmark_register(bench, "inlist",
+                           EINA_BENCHMARK(
+                              eina_bench_inlist_4evas_render),          200,
+                           4000, 100);
+   eina_benchmark_register(bench, "inlist-iterator",
+                           EINA_BENCHMARK(
+                              eina_bench_inlist_4evas_render_iterator), 200,
+                           4000, 100);
 #ifdef EINA_BENCH_HAVE_GLIB
-   eina_benchmark_register(bench, "glist", EINA_BENCHMARK(eina_bench_glist_4evas_render), 200, 4000, 100);
-   eina_benchmark_register(bench, "gptrarray", EINA_BENCHMARK(eina_bench_gptrarray_4evas_render), 200, 4000, 100);
+   eina_benchmark_register(bench, "glist",
+                           EINA_BENCHMARK(
+                              eina_bench_glist_4evas_render),           200,
+                           4000, 100);
+   eina_benchmark_register(bench, "gptrarray",
+                           EINA_BENCHMARK(
+                              eina_bench_gptrarray_4evas_render),       200,
+                           4000, 100);
 #endif
-   eina_benchmark_register(bench, "evas", EINA_BENCHMARK(eina_bench_evas_list_4evas_render), 200, 4000, 100);
-   eina_benchmark_register(bench, "ecore", EINA_BENCHMARK(eina_bench_ecore_list_4evas_render), 200, 1000, 100);
+   eina_benchmark_register(bench, "evas",
+                           EINA_BENCHMARK(
+                              eina_bench_evas_list_4evas_render),       200,
+                           4000, 100);
+   eina_benchmark_register(bench, "ecore",
+                           EINA_BENCHMARK(
+                              eina_bench_ecore_list_4evas_render),      200,
+                           1000, 100);
 }
 
index 1217655..aafe9ea 100644 (file)
@@ -42,7 +42,7 @@ eina_bench_convert_itoa_10(int request)
 
    for (i = 0; i < request; ++i)
      {
-       eina_convert_itoa(rand(), tmp);
+        eina_convert_itoa(rand(), tmp);
      }
 }
 
@@ -56,7 +56,7 @@ eina_bench_convert_itoa_16(int request)
 
    for (i = 0; i < request; ++i)
      {
-       eina_convert_xtoa(rand(), tmp);
+        eina_convert_xtoa(rand(), tmp);
      }
 }
 
@@ -70,7 +70,7 @@ eina_bench_convert_snprintf_10(int request)
 
    for (i = 0; i < request; ++i)
      {
-       snprintf(tmp, 128, "%i", rand());
+        snprintf(tmp, 128, "%i", rand());
      }
 }
 
@@ -84,7 +84,7 @@ eina_bench_convert_snprintf_x(int request)
 
    for (i = 0; i < request; ++i)
      {
-       snprintf(tmp, 128, "%x", rand());
+        snprintf(tmp, 128, "%x", rand());
      }
 }
 
@@ -99,9 +99,9 @@ eina_bench_convert_snprintf_a(int request)
 
    for (i = 0; i < request; ++i)
      {
-       r = 10000 * (rand() / ((double)RAND_MAX + 1));
-       snprintf(tmp, 128, "%a", r);
-       sscanf(tmp, "%la", &r);
+        r = 10000 * (rand() / ((double)RAND_MAX + 1));
+        snprintf(tmp, 128, "%a", r);
+        sscanf(tmp, "%la", &r);
      }
 }
 
@@ -118,10 +118,10 @@ eina_bench_convert_dtoa(int request)
 
    for (i = 0; i < request; ++i)
      {
-       r = 10000 * (rand() / ((double)RAND_MAX + 1));
-       eina_convert_dtoa(r, tmp);
-       eina_convert_atod(tmp, 128, &m, &e);
-       r = ldexp((double)m, e);
+        r = 10000 * (rand() / ((double)RAND_MAX + 1));
+        eina_convert_dtoa(r, tmp);
+        eina_convert_atod(tmp, 128, &m, &e);
+        r = ldexp((double)m, e);
      }
 }
 
@@ -137,23 +137,44 @@ eina_bench_convert_gstrtod(int request)
 
    for (i = 0; i < request; ++i)
      {
-       r = 10000 * (rand() / ((double)RAND_MAX + 1));
-       g_ascii_dtostr(tmp, 128, r);
-       r = g_ascii_strtod(tmp, NULL);
+        r = 10000 * (rand() / ((double)RAND_MAX + 1));
+        g_ascii_dtostr(tmp, 128, r);
+        r = g_ascii_strtod(tmp, NULL);
      }
 }
 #endif
 
 void eina_bench_convert(Eina_Benchmark *bench)
 {
-   eina_benchmark_register(bench, "itoa 10", EINA_BENCHMARK(eina_bench_convert_itoa_10), 1000, 200000, 500);
-   eina_benchmark_register(bench, "itoa 16", EINA_BENCHMARK(eina_bench_convert_itoa_16), 1000, 200000, 500);
-   eina_benchmark_register(bench, "snprintf 10", EINA_BENCHMARK(eina_bench_convert_snprintf_10), 1000, 200000, 500);
-   eina_benchmark_register(bench, "snprintf 16", EINA_BENCHMARK(eina_bench_convert_snprintf_x), 1000, 200000, 500);
-   eina_benchmark_register(bench, "snprintf a", EINA_BENCHMARK(eina_bench_convert_snprintf_a), 1000, 200000, 500);
-   eina_benchmark_register(bench, "dtoa", EINA_BENCHMARK(eina_bench_convert_dtoa), 1000, 200000, 500);
+   eina_benchmark_register(bench, "itoa 10",
+                           EINA_BENCHMARK(
+                              eina_bench_convert_itoa_10),     1000, 200000,
+                           500);
+   eina_benchmark_register(bench, "itoa 16",
+                           EINA_BENCHMARK(
+                              eina_bench_convert_itoa_16),     1000, 200000,
+                           500);
+   eina_benchmark_register(bench, "snprintf 10",
+                           EINA_BENCHMARK(
+                              eina_bench_convert_snprintf_10), 1000, 200000,
+                           500);
+   eina_benchmark_register(bench, "snprintf 16",
+                           EINA_BENCHMARK(
+                              eina_bench_convert_snprintf_x),  1000, 200000,
+                           500);
+   eina_benchmark_register(bench, "snprintf a",
+                           EINA_BENCHMARK(
+                              eina_bench_convert_snprintf_a),  1000, 200000,
+                           500);
+   eina_benchmark_register(bench, "dtoa",
+                           EINA_BENCHMARK(
+                              eina_bench_convert_dtoa),        1000, 200000,
+                           500);
 #ifdef EINA_BENCH_HAVE_GLIB
-   eina_benchmark_register(bench, "gstrtod", EINA_BENCHMARK(eina_bench_convert_gstrtod), 1000, 200000, 500);
+   eina_benchmark_register(bench, "gstrtod",
+                           EINA_BENCHMARK(
+                              eina_bench_convert_gstrtod),     1000, 200000,
+                           500);
 #endif
 }
 
index 686ab92..a615a15 100644 (file)
@@ -47,16 +47,25 @@ struct _Eina_Bench_Rbtree
 };
 
 static Eina_Rbtree_Direction
-_eina_bench_rbtree_cmp(const Eina_Bench_Rbtree *left, const Eina_Bench_Rbtree *right, __UNUSED__ void *data)
+_eina_bench_rbtree_cmp(const Eina_Bench_Rbtree *left,
+                       const Eina_Bench_Rbtree *right,
+                       __UNUSED__ void *data)
 {
-   if (!left) return EINA_RBTREE_RIGHT;
-   if (!right) return EINA_RBTREE_LEFT;
+   if (!left)
+      return EINA_RBTREE_RIGHT;
 
-   return strcmp(left->key, right->key) < 0 ? EINA_RBTREE_LEFT : EINA_RBTREE_RIGHT;
+   if (!right)
+      return EINA_RBTREE_LEFT;
+
+   return strcmp(left->key,
+                 right->key) < 0 ? EINA_RBTREE_LEFT : EINA_RBTREE_RIGHT;
 }
 
 static inline int
-_eina_bench_rbtree_key(const Eina_Bench_Rbtree *node, const char *key, int length, __UNUSED__ void *data)
+_eina_bench_rbtree_key(const Eina_Bench_Rbtree *node,
+                       const char *key,
+                       int length,
+                       __UNUSED__ void *data)
 {
    return strncmp(node->key, key, length);
 }
@@ -76,29 +85,39 @@ eina_bench_lookup_rbtree(int request)
 
    for (i = 0; i < request; ++i)
      {
-       Eina_Bench_Rbtree *tmp;
+        Eina_Bench_Rbtree *tmp;
 
-       tmp = malloc(sizeof (Eina_Bench_Rbtree));
-       if (!tmp) continue ;
+        tmp = malloc(sizeof (Eina_Bench_Rbtree));
+        if (!tmp)
+           continue;
 
-       tmp->value = i;
-       eina_convert_itoa(i, tmp->key);
+        tmp->value = i;
+        eina_convert_itoa(i, tmp->key);
 
-       root = eina_rbtree_inline_insert(root, &tmp->node, EINA_RBTREE_CMP_NODE_CB(_eina_bench_rbtree_cmp), NULL);
+        root = eina_rbtree_inline_insert(root,
+                                         &tmp->node,
+                                         EINA_RBTREE_CMP_NODE_CB(
+                                            _eina_bench_rbtree_cmp),
+                                         NULL);
      }
 
    srand(time(NULL));
 
    for (j = 0; j < 200; ++j)
-     for (i = 0; i < request; ++i)
-       {
-         Eina_Rbtree *tmp;
-         char tmp_key[10];
+      for (i = 0; i < request; ++i)
+        {
+           Eina_Rbtree *tmp;
+           char tmp_key[10];
 
-         eina_convert_itoa(rand() % request, tmp_key);
+           eina_convert_itoa(rand() % request, tmp_key);
 
-         tmp = eina_rbtree_inline_lookup(root, tmp_key, 10, EINA_RBTREE_CMP_KEY_CB(_eina_bench_rbtree_key), NULL);
-       }
+           tmp = eina_rbtree_inline_lookup(root,
+                                           tmp_key,
+                                           10,
+                                           EINA_RBTREE_CMP_KEY_CB(
+                                              _eina_bench_rbtree_key),
+                                           NULL);
+        }
 
    eina_rbtree_delete(root, EINA_RBTREE_FREE_CB(_eina_bench_rbtree_free), NULL);
 }
@@ -113,30 +132,31 @@ eina_bench_lookup_superfast(int request)
 
    hash = eina_hash_string_superfast_new(free);
 
-   for (i = 0; i < (unsigned int) request; ++i)
+   for (i = 0; i < (unsigned int)request; ++i)
      {
-       char tmp_key[10];
+        char tmp_key[10];
 
-       tmp_val = malloc(sizeof (int));
+        tmp_val = malloc(sizeof (int));
 
-       if (!tmp_val) continue ;
+        if (!tmp_val)
+           continue;
 
-       eina_convert_itoa(i, tmp_key);
-       *tmp_val = i;
+        eina_convert_itoa(i, tmp_key);
+        *tmp_val = i;
 
-       eina_hash_add(hash, tmp_key, tmp_val);
+        eina_hash_add(hash, tmp_key, tmp_val);
      }
 
    srand(time(NULL));
 
    for (j = 0; j < 200; ++j)
-     for (i = 0; i < (unsigned int) request; ++i)
-       {
-         char tmp_key[10];
+      for (i = 0; i < (unsigned int)request; ++i)
+        {
+           char tmp_key[10];
 
-         eina_convert_itoa(rand() % request, tmp_key);
-         tmp_val = eina_hash_find(hash, tmp_key);
-       }
+           eina_convert_itoa(rand() % request, tmp_key);
+           tmp_val = eina_hash_find(hash, tmp_key);
+        }
 
    eina_hash_free(hash);
 }
@@ -151,31 +171,32 @@ eina_bench_lookup_djb2(int request)
 
    hash = eina_hash_string_djb2_new(free);
 
-   for (i = 0; i < (unsigned int) request; ++i)
+   for (i = 0; i < (unsigned int)request; ++i)
      {
-       char tmp_key[10];
+        char tmp_key[10];
 
-       tmp_val = malloc(sizeof (int));
+        tmp_val = malloc(sizeof (int));
 
-       if (!tmp_val) continue ;
+        if (!tmp_val)
+           continue;
 
-       eina_convert_itoa(i, tmp_key);
-       *tmp_val = i;
+        eina_convert_itoa(i, tmp_key);
+        *tmp_val = i;
 
-       eina_hash_add(hash, tmp_key, tmp_val);
+        eina_hash_add(hash, tmp_key, tmp_val);
      }
 
    srand(time(NULL));
 
    for (j = 0; j < 200; ++j)
-     for (i = 0; i < (unsigned int) request; ++i)
-       {
-         char tmp_key[10];
+      for (i = 0; i < (unsigned int)request; ++i)
+        {
+           char tmp_key[10];
 
-         eina_convert_itoa(rand() % request, tmp_key);
+           eina_convert_itoa(rand() % request, tmp_key);
 
-         tmp_val = eina_hash_find(hash, tmp_key);
-       }
+           tmp_val = eina_hash_find(hash, tmp_key);
+        }
 
    eina_hash_free(hash);
 }
@@ -197,33 +218,37 @@ eina_bench_lookup_djb2_inline(int request)
 
    hash = eina_hash_string_djb2_new(free);
 
-   for (i = 0; i < (unsigned int) request; ++i)
+   for (i = 0; i < (unsigned int)request; ++i)
      {
-       int length;
+        int length;
 
-       elm = malloc(sizeof (Eina_Bench_DJB2) + 10);
-       if (!elm) continue ;
+        elm = malloc(sizeof (Eina_Bench_DJB2) + 10);
+        if (!elm)
+           continue;
 
-       elm->key = (char*) (elm + 1);
+        elm->key = (char *)(elm + 1);
 
-       length = eina_convert_itoa(i, elm->key) + 1;
-       elm->value = i;
+        length = eina_convert_itoa(i, elm->key) + 1;
+        elm->value = i;
 
-       eina_hash_direct_add_by_hash(hash, elm->key, length, eina_hash_djb2(elm->key, length), elm);
+        eina_hash_direct_add_by_hash(hash, elm->key, length,
+                                     eina_hash_djb2(elm->key, length), elm);
      }
 
    srand(time(NULL));
 
    for (j = 0; j < 200; ++j)
-     for (i = 0; i < (unsigned int) request; ++i)
-       {
-         char tmp_key[10];
-         int length = 6;
+      for (i = 0; i < (unsigned int)request; ++i)
+        {
+           char tmp_key[10];
+           int length = 6;
 
-         length = eina_convert_itoa(rand() % request, tmp_key) + 1;
+           length = eina_convert_itoa(rand() % request, tmp_key) + 1;
 
-         elm = eina_hash_find_by_hash(hash, tmp_key, length, eina_hash_djb2(tmp_key, length));
-       }
+           elm =
+              eina_hash_find_by_hash(hash, tmp_key, length,
+                                     eina_hash_djb2(tmp_key, length));
+        }
 
    eina_hash_free(hash);
 }
@@ -246,30 +271,31 @@ eina_bench_lookup_ghash(int request)
 
    hash = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, free);
 
-   for (i = 0; i < (unsigned int) request; ++i)
+   for (i = 0; i < (unsigned int)request; ++i)
      {
-       elm = malloc(sizeof (Eina_Bench_Glib) + 10);
-       if (!elm) continue ;
+        elm = malloc(sizeof (Eina_Bench_Glib) + 10);
+        if (!elm)
+           continue;
 
-       elm->key = (char*) (elm + 1);
+        elm->key = (char *)(elm + 1);
 
-       eina_convert_itoa(i, elm->key);
-       elm->value = i;
+        eina_convert_itoa(i, elm->key);
+        elm->value = i;
 
-       g_hash_table_insert(hash, elm->key, elm);
+        g_hash_table_insert(hash, elm->key, elm);
      }
 
    srand(time(NULL));
 
    for (j = 0; j < 200; ++j)
-     for (i = 0; i < (unsigned int) request; ++i)
-       {
-         char tmp_key[10];
+      for (i = 0; i < (unsigned int)request; ++i)
+        {
+           char tmp_key[10];
 
-         eina_convert_itoa(rand() % request, tmp_key);
+           eina_convert_itoa(rand() % request, tmp_key);
 
-         elm = g_hash_table_lookup(hash, tmp_key);
-       }
+           elm = g_hash_table_lookup(hash, tmp_key);
+        }
 
    g_hash_table_destroy(hash);
 }
@@ -287,38 +313,40 @@ eina_bench_lookup_evas(int request)
 
    array = eina_array_new(1000);
 
-   for (i = 0; i < (unsigned int) request; ++i)
+   for (i = 0; i < (unsigned int)request; ++i)
      {
-       char tmp_key[10];
+        char tmp_key[10];
 
-       tmp_val = malloc(sizeof (int));
+        tmp_val = malloc(sizeof (int));
 
-       if (!tmp_val) continue ;
+        if (!tmp_val)
+           continue;
 
-       eina_convert_itoa(i, tmp_key);
-       *tmp_val = i;
+        eina_convert_itoa(i, tmp_key);
+        *tmp_val = i;
 
-       hash = evas_hash_add(hash, tmp_key, tmp_val);
+        hash = evas_hash_add(hash, tmp_key, tmp_val);
 
-       eina_array_push(array, tmp_val);
+        eina_array_push(array, tmp_val);
      }
 
    srand(time(NULL));
 
    for (j = 0; j < 200; ++j)
-     for (i = 0; i < (unsigned int) request; ++i)
-       {
-         char tmp_key[10];
+      for (i = 0; i < (unsigned int)request; ++i)
+        {
+           char tmp_key[10];
 
-         eina_convert_itoa(rand() % request, tmp_key);
+           eina_convert_itoa(rand() % request, tmp_key);
 
-         tmp_val = evas_hash_find(hash, tmp_key);
-       }
+           tmp_val = evas_hash_find(hash, tmp_key);
+        }
 
    evas_hash_free(hash);
 
-   EINA_ARRAY_ITER_NEXT(array, i, tmp_val, it)
+   EINA_ARRAY_THREADSAFE_ITER_NEXT(array, i, tmp_val, it,
      free(tmp_val);
+   );
 
    eina_array_free(array);
 }
@@ -343,42 +371,57 @@ eina_bench_lookup_ecore(int request)
    ecore_hash_free_key_cb_set(hash, NULL);
    ecore_hash_free_value_cb_set(hash, free);
 
-   for (i = 0; i < (unsigned int) request; ++i)
+   for (i = 0; i < (unsigned int)request; ++i)
      {
-       elm = malloc(sizeof (Eina_Bench_Ecore) + 10);
-       if (!elm) continue;
+        elm = malloc(sizeof (Eina_Bench_Ecore) + 10);
+        if (!elm)
+           continue;
 
-       elm->key = (char*) (elm + 1);
-       eina_convert_itoa(i, elm->key);
-       elm->value = i;
+        elm->key = (char *)(elm + 1);
+        eina_convert_itoa(i, elm->key);
+        elm->value = i;
 
-       ecore_hash_set(hash, elm->key, elm);
+        ecore_hash_set(hash, elm->key, elm);
      }
 
    srand(time(NULL));
 
    for (j = 0; j < 200; ++j)
-     for (i = 0; i < (unsigned int) request; ++i)
-       {
-         char tmp_key[10];
+      for (i = 0; i < (unsigned int)request; ++i)
+        {
+           char tmp_key[10];
 
-         eina_convert_itoa(rand() % request, tmp_key);
+           eina_convert_itoa(rand() % request, tmp_key);
 
-         elm = ecore_hash_get(hash, tmp_key);
-       }
+           elm = ecore_hash_get(hash, tmp_key);
+        }
 
    ecore_hash_destroy(hash);
 }
 
 void eina_bench_hash(Eina_Benchmark *bench)
 {
-   eina_benchmark_register(bench, "superfast-lookup", EINA_BENCHMARK(eina_bench_lookup_superfast), 10, 3000, 10);
-   eina_benchmark_register(bench, "djb2-lookup", EINA_BENCHMARK(eina_bench_lookup_djb2), 10, 3000, 10);
-   eina_benchmark_register(bench, "djb2-lookup-inline", EINA_BENCHMARK(eina_bench_lookup_djb2_inline), 10, 3000, 10);
-   eina_benchmark_register(bench, "rbtree", EINA_BENCHMARK(eina_bench_lookup_rbtree), 10, 3000, 10);
+   eina_benchmark_register(bench, "superfast-lookup",
+                           EINA_BENCHMARK(
+                              eina_bench_lookup_superfast),   10, 3000, 10);
+   eina_benchmark_register(bench, "djb2-lookup",
+                           EINA_BENCHMARK(
+                              eina_bench_lookup_djb2),        10, 3000, 10);
+   eina_benchmark_register(bench, "djb2-lookup-inline",
+                           EINA_BENCHMARK(
+                              eina_bench_lookup_djb2_inline), 10, 3000, 10);
+   eina_benchmark_register(bench, "rbtree",
+                           EINA_BENCHMARK(
+                              eina_bench_lookup_rbtree),      10, 3000, 10);
 #ifdef EINA_BENCH_HAVE_GLIB
-   eina_benchmark_register(bench, "ghash-lookup", EINA_BENCHMARK(eina_bench_lookup_ghash), 10, 3000, 10);
+   eina_benchmark_register(bench, "ghash-lookup",
+                           EINA_BENCHMARK(
+                              eina_bench_lookup_ghash),       10, 3000, 10);
 #endif
-   eina_benchmark_register(bench, "evas-lookup", EINA_BENCHMARK(eina_bench_lookup_evas), 10, 3000, 10);
-   eina_benchmark_register(bench, "ecore-lookup", EINA_BENCHMARK(eina_bench_lookup_ecore), 10, 3000, 10);
+   eina_benchmark_register(bench, "evas-lookup",
+                           EINA_BENCHMARK(
+                              eina_bench_lookup_evas),        10, 3000, 10);
+   eina_benchmark_register(bench, "ecore-lookup",
+                           EINA_BENCHMARK(
+                              eina_bench_lookup_ecore),       10, 3000, 10);
 }
index 5c75183..ac6f5b4 100644 (file)
@@ -39,15 +39,15 @@ _eina_mempool_bench(Eina_Mempool *mp, int request)
 
    for (i = 0; i < 100; ++i)
      {
-       for (j = 0; j < request; ++j)
-         {
-            eina_array_push(array, eina_mempool_malloc(mp, sizeof (int)));
-         }
-
-       for (j = 0; j < request; ++j)
-         {
-            eina_mempool_free(mp, eina_array_pop(array));
-         }
+        for (j = 0; j < request; ++j)
+          {
+             eina_array_push(array, eina_mempool_malloc(mp, sizeof (int)));
+          }
+
+        for (j = 0; j < request; ++j)
+          {
+             eina_mempool_free(mp, eina_array_pop(array));
+          }
      }
 
    eina_array_free(array);
@@ -108,7 +108,15 @@ eina_mempool_ememoa_unknown(int request)
 {
    Eina_Mempool *mp;
 
-   mp = eina_mempool_add("ememoa_unknown", "test", NULL, 0, 2, sizeof (int), 8, sizeof (int) * 2, 8);
+   mp = eina_mempool_add("ememoa_unknown",
+                         "test",
+                         NULL,
+                         0,
+                         2,
+                         sizeof (int),
+                         8,
+                         sizeof (int) * 2,
+                         8);
    _eina_mempool_bench(mp, request);
    eina_mempool_del(mp);
 }
@@ -127,15 +135,15 @@ eina_mempool_glib(int request)
 
    for (i = 0; i < 100; ++i)
      {
-       for (j = 0; j < request; ++j)
-         {
-            eina_array_push(array, g_slice_alloc(sizeof (int)));
-         }
-
-       for (j = 0; j < request; ++j)
-         {
-            g_slice_free1(sizeof (int), eina_array_pop(array));
-         }
+        for (j = 0; j < request; ++j)
+          {
+             eina_array_push(array, g_slice_alloc(sizeof (int)));
+          }
+
+        for (j = 0; j < request; ++j)
+          {
+             g_slice_free1(sizeof (int), eina_array_pop(array));
+          }
      }
 
    eina_array_free(array);
@@ -148,21 +156,33 @@ void
 eina_bench_mempool(Eina_Benchmark *bench)
 {
 #ifdef EINA_BUILD_CHAINED_POOL
-   eina_benchmark_register(bench, "chained mempool", EINA_BENCHMARK(eina_mempool_chained_mempool), 10, 1000, 10);
+   eina_benchmark_register(bench, "chained mempool",
+                           EINA_BENCHMARK(
+                              eina_mempool_chained_mempool), 10, 1000, 10);
 #endif
 #ifdef EINA_BUILD_PASS_THROUGH
-   eina_benchmark_register(bench, "pass through", EINA_BENCHMARK(eina_mempool_pass_through), 10, 1000, 10);
+   eina_benchmark_register(bench, "pass through",
+                           EINA_BENCHMARK(
+                              eina_mempool_pass_through),    10, 1000, 10);
 #endif
 #ifdef EINA_BUILD_FIXED_BITMAP
-   eina_benchmark_register(bench, "fixed bitmap", EINA_BENCHMARK(eina_mempool_fixed_bitmap), 10, 1000, 10);
+   eina_benchmark_register(bench, "fixed bitmap",
+                           EINA_BENCHMARK(
+                              eina_mempool_fixed_bitmap),    10, 1000, 10);
 #endif
 #ifdef EINA_BUILD_EMEMOA_FIXED
-   eina_benchmark_register(bench, "ememoa fixed", EINA_BENCHMARK(eina_mempool_ememoa_fixed), 10, 1000, 10);
+   eina_benchmark_register(bench, "ememoa fixed",
+                           EINA_BENCHMARK(
+                              eina_mempool_ememoa_fixed),    10, 1000, 10);
 #endif
 #ifdef EINA_BUILD_EMEMOA_UNKNOWN
-   eina_benchmark_register(bench, "ememoa unknown", EINA_BENCHMARK(eina_mempool_ememoa_unknown), 10, 1000, 10);
+   eina_benchmark_register(bench, "ememoa unknown",
+                           EINA_BENCHMARK(
+                              eina_mempool_ememoa_unknown),  10, 1000, 10);
 #endif
 #ifdef EINA_BENCH_HAVE_GLIB
-   eina_benchmark_register(bench, "gslice", EINA_BENCHMARK(eina_mempool_glib), 10, 1000, 10);
+   eina_benchmark_register(bench, "gslice",
+                           EINA_BENCHMARK(
+                              eina_mempool_glib),            10, 1000, 10);
 #endif
 }
index 0a0702a..76d6667 100644 (file)
@@ -37,83 +37,87 @@ eina_bench_render_loop(int request)
    eina_init();
 
    for (i = 0; i < request; ++i)
-     objects = eina_list_append(objects,
-                               eina_rectangle_new((rand() * WIDTH) / RAND_MAX,
-                                                  (rand() * HEIGHT) / RAND_MAX,
-                                                  (rand() * WIDTH / 2) / RAND_MAX,
-                                                  (rand() * HEIGHT / 2) / RAND_MAX));
+      objects = eina_list_append(objects,
+                                 eina_rectangle_new((rand() * WIDTH) / RAND_MAX,
+                                                    (rand() *
+                                                     HEIGHT) / RAND_MAX,
+                                                    (rand() * WIDTH /
+                                                     2) / RAND_MAX,
+                                                    (rand() * HEIGHT /
+                                                     2) / RAND_MAX));
 
    for (j = 0; j < 100; ++j)
      {
-       Eina_Rectangle *collide;
-       Eina_List *collided = NULL;
-       Eina_List *changed = NULL;
-       Eina_List *l;
-
-       /* Delete 25% of all objects */
-       i = request * 25 / 100;
-       for (; i > 0; --i)
-         {
-            eina_rectangle_free(eina_list_data_get(objects));
-            objects = eina_list_remove_list(objects, objects);
-         }
-
-       /* Add them back */
-       i = request * 25 / 100;
-       for (; i > 0; --i)
-         {
-            r = eina_rectangle_new((rand() * WIDTH) / RAND_MAX,
-                                   (rand() * HEIGHT) / RAND_MAX,
-                                   (rand() * WIDTH / 3) / RAND_MAX,
-                                   (rand() * HEIGHT / 3) / RAND_MAX);
-            objects = eina_list_prepend(objects, r);
-            changed = eina_list_append(changed, r);
-         }
-
-       /* Do one collide search */
-       collide = eina_rectangle_new((rand() * WIDTH) / RAND_MAX,
-                                    (rand() * HEIGHT) / RAND_MAX,
-                                    (rand() * WIDTH / 4) / RAND_MAX,
-                                    (rand() * HEIGHT / 4) / RAND_MAX);
-       EINA_LIST_FOREACH(objects, l, r)
-         if (eina_rectangles_intersect(r, collide))
-           collided = eina_list_append(collided, r);
-       collided = eina_list_free(collided);
-       eina_rectangle_free(collide);
-
-       /* Modify 50% of all objects */
-       i = request * 50 / 100;
-       for (; i > 0; --i)
-         {
-            r = eina_list_data_get(eina_list_last(objects));
-            objects = eina_list_remove_list(objects, eina_list_last(objects));
-
-            r->x = (rand() * WIDTH) / RAND_MAX;
-            r->y = (rand() * HEIGHT) / RAND_MAX;
-            r->w = (rand() * WIDTH / 3) / RAND_MAX;
-            r->h = (rand() * HEIGHT / 3) / RAND_MAX;
-
-            objects = eina_list_prepend(objects, r);
-            changed = eina_list_append(changed, r);
-         }
-
-       /* Emulating the render loop by colliding all modified
-          object with all intersecting object */
-       EINA_LIST_FREE(changed, r)
-         {
-            EINA_LIST_FOREACH(objects, l, collide)
-              if (r != collide && eina_rectangles_intersect(collide, r))
-                collided = eina_list_append(collided, collide);
-
-            collided = eina_list_append(collided, r);
-         }
-
-       /* Ok, we compute it, now it's done */
-       collided = eina_list_free(collided);
+        Eina_Rectangle *collide;
+        Eina_List *collided = NULL;
+        Eina_List *changed = NULL;
+        Eina_List *l;
+
+        /* Delete 25% of all objects */
+        i = request * 25 / 100;
+        for (; i > 0; --i)
+          {
+             eina_rectangle_free(eina_list_data_get(objects));
+             objects = eina_list_remove_list(objects, objects);
+          }
+
+        /* Add them back */
+        i = request * 25 / 100;
+        for (; i > 0; --i)
+          {
+             r = eina_rectangle_new((rand() * WIDTH) / RAND_MAX,
+                                    (rand() * HEIGHT) / RAND_MAX,
+                                    (rand() * WIDTH / 3) / RAND_MAX,
+                                    (rand() * HEIGHT / 3) / RAND_MAX);
+             objects = eina_list_prepend(objects, r);
+             changed = eina_list_append(changed, r);
+          }
+
+        /* Do one collide search */
+        collide = eina_rectangle_new((rand() * WIDTH) / RAND_MAX,
+                                     (rand() * HEIGHT) / RAND_MAX,
+                                     (rand() * WIDTH / 4) / RAND_MAX,
+                                     (rand() * HEIGHT / 4) / RAND_MAX);
+        EINA_LIST_FOREACH(objects, l, r)
+        if (eina_rectangles_intersect(r, collide))
+           collided = eina_list_append(collided, r);
+
+        collided = eina_list_free(collided);
+        eina_rectangle_free(collide);
+
+        /* Modify 50% of all objects */
+        i = request * 50 / 100;
+        for (; i > 0; --i)
+          {
+             r = eina_list_data_get(eina_list_last(objects));
+             objects = eina_list_remove_list(objects, eina_list_last(objects));
+
+             r->x = (rand() * WIDTH) / RAND_MAX;
+             r->y = (rand() * HEIGHT) / RAND_MAX;
+             r->w = (rand() * WIDTH / 3) / RAND_MAX;
+             r->h = (rand() * HEIGHT / 3) / RAND_MAX;
+
+             objects = eina_list_prepend(objects, r);
+             changed = eina_list_append(changed, r);
+          }
+
+        /* Emulating the render loop by colliding all modified
+           object with all intersecting object */
+        EINA_LIST_FREE(changed, r)
+        {
+           EINA_LIST_FOREACH(objects, l, collide)
+           if (r != collide && eina_rectangles_intersect(collide, r))
+              collided = eina_list_append(collided, collide);
+
+           collided = eina_list_append(collided, r);
+        }
+
+        /* Ok, we compute it, now it's done */
+        collided = eina_list_free(collided);
      }
 
    EINA_LIST_FREE(objects, r)
-     eina_rectangle_free(r);
+   eina_rectangle_free(r);
 
    eina_shutdown();
 }
@@ -131,12 +135,14 @@ _eina_bench_quadtree_vertical(const void *object, size_t middle)
    const Eina_Bench_Quad *b = object;
    size_t y;
 
-   y = b->r.y < 0 ? 0 : (size_t) b->r.y;
+   y = b->r.y < 0 ? 0 : (size_t)b->r.y;
 
    if (y + b->r.h < middle)
-     return EINA_QUAD_LEFT;
+      return EINA_QUAD_LEFT;
+
    if (y > middle)
-     return EINA_QUAD_RIGHT;
+      return EINA_QUAD_RIGHT;
+
    return EINA_QUAD_BOTH;
 }
 
@@ -146,12 +152,14 @@ _eina_bench_quadtree_horizontal(const void *object, size_t middle)
    const Eina_Bench_Quad *b = object;
    size_t x;
 
-   x = b->r.x < 0 ? 0 : (size_t) b->r.x;
+   x = b->r.x < 0 ? 0 : (size_t)b->r.x;
 
    if (x + b->r.w < middle)
-     return EINA_QUAD_LEFT;
+      return EINA_QUAD_LEFT;
+
    if (x > middle)
-     return EINA_QUAD_RIGHT;
+      return EINA_QUAD_RIGHT;
+
    return EINA_QUAD_BOTH;
 }
 
@@ -169,126 +177,127 @@ eina_bench_quadtree_render_loop(int request)
    eina_init();
 
    mp = eina_mempool_add("chained_mempool", "bench-quad", NULL,
-                        sizeof (Eina_Bench_Quad), 320);
+                         sizeof (Eina_Bench_Quad), 320);
 
    q = eina_quadtree_new(WIDTH, HEIGHT,
-                        _eina_bench_quadtree_vertical,
-                        _eina_bench_quadtree_horizontal);
+                         _eina_bench_quadtree_vertical,
+                         _eina_bench_quadtree_horizontal);
 
    /* Create requested object */
    for (i = 0; i < request; ++i)
      {
-       b = eina_mempool_malloc(mp, sizeof (Eina_Bench_Quad));
-       EINA_RECTANGLE_SET(&b->r,
-                          (rand() * WIDTH) / RAND_MAX,
-                          (rand() * HEIGHT) / RAND_MAX,
-                          (rand() * WIDTH / 2) / RAND_MAX,
-                          (rand() * HEIGHT / 2) / RAND_MAX);
-       b->item = eina_quadtree_add(q, b);
-
-       objects = eina_list_append(objects, b);
+        b = eina_mempool_malloc(mp, sizeof (Eina_Bench_Quad));
+        EINA_RECTANGLE_SET(&b->r,
+                           (rand() * WIDTH) / RAND_MAX,
+                           (rand() * HEIGHT) / RAND_MAX,
+                           (rand() * WIDTH / 2) / RAND_MAX,
+                           (rand() * HEIGHT / 2) / RAND_MAX);
+        b->item = eina_quadtree_add(q, b);
+
+        objects = eina_list_append(objects, b);
      }
 
    for (j = 0; j < 100; ++j)
      {
-       Eina_Bench_Quad *collide;
-       Eina_List *changed = NULL;
-       Eina_List *collided = NULL;
-
-       /* Delete 25% of all objects */
-       i = request * 25 / 100;
-       for (; i > 0; --i)
-         {
-            b = eina_list_data_get(objects);
-            eina_quadtree_del(b->item);
-            eina_mempool_free(mp, b);
-
-            objects = eina_list_remove_list(objects, objects);
-         }
-
-       /* Add them back */
-       i = request * 25 / 100;
-       for (; i > 0; --i)
-         {
-            b = eina_mempool_malloc(mp, sizeof (Eina_Bench_Quad));
-            EINA_RECTANGLE_SET(&b->r,
-                               (rand() * WIDTH) / RAND_MAX,
-                               (rand() * HEIGHT) / RAND_MAX,
-                               (rand() * WIDTH / 3) / RAND_MAX,
-                               (rand() * HEIGHT / 3) / RAND_MAX);
-            b->item = eina_quadtree_add(q, b);
-
-            objects = eina_list_prepend(objects, b);
-            changed = eina_list_append(changed, b);
-         }
-
-       /* Do one collide search */
-       collide = eina_mempool_malloc(mp, sizeof (Eina_Bench_Quad));
-       EINA_RECTANGLE_SET(&collide->r,
-                          (rand() * WIDTH) / RAND_MAX,
-                          (rand() * HEIGHT) / RAND_MAX,
-                          (rand() * WIDTH / 4) / RAND_MAX,
-                          (rand() * HEIGHT / 4) / RAND_MAX);
-       possibility = eina_quadtree_collide(q,
-                                           collide->r.x, collide->r.y,
-                                           collide->r.w, collide->r.h);
-       while (possibility)
-         {
-            b = eina_quadtree_object(possibility);
-            possibility = possibility->next;
-
-            if (eina_rectangles_intersect(&b->r, &collide->r))
-              collided = eina_list_append(collided, b);
-         }
-
-       collided = eina_list_free(collided);
-       eina_mempool_free(mp, collide);
-
-       /* Modify 50% of all objects */
-       i = request * 50 / 100;
-       for (; i > 0; --i)
-         {
-            b = eina_list_data_get(eina_list_last(objects));
-            objects = eina_list_remove_list(objects, eina_list_last(objects));
-
-            b->r.x = (rand() * WIDTH) / RAND_MAX;
-            b->r.y = (rand() * HEIGHT) / RAND_MAX;
-            b->r.w = (rand() * WIDTH / 3) / RAND_MAX;
-            b->r.h = (rand() * HEIGHT / 3) / RAND_MAX;
-
-            eina_quadtree_change(b->item);
-
-            objects = eina_list_prepend(objects, b);
-            changed = eina_list_append(changed, b);
-         }
-
-       /* Emulating the render loop by colliding all modified
-          object with all intersecting object */
-       EINA_LIST_FREE(changed, b)
-         {
-            possibility = eina_quadtree_collide(q,
-                                                b->r.x, b->r.y, b->r.w, b->r.h);
-            while (possibility)
-              {
-                 collide = eina_quadtree_object(possibility);
-                 possibility = possibility->next;
-
-                 if (collide != b && eina_rectangles_intersect(&b->r, &collide->r))
-                   collided = eina_list_append(collided, collide);
-              }
-
-            collided = eina_list_append(collided, b);
-         }
-
-       /* Ok, we compute it, now it's done */
-       collided = eina_list_free(collided);
+        Eina_Bench_Quad *collide;
+        Eina_List *changed = NULL;
+        Eina_List *collided = NULL;
+
+        /* Delete 25% of all objects */
+        i = request * 25 / 100;
+        for (; i > 0; --i)
+          {
+             b = eina_list_data_get(objects);
+             eina_quadtree_del(b->item);
+             eina_mempool_free(mp, b);
+
+             objects = eina_list_remove_list(objects, objects);
+          }
+
+        /* Add them back */
+        i = request * 25 / 100;
+        for (; i > 0; --i)
+          {
+             b = eina_mempool_malloc(mp, sizeof (Eina_Bench_Quad));
+             EINA_RECTANGLE_SET(&b->r,
+                                (rand() * WIDTH) / RAND_MAX,
+                                (rand() * HEIGHT) / RAND_MAX,
+                                (rand() * WIDTH / 3) / RAND_MAX,
+                                (rand() * HEIGHT / 3) / RAND_MAX);
+             b->item = eina_quadtree_add(q, b);
+
+             objects = eina_list_prepend(objects, b);
+             changed = eina_list_append(changed, b);
+          }
+
+        /* Do one collide search */
+        collide = eina_mempool_malloc(mp, sizeof (Eina_Bench_Quad));
+             EINA_RECTANGLE_SET(&collide->r,
+                           (rand() * WIDTH) / RAND_MAX,
+                           (rand() * HEIGHT) / RAND_MAX,
+                           (rand() * WIDTH / 4) / RAND_MAX,
+                           (rand() * HEIGHT / 4) / RAND_MAX);
+        possibility = eina_quadtree_collide(q,
+                                            collide->r.x, collide->r.y,
+                                            collide->r.w, collide->r.h);
+        while (possibility)
+          {
+             b = eina_quadtree_object(possibility);
+             possibility = possibility->next;
+
+             if (eina_rectangles_intersect(&b->r, &collide->r))
+                collided = eina_list_append(collided, b);
+          }
+
+        collided = eina_list_free(collided);
+        eina_mempool_free(mp, collide);
+
+        /* Modify 50% of all objects */
+        i = request * 50 / 100;
+        for (; i > 0; --i)
+          {
+             b = eina_list_data_get(eina_list_last(objects));
+             objects = eina_list_remove_list(objects, eina_list_last(objects));
+
+             b->r.x = (rand() * WIDTH) / RAND_MAX;
+             b->r.y = (rand() * HEIGHT) / RAND_MAX;
+             b->r.w = (rand() * WIDTH / 3) / RAND_MAX;
+             b->r.h = (rand() * HEIGHT / 3) / RAND_MAX;
+
+             eina_quadtree_change(b->item);
+
+             objects = eina_list_prepend(objects, b);
+             changed = eina_list_append(changed, b);
+          }
+
+        /* Emulating the render loop by colliding all modified
+           object with all intersecting object */
+        EINA_LIST_FREE(changed, b)
+        {
+           possibility = eina_quadtree_collide(q,
+                                               b->r.x, b->r.y, b->r.w, b->r.h);
+           while (possibility)
+             {
+                collide = eina_quadtree_object(possibility);
+                possibility = possibility->next;
+
+                if (collide != b &&
+                    eina_rectangles_intersect(&b->r, &collide->r))
+                   collided = eina_list_append(collided, collide);
+             }
+
+           collided = eina_list_append(collided, b);
+        }
+
+        /* Ok, we compute it, now it's done */
+        collided = eina_list_free(collided);
      }
 
    EINA_LIST_FREE(objects, b)
-     {
-       eina_quadtree_del(b->item);
-       eina_mempool_free(mp, b);
-     }
+   {
+      eina_quadtree_del(b->item);
+      eina_mempool_free(mp, b);
+   }
 
    eina_mempool_del(mp);
 
@@ -301,9 +310,9 @@ void
 eina_bench_quadtree(Eina_Benchmark *bench)
 {
    eina_benchmark_register(bench, "collide-all",
-                          EINA_BENCHMARK(eina_bench_render_loop),
-                          100, 1500, 50);
+                           EINA_BENCHMARK(eina_bench_render_loop),
+                           100, 1500, 50);
    eina_benchmark_register(bench, "collide-quad-tree",
-                          EINA_BENCHMARK(eina_bench_quadtree_render_loop),
-                          100, 1500, 50);
+                           EINA_BENCHMARK(eina_bench_quadtree_render_loop),
+                           100, 1500, 50);
 }
index 1214c75..96d4b1b 100644 (file)
@@ -35,28 +35,29 @@ eina_bench_eina_rectangle_pool(int request)
    eina_init();
 
    pool = eina_rectangle_pool_new(2048, 2048);
-   if (!pool) return ;
-
+   if (!pool)
+      return;
 
    for (i = 0; i < request; ++i)
      {
-       rect = NULL;
+        rect = NULL;
+
+        while (!rect)
+          {
+             rect = eina_rectangle_pool_request(pool, i & 0xFF, 256 - (i & 0xFF));
+             if (!rect)
+               {
+                  rect = eina_list_data_get(list);
+                  list = eina_list_remove_list(list, list);
+                  if (rect)
+                     eina_rectangle_pool_release(rect);
+               }
+             else
+                list = eina_list_append(list, rect);
 
-       while (!rect)
-         {
-            rect = eina_rectangle_pool_request(pool, i & 0xFF, 256 - (i & 0xFF));
-            if (!rect)
-              {
-                 rect = eina_list_data_get(list);
-                 list = eina_list_remove_list(list, list);
-                 if (rect) eina_rectangle_pool_release(rect);
-              }
-            else
-              {
-                 list = eina_list_append(list, rect);
-              }
-            if (!(i & 0xFF)) break;
-         }
+             if (!(i & 0xFF))
+                break;
+          }
      }
 
    eina_rectangle_pool_free(pool);
@@ -67,7 +68,9 @@ eina_bench_eina_rectangle_pool(int request)
 
 void eina_bench_rectangle_pool(Eina_Benchmark *bench)
 {
-   eina_benchmark_register(bench, "eina", EINA_BENCHMARK(eina_bench_eina_rectangle_pool), 10, 4000, 100);
+   eina_benchmark_register(bench, "eina",
+                           EINA_BENCHMARK(
+                              eina_bench_eina_rectangle_pool), 10, 4000, 100);
 }
 
 
index 45e4e10..c3c9d9f 100644 (file)
@@ -53,19 +53,19 @@ eina_bench_sort_eina(int request)
 
    for (i = 0; i < request; ++i)
      {
-       char buffer[10];
+        char buffer[10];
 
-       eina_convert_itoa(rand() % request, buffer);
+        eina_convert_itoa(rand() % request, buffer);
 
-       list = eina_list_prepend(list, strdup(buffer));
+        list = eina_list_prepend(list, strdup(buffer));
      }
 
    list = eina_list_sort(list, -1, EINA_COMPARE_CB(_eina_cmp_str));
 
    while (list)
      {
-       free(eina_list_data_get(list));
-       list = eina_list_remove_list(list, list);
+        free(eina_list_data_get(list));
+        list = eina_list_remove_list(list, list);
      }
 
    eina_shutdown();
@@ -81,19 +81,19 @@ eina_bench_sort_evas(int request)
 
    for (i = 0; i < request; ++i)
      {
-       char buffer[10];
+        char buffer[10];
 
-       eina_convert_itoa(rand() % request, buffer);
+        eina_convert_itoa(rand() % request, buffer);
 
-       list = evas_list_prepend(list, strdup(buffer));
+        list = evas_list_prepend(list, strdup(buffer));
      }
 
-   list = evas_list_sort(list, -1, (void*) _eina_cmp_str);
+   list = evas_list_sort(list, -1, (void *)_eina_cmp_str);
 
    while (list)
      {
-       free(evas_list_data(list));
-       list = evas_list_remove_list(list, list);
+        free(evas_list_data(list));
+        list = evas_list_remove_list(list, list);
      }
 }
 
@@ -108,19 +108,19 @@ eina_bench_sort_glist(int request)
 
    for (i = 0; i < request; ++i)
      {
-       char buffer[10];
+        char buffer[10];
 
-       eina_convert_itoa(rand() % request, buffer);
+        eina_convert_itoa(rand() % request, buffer);
 
-       list = g_list_prepend(list, strdup(buffer));
+        list = g_list_prepend(list, strdup(buffer));
      }
 
-   list = g_list_sort(list, (void*) _eina_cmp_str);
+   list = g_list_sort(list, (void *)_eina_cmp_str);
 
    while (list)
      {
-       free(list->data);
-       list = g_list_delete_link(list, list);
+        free(list->data);
+        list = g_list_delete_link(list, list);
      }
 }
 #endif
@@ -136,11 +136,11 @@ eina_bench_sort_ecore_default(int request)
 
    for (i = 0; i < request; ++i)
      {
-       char buffer[10];
+        char buffer[10];
 
-       eina_convert_itoa(rand() % request, buffer);
+        eina_convert_itoa(rand() % request, buffer);
 
-       ecore_list_prepend(list, strdup(buffer));
+        ecore_list_prepend(list, strdup(buffer));
      }
 
    ecore_list_sort(list, ECORE_COMPARE_CB(_eina_cmp_str), 0);
@@ -159,11 +159,11 @@ eina_bench_sort_ecore_merge(int request)
 
    for (i = 0; i < request; ++i)
      {
-       char buffer[10];
+        char buffer[10];
 
-       eina_convert_itoa(rand() % request, buffer);
+        eina_convert_itoa(rand() % request, buffer);
 
-       ecore_list_prepend(list, strdup(buffer));
+        ecore_list_prepend(list, strdup(buffer));
      }
 
    ecore_list_mergesort(list, ECORE_COMPARE_CB(_eina_cmp_str), 0);
@@ -182,11 +182,11 @@ eina_bench_sort_ecore_heap(int request)
 
    for (i = 0; i < request; ++i)
      {
-       char buffer[10];
+        char buffer[10];
 
-       eina_convert_itoa(rand() % request, buffer);
+        eina_convert_itoa(rand() % request, buffer);
 
-       ecore_list_prepend(list, strdup(buffer));
+        ecore_list_prepend(list, strdup(buffer));
      }
 
    ecore_list_heapsort(list, ECORE_COMPARE_CB(_eina_cmp_str), 0);
@@ -196,14 +196,26 @@ eina_bench_sort_ecore_heap(int request)
 
 void eina_bench_sort(Eina_Benchmark *bench)
 {
-   eina_benchmark_register(bench, "eina", EINA_BENCHMARK(eina_bench_sort_eina), 10, 10000, 100);
+   eina_benchmark_register(bench, "eina",
+                           EINA_BENCHMARK(
+                              eina_bench_sort_eina),          10, 10000, 100);
 #ifdef EINA_BENCH_HAVE_GLIB
-   eina_benchmark_register(bench, "glist", EINA_BENCHMARK(eina_bench_sort_glist), 10, 10000, 100);
+   eina_benchmark_register(bench, "glist",
+                           EINA_BENCHMARK(
+                              eina_bench_sort_glist),         10, 10000, 100);
 #endif
-   eina_benchmark_register(bench, "ecore", EINA_BENCHMARK(eina_bench_sort_ecore_default), 10, 10000, 100);
-   eina_benchmark_register(bench, "ecore-merge", EINA_BENCHMARK(eina_bench_sort_ecore_merge), 10, 10000, 100);
-   eina_benchmark_register(bench, "ecore-heap", EINA_BENCHMARK(eina_bench_sort_ecore_heap), 10, 10000, 100);
-   eina_benchmark_register(bench, "evas", EINA_BENCHMARK(eina_bench_sort_evas), 10, 10000, 100);
+   eina_benchmark_register(bench, "ecore",
+                           EINA_BENCHMARK(
+                              eina_bench_sort_ecore_default), 10, 10000, 100);
+   eina_benchmark_register(bench, "ecore-merge",
+                           EINA_BENCHMARK(
+                              eina_bench_sort_ecore_merge),   10, 10000, 100);
+   eina_benchmark_register(bench, "ecore-heap",
+                           EINA_BENCHMARK(
+                              eina_bench_sort_ecore_heap),    10, 10000, 100);
+   eina_benchmark_register(bench, "evas",
+                           EINA_BENCHMARK(
+                              eina_bench_sort_evas),          10, 10000, 100);
 }
 
 
index f65cc76..a2c7b38 100644 (file)
@@ -47,22 +47,22 @@ eina_bench_stringshare_job(int request)
 
    for (i = 0; i < request; ++i)
      {
-       char build[64] = "string_";
+        char build[64] = "string_";
 
-       eina_convert_xtoa(i, build + 7);
-       tmp = eina_stringshare_add(build);
+        eina_convert_xtoa(i, build + 7);
+        tmp = eina_stringshare_add(build);
      }
 
    srand(time(NULL));
 
    for (j = 0; j < 200; ++j)
-     for (i = 0; i < request; ++i)
-       {
-         char build[64] = "string_";
+      for (i = 0; i < request; ++i)
+        {
+           char build[64] = "string_";
 
-         eina_convert_xtoa(rand() % request, build + 7);
-         tmp = eina_stringshare_add(build);
-       }
+           eina_convert_xtoa(rand() % request, build + 7);
+           tmp = eina_stringshare_add(build);
+        }
 
    eina_shutdown();
 }
@@ -79,22 +79,22 @@ eina_bench_stringchunk_job(int request)
 
    for (i = 0; i < request; ++i)
      {
-       char build[64] = "string_";
+        char build[64] = "string_";
 
-       eina_convert_xtoa(i, build + 7);
-       g_string_chunk_insert_const(chunk, build);
+        eina_convert_xtoa(i, build + 7);
+        g_string_chunk_insert_const(chunk, build);
      }
 
    srand(time(NULL));
 
    for (j = 0; j < 200; ++j)
-     for (i = 0; i < request; ++i)
-       {
-         char build[64] = "string_";
+      for (i = 0; i < request; ++i)
+        {
+           char build[64] = "string_";
 
-         eina_convert_xtoa(rand() % request, build + 7);
-         g_string_chunk_insert_const(chunk, build);
-       }
+           eina_convert_xtoa(rand() % request, build + 7);
+           g_string_chunk_insert_const(chunk, build);
+        }
 
    g_string_chunk_free(chunk);
 }
@@ -109,22 +109,22 @@ eina_bench_evas_job(int request)
 
    for (i = 0; i < request; ++i)
      {
-       char build[64] = "string_";
+        char build[64] = "string_";
 
-       eina_convert_xtoa(i, build + 7);
-       tmp = evas_stringshare_add(build);
+        eina_convert_xtoa(i, build + 7);
+        tmp = evas_stringshare_add(build);
      }
 
    srand(time(NULL));
 
    for (j = 0; j < 200; ++j)
-     for (i = 0; i < request; ++i)
-       {
-         char build[64] = "string_";
+      for (i = 0; i < request; ++i)
+        {
+           char build[64] = "string_";
 
-         eina_convert_xtoa(rand() % request, build + 7);
-         tmp = evas_stringshare_add(build);
-       }
+           eina_convert_xtoa(rand() % request, build + 7);
+           tmp = evas_stringshare_add(build);
+        }
 }
 
 static void
@@ -138,32 +138,40 @@ eina_bench_ecore_job(int request)
 
    for (i = 0; i < request; ++i)
      {
-       char build[64] = "string_";
+        char build[64] = "string_";
 
-       eina_convert_xtoa(i, build + 7);
-       tmp = ecore_string_instance(build);
+        eina_convert_xtoa(i, build + 7);
+        tmp = ecore_string_instance(build);
      }
 
    srand(time(NULL));
 
    for (j = 0; j < 200; ++j)
-     for (i = 0; i < request; ++i)
-       {
-         char build[64] = "string_";
+      for (i = 0; i < request; ++i)
+        {
+           char build[64] = "string_";
 
-         eina_convert_xtoa(rand() % request, build + 7);
-         tmp = ecore_string_instance(build);
-       }
+           eina_convert_xtoa(rand() % request, build + 7);
+           tmp = ecore_string_instance(build);
+        }
 
    ecore_string_shutdown();
 }
 
 void eina_bench_stringshare(Eina_Benchmark *bench)
 {
-   eina_benchmark_register(bench, "stringshare", EINA_BENCHMARK(eina_bench_stringshare_job), 100, 20100, 500);
+   eina_benchmark_register(bench, "stringshare",
+                           EINA_BENCHMARK(
+                              eina_bench_stringshare_job), 100, 20100, 500);
 #ifdef EINA_BENCH_HAVE_GLIB
-   eina_benchmark_register(bench, "stringchunk (glib)", EINA_BENCHMARK(eina_bench_stringchunk_job), 100, 20100, 500);
+   eina_benchmark_register(bench, "stringchunk (glib)",
+                           EINA_BENCHMARK(
+                              eina_bench_stringchunk_job), 100, 20100, 500);
 #endif
-   eina_benchmark_register(bench, "stringshare (evas)", EINA_BENCHMARK(eina_bench_evas_job), 100, 20100, 500);
-   eina_benchmark_register(bench, "stringshare (ecore)", EINA_BENCHMARK(eina_bench_ecore_job), 100, 20100, 500);
+   eina_benchmark_register(bench, "stringshare (evas)",
+                           EINA_BENCHMARK(
+                              eina_bench_evas_job),        100, 20100, 500);
+   eina_benchmark_register(bench, "stringshare (ecore)",
+                           EINA_BENCHMARK(
+                              eina_bench_ecore_job),       100, 20100, 500);
 }
index 50826c7..6ab0a80 100644 (file)
@@ -41,41 +41,41 @@ struct _Eina_Stringshare_Test
    const char *name;
 
    int (*init)(void);
-   const char *(*add)(const charstr);
-   void (*del)(const charstr);
+   const char *(*add)(const char *str);
+   void (*del)(const char *str);
    int (*shutdown)(void);
 };
 
 static const char *strings[30000];
 static Eina_Stringshare_Test eina_str = {
-  "eina",
-  eina_init,
-  eina_stringshare_add,
-  eina_stringshare_del,
-  eina_shutdown
+   "eina",
+   eina_init,
+   eina_stringshare_add,
+   eina_stringshare_del,
+   eina_shutdown
 };
 
 static Eina_Stringshare_Test evas_str = {
-  "evas",
+   "evas",
 /*  evas_stringshare_init, */
-  evas_stringshare_add,
-  evas_stringshare_del
+   evas_stringshare_add,
+   evas_stringshare_del
 /*  evas_stringshare_shutdown */
 };
 
 static Eina_Stringshare_Test ecore_str = {
-  "ecore",
-  ecore_string_init,
-  ecore_string_instance,
-  ecore_string_release,
-  ecore_string_shutdown
+   "ecore",
+   ecore_string_init,
+   ecore_string_instance,
+   ecore_string_release,
+   ecore_string_shutdown
 };
 
-static Eina_Stringshare_Teststr[] = {
-  &eina_str,
-  &evas_str,
-  &ecore_str,
-  NULL
+static Eina_Stringshare_Test *str[] = {
+   &eina_str,
+   &evas_str,
+   &ecore_str,
+   NULL
 };
 
 static void
@@ -111,7 +111,7 @@ eina_bench_e17(void)
    eina_init();
 
    for (i = 0; str[i]; ++i)
-     eina_bench_e17_stringshare(str[i]);
+      eina_bench_e17_stringshare(str[i]);
 
    eina_shutdown();
 #endif
index 53af95d..78a014f 100644 (file)
@@ -33,53 +33,57 @@ struct _Eina_Test_Case
 };
 
 static const Eina_Test_Case etc[] = {
-  { "FixedPoint", eina_test_fp },
-  { "Array", eina_test_array },
-  { "String Share", eina_test_stringshare },
-  { "Log", eina_test_log },
-  { "Error", eina_test_error },
-  { "Magic", eina_test_magic },
-  { "Inlist", eina_test_inlist },
-  { "Lazy alloc", eina_test_lalloc },
-  { "Main", eina_test_main },
-  { "Counter", eina_test_counter },
-  { "Hash", eina_test_hash },
-  { "List", eina_test_list },
-  { "Iterator", eina_test_iterator },
-  { "Accessor", eina_test_accessor },
-  { "Module", eina_test_module },
-  { "Convert", eina_test_convert },
-  { "Rbtree", eina_test_rbtree },
-  { "File", eina_test_file },
-  { "Benchmark", eina_test_benchmark },
-  { "Mempool", eina_test_mempool },
-  { "Rectangle", eina_test_rectangle },
-  { "Matrix Sparse", eina_test_matrixsparse },
-  { "Eina Tiler", eina_test_tiler },
-  { "Eina Strbuf", eina_test_strbuf },
-  { "String", eina_test_str },
-  { "QuadTree", eina_test_quadtree },
-  { NULL, NULL }
+   { "FixedPoint", eina_test_fp },
+   { "Array", eina_test_array },
+   { "Binary Share", eina_test_binshare },
+   { "String Share", eina_test_stringshare },
+   { "UString Share", eina_test_ustringshare },
+   { "Log", eina_test_log },
+   { "Error", eina_test_error },
+   { "Magic", eina_test_magic },
+   { "Inlist", eina_test_inlist },
+   { "Lazy alloc", eina_test_lalloc },
+   { "Main", eina_test_main },
+   { "Counter", eina_test_counter },
+   { "Hash", eina_test_hash },
+   { "List", eina_test_list },
+   { "Iterator", eina_test_iterator },
+   { "Accessor", eina_test_accessor },
+   { "Module", eina_test_module },
+   { "Convert", eina_test_convert },
+   { "Rbtree", eina_test_rbtree },
+   { "File", eina_test_file },
+   { "Benchmark", eina_test_benchmark },
+   { "Mempool", eina_test_mempool },
+   { "Rectangle", eina_test_rectangle },
+   { "Matrix Sparse", eina_test_matrixsparse },
+   { "Eina Tiler", eina_test_tiler },
+   { "Eina Strbuf", eina_test_strbuf },
+   { "String", eina_test_str },
+   { "Unicode String", eina_test_ustr },
+   { "QuadTree", eina_test_quadtree },
+   { NULL, NULL }
 };
 
 static void
 _list_tests(void)
 {
    const Eina_Test_Case *itr = etc;
-   fputs("Available Test Cases:\n", stderr);
+      fputs("Available Test Cases:\n", stderr);
    for (; itr->test_case != NULL; itr++)
-     fprintf(stderr, "\t%s\n", itr->test_case);
+      fprintf(stderr, "\t%s\n", itr->test_case);
 }
 
 static Eina_Bool
 _use_test(int argc, const char **argv, const char *test_case)
 {
    if (argc < 1)
-     return 1;
+      return 1;
 
    for (; argc > 0; argc--, argv++)
-     if (strcmp(test_case, *argv) == 0)
-       return 1;
+      if (strcmp(test_case, *argv) == 0)
+         return 1;
+
    return 0;
 }
 
@@ -94,13 +98,15 @@ eina_build_suite(int argc, const char **argv)
 
    for (i = 0; etc[i].test_case != NULL; ++i)
      {
-       if (!_use_test(argc, argv, etc[i].test_case)) continue;
-       tc = tcase_create(etc[i].test_case);
+        if (!_use_test(argc, argv, etc[i].test_case))
+           continue;
+
+        tc = tcase_create(etc[i].test_case);
 
-       etc[i].build(tc);
+        etc[i].build(tc);
 
-       suite_add_tcase(s, tc);
-       tcase_set_timeout(tc, 0);
+        suite_add_tcase(s, tc);
+        tcase_set_timeout(tc, 0);
      }
 
    return s;
@@ -112,10 +118,14 @@ eina_build_suite(int argc, const char **argv)
 static Eina_Array *_modules;
 static void _mempool_init(void)
 {
-    eina_init();
-    /* force modules to be loaded in case they are not installed */
-    _modules = eina_module_list_get(NULL, PACKAGE_BUILD_DIR"/src/modules", 1, NULL, NULL);
-    eina_module_list_load(_modules);
+   eina_init();
+   /* force modules to be loaded in case they are not installed */
+   _modules = eina_module_list_get(NULL,
+                                   PACKAGE_BUILD_DIR "/src/modules",
+                                   1,
+                                   NULL,
+                                   NULL);
+   eina_module_list_load(_modules);
 }
 
 static void _mempool_shutdown(void)
@@ -133,20 +143,20 @@ main(int argc, char **argv)
    int i, failed_count;
 
    for (i = 1; i < argc; i++)
-     if ((strcmp(argv[i], "-h") == 0) ||
-        (strcmp(argv[i], "--help") == 0))
-       {
-         fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n",
-                 argv[0]);
-         _list_tests();
-         return 0;
-       }
-     else if ((strcmp(argv[i], "-l") == 0) ||
-             (strcmp(argv[i], "--list") == 0))
-       {
-         _list_tests();
-         return 0;
-       }
+      if ((strcmp(argv[i], "-h") == 0) ||
+          (strcmp(argv[i], "--help") == 0))
+        {
+           fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n",
+                   argv[0]);
+           _list_tests();
+           return 0;
+        }
+      else if ((strcmp(argv[i], "-l") == 0) ||
+               (strcmp(argv[i], "--list") == 0))
+        {
+           _list_tests();
+           return 0;
+        }
 
    s = eina_build_suite(argc - 1, (const char **)argv + 1);
    sr = srunner_create(s);
index 9de0dab..b63cb60 100644 (file)
@@ -22,6 +22,8 @@
 #include <check.h>
 
 void eina_test_stringshare(TCase *tc);
+void eina_test_ustringshare(TCase *tc);
+void eina_test_binshare(TCase *tc);
 void eina_test_array(TCase *tc);
 void eina_test_log(TCase *tc);
 void eina_test_error(TCase *tc);
@@ -45,6 +47,7 @@ void eina_test_matrixsparse(TCase *tc);
 void eina_test_tiler(TCase *tc);
 void eina_test_strbuf(TCase *tc);
 void eina_test_str(TCase *tc);
+void eina_test_ustr(TCase *tc);
 void eina_test_quadtree(TCase *tc);
 void eina_test_fp(TCase *tc);
 
index 88b74ad..3c85ef0 100644 (file)
@@ -27,7 +27,7 @@
 
 static Eina_Bool
 eina_accessor_check(__UNUSED__ const Eina_Array *array,
-                   int *data,  int *fdata)
+                    int *data,  int *fdata)
 {
    fail_if(*fdata > *data);
    *fdata = *data;
@@ -45,26 +45,26 @@ START_TEST(eina_accessor_array_simple)
    eina_init();
 
    ea = eina_array_new(11);
-   fail_if(!ea);
+        fail_if(!ea);
 
    for (i = 0; i < 200; ++i)
      {
-       tmp = malloc(sizeof(int));
-       fail_if(!tmp);
-       *tmp = i;
+        tmp = malloc(sizeof(int));
+        fail_if(!tmp);
+        *tmp = i;
 
-       eina_array_push(ea, tmp);
+        eina_array_push(ea, tmp);
      }
 
    it = eina_array_accessor_new(ea);
    fail_if(!it);
 
-   fail_if(eina_accessor_data_get(it, 100, (void**) &tmp) != EINA_TRUE);
+   fail_if(eina_accessor_data_get(it, 100, (void **)&tmp) != EINA_TRUE);
    fail_if(!tmp);
    fail_if(*tmp != 100);
 
    i = 50;
-   eina_accessor_over(it, EINA_EACH(eina_accessor_check), 50, 100, &i);
+   eina_accessor_over(it, EINA_EACH_CB(eina_accessor_check), 50, 100, &i);
    fail_if(i != 99);
 
    fail_if(eina_accessor_container_get(it) != ea);
@@ -84,7 +84,7 @@ struct _Eina_Test_Inlist
    int i;
 };
 
-static Eina_Test_Inlist*
+static Eina_Test_Inlist *
 _eina_test_inlist_build(int i)
 {
    Eina_Test_Inlist *tmp;
@@ -97,11 +97,14 @@ _eina_test_inlist_build(int i)
 }
 
 static Eina_Bool
-eina_accessor_inlist_data_check(__UNUSED__ const Eina_Inlist *in_list, Eina_Test_Inlist *data, int *fdata)
+eina_accessor_inlist_data_check(__UNUSED__ const Eina_Inlist *in_list,
+                                Eina_Test_Inlist *data,
+                                int *fdata)
 {
    switch (*fdata)
      {
       case 0: fail_if(data->i != 3227); break;
+
       case 1: fail_if(data->i != 1664); break;
      }
 
@@ -125,13 +128,14 @@ START_TEST(eina_accessor_inlist_simple)
    tmp = _eina_test_inlist_build(1664);
    lst = eina_inlist_append_relative(lst, EINA_INLIST_GET(tmp), lst);
    fail_if(!lst);
-   fail_if(((Eina_Test_Inlist*)lst)->i != 42);
+   fail_if(((Eina_Test_Inlist *)lst)->i != 42);
 
    prev = tmp;
    tmp = _eina_test_inlist_build(3227);
-   lst = eina_inlist_prepend_relative(lst, EINA_INLIST_GET(tmp), EINA_INLIST_GET(prev));
+   lst = eina_inlist_prepend_relative(lst, EINA_INLIST_GET(
+                                         tmp), EINA_INLIST_GET(prev));
    fail_if(!lst);
-   fail_if(((Eina_Test_Inlist*)lst)->i != 42);
+   fail_if(((Eina_Test_Inlist *)lst)->i != 42);
 
    tmp = _eina_test_inlist_build(27);
    lst = eina_inlist_prepend_relative(lst, EINA_INLIST_GET(tmp), NULL);
@@ -146,14 +150,14 @@ START_TEST(eina_accessor_inlist_simple)
    fail_if(!it);
    fail_if(eina_accessor_container_get(it) != lst);
 
-   eina_accessor_over(it, EINA_EACH(eina_accessor_inlist_data_check), 2, 4, &i);
+   eina_accessor_over(it, EINA_EACH_CB(eina_accessor_inlist_data_check), 2, 4, &i);
 
-   fail_if(eina_accessor_data_get(it, 5, (void**) &tmp) != EINA_TRUE);
-   fail_if(eina_accessor_data_get(it, 3, (void**) &tmp) != EINA_TRUE);
+   fail_if(eina_accessor_data_get(it, 5, (void **)&tmp) != EINA_TRUE);
+   fail_if(eina_accessor_data_get(it, 3, (void **)&tmp) != EINA_TRUE);
    fail_if(tmp->i != 1664);
-   fail_if(eina_accessor_data_get(it, 3, (void**) &tmp) != EINA_TRUE);
+   fail_if(eina_accessor_data_get(it, 3, (void **)&tmp) != EINA_TRUE);
    fail_if(tmp->i != 1664);
-   fail_if(eina_accessor_data_get(it, 1, (void**) &tmp) != EINA_TRUE);
+   fail_if(eina_accessor_data_get(it, 1, (void **)&tmp) != EINA_TRUE);
    fail_if(tmp->i != 42);
 
    eina_accessor_free(it);
@@ -163,11 +167,14 @@ START_TEST(eina_accessor_inlist_simple)
 END_TEST
 
 static Eina_Bool
-eina_iterator_list_data_check(__UNUSED__ const Eina_List *list, int *data, int *fdata)
+eina_iterator_list_data_check(__UNUSED__ const Eina_List *list,
+                              int *data,
+                              int *fdata)
 {
    switch (*fdata)
      {
       case 0: fail_if(*data != 9); break;
+
       case 1: fail_if(*data != 6); break;
      }
 
@@ -210,17 +217,17 @@ START_TEST(eina_accessor_list_simple)
    it = eina_list_accessor_new(list);
    fail_if(!it);
 
-   eina_accessor_over(it, EINA_EACH(eina_iterator_list_data_check), 2, 4, &i);
+   eina_accessor_over(it, EINA_EACH_CB(eina_iterator_list_data_check), 2, 4, &i);
 
-   fail_if(eina_accessor_data_get(it, 5, (void**) &j) != EINA_TRUE);
+   fail_if(eina_accessor_data_get(it, 5, (void **)&j) != EINA_TRUE);
    fail_if(*j != 1);
-   fail_if(eina_accessor_data_get(it, 3, (void**) &j) != EINA_TRUE);
+   fail_if(eina_accessor_data_get(it, 3, (void **)&j) != EINA_TRUE);
    fail_if(*j != 6);
-   fail_if(eina_accessor_data_get(it, 3, (void**) &j) != EINA_TRUE);
+   fail_if(eina_accessor_data_get(it, 3, (void **)&j) != EINA_TRUE);
    fail_if(*j != 6);
-   fail_if(eina_accessor_data_get(it, 1, (void**) &j) != EINA_TRUE);
+   fail_if(eina_accessor_data_get(it, 1, (void **)&j) != EINA_TRUE);
    fail_if(*j != 7);
-   fail_if(eina_accessor_data_get(it, 5, (void**) &j) != EINA_TRUE);
+   fail_if(eina_accessor_data_get(it, 5, (void **)&j) != EINA_TRUE);
    fail_if(*j != 1);
 
    eina_accessor_free(it);
index b3ad459..0b054ea 100644 (file)
@@ -35,15 +35,15 @@ START_TEST(eina_array_simple)
    eina_init();
 
    ea = eina_array_new(11);
-   fail_if(!ea);
+        fail_if(!ea);
 
    for (i = 0; i < 201; ++i)
      {
-       tmp = malloc(sizeof(char) * 10);
-       fail_if(!tmp);
-       eina_convert_itoa(i, tmp);
+        tmp = malloc(sizeof(char) * 10);
+        fail_if(!tmp);
+        eina_convert_itoa(i, tmp);
 
-       eina_array_push(ea, tmp);
+        eina_array_push(ea, tmp);
      }
 
    fail_if(eina_array_data_get(ea, 10) == NULL);
@@ -55,7 +55,7 @@ START_TEST(eina_array_simple)
 
    EINA_ARRAY_ITER_NEXT(ea, i, tmp, it)
      {
-       fail_if((unsigned int) atoi(tmp) != i);
+       fail_if((unsigned int)atoi(tmp) != i);
        free(tmp);
      }
 
@@ -78,15 +78,15 @@ START_TEST(eina_array_static)
 
    eina_init();
 
-   eina_array_step_set(&sea, 10);
+   eina_array_step_set(&sea, sizeof(sea), 10);
 
    for (i = 0; i < 200; ++i)
      {
-       tmp = malloc(sizeof(char) * 10);
-       fail_if(!tmp);
-       eina_convert_itoa(i, tmp);
+        tmp = malloc(sizeof(char) * 10);
+        fail_if(!tmp);
+        eina_convert_itoa(i, tmp);
 
-       eina_array_push(&sea, tmp);
+        eina_array_push(&sea, tmp);
      }
 
    fail_if(eina_array_data_get(&sea, 10) == NULL);
@@ -94,8 +94,8 @@ START_TEST(eina_array_static)
 
    EINA_ARRAY_ITER_NEXT(&sea, i, tmp, it)
      {
-       fail_if((unsigned int) atoi(tmp) != i);
-       free(tmp);
+       fail_if((unsigned int)atoi(tmp) != i);
+        free(tmp);
      }
 
    fail_if(i != 200);
@@ -115,7 +115,9 @@ keep_int(void *data, void *gdata)
    fail_if(gdata);
    fail_if(!tmp);
 
-   if (*tmp == 0) return EINA_FALSE;
+   if (*tmp == 0)
+      return EINA_FALSE;
+
    return EINA_TRUE;
 }
 
@@ -129,23 +131,23 @@ START_TEST(eina_array_remove_stuff)
    eina_init();
 
    ea = eina_array_new(64);
-   fail_if(!ea);
+        fail_if(!ea);
 
    for (i = 0; i < 1000; ++i)
      {
-       tmp = malloc(sizeof(int));
-       fail_if(!tmp);
-       *tmp = i;
+        tmp = malloc(sizeof(int));
+        fail_if(!tmp);
+        *tmp = i;
 
-       eina_array_push(ea, tmp);
+        eina_array_push(ea, tmp);
      }
 
    // Remove the first 10 items
    for (i = 0; i < 10; ++i)
      {
-       tmp = eina_array_data_get(ea, i);
-       fail_if(!tmp);
-       *tmp = 0;
+        tmp = eina_array_data_get(ea, i);
+        fail_if(!tmp);
+        *tmp = 0;
      }
    fail_if(eina_array_remove(ea, keep_int, NULL) != EINA_TRUE);
 
@@ -156,18 +158,18 @@ START_TEST(eina_array_remove_stuff)
    // Remove the last items
    for (i = 980; i < 990; ++i)
      {
-       tmp = eina_array_data_get(ea, i);
-       fail_if(!tmp);
-       *tmp = 0;
+        tmp = eina_array_data_get(ea, i);
+        fail_if(!tmp);
+        *tmp = 0;
      }
-   eina_array_remove(ea, keep_int, NULL);
+        eina_array_remove(ea, keep_int, NULL);
 
    // Remove all items
    fail_if(eina_array_count_get(ea) != 980);
    EINA_ARRAY_ITER_NEXT(ea, i, tmp, it)
      {
-       fail_if(*tmp == 0);
-       *tmp = 0;
+        fail_if(*tmp == 0);
+        *tmp = 0;
      }
 
    eina_array_remove(ea, keep_int, NULL);
index 129932e..4352c16 100644 (file)
@@ -34,7 +34,7 @@ _eina_benchmark_specimens(int request)
    int a = 0;
 
    for (i = 0; i < request; ++i)
-     a += i;
+      a += i;
 
    global_test = a;
 }
@@ -50,15 +50,17 @@ START_TEST(eina_benchmark_simple)
    eb = eina_benchmark_new("benchmark", "test");
    fail_if(!eb);
 
-   eina_benchmark_register(eb, "specimens_check", EINA_BENCHMARK(_eina_benchmark_specimens), 1000, 1100, 100);
+   eina_benchmark_register(eb, "specimens_check",
+                           EINA_BENCHMARK(_eina_benchmark_specimens),
+                          1000, 1100, 100);
 
    ea = eina_benchmark_run(eb);
    fail_if(!ea);
 
    EINA_ARRAY_ITER_NEXT(ea, i, tmp, it)
      {
-       fail_if(!tmp);
-       fail_if(unlink(tmp));
+        fail_if(!tmp);
+        fail_if(unlink(tmp));
      }
 
    fail_if(global_test != 499500);
diff --git a/src/tests/eina_test_binshare.c b/src/tests/eina_test_binshare.c
new file mode 100644 (file)
index 0000000..b6c4c79
--- /dev/null
@@ -0,0 +1,209 @@
+/* EINA - EFL data type library
+ * Copyright (C) 2008 Cedric Bail
+ *
+ * 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
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+
+#include "eina_suite.h"
+#include "Eina.h"
+
+#define TEST0 "te\0st/0"
+#define TEST0_SIZE 7
+#define TEST1 "te\0st/11"
+#define TEST1_SIZE 8
+
+START_TEST(eina_binshare_simple)
+{
+   const char *t0;
+   const char *t1;
+
+   eina_init();
+   eina_binshare_init();
+
+   t0 = eina_binshare_add_length(TEST0, TEST0_SIZE);
+   t1 = eina_binshare_add_length(TEST1, TEST1_SIZE);
+
+   fail_if(t0 == NULL);
+   fail_if(t1 == NULL);
+   fail_if(memcmp(t0, TEST0, TEST0_SIZE) != 0);
+   fail_if(memcmp(t1, TEST1, TEST1_SIZE) != 0);
+
+   t0 = eina_binshare_ref(t0);
+   fail_if(t0 == NULL);
+   fail_if(memcmp(t0, TEST0, TEST0_SIZE) != 0);
+
+   eina_binshare_del(t0);
+   eina_binshare_del(t0);
+   eina_binshare_del(t1);
+
+   eina_binshare_shutdown();
+   eina_shutdown();
+}
+END_TEST
+
+START_TEST(eina_binshare_small)
+{
+   char buf[4];
+   int i;
+
+   eina_init();
+   eina_binshare_init();
+
+   for (i = 1; i < 3; i++)
+     {
+        const char *t0, *t1;
+        int j;
+
+        for (j = 0; j < i; j++)
+          {
+             char c;
+             for (c = 'a'; c <= 'z'; c++)
+                buf[j] = c;
+          }
+        buf[i] = '\0';
+        t0 = eina_binshare_add_length(buf, i);
+        t1 = eina_binshare_add_length(buf, i);
+
+        fail_if(t0 == NULL);
+        fail_if(t1 == NULL);
+        fail_if(t0 != t1);
+        fail_if(memcmp(t0, buf, i) != 0);
+
+        eina_binshare_del(t0);
+        eina_binshare_del(t1);
+     }
+        eina_binshare_shutdown();
+   eina_shutdown();
+}
+END_TEST
+
+
+START_TEST(eina_binshare_test_share)
+{
+   const char *t0;
+   const char *t1;
+
+   eina_init();
+   eina_binshare_init();
+
+   t0 = eina_binshare_add_length(TEST0, TEST0_SIZE);
+   t1 = eina_binshare_add_length(TEST0, TEST0_SIZE);
+
+   fail_if(t0 == NULL);
+   fail_if(t1 == NULL);
+   fail_if(memcmp(t0, TEST0, TEST0_SIZE) != 0);
+   fail_if(memcmp(t1, TEST0, TEST0_SIZE) != 0);
+   fail_if(t0 != t1);
+   fail_if(TEST0_SIZE != eina_binshare_length(t0));
+
+   eina_binshare_del(t0);
+   eina_binshare_del(t1);
+   eina_binshare_shutdown();
+   eina_shutdown();
+}
+END_TEST
+
+START_TEST(eina_binshare_putstuff)
+{
+   const char *tmp;
+   int i;
+
+   eina_init();
+   eina_binshare_init();
+
+   for (i = 10000; i > 0; --i)
+     {
+        char build[64] = "string_";
+
+        eina_convert_xtoa(i, build + 7);
+        tmp = eina_binshare_add_length(build, strlen(build));
+        fail_if(tmp != eina_binshare_add_length(build, strlen(build)));
+        fail_if((int)strlen(build) != eina_binshare_length(tmp));
+     }
+        eina_binshare_shutdown();
+   eina_shutdown();
+}
+END_TEST
+
+START_TEST(eina_binshare_collision)
+{
+   Eina_Array *ea;
+   char buffer[50];
+   int i;
+
+   srand(time(NULL));
+
+   eina_init();
+   eina_binshare_init();
+
+   ea = eina_array_new(256);
+   fail_if(!ea);
+
+   for (i = 0; i < 10000; ++i)
+     {
+        eina_convert_itoa(rand(), buffer);
+        eina_array_push(ea,
+                        (void *)eina_binshare_add_length(buffer, strlen(buffer)));
+        if (rand() > RAND_MAX / 2)
+          {
+             const char *r = eina_binshare_add_length(buffer, strlen(buffer));
+             fail_if(r == NULL);
+          }
+     }
+
+   for (i = 0; i < 10000; ++i)
+     {
+        const char *r;
+
+        eina_convert_itoa(60000 - i, buffer);
+        eina_array_push(ea,
+                        (void *)eina_binshare_add_length(buffer, strlen(buffer)));
+        r = eina_binshare_add_length(buffer, strlen(buffer));
+        fail_if(r == NULL);
+        r = eina_binshare_add_length(buffer, strlen(buffer));
+        fail_if(r == NULL);
+     }
+
+   for (i = 0; i < 200; ++i)
+      eina_binshare_del(eina_array_data_get(ea, i));
+
+   for (i = 0; i < 1000; ++i)
+      eina_binshare_del(eina_array_pop(ea));
+
+      eina_binshare_shutdown();
+   eina_shutdown();
+
+   eina_array_free(ea);
+}
+END_TEST
+
+void
+eina_test_binshare(TCase *tc)
+{
+   tcase_add_test(tc, eina_binshare_simple);
+   tcase_add_test(tc, eina_binshare_small);
+   tcase_add_test(tc, eina_binshare_test_share);
+   tcase_add_test(tc, eina_binshare_collision);
+   tcase_add_test(tc, eina_binshare_putstuff);
+}
index cb13f19..8e7f58c 100644 (file)
@@ -78,19 +78,19 @@ _eina_convert_check(double test, int length)
    fail_if(fabs(r - test) > DBL_MIN);
 }
 
-START_TEST(eina_convert_double)
+   START_TEST(eina_convert_double)
 {
    long long int m = 0;
    long e = 0;
 
    eina_init();
 
-   _eina_convert_check(EET_TEST_DOUBLE0, 20);
+   _eina_convert_check(EET_TEST_DOUBLE0,  20);
    _eina_convert_check(-EET_TEST_DOUBLE0, 21);
-   _eina_convert_check(EET_TEST_DOUBLE1, 6);
-   _eina_convert_check(EET_TEST_DOUBLE2, 6);
-   _eina_convert_check(EET_TEST_DOUBLE3, 21);
-   _eina_convert_check(EET_TEST_DOUBLE4, 21);
+   _eina_convert_check(EET_TEST_DOUBLE1,   6);
+   _eina_convert_check(EET_TEST_DOUBLE2,   6);
+   _eina_convert_check(EET_TEST_DOUBLE3,  21);
+   _eina_convert_check(EET_TEST_DOUBLE4,  21);
 
    fail_if(eina_convert_atod("ah ah ah", 8, &m, &e) != EINA_FALSE);
    fail_if(eina_convert_atod("0xjo", 8, &m, &e) != EINA_FALSE);
@@ -145,13 +145,13 @@ _eina_convert_fp_check(double d, Eina_F32p32 fp, int length)
    fail_if(fabs(fpd - d) > DBL_MIN);
 }
 
-START_TEST(eina_convert_fp)
+   START_TEST(eina_convert_fp)
 {
-   _eina_convert_fp_check(1.0, 0x0000000100000000, 6);
-   _eina_convert_fp_check(0.5, 0x0000000080000000, 8);
-   _eina_convert_fp_check(0.625, 0x00000000a0000000, 8);
-   _eina_convert_fp_check(256.0, 0x0000010000000000, 6);
-   _eina_convert_fp_check(0.5, 0x0000000080000000, 8);
+   _eina_convert_fp_check(1.0,     0x0000000100000000,  6);
+   _eina_convert_fp_check(0.5,     0x0000000080000000,  8);
+   _eina_convert_fp_check(0.625,   0x00000000a0000000,  8);
+   _eina_convert_fp_check(256.0,   0x0000010000000000,  6);
+   _eina_convert_fp_check(0.5,     0x0000000080000000,  8);
    _eina_convert_fp_check(128.625, 0x00000080a0000000, 10);
 }
 END_TEST
@@ -161,5 +161,5 @@ eina_test_convert(TCase *tc)
 {
    tcase_add_test(tc, eina_convert_simple);
    tcase_add_test(tc, eina_convert_double);
-   tcase_add_test(tc, eina_convert_fp);
+   tcase_add_test(tc,     eina_convert_fp);
 }
index a40999e..2a3f30d 100644 (file)
@@ -42,8 +42,8 @@ START_TEST(eina_counter_simple)
 
    for (i = 0; i < 100000; ++i)
      {
-       void *tmp = malloc(sizeof(long int));
-       free(tmp);
+        void *tmp = malloc(sizeof(long int));
+        free(tmp);
      }
 
    eina_counter_stop(cnt, i);
@@ -52,8 +52,8 @@ START_TEST(eina_counter_simple)
 
    for (i = 0; i < 200000; ++i)
      {
-       void *tmp = malloc(sizeof(long int));
-       free(tmp);
+        void *tmp = malloc(sizeof(long int));
+        free(tmp);
      }
 
    eina_counter_stop(cnt, i);
index 1cd0435..506f406 100644 (file)
 #include <stdio.h>
 #include <string.h>
 
+#ifdef HAVE_EVIL
+# include <Evil.h>
+#endif
+
 #include "eina_suite.h"
 #include "Eina.h"
 
index d05a095..aeb5461 100644 (file)
@@ -41,7 +41,11 @@ START_TEST(eina_file_split_simple)
    fail_if(eina_error_get() != EINA_ERROR_SAFETY_FAILED);
 #endif
 
+#ifdef _WIN32
+   ea = eina_file_split(strdup("\\this\\is\\a\\small\\test"));
+#else
    ea = eina_file_split(strdup("/this/is/a/small/test"));
+#endif
 
    fail_if(!ea);
    fail_if(eina_array_count_get(ea) != 5);
@@ -53,7 +57,13 @@ START_TEST(eina_file_split_simple)
 
    eina_array_free(ea);
 
+#ifdef _WIN32
+   ea =
+      eina_file_split(strdup(
+                         "this\\\\is\\\\\\a \\more\\complex\\\\\\case\\\\\\"));
+#else
    ea = eina_file_split(strdup("this//is///a /more/complex///case///"));
+#endif
 
    fail_if(!ea);
    fail_if(eina_array_count_get(ea) != 6);
index 0df9f8a..bdb3100 100644 (file)
@@ -36,22 +36,22 @@ START_TEST(eina_fp_cos)
    double dresult;
    double delta;
 
-   fail_if(!eina_init());
+        fail_if(!eina_init());
 
    fl = eina_f32p32_scale(EINA_F32P32_PI, 4);
    step = eina_f32p32_div(fl, eina_f32p32_int_from(2048));
 
    for (fc = 0; fc < fl; fc += step)
      {
-       fresult = eina_f32p32_cos(fc);
-       dc = eina_f32p32_double_to(fc);
-       dresult = cos(dc);
+        fresult = eina_f32p32_cos(fc);
+        dc = eina_f32p32_double_to(fc);
+        dresult = cos(dc);
 
-       delta = fabs(dresult - eina_f32p32_double_to(fresult));
-       fail_if(delta > 0.005);
+        delta = fabs(dresult - eina_f32p32_double_to(fresult));
+        fail_if(delta > 0.005);
      }
 
-   eina_shutdown();
+        eina_shutdown();
 }
 END_TEST
 
@@ -65,19 +65,19 @@ START_TEST(eina_fp_sin)
    double dresult;
    double delta;
 
-   fail_if(!eina_init());
+        fail_if(!eina_init());
 
    fl = eina_f32p32_scale(EINA_F32P32_PI, 4);
    step = eina_f32p32_div(fl, eina_f32p32_int_from(2048));
 
    for (fc = 0; fc < fl; fc += step)
      {
-       fresult = eina_f32p32_sin(fc);
-       dc = eina_f32p32_double_to(fc);
-       dresult = sin(dc);
+        fresult = eina_f32p32_sin(fc);
+        dc = eina_f32p32_double_to(fc);
+        dresult = sin(dc);
 
-       delta = fabs(dresult - eina_f32p32_double_to(fresult));
-       fail_if(delta > 0.005);
+        delta = fabs(dresult - eina_f32p32_double_to(fresult));
+        fail_if(delta > 0.005);
      }
 
 
index 5b7d803..aeeb655 100644 (file)
 #include "Eina.h"
 
 static Eina_Bool
-eina_foreach_check(__UNUSED__ const Eina_Hash *hash, const void *key, void *data, __UNUSED__ void *fdata)
+eina_foreach_check(__UNUSED__ const Eina_Hash *hash,
+                   const void *key,
+                   void *data,
+                   __UNUSED__ void *fdata)
 {
    int *j = data;
    int i;
 
-   if (strlen(key) <= 0) return EINA_TRUE;
+   if (strlen(key) <= 0)
+      return EINA_TRUE;
 
    i = atoi(key);
    fail_if(i != *j);
@@ -95,7 +99,7 @@ START_TEST(eina_hash_simple)
    eina_hash_free(hash);
 
    /* Same comment as eina_init */
-   fail_if(eina_shutdown() != 1);
+        fail_if(eina_shutdown() != 1);
 }
 END_TEST
 
@@ -104,24 +108,24 @@ START_TEST(eina_hash_extended)
    Eina_Hash *hash = NULL;
    int i;
 
-   fail_if(eina_init() != 2);
+        fail_if(eina_init() != 2);
 
    hash = eina_hash_string_djb2_new(NULL);
-   fail_if(hash == NULL);
+        fail_if(hash == NULL);
 
-   fail_if(eina_hash_direct_add(hash, "42", "42") != EINA_TRUE);
+        fail_if(eina_hash_direct_add(hash, "42", "42") != EINA_TRUE);
 
    for (i = 43; i < 3043; ++i)
      {
-       char *tmp = malloc(10);
-       fail_if(!tmp);
-       eina_convert_itoa(i, tmp);
-       fail_if(eina_hash_direct_add(hash, tmp, tmp) != EINA_TRUE);
+        char *tmp = malloc(10);
+        fail_if(!tmp);
+        eina_convert_itoa(i, tmp);
+        fail_if(eina_hash_direct_add(hash, tmp, tmp) != EINA_TRUE);
      }
 
-   fail_if(eina_hash_find(hash, "42") == NULL);
+        fail_if(eina_hash_find(hash, "42") == NULL);
 
-   eina_hash_free(hash);
+        eina_hash_free(hash);
 
    fail_if(eina_shutdown() != 1);
 }
@@ -147,7 +151,7 @@ START_TEST(eina_hash_double_item)
 
    eina_hash_free(hash);
 
-   fail_if(eina_shutdown() != 1);
+      fail_if(eina_shutdown() != 1);
 }
 END_TEST
 
@@ -160,34 +164,34 @@ START_TEST(eina_hash_all_int)
    int *test;
    int it;
 
-   fail_if(eina_init() != 2);
+      fail_if(eina_init() != 2);
 
    hash = eina_hash_int32_new(NULL);
-   fail_if(hash == NULL);
+      fail_if(hash == NULL);
 
    for (it = 0; it < 4; ++it)
-     fail_if(eina_hash_add(hash, &i[it], &i[it]) != EINA_TRUE);
+      fail_if(eina_hash_add(hash, &i[it], &i[it]) != EINA_TRUE);
 
-   fail_if(eina_hash_del(hash, &i[1], &i[1]) != EINA_TRUE);
+      fail_if(eina_hash_del(hash, &i[1], &i[1]) != EINA_TRUE);
    test = eina_hash_find(hash, &i[2]);
-   fail_if(test != &i[2]);
+      fail_if(test != &i[2]);
 
    test = eina_hash_find(hash, &i[3]);
-   fail_if(test != &i[3]);
+      fail_if(test != &i[3]);
 
-   eina_hash_free(hash);
+      eina_hash_free(hash);
 
    hash = eina_hash_int64_new(NULL);
-   fail_if(hash == NULL);
+      fail_if(hash == NULL);
 
    for (it = 0; it < 4; ++it)
-     fail_if(eina_hash_add(hash, &j[it], &j[it]) != EINA_TRUE);
+      fail_if(eina_hash_add(hash, &j[it], &j[it]) != EINA_TRUE);
 
-   fail_if(eina_hash_del(hash, &j[1], &j[1]) != EINA_TRUE);
+      fail_if(eina_hash_del(hash, &j[1], &j[1]) != EINA_TRUE);
    test2 = eina_hash_find(hash, &j[0]);
-   fail_if(test2 != &j[0]);
+      fail_if(test2 != &j[0]);
 
-   eina_hash_free(hash);
+      eina_hash_free(hash);
 
    fail_if(eina_shutdown() != 1);
 }
index abc6638..6d8b210 100644 (file)
@@ -34,7 +34,7 @@ struct _Eina_Test_Inlist
    EINA_INLIST;
 };
 
-static Eina_Test_Inlist*
+static Eina_Test_Inlist *
 _eina_test_inlist_build(int i)
 {
    Eina_Test_Inlist *tmp;
@@ -67,7 +67,8 @@ START_TEST(eina_inlist_simple)
 
    prev = tmp;
    tmp = _eina_test_inlist_build(3227);
-   lst = eina_inlist_prepend_relative(lst, EINA_INLIST_GET(tmp), EINA_INLIST_GET(prev));
+   lst = eina_inlist_prepend_relative(lst, EINA_INLIST_GET(
+                                         tmp), EINA_INLIST_GET(prev));
    fail_if(!lst);
    fail_if(EINA_INLIST_CONTAINER_GET(lst, Eina_Test_Inlist)->i != 42);
 
@@ -85,18 +86,22 @@ START_TEST(eina_inlist_simple)
    lst = eina_inlist_append_relative(lst, EINA_INLIST_GET(tmp), NULL);
 
    EINA_INLIST_FOREACH(lst, tmp)
-     {
-       switch (i)
-         {
-          case 0: fail_if(tmp->i != 27); break;
-          case 1: fail_if(tmp->i != 3227); break;
-          case 2: fail_if(tmp->i != 42); break;
-          case 3: fail_if(tmp->i != 1664); break;
-          case 4: fail_if(tmp->i != 81); break;
-         }
-
-       ++i;
-     }
+   {
+      switch (i)
+        {
+         case 0: fail_if(tmp->i != 27); break;
+
+         case 1: fail_if(tmp->i != 3227); break;
+
+         case 2: fail_if(tmp->i != 42); break;
+
+         case 3: fail_if(tmp->i != 1664); break;
+
+         case 4: fail_if(tmp->i != 81); break;
+        }
+
+      ++i;
+   }
 
 #ifdef EINA_SAFETY_CHECKS
    fprintf(stderr, "you should have a safety check failure below:\n");
@@ -106,7 +111,7 @@ START_TEST(eina_inlist_simple)
       fail_if(eina_error_get() != EINA_ERROR_SAFETY_FAILED);
    }
 
-   fprintf(stderr, "you should have a safety check failure below:\n");
+      fprintf(stderr, "you should have a safety check failure below:\n");
    lst = eina_inlist_remove(lst, NULL);
    fail_if(eina_error_get() != EINA_ERROR_SAFETY_FAILED);
 #endif
@@ -118,14 +123,15 @@ START_TEST(eina_inlist_simple)
    lst = eina_inlist_promote(lst, EINA_INLIST_GET(tmp));
    fail_if(lst != EINA_INLIST_GET(tmp));
 
-   tmp = EINA_INLIST_CONTAINER_GET(eina_inlist_find(lst, EINA_INLIST_GET(prev)), Eina_Test_Inlist);
+   tmp = EINA_INLIST_CONTAINER_GET(eina_inlist_find(lst, EINA_INLIST_GET(
+                                                       prev)), Eina_Test_Inlist);
    lst = eina_inlist_remove(lst, EINA_INLIST_GET(tmp));
    prev = (Eina_Test_Inlist *)eina_inlist_find(lst, EINA_INLIST_GET(tmp));
    tmp = prev ? EINA_INLIST_CONTAINER_GET(prev, Eina_Test_Inlist) : NULL;
    fail_if(tmp != NULL);
 
    while (lst)
-     lst = eina_inlist_remove(lst, lst);
+      lst = eina_inlist_remove(lst, lst);
 }
 END_TEST
 
index cc77f07..84bb336 100644 (file)
@@ -27,7 +27,7 @@
 
 static Eina_Bool
 eina_iterator_array_check(__UNUSED__ const Eina_Array *array,
-                         int *data,  int *fdata)
+                          int *data,  int *fdata)
 {
    fail_if(*fdata > *data);
    *fdata = *data;
@@ -45,26 +45,26 @@ START_TEST(eina_iterator_array_simple)
    eina_init();
 
    ea = eina_array_new(11);
-   fail_if(!ea);
+        fail_if(!ea);
 
    for (i = 0; i < 200; ++i)
      {
-       tmp = malloc(sizeof(int));
-       fail_if(!tmp);
-       *tmp = i;
+        tmp = malloc(sizeof(int));
+        fail_if(!tmp);
+        *tmp = i;
 
-       eina_array_push(ea, tmp);
+        eina_array_push(ea, tmp);
      }
 
    it = eina_array_iterator_new(ea);
    fail_if(!it);
 
    i = -1;
-   eina_iterator_foreach(it, EINA_EACH(eina_iterator_array_check), &i);
+   eina_iterator_foreach(it, EINA_EACH_CB(eina_iterator_array_check), &i);
    fail_if(i != 199);
 
    fail_if(eina_iterator_container_get(it) != ea);
-   fail_if(eina_iterator_next(it, (void**) &tmp) != EINA_FALSE);
+   fail_if(eina_iterator_next(it, (void **)&tmp) != EINA_FALSE);
 
    eina_iterator_free(it);
 
@@ -75,14 +75,18 @@ START_TEST(eina_iterator_array_simple)
 END_TEST
 
 static Eina_Bool
-eina_iterator_hash_key_check(const Eina_Hash *hash, const char *key, __UNUSED__ void *fdata)
+eina_iterator_hash_key_check(const Eina_Hash *hash,
+                             const char *key,
+                             __UNUSED__ void *fdata)
 {
    fail_if(eina_hash_find(hash, key) == NULL);
 
    return EINA_TRUE;
 }
 static Eina_Bool
-eina_iterator_hash_data_check(const Eina_Hash *hash, int *data, __UNUSED__ void *fdata)
+eina_iterator_hash_data_check(const Eina_Hash *hash,
+                              int *data,
+                              __UNUSED__ void *fdata)
 {
    char tmp[10];
 
@@ -92,9 +96,11 @@ eina_iterator_hash_data_check(const Eina_Hash *hash, int *data, __UNUSED__ void
    return EINA_TRUE;
 }
 static Eina_Bool
-eina_iterator_hash_tuple_check(__UNUSED__ const Eina_Hash *hash, Eina_Hash_Tuple *tuple, __UNUSED__ void *fdata)
+eina_iterator_hash_tuple_check(__UNUSED__ const Eina_Hash *hash,
+                               Eina_Hash_Tuple *tuple,
+                               __UNUSED__ void *fdata)
 {
-   fail_if(atoi((char*) tuple->key) != *((int*) tuple->data));
+   fail_if(atoi((char *)tuple->key) != *((int *)tuple->data));
 
    return EINA_TRUE;
 }
@@ -117,15 +123,15 @@ START_TEST(eina_iterator_hash_simple)
    fail_if(eina_hash_add(hash, "6", &array[4]) != EINA_TRUE);
 
    it = eina_hash_iterator_key_new(hash);
-   eina_iterator_foreach(it, EINA_EACH(eina_iterator_hash_key_check), NULL);
+   eina_iterator_foreach(it, EINA_EACH_CB(eina_iterator_hash_key_check), NULL);
    eina_iterator_free(it);
 
    it = eina_hash_iterator_data_new(hash);
-   eina_iterator_foreach(it, EINA_EACH(eina_iterator_hash_data_check), NULL);
+   eina_iterator_foreach(it, EINA_EACH_CB(eina_iterator_hash_data_check), NULL);
    eina_iterator_free(it);
 
    it = eina_hash_iterator_tuple_new(hash);
-   eina_iterator_foreach(it, EINA_EACH(eina_iterator_hash_tuple_check), NULL);
+   eina_iterator_foreach(it, EINA_EACH_CB(eina_iterator_hash_tuple_check), NULL);
    eina_iterator_free(it);
 
    eina_hash_free(hash);
@@ -141,7 +147,7 @@ struct _Eina_Test_Inlist
    int i;
 };
 
-static Eina_Test_Inlist*
+static Eina_Test_Inlist *
 _eina_test_inlist_build(int i)
 {
    Eina_Test_Inlist *tmp;
@@ -154,14 +160,20 @@ _eina_test_inlist_build(int i)
 }
 
 static Eina_Bool
-eina_iterator_inlist_data_check(__UNUSED__ const Eina_Inlist *in_list, Eina_Test_Inlist *data, int *fdata)
+eina_iterator_inlist_data_check(__UNUSED__ const Eina_Inlist *in_list,
+                                Eina_Test_Inlist *data,
+                                int *fdata)
 {
    switch (*fdata)
      {
       case 0: fail_if(data->i != 27); break;
+
       case 1: fail_if(data->i != 42); break;
+
       case 2: fail_if(data->i != 3227); break;
+
       case 3: fail_if(data->i != 1664); break;
+
       case 4: fail_if(data->i != 81); break;
      }
 
@@ -185,13 +197,14 @@ START_TEST(eina_iterator_inlist_simple)
    tmp = _eina_test_inlist_build(1664);
    lst = eina_inlist_append_relative(lst, EINA_INLIST_GET(tmp), lst);
    fail_if(!lst);
-   fail_if(((Eina_Test_Inlist*)lst)->i != 42);
+   fail_if(((Eina_Test_Inlist *)lst)->i != 42);
 
    prev = tmp;
    tmp = _eina_test_inlist_build(3227);
-   lst = eina_inlist_prepend_relative(lst, EINA_INLIST_GET(tmp), EINA_INLIST_GET(prev));
+   lst = eina_inlist_prepend_relative(lst, EINA_INLIST_GET(
+                                         tmp), EINA_INLIST_GET(prev));
    fail_if(!lst);
-   fail_if(((Eina_Test_Inlist*)lst)->i != 42);
+   fail_if(((Eina_Test_Inlist *)lst)->i != 42);
 
    tmp = _eina_test_inlist_build(27);
    lst = eina_inlist_prepend_relative(lst, EINA_INLIST_GET(tmp), NULL);
@@ -202,7 +215,7 @@ START_TEST(eina_iterator_inlist_simple)
    it = eina_inlist_iterator_new(lst);
    fail_if(!it);
 
-   eina_iterator_foreach(it, EINA_EACH(eina_iterator_inlist_data_check), &i);
+   eina_iterator_foreach(it, EINA_EACH_CB(eina_iterator_inlist_data_check), &i);
    eina_iterator_free(it);
 
    fail_if(i != 5);
@@ -210,16 +223,24 @@ START_TEST(eina_iterator_inlist_simple)
 END_TEST
 
 static Eina_Bool
-eina_iterator_list_data_check(__UNUSED__ const Eina_List *list, int *data, int *fdata)
+eina_iterator_list_data_check(__UNUSED__ const Eina_List *list,
+                              int *data,
+                              int *fdata)
 {
    switch (*fdata)
      {
       case 0: fail_if(*data != 81); break;
+
       case 1: fail_if(*data != 7); break;
+
       case 2: fail_if(*data != 9); break;
+
       case 3: fail_if(*data != 6); break;
+
       case 4: fail_if(*data != 42); break;
+
       case 5: fail_if(*data != 1); break;
+
       case 6: fail_if(*data != 1337); break;
      }
 
@@ -261,7 +282,7 @@ START_TEST(eina_iterator_list_simple)
    it = eina_list_iterator_new(list);
    fail_if(!it);
 
-   eina_iterator_foreach(it, EINA_EACH(eina_iterator_list_data_check), &i);
+   eina_iterator_foreach(it, EINA_EACH_CB(eina_iterator_list_data_check), &i);
    eina_iterator_free(it);
 }
 END_TEST
@@ -279,7 +300,9 @@ eina_rbtree_int_cmp(const Eina_Rbtree_Int *left, const Eina_Rbtree_Int *right)
    fail_if(!left);
    fail_if(!right);
 
-   if (left->value < right->value) return EINA_RBTREE_LEFT;
+   if (left->value < right->value)
+      return EINA_RBTREE_LEFT;
+
    return EINA_RBTREE_RIGHT;
 }
 
@@ -297,14 +320,20 @@ _eina_rbtree_int_new(int value)
 }
 
 static Eina_Bool
-eina_iterator_rbtree_data_check_sorted(__UNUSED__ const Eina_List *list, Eina_Rbtree_Int *data, int *fdata)
+eina_iterator_rbtree_data_check_sorted(__UNUSED__ const Eina_List *list,
+                                       Eina_Rbtree_Int *data,
+                                       int *fdata)
 {
    switch (*fdata)
      {
       case 0: fail_if(data->value != 10); break;
+
       case 1: fail_if(data->value != 27); break;
+
       case 2: fail_if(data->value != 42); break;
+
       case 3: fail_if(data->value != 69); break;
+
       case 4: fail_if(data->value != 1337); break;
      }
 
@@ -314,14 +343,20 @@ eina_iterator_rbtree_data_check_sorted(__UNUSED__ const Eina_List *list, Eina_Rb
 }
 
 static Eina_Bool
-eina_iterator_rbtree_data_check_prefix(__UNUSED__ const Eina_List *list, Eina_Rbtree_Int *data, int *fdata)
+eina_iterator_rbtree_data_check_prefix(__UNUSED__ const Eina_List *list,
+                                       Eina_Rbtree_Int *data,
+                                       int *fdata)
 {
    switch (*fdata)
      {
       case 0: fail_if(data->value != 27); break;
+
       case 1: fail_if(data->value != 10); break;
+
       case 2: fail_if(data->value != 69); break;
+
       case 3: fail_if(data->value != 42); break;
+
       case 4: fail_if(data->value != 1337); break;
      }
 
@@ -331,14 +366,20 @@ eina_iterator_rbtree_data_check_prefix(__UNUSED__ const Eina_List *list, Eina_Rb
 }
 
 static Eina_Bool
-eina_iterator_rbtree_data_check_postfix(__UNUSED__ const Eina_List *list, Eina_Rbtree_Int *data, int *fdata)
+eina_iterator_rbtree_data_check_postfix(__UNUSED__ const Eina_List *list,
+                                        Eina_Rbtree_Int *data,
+                                        int *fdata)
 {
    switch (*fdata)
      {
       case 0: fail_if(data->value != 10); break;
+
       case 1: fail_if(data->value != 42); break;
+
       case 2: fail_if(data->value != 1337); break;
+
       case 3: fail_if(data->value != 69); break;
+
       case 4: fail_if(data->value != 27); break;
      }
 
@@ -353,26 +394,43 @@ START_TEST(eina_iterator_rbtree_simple)
    Eina_Iterator *it;
    int i;
 
-   root = eina_rbtree_inline_insert(NULL, _eina_rbtree_int_new(10), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
+   root = eina_rbtree_inline_insert(NULL,
+                                   _eina_rbtree_int_new(10),
+                                    EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp),
+                                   NULL);
    fail_if(!root);
 
-   root = eina_rbtree_inline_insert(root, _eina_rbtree_int_new(1337), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
+   root = eina_rbtree_inline_insert(root,
+                                   _eina_rbtree_int_new(1337),
+                                    EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp),
+                                   NULL);
    fail_if(!root);
 
-   root = eina_rbtree_inline_insert(root, _eina_rbtree_int_new(27), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
+   root = eina_rbtree_inline_insert(root,
+                                   _eina_rbtree_int_new(27),
+                                    EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp),
+                                   NULL);
    fail_if(!root);
 
-   root = eina_rbtree_inline_insert(root, _eina_rbtree_int_new(69), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
+   root = eina_rbtree_inline_insert(root,
+                                   _eina_rbtree_int_new(69),
+                                    EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp),
+                                   NULL);
    fail_if(!root);
 
-   root = eina_rbtree_inline_insert(root, _eina_rbtree_int_new(42), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
+   root = eina_rbtree_inline_insert(root,
+                                   _eina_rbtree_int_new(42),
+                                    EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp),
+                                   NULL);
    fail_if(!root);
 
    i = 0;
    it = eina_rbtree_iterator_prefix(root);
    fail_if(!it);
 
-   eina_iterator_foreach(it, EINA_EACH(eina_iterator_rbtree_data_check_prefix), &i);
+   eina_iterator_foreach(it,
+                        EINA_EACH_CB(eina_iterator_rbtree_data_check_prefix),
+                        &i);
    eina_iterator_free(it);
 
    /* This will return the item sorted. */
@@ -380,14 +438,18 @@ START_TEST(eina_iterator_rbtree_simple)
    it = eina_rbtree_iterator_infix(root);
    fail_if(!it);
 
-   eina_iterator_foreach(it, EINA_EACH(eina_iterator_rbtree_data_check_sorted), &i);
+   eina_iterator_foreach(it,
+                        EINA_EACH_CB(eina_iterator_rbtree_data_check_sorted),
+                        &i);
    eina_iterator_free(it);
 
    i = 0;
    it = eina_rbtree_iterator_postfix(root);
    fail_if(!it);
 
-   eina_iterator_foreach(it, EINA_EACH(eina_iterator_rbtree_data_check_postfix), &i);
+   eina_iterator_foreach(it,
+                        EINA_EACH_CB(eina_iterator_rbtree_data_check_postfix),
+                        &i);
    eina_iterator_free(it);
 }
 END_TEST
index 6327f5f..13fd607 100644 (file)
@@ -36,8 +36,11 @@ struct _Eina_Lazy_Allocator_Test
 static Eina_Bool
 _test_alloc(Eina_Lazy_Allocator_Test *elat, int num)
 {
-   if (elat->num == 10 && num == 1) return EINA_FALSE;
-   if (elat->num == 122 && num == 128) return EINA_FALSE;
+   if (elat->num == 10 && num == 1)
+      return EINA_FALSE;
+
+   if (elat->num == 122 && num == 128)
+      return EINA_FALSE;
 
    elat->num += num;
    elat->data = realloc(elat->data, elat->num);
@@ -60,21 +63,22 @@ START_TEST(eina_lalloc_simple)
    int i;
 
    elat = calloc(1, sizeof (Eina_Lazy_Allocator_Test));
-   fail_if(!elat);
+      fail_if(!elat);
 
-   test = eina_lalloc_new(elat, EINA_LALLOC_ALLOC(_test_alloc), EINA_LALLOC_FREE(_test_free), 10);
-   fail_if(!test);
+   test = eina_lalloc_new(elat, EINA_LALLOC_ALLOC(
+                             _test_alloc), EINA_LALLOC_FREE(_test_free), 10);
+      fail_if(!test);
 
    for (i = 0; i < 10; ++i)
-     fail_if(eina_lalloc_element_add(test) != EINA_TRUE);
-   fail_if(eina_lalloc_element_add(test) != EINA_FALSE);
-   fail_if(eina_lalloc_elements_add(test, 5) != EINA_TRUE);
+      fail_if(eina_lalloc_element_add(test) != EINA_TRUE);
+      fail_if(eina_lalloc_element_add(test) != EINA_FALSE);
+      fail_if(eina_lalloc_elements_add(test, 5) != EINA_TRUE);
    for (i = 0; i < 21; ++i)
-     fail_if(eina_lalloc_element_add(test) != EINA_TRUE);
+      fail_if(eina_lalloc_element_add(test) != EINA_TRUE);
 
-   fail_if(eina_lalloc_elements_add(test, 50) != EINA_FALSE);
+      fail_if(eina_lalloc_elements_add(test, 50) != EINA_FALSE);
 
-   eina_lalloc_free(test);
+      eina_lalloc_free(test);
 }
 END_TEST
 
index e822a03..6e08847 100644 (file)
@@ -32,16 +32,17 @@ static Eina_Bool eina_list_sorted_check(const Eina_List *list)
    int last = *(int *)list->data;
 
    EINA_LIST_FOREACH(list->next, n, d)
-     {
-       int current = *(int *)d;
-       if (last > current)
-         {
-            fprintf(stderr, "list is not sorted: last=%d, current=%d\n",
-                    last, current);
-            return 0;
-         }
-       last = current;
-     }
+   {
+      int current = *(int *)d;
+      if (last > current)
+        {
+           fprintf(stderr, "list is not sorted: last=%d, current=%d\n",
+                   last, current);
+           return 0;
+        }
+
+      last = current;
+   }
 
    return 1;
 }
@@ -68,71 +69,71 @@ START_TEST(eina_test_simple)
    eina_init();
 
    list = eina_list_append(list, &data[0]);
-   fail_if(list == NULL);
+        fail_if(list == NULL);
 
    list = eina_list_prepend(list, &data[1]);
-   fail_if(list == NULL);
+        fail_if(list == NULL);
 
    list = eina_list_append(list, &data[2]);
-   fail_if(list == NULL);
+        fail_if(list == NULL);
 
    list = eina_list_remove(list, &data[0]);
-   fail_if(list == NULL);
+        fail_if(list == NULL);
 
    list = eina_list_remove(list, &data[0]);
-   fail_if(list == NULL);
+        fail_if(list == NULL);
 
    tmp = eina_list_data_find_list(list, &data[2]);
-   fail_if(tmp == NULL);
+        fail_if(tmp == NULL);
 
    list = eina_list_append_relative_list(list, &data[3], tmp);
-   fail_if(list == NULL);
+        fail_if(list == NULL);
 
    list = eina_list_prepend_relative_list(list, &data[4], tmp);
-   fail_if(list == NULL);
+        fail_if(list == NULL);
 
    list = eina_list_promote_list(list, tmp);
-   fail_if(list == NULL);
+        fail_if(list == NULL);
 
    list = eina_list_append_relative(list, &data[5], &data[2]);
-   fail_if(list == NULL);
+        fail_if(list == NULL);
 
    list = eina_list_prepend_relative(list, &data[6], &data[2]);
-   fail_if(list == NULL);
+        fail_if(list == NULL);
 
    list = eina_list_remove_list(list, tmp);
-   fail_if(list == NULL);
+        fail_if(list == NULL);
 
-   fail_if(eina_list_data_find_list(list, &data[2]) != NULL);
-   fail_if(eina_list_data_find(list, &data[2]) != NULL);
-   fail_if(eina_list_data_find(list, &data[5]) != &data[5]);
+        fail_if(eina_list_data_find_list(list, &data[2]) != NULL);
+        fail_if(eina_list_data_find(list, &data[2]) != NULL);
+        fail_if(eina_list_data_find(list, &data[5]) != &data[5]);
 
-   fail_if(eina_list_count(list) != 5);
-   fail_if(eina_list_nth(list, 4) != &data[3]);
-   fail_if(eina_list_nth(list, 10) != NULL);
-   fail_if(eina_list_nth_list(list, 10) != NULL);
+        fail_if(eina_list_count(list) != 5);
+        fail_if(eina_list_nth(list, 4) != &data[3]);
+        fail_if(eina_list_nth(list, 10) != NULL);
+        fail_if(eina_list_nth_list(list, 10) != NULL);
 
    for (tmp = list, i = 0; tmp != NULL; tmp = eina_list_next(tmp), ++i)
      {
-       int *d = eina_list_data_get(tmp);
-       fail_if(d == NULL);
-       fail_if(*d != result[i]);
+        int *d = eina_list_data_get(tmp);
+        fail_if(d == NULL);
+        fail_if(*d != result[i]);
      }
 
    list = eina_list_reverse(list);
 
    for (tmp = list; tmp != NULL; tmp = eina_list_next(tmp), --i)
      {
-       int *d = eina_list_data_get(tmp);
-       fail_if(d == NULL);
-       fail_if(*d != result[i - 1]);
+        int *d = eina_list_data_get(tmp);
+        fail_if(d == NULL);
+        fail_if(*d != result[i - 1]);
      }
 
    list = eina_list_append_relative(list, &data[7], &data[7]);
-   fail_if(list == NULL);
+        fail_if(list == NULL);
 
    list = eina_list_prepend_relative(list, &data[8], &data[8]);
-   fail_if(list == NULL);
+        fail_if(list == NULL);
 
    list = eina_list_sort(list, 2, eina_int_cmp);
 
@@ -142,9 +143,9 @@ START_TEST(eina_test_simple)
    test2 = eina_list_nth(list, 1);
    test3 = eina_list_nth(list, 2);
 
-   fail_if(test1 == NULL || test2 == NULL || test3 == NULL);
-   fail_if(*test1 > *test2);
-   fail_if(*test3 == *test2);
+        fail_if(test1 == NULL || test2 == NULL || test3 == NULL);
+        fail_if(*test1 > *test2);
+        fail_if(*test3 == *test2);
 
    list = eina_list_sort(list, 5, eina_int_cmp);
 
@@ -152,54 +153,54 @@ START_TEST(eina_test_simple)
    test2 = eina_list_nth(list, 4);
    test3 = eina_list_nth(list, 5);
 
-   fail_if(test1 == NULL || test2 == NULL || test3 == NULL);
-   fail_if(*test1 > *test2);
-   fail_if(*test3 > *test2);
+        fail_if(test1 == NULL || test2 == NULL || test3 == NULL);
+        fail_if(*test1 > *test2);
+        fail_if(*test3 > *test2);
 
    list = eina_list_append(list, &data[8]);
-   fail_if(list == NULL);
+        fail_if(list == NULL);
 
    list = eina_list_append(list, &data[7]);
-   fail_if(list == NULL);
+        fail_if(list == NULL);
 
    list = eina_list_sort(list, -1, eina_int_cmp);
 
    test1 = eina_list_nth(list, 0);
    for (tmp = list; tmp != NULL; tmp = eina_list_next(tmp))
      {
-       int *d = eina_list_data_get(tmp);
-       fail_if(*test1 > *d);
+        int *d = eina_list_data_get(tmp);
+        fail_if(*test1 > *d);
 
-       test1 = d;
+        test1 = d;
      }
 
    test3 = eina_list_nth(list, 5);
-   fail_if(test3 == NULL);
+        fail_if(test3 == NULL);
 
    list = eina_list_promote_list(list, list);
-   fail_if(list == NULL);
+        fail_if(list == NULL);
 
    list = eina_list_promote_list(list, eina_list_last(list));
-   fail_if(list == NULL);
+        fail_if(list == NULL);
 
    test1 = eina_list_nth(list, 0);
    test2 = eina_list_nth(list, 1);
 
    list = eina_list_promote_list(eina_list_next(list), list);
-   fail_if(list == NULL);
-   fail_if(eina_list_data_get(list) != test1);
-   fail_if(eina_list_data_get(eina_list_next(list)) != test2);
+        fail_if(list == NULL);
+        fail_if(eina_list_data_get(list) != test1);
+        fail_if(eina_list_data_get(eina_list_next(list)) != test2);
 
    list = eina_list_remove_list(list, list);
-   fail_if(list == NULL);
+        fail_if(list == NULL);
 
    list = eina_list_remove_list(list, eina_list_last(list));
-   fail_if(list == NULL);
+        fail_if(list == NULL);
 
    list = eina_list_free(list);
-   fail_if(list != NULL);
+        fail_if(list != NULL);
 
-   eina_shutdown();
+        eina_shutdown();
 }
 END_TEST
 
@@ -219,39 +220,39 @@ START_TEST(eina_test_merge)
    l1 = eina_list_append(l1, &data[1]);
    l1 = eina_list_append(l1, &data[2]);
    l1 = eina_list_append(l1, &data[3]);
-   fail_if(l1 == NULL);
+      fail_if(l1 == NULL);
 
    l2 = eina_list_append(NULL, &data[4]);
    l2 = eina_list_append(l2, &data[5]);
-   fail_if(l2 == NULL);
+      fail_if(l2 == NULL);
 
    l1 = eina_list_merge(l1, l2);
-   fail_if(l1 == NULL);
-   fail_if(eina_list_count(l1) != 6);
+      fail_if(l1 == NULL);
+      fail_if(eina_list_count(l1) != 6);
    for (i = 0, l2 = l1; ((l2 != NULL) && (i < 6)); ++i, l2 = l2->next)
-     fail_if(l2->data != &data[i]);
-   fail_if(i != 6);
-   fail_if(l2 != NULL);
+      fail_if(l2->data != &data[i]);
+      fail_if(i != 6);
+      fail_if(l2 != NULL);
 
-   eina_list_free(l1);
+      eina_list_free(l1);
 
    l1 = eina_list_append(NULL, &data[0]);
    l1 = eina_list_append(l1, &data[1]);
-   fail_if(l1 == NULL);
+      fail_if(l1 == NULL);
 
    l2 = eina_list_append(NULL, &data[2]);
    l2 = eina_list_append(l2, &data[3]);
    l2 = eina_list_append(l2, &data[4]);
    l2 = eina_list_append(l2, &data[5]);
-   fail_if(l2 == NULL);
+      fail_if(l2 == NULL);
 
    l1 = eina_list_merge(l1, l2);
-   fail_if(l1 == NULL);
-   fail_if(eina_list_count(l1) != 6);
+      fail_if(l1 == NULL);
+      fail_if(eina_list_count(l1) != 6);
    for (i = 0, l2 = l1; ((l2 != NULL) && (i < 6)); ++i, l2 = l2->next)
-     fail_if(l2->data != &data[i]);
-   fail_if(i != 6);
-   fail_if(l2 != NULL);
+      fail_if(l2->data != &data[i]);
+      fail_if(i != 6);
+      fail_if(l2 != NULL);
 
    l3 = eina_list_append(NULL, &data[6]);
    l3 = eina_list_append(l3, &data[7]);
@@ -271,20 +272,20 @@ START_TEST(eina_test_merge)
    l5 = eina_list_sort(l5, -1, eina_int_cmp);
 
    l1 = eina_list_sorted_merge(l1, l3, eina_int_cmp);
-   fail_if(l1 == NULL);
-   fail_if(eina_list_count(l1) != 9);
+      fail_if(l1 == NULL);
+      fail_if(eina_list_count(l1) != 9);
 
    l1 = eina_list_sorted_merge(l1, l4, eina_int_cmp);
-   fail_if(l1 == NULL);
-   fail_if(eina_list_count(l1) != 12);
+      fail_if(l1 == NULL);
+      fail_if(eina_list_count(l1) != 12);
 
    l1 = eina_list_sorted_merge(l1, l5, eina_int_cmp);
-   fail_if(l1 == NULL);
-   fail_if(eina_list_count(l1) != 15);
+      fail_if(l1 == NULL);
+      fail_if(eina_list_count(l1) != 15);
 
-   fail_if(!eina_list_sorted_check(l1));
+      fail_if(!eina_list_sorted_check(l1));
 
-   eina_shutdown();
+      eina_shutdown();
 }
 END_TEST
 
@@ -298,18 +299,18 @@ START_TEST(eina_test_sorted_insert)
 
    eina_init();
 
-   count = sizeof(data)/sizeof(data[0]);
+   count = sizeof(data) / sizeof(data[0]);
 
    l1 = NULL;
    for (i = 0; i < count; i++)
-     l1 = eina_list_sorted_insert(l1, eina_int_cmp, data + i);
+      l1 = eina_list_sorted_insert(l1, eina_int_cmp, data + i);
 
    fail_if(l1 == NULL);
    fail_if(!eina_list_sorted_check(l1));
 
    l2 = NULL;
    EINA_LIST_FOREACH(l1, itr, d)
-     l2 = eina_list_sorted_insert(l2, eina_int_cmp, d);
+   l2 = eina_list_sorted_insert(l2, eina_int_cmp, d);
 
    fail_if(l2 == NULL);
    fail_if(!eina_list_sorted_check(l2));
@@ -317,17 +318,17 @@ START_TEST(eina_test_sorted_insert)
 
    l2 = NULL;
    EINA_LIST_REVERSE_FOREACH(l1, itr, d)
-     l2 = eina_list_sorted_insert(l2, eina_int_cmp, d);
+   l2 = eina_list_sorted_insert(l2, eina_int_cmp, d);
 
    fail_if(l2 == NULL);
    fail_if(!eina_list_sorted_check(l2));
    eina_list_free(l2);
    eina_list_free(l1);
 
-   count = sizeof(data2)/sizeof(data2[0]);
+   count = sizeof(data2) / sizeof(data2[0]);
    l1 = NULL;
    for (i = 0; i < count; i++)
-     l1 = eina_list_sorted_insert(l1, eina_int_cmp, data2 + i);
+      l1 = eina_list_sorted_insert(l1, eina_int_cmp, data2 + i);
 
    fail_if(l1 == NULL);
    fail_if(!eina_list_sorted_check(l1));
index 49326a4..ba17d5f 100644 (file)
@@ -27,7 +27,7 @@
 #include "eina_suite.h"
 #include "Eina.h"
 
-START_TEST(eina_log_macro)
+   START_TEST(eina_log_macro)
 {
    fail_if(!eina_init());
 
@@ -63,15 +63,15 @@ END_TEST
 
 START_TEST(eina_log_domains_registry)
 {
-   fail_if(!eina_init());
+        fail_if(!eina_init());
 
    int i;
    int d[50];
 
    for (i = 0; i < 50; i++)
      {
-       d[i] = eina_log_domain_register("Test", EINA_COLOR_GREEN);
-       fail_if(d[i] < 0);
+        d[i] = eina_log_domain_register("Test", EINA_COLOR_GREEN);
+        fail_if(d[i] < 0);
      }
 
    for (i = 0; i < 50; i++)
@@ -83,8 +83,8 @@ END_TEST
 
 START_TEST(eina_log_domains_slot_reuse)
 {
-   fail_if(!eina_init());
-   fail_if(!eina_threads_init());
+        fail_if(!eina_init());
+        fail_if(!eina_threads_init());
 
    // Create 9 domains
    int idx[9];
@@ -92,8 +92,8 @@ START_TEST(eina_log_domains_slot_reuse)
 
    for (i = 0; i < 9; i++)
      {
-       idx[i] = eina_log_domain_register("Test1", EINA_COLOR_GREEN);
-       fail_if(idx[i] < 0);
+        idx[i] = eina_log_domain_register("Test1", EINA_COLOR_GREEN);
+        fail_if(idx[i] < 0);
      }
 
    // Slot 0 by default contains the global logger. The above code created
@@ -131,7 +131,7 @@ START_TEST(eina_log_level_indexes)
    EINA_LOG(d, -1, "Negative index message\n");
 
    // Displayed only if user sets level 6 or higher
-   EINA_LOG(d, 6, "Higher level debug\n");
+   EINA_LOG(d, 6,  "Higher level debug\n");
 
    eina_threads_shutdown();
    eina_threads_shutdown();
@@ -148,16 +148,16 @@ START_TEST(eina_log_customize)
 
    fail_if(!eina_init());
 
-#define test_set_get(func, val)                        \
-   eina_log_##func##_set(val);                 \
-   fail_if(eina_log_##func##_get() != val)
+#define test_set_get(func, val)                 \
+   eina_log_ ## func ## _set(val);                  \
+   fail_if(eina_log_ ## func ## _get() != val)
 
    test_set_get(level, -1234);
    test_set_get(level, 4567);
 
-#define test_set_get_bool(func)                        \
-   test_set_get(func, EINA_FALSE);             \
-   test_set_get(func, EINA_TRUE)
+#define test_set_get_bool(func)                 \
+   test_set_get(func,  EINA_FALSE);              \
+   test_set_get(func,  EINA_TRUE)
 
    test_set_get_bool(color_disable);
    test_set_get_bool(file_disable);
@@ -183,8 +183,8 @@ START_TEST(eina_log_customize)
 
    eina_log_domain_unregister(d);
    fputs("NOTE: You should see a failed safety check or "
-        "a crash if compiled without safety checks support.\n",
-        stderr);
+         "a crash if compiled without safety checks support.\n",
+         stderr);
    eina_log_abort_on_critical_set(EINA_FALSE);
    fail_if(eina_log_domain_registered_level_get(d) != EINA_LOG_LEVEL_UNKNOWN);
 
@@ -201,19 +201,19 @@ START_TEST(eina_log_level_name)
 
    fail_if(!eina_init());
 
-#define tst(level, str)                                \
-   eina_log_level_name_get(level, name);       \
+#define tst(level, str)                         \
+   eina_log_level_name_get(level, name);        \
    fail_if(strcmp(name, str) != 0)
 
-   tst(0, "CRI");
-   tst(1, "ERR");
-   tst(2, "WRN");
-   tst(3, "INF");
-   tst(4, "DBG");
-   tst(5, "005");
-   tst(12, "012");
+   tst(0,   "CRI");
+   tst(1,   "ERR");
+   tst(2,   "WRN");
+   tst(3,   "INF");
+   tst(4,   "DBG");
+   tst(5,   "005");
+   tst(12,  "012");
    tst(369, "369");
-   tst(-1, "-01");
+   tst(-1,  "-01");
    tst(-48, "-48");
 
 #undef tst
index 25dd13c..d2c3d49 100644 (file)
@@ -61,7 +61,8 @@ START_TEST(eina_magic_simple)
    eina_magic_string_set(EINA_MAGIC_TEST2, EINA_MAGIC_STRING);
 
    fail_if(eina_magic_string_get(EINA_MAGIC_TEST) == NULL);
-   fail_if(strcmp(eina_magic_string_get(EINA_MAGIC_TEST), EINA_MAGIC_STRING) != 0);
+   fail_if(strcmp(eina_magic_string_get(
+                     EINA_MAGIC_TEST), EINA_MAGIC_STRING) != 0);
 
 #ifdef EINA_MAGIC_DEBUG
    fail_if(EINA_MAGIC_CHECK(ems, EINA_MAGIC_TEST));
@@ -75,7 +76,8 @@ START_TEST(eina_magic_simple)
    fail_if(!EINA_MAGIC_CHECK(ems, EINA_MAGIC_TEST));
 
    EINA_MAGIC_SET(ems, EINA_MAGIC_NONE);
-   fprintf(stderr, "you should see 'Input handle has already been freed' below\n");
+   fprintf(stderr,
+           "you should see 'Input handle has already been freed' below\n");
    EINA_MAGIC_FAIL(ems, EINA_MAGIC_TEST);
 
    EINA_MAGIC_SET(ems, 42424242);
index b9cd469..04364a1 100644 (file)
@@ -25,7 +25,7 @@
 #include "eina_suite.h"
 #include "Eina.h"
 
-START_TEST(eina_simple)
+   START_TEST(eina_simple)
 {
    fail_if(eina_init() != 2); /* one init by test suite */
    fail_if(eina_shutdown() != 1);
index 859e690..e07b1ee 100644 (file)
 #define MAX_ROWS 10
 #define MAX_COLS 10
 
-static void eina_matrixsparse_free_cell_cb(void *user_data __UNUSED__, void *cell_data __UNUSED__)
+static void eina_matrixsparse_free_cell_cb(void *user_data __UNUSED__,
+                                           void *cell_data __UNUSED__)
 {
 }
 
-static void matrixsparse_initialize(Eina_Matrixsparse *matrix, long data[MAX_ROWS][MAX_COLS], unsigned long nrows, unsigned long ncols)
+static void matrixsparse_initialize(Eina_Matrixsparse *matrix,
+                                    long data[MAX_ROWS][MAX_COLS],
+                                    unsigned long nrows,
+                                    unsigned long ncols)
 {
    unsigned long i, j;
    Eina_Bool r;
 
    for (i = 0; i < nrows; i++)
-     for (j = 0; j < ncols; j++)
-       if (data[i][j] != 0)
-        {
-           r = eina_matrixsparse_data_idx_set(matrix, i, j, &data[i][j]);
-           fail_if(r == EINA_FALSE);
-        }
+      for (j = 0; j < ncols; j++)
+         if (data[i][j] != 0)
+           {
+              r = eina_matrixsparse_data_idx_set(matrix, i, j, &data[i][j]);
+                fail_if(r == EINA_FALSE);
+           }
+
 }
 
-static void matrixsparse_check(Eina_Matrixsparse *matrix, long data[MAX_ROWS][MAX_COLS], unsigned long nrows __UNUSED__, unsigned long ncols __UNUSED__)
+static void matrixsparse_check(Eina_Matrixsparse *matrix,
+                               long data[MAX_ROWS][MAX_COLS],
+                               unsigned long nrows __UNUSED__,
+                               unsigned long ncols __UNUSED__)
 {
    unsigned long i, j;
    long *test1;
 
    for (i = 0; i < MAX_ROWS; i++)
-     for (j = 0; j < MAX_COLS; j++)
-       {
-         if (data[i][j] != 0)
-           {
-              test1 = eina_matrixsparse_data_idx_get(matrix, i, j);
-              fail_if(test1 == NULL || *test1 != data[i][j]);
-           }
-         else
-           {
-              test1 = eina_matrixsparse_data_idx_get(matrix, i, j);
-              fail_if(test1 != NULL);
-           }
-       }
+      for (j = 0; j < MAX_COLS; j++)
+        {
+           if (data[i][j] != 0)
+             {
+                test1 = eina_matrixsparse_data_idx_get(matrix, i, j);
+                fail_if(test1 == NULL || *test1 != data[i][j]);
+             }
+           else
+             {
+                test1 = eina_matrixsparse_data_idx_get(matrix, i, j);
+                fail_if(test1 != NULL);
+             }
+        }
 }
 
 START_TEST(eina_test_simple)
@@ -61,8 +69,8 @@ START_TEST(eina_test_simple)
    long data[MAX_ROWS][MAX_COLS];
 
    for (i = 0; i < MAX_ROWS; i++)
-     for (j = 0; j < MAX_COLS; j++)
-       data[i][j] = 0;
+      for (j = 0; j < MAX_COLS; j++)
+         data[i][j] = 0;
 
    data[0][3] = 3;
    data[1][3] = 13;
@@ -99,7 +107,7 @@ START_TEST(eina_test_simple)
    eina_init();
 
    matrix = eina_matrixsparse_new(MAX_ROWS, MAX_COLS,
-                                 eina_matrixsparse_free_cell_cb, data);
+                                  eina_matrixsparse_free_cell_cb, data);
    fail_if(matrix == NULL);
 
    r = eina_matrixsparse_cell_idx_get(matrix, 3, 5, &cell);
@@ -146,7 +154,7 @@ START_TEST(eina_test_simple)
    r = eina_matrixsparse_data_idx_set(matrix, 1, 9, &data[1][9]);
    fail_if(r == EINA_FALSE);
 
-   r = eina_matrixsparse_data_idx_replace(matrix, 4, 3, &value, (void**)&test1);
+   r = eina_matrixsparse_data_idx_replace(matrix, 4, 3, &value, (void **)&test1);
    fail_if(r == EINA_FALSE);
    fail_if(test1 == NULL);
    fail_if(*test1 != data[4][3]);
@@ -155,7 +163,7 @@ START_TEST(eina_test_simple)
    test1 = eina_matrixsparse_data_idx_get(matrix, 4, 3);
    fail_if(test1 == NULL || *test1 != value);
 
-   r = eina_matrixsparse_cell_data_replace(cell, &value2, (void**)&test1);
+   r = eina_matrixsparse_cell_data_replace(cell, &value2, (void **)&test1);
    fail_if(r == EINA_FALSE);
    fail_if(test1 == NULL);
    fail_if(*test1 != data[3][5]);
@@ -175,7 +183,11 @@ START_TEST(eina_test_simple)
    test1 = eina_matrixsparse_data_idx_get(matrix, 4, 2);
    fail_if(test1 == NULL || *test1 != value3);
 
-   r = eina_matrixsparse_data_idx_replace(matrix, 6, 5, &value4, (void**)&test1);
+   r = eina_matrixsparse_data_idx_replace(matrix,
+                                          6,
+                                          5,
+                                          &value4,
+                                          (void **)&test1);
    fail_if(r == EINA_FALSE || test1 != NULL);
    data[6][5] = value4;
 
@@ -267,13 +279,13 @@ START_TEST(eina_test_resize)
    long data[MAX_ROWS][MAX_COLS];
 
    for (i = 0; i < MAX_ROWS; i++)
-     for (j = 0; j < MAX_COLS; j++)
-       data[i][j] = 0;
+      for (j = 0; j < MAX_COLS; j++)
+         data[i][j] = 0;
 
    eina_init();
 
    matrix = eina_matrixsparse_new(MAX_ROWS, MAX_COLS,
-                                 eina_matrixsparse_free_cell_cb, data);
+                                  eina_matrixsparse_free_cell_cb, data);
    fail_if(matrix == NULL);
 
    /* cell insertion */
@@ -384,18 +396,18 @@ START_TEST(eina_test_iterators)
    value = 0;
    for (i = 0; i < MAX_ROWS; i++)
      {
-       for (j = 0; j < MAX_COLS; j++)
-         {
-            data[i][j] = value++;
-            printf("%4ld ", data[i][j]);
-         }
-       printf("\n");
+        for (j = 0; j < MAX_COLS; j++)
+          {
+             data[i][j] = value++;
+             printf("%4ld ", data[i][j]);
+          }
+             printf("\n");
      }
 
-   eina_init();
+             eina_init();
 
    matrix = eina_matrixsparse_new(MAX_ROWS, MAX_COLS,
-                                 eina_matrixsparse_free_cell_cb, data);
+                                  eina_matrixsparse_free_cell_cb, data);
    fail_if(matrix == NULL);
 
    r = eina_matrixsparse_data_idx_set(matrix, 3, 5, &data[3][5]);
@@ -438,29 +450,29 @@ START_TEST(eina_test_iterators)
    it = eina_matrixsparse_iterator_new(matrix);
    fail_if(it == NULL);
    EINA_ITERATOR_FOREACH(it, cell)
-     {
-       fail_if(cell == NULL);
-       r = eina_matrixsparse_cell_position_get(cell, &row, &col);
-       fail_if(r == EINA_FALSE);
+   {
+      fail_if(cell == NULL);
+      r = eina_matrixsparse_cell_position_get(cell, &row, &col);
+      fail_if(r == EINA_FALSE);
 
-       test1 = eina_matrixsparse_cell_data_get(cell);
-       fail_if(test1 == NULL || *test1 != data[row][col]);
-     }
-   eina_iterator_free(it);
+      test1 = eina_matrixsparse_cell_data_get(cell);
+      fail_if(test1 == NULL || *test1 != data[row][col]);
+   }
+      eina_iterator_free(it);
 
    it = eina_matrixsparse_iterator_complete_new(matrix);
    fail_if(it == NULL);
    EINA_ITERATOR_FOREACH(it, cell)
-     {
-       fail_if(cell == NULL);
-       r = eina_matrixsparse_cell_position_get(cell, &row, &col);
-       fail_if(r == EINA_FALSE);
+   {
+         fail_if(cell == NULL);
+      r = eina_matrixsparse_cell_position_get(cell, &row, &col);
+         fail_if(r == EINA_FALSE);
 
-       test1 = eina_matrixsparse_cell_data_get(cell);
-       if (test1)
-         fail_if(*test1 != data[row][col]);
-     }
-   eina_iterator_free(it);
+      test1 = eina_matrixsparse_cell_data_get(cell);
+      if (test1)
+         fail_if(*test1 != data[row][col]);
+   }
+         eina_iterator_free(it);
 
    eina_matrixsparse_free(matrix);
 
@@ -471,7 +483,7 @@ END_TEST
 void
 eina_test_matrixsparse(TCase *tc)
 {
-    tcase_add_test(tc, eina_test_simple);
-    tcase_add_test(tc, eina_test_resize);
-    tcase_add_test(tc, eina_test_iterators);
+   tcase_add_test(tc, eina_test_simple);
+   tcase_add_test(tc, eina_test_resize);
+   tcase_add_test(tc, eina_test_iterators);
 }
index ad902e5..f911fff 100644 (file)
@@ -28,10 +28,14 @@ static Eina_Array *_modules;
 static void
 _mempool_init(void)
 {
-    eina_init();
-    /* force modules to be loaded in case they are not installed */
-    _modules = eina_module_list_get(NULL, PACKAGE_BUILD_DIR"/src/modules", 1, NULL, NULL);
-    eina_module_list_load(_modules);
+   eina_init();
+   /* force modules to be loaded in case they are not installed */
+   _modules = eina_module_list_get(NULL,
+                                   PACKAGE_BUILD_DIR "/src/modules",
+                                   1,
+                                   NULL,
+                                   NULL);
+   eina_module_list_load(_modules);
 }
 
 static void
@@ -48,30 +52,30 @@ _eina_mempool_test(Eina_Mempool *mp, Eina_Bool with_realloc, Eina_Bool with_gc)
    int *tbl[512];
    int i;
 
-   fail_if(!mp);
+        fail_if(!mp);
 
    for (i = 0; i < 512; ++i)
      {
-       tbl[i] = eina_mempool_malloc(mp, sizeof (int));
-       fail_if(!tbl[i]);
-       *tbl[i] = i;
+        tbl[i] = eina_mempool_malloc(mp, sizeof (int));
+        fail_if(!tbl[i]);
+        *tbl[i] = i;
      }
 
    for (i = 0; i < 512; ++i)
-     fail_if(*tbl[i] != i);
+        fail_if(*tbl[i] != i);
 
    for (i = 0; i < 256; ++i)
-     eina_mempool_free(mp, tbl[i]);
+        eina_mempool_free(mp, tbl[i]);
 
    if (with_realloc)
-     fail_if(eina_mempool_realloc(mp, tbl[500], 25) == NULL);
+      fail_if(eina_mempool_realloc(mp, tbl[500], 25) == NULL);
    else
-     fail_if(eina_mempool_realloc(mp, tbl[500], 25) != NULL);
+      fail_if(eina_mempool_realloc(mp, tbl[500], 25) != NULL);
 
    if (with_gc)
      {
-       eina_mempool_gc(mp);
-       eina_mempool_statistics(mp);
+        eina_mempool_gc(mp);
+        eina_mempool_statistics(mp);
      }
 
    eina_mempool_del(mp);
@@ -144,7 +148,15 @@ START_TEST(eina_mempool_ememoa_unknown)
 
    _mempool_init();
 
-   mp = eina_mempool_add("ememoa_unknown", "test", NULL, 0, 2, sizeof (int), 8, sizeof (int) * 2, 8);
+   mp = eina_mempool_add("ememoa_unknown",
+                         "test",
+                         NULL,
+                         0,
+                         2,
+                         sizeof (int),
+                         8,
+                         sizeof (int) * 2,
+                         8);
    _eina_mempool_test(mp, EINA_TRUE, EINA_TRUE);
 
    _mempool_shutdown();
index fdfa171..f32fe21 100644 (file)
@@ -49,7 +49,11 @@ START_TEST(eina_module_load_unload)
    Eina_Array *_modules;
 
    eina_init();
-   _modules = eina_module_list_get(NULL, PACKAGE_BUILD_DIR"/src/tests/", 1, &list_cb, NULL);
+   _modules = eina_module_list_get(NULL,
+                                   PACKAGE_BUILD_DIR "/src/tests/",
+                                   1,
+                                   &list_cb,
+                                   NULL);
    fail_if(!_modules);
    eina_module_list_load(_modules);
    eina_module_list_unload(_modules);
index 5df9372..d42b530 100644 (file)
@@ -1,14 +1,19 @@
-#include "Eina.h"
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <stdio.h>
 
+#include "Eina.h"
+
 Eina_Bool dummy_module_init(void)
 {
-       return EINA_TRUE;
+   return EINA_TRUE;
 }
 
 void dummy_module_shutdown(void)
 {
-       
+
 }
 
 EAPI int dummy_symbol = 0xbad;
index 1e9bdbd..52faeec 100644 (file)
@@ -20,6 +20,9 @@
 # include "config.h"
 #endif
 
+#include <assert.h>
+#include <stdio.h>
+
 #include "eina_suite.h"
 #include "Eina.h"
 
@@ -28,10 +31,12 @@ _eina_quadtree_rectangle_vert(const void *object, size_t middle)
 {
    const Eina_Rectangle *r = object;
 
-   if (r->y + r->h < (int) middle)
-     return EINA_QUAD_LEFT;
-   if (r->y > (int) middle)
-     return EINA_QUAD_RIGHT;
+   if (r->y + r->h < (int)middle)
+      return EINA_QUAD_LEFT;
+
+   if (r->y > (int)middle)
+      return EINA_QUAD_RIGHT;
+
    return EINA_QUAD_BOTH;
 }
 
@@ -40,41 +45,45 @@ _eina_quadtree_rectangle_hort(const void *object, size_t middle)
 {
    const Eina_Rectangle *r = object;
 
-   if (r->x + r->w < (int) middle)
-     return EINA_QUAD_LEFT;
-   if (r->x > (int) middle)
-     return EINA_QUAD_RIGHT;
+   if (r->x + r->w < (int)middle)
+      return EINA_QUAD_LEFT;
+
+   if (r->x > (int)middle)
+      return EINA_QUAD_RIGHT;
+
    return EINA_QUAD_BOTH;
 }
 
 START_TEST(eina_quadtree_collision)
 {
-   struct {
+   struct
+   {
       Eina_Rectangle r;
       Eina_QuadTree_Item *item;
    } objects[] = {
-     { { 10, 10, 30, 30 }, NULL },
-     { { 20, 20, 30, 30 }, NULL },
-     { { 5, 30, 30, 30 }, NULL },
-     { { 70, 130, 100, 100 }, NULL },
-     { { 10, 220, 50, 40 }, NULL },
-     { { 310, 20, 50, 30 }, NULL },
-     { { 300, 220, 40, 40 }, NULL },
-     { { 500, 150, 40, 40 }, NULL },
-     { { 500, 220, 40, 40 }, NULL },
-     { { 330, 250, 40, 40 }, NULL },
-     { { 300, 400, 40, 40 }, NULL },
-     { { 10, 400, 40, 40 }, NULL },
-     { { 0, 0, 0, 0 }, NULL }
-     };
-   struct {
+      { { 10, 10, 30, 30 }, NULL },
+      { { 20, 20, 30, 30 }, NULL },
+      { { 5, 30, 30, 30 }, NULL },
+      { { 70, 130, 100, 100 }, NULL },
+      { { 10, 220, 50, 40 }, NULL },
+      { { 310, 20, 50, 30 }, NULL },
+      { { 300, 220, 40, 40 }, NULL },
+      { { 500, 150, 40, 40 }, NULL },
+      { { 500, 220, 40, 40 }, NULL },
+      { { 330, 250, 40, 40 }, NULL },
+      { { 300, 400, 40, 40 }, NULL },
+      { { 10, 400, 40, 40 }, NULL },
+      { { 0, 0, 0, 0 }, NULL }
+   };
+   struct
+   {
       Eina_Rectangle r;
       int count;
       int result[20];
    } tests [] = {
-     { { 600, 400, 40, 40 }, 4, { 4, 6, 8, 10 } },
-     { { 20, 30, 10, 10 }, 7, { 0, 1, 2, 4, 5, 6, 8 } },
-     { { 0, 0, 0, 0 }, -1, {} },
+      { { 600, 400, 40, 40 }, 4, { 4, 6, 8, 10 } },
+      { { 20, 30, 10, 10 }, 7, { 0, 1, 2, 4, 5, 6, 8 } },
+      { { 0, 0, 0, 0 }, -1, {} },
    };
    int hidden[] = { 4, 5, 6, 8, 10 };
    int show[] = { 0, 1, 2 };
@@ -84,89 +93,92 @@ START_TEST(eina_quadtree_collision)
    int count;
    int i;
 
-   fail_if(!eina_init());
+        fail_if(!eina_init());
 
    q = eina_quadtree_new(640, 480,
-                        _eina_quadtree_rectangle_vert,
-                        _eina_quadtree_rectangle_hort);
+                         _eina_quadtree_rectangle_vert,
+                         _eina_quadtree_rectangle_hort);
 
-   fail_if(!q);
+        fail_if(!q);
 
    for (i = 0; objects[i].r.w != 0 && objects[i].r.h != 0; ++i)
      {
-       objects[i].item = eina_quadtree_add(q, &objects[i].r);
-       fail_if(!objects[i].item);
-       fail_if(!eina_quadtree_show(objects[i].item));
+        objects[i].item = eina_quadtree_add(q, &objects[i].r);
+        fail_if(!objects[i].item);
+        fail_if(!eina_quadtree_show(objects[i].item));
      }
 
-   eina_quadtree_resize(q, 640, 480);
+        eina_quadtree_resize(q, 640, 480);
 
    for (i = 0; tests[i].count != -1; ++i)
      {
-       head = eina_quadtree_collide(q,
-                                    tests[i].r.x, tests[i].r.y,
-                                    tests[i].r.w, tests[i].r.h);
-
-       count = 0;
-       while (head)
-         {
-            int k;
-
-            r = eina_quadtree_object(head);
-
-            for (k = 0; k < tests[i].count; ++k)
-              {
-                 if (&objects[tests[i].result[k]].r == r)
-                   break;
-              }
-            fail_if(k == tests[i].count);
-
-            head = head->next;
-            count++;
-         }
-       fail_if(count != tests[i].count);
+        head = eina_quadtree_collide(q,
+                                     tests[i].r.x, tests[i].r.y,
+                                     tests[i].r.w, tests[i].r.h);
+
+        count = 0;
+        while (head)
+          {
+             int k;
+
+             r = eina_quadtree_object(head);
+
+             for (k = 0; k < tests[i].count; ++k)
+               {
+                  if (&objects[tests[i].result[k]].r == r)
+                     break;
+               }
+             fail_if(k == tests[i].count);
+
+             head = head->next;
+             count++;
+          }
+             fail_if(count != tests[i].count);
      }
 
-   for (i = 0; i < (int) (sizeof (hidden) / sizeof (int)); ++i)
-     eina_quadtree_hide(objects[hidden[i]].item);
-   for (i = 0; i < (int) (sizeof (show) / sizeof (int)); ++i)
-     eina_quadtree_show(objects[show[i]].item);
+   for (i = 0; i < (int)(sizeof (hidden) / sizeof (int)); ++i)
+      eina_quadtree_hide(objects[hidden[i]].item);
+   for (i = 0; i < (int)(sizeof (show) / sizeof (int)); ++i)
+      eina_quadtree_show(objects[show[i]].item);
 
    head = eina_quadtree_collide(q,
-                               tests[1].r.x, tests[1].r.y,
-                               tests[1].r.w, tests[1].r.h);
+                                tests[1].r.x, tests[1].r.y,
+                                tests[1].r.w, tests[1].r.h);
 
    count = 0;
    while (head)
      {
-       r = eina_quadtree_object(head);
+        r = eina_quadtree_object(head);
 
-       fail_if(r != &objects[tests[1].result[show[count]]].r);
+        fail_if(r != &objects[tests[1].result[show[count]]].r);
 
-       head = head->next;
-       count++;
+        head = head->next;
+        count++;
      }
-   fail_if(count != 3);
+        fail_if(count != 3);
 
-   eina_quadtree_cycle(q);
+        eina_quadtree_cycle(q);
    eina_quadtree_show(objects[4].item);
+   eina_quadtree_increase(objects[4].item);
    eina_quadtree_show(objects[5].item);
+   eina_quadtree_increase(objects[5].item);
    eina_quadtree_del(objects[5].item);
    eina_quadtree_change(objects[10].item);
+   eina_quadtree_increase(objects[10].item);
 
    eina_quadtree_resize(q, 641, 480);
 
    head = eina_quadtree_collide(q,
-                               tests[0].r.x, tests[0].r.y,
-                               tests[0].r.w, tests[0].r.h);
+                                tests[0].r.x, tests[0].r.y,
+                                tests[0].r.w, tests[0].r.h);
 
    count = 0;
    while (head)
      {
-       r = eina_quadtree_object(head);
+        r = eina_quadtree_object(head);
 
-       head = head->next;
-       count++;
+        head = head->next;
+        count++;
      }
    fail_if(count != 1);
 
index a7b66e6..fabe2bf 100644 (file)
@@ -42,13 +42,15 @@ _eina_rbtree_black_height(Eina_Rbtree *tree, Eina_Rbtree_Cmp_Node_Cb cmp)
    int left_height;
    int right_height;
 
-   if (!tree) return 1;
+   if (!tree)
+      return 1;
 
    left = tree->son[EINA_RBTREE_LEFT];
    right = tree->son[EINA_RBTREE_RIGHT];
 
    /* Consecutive red links. */
-   fail_if(_eina_rbtree_is_red(tree) && (_eina_rbtree_is_red(left) || _eina_rbtree_is_red(right)));
+        fail_if(_eina_rbtree_is_red(tree) &&
+           (_eina_rbtree_is_red(left) || _eina_rbtree_is_red(right)));
 
    left_height = _eina_rbtree_black_height(left, cmp);
    right_height = _eina_rbtree_black_height(right, cmp);
@@ -56,19 +58,20 @@ _eina_rbtree_black_height(Eina_Rbtree *tree, Eina_Rbtree_Cmp_Node_Cb cmp)
    /* Check binary search tree. */
    if (left)
      {
-       dir = cmp(tree, left, NULL);
-       fail_if(dir != EINA_RBTREE_LEFT);
+        dir = cmp(tree, left, NULL);
+        fail_if(dir != EINA_RBTREE_LEFT);
      }
 
    if (right)
      {
-       dir = cmp(tree, right, NULL);
-       fail_if(dir != EINA_RBTREE_RIGHT);
+        dir = cmp(tree, right, NULL);
+        fail_if(dir != EINA_RBTREE_RIGHT);
      }
 
    /* Check black height */
    if (left_height != right_height)
-     fprintf(stderr, "%i != %i\n", left_height, right_height);
+      fprintf(stderr, "%i != %i\n", left_height, right_height);
+
    fail_if(left_height != right_height);
 
    return _eina_rbtree_is_red(tree) ? left_height : left_height + 1;
@@ -82,17 +85,24 @@ struct _Eina_Rbtree_Int
 };
 
 static Eina_Rbtree_Direction
-eina_rbtree_int_cmp(const Eina_Rbtree_Int *left, const Eina_Rbtree_Int *right, __UNUSED__ void *data)
+eina_rbtree_int_cmp(const Eina_Rbtree_Int *left,
+                    const Eina_Rbtree_Int *right,
+                    __UNUSED__ void *data)
 {
    fail_if(!left);
    fail_if(!right);
 
-   if (left->value < right->value) return EINA_RBTREE_LEFT;
+   if (left->value < right->value)
+      return EINA_RBTREE_LEFT;
+
    return EINA_RBTREE_RIGHT;
 }
 
 static int
-eina_rbtree_int_key(const Eina_Rbtree_Int *node, const int *key, __UNUSED__ int length, __UNUSED__ void *data)
+eina_rbtree_int_key(const Eina_Rbtree_Int *node,
+                    const int *key,
+                    __UNUSED__ int length,
+                    __UNUSED__ void *data)
 {
    fail_if(!node);
    return node->value - *key;
@@ -121,11 +131,18 @@ START_TEST(eina_rbtree_insertion)
 
    for (i = 0; i < 500; ++i)
      {
-       item = _eina_rbtree_int_new(rand());
-       root = (Eina_Rbtree_Int*) eina_rbtree_inline_insert(&root->node, &item->node, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
+        item = _eina_rbtree_int_new(rand());
+        root = (Eina_Rbtree_Int *)eina_rbtree_inline_insert(
+              &root->node,
+              &item->node,
+              EINA_RBTREE_CMP_NODE_CB(
+                 eina_rbtree_int_cmp),
+              NULL);
      }
 
-   _eina_rbtree_black_height(&root->node, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp));
+   _eina_rbtree_black_height(&root->node,
+                             EINA_RBTREE_CMP_NODE_CB(
+                                eina_rbtree_int_cmp));
 }
 END_TEST
 
@@ -138,15 +155,31 @@ START_TEST(eina_rbtree_lookup)
 
    for (i = 0; i < sizeof (list) / sizeof (int); ++i)
      {
-       item = _eina_rbtree_int_new(list[i]);
-       root = (Eina_Rbtree_Int*) eina_rbtree_inline_insert(&root->node, &item->node, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
+        item = _eina_rbtree_int_new(list[i]);
+        root = (Eina_Rbtree_Int *)eina_rbtree_inline_insert(
+              &root->node,
+              &item->node,
+                             EINA_RBTREE_CMP_NODE_CB(
+                 eina_rbtree_int_cmp),
+              NULL);
      }
 
-   item = (Eina_Rbtree_Int*) eina_rbtree_inline_lookup(&root->node, &list[0], sizeof(int), EINA_RBTREE_CMP_KEY_CB(eina_rbtree_int_key), NULL);
+   item = (Eina_Rbtree_Int *)eina_rbtree_inline_lookup(&root->node,
+                                                       &list[0],
+                                                       sizeof(int),
+                                                       EINA_RBTREE_CMP_KEY_CB(
+                                                          eina_rbtree_int_key),
+                                                       NULL);
    fail_if(!item);
 
    i = 42;
-   item = (Eina_Rbtree_Int*) eina_rbtree_inline_lookup(&root->node, &i, sizeof(int), EINA_RBTREE_CMP_KEY_CB(eina_rbtree_int_key), NULL);
+   item =
+      (Eina_Rbtree_Int *)eina_rbtree_inline_lookup(&root->node,
+                                                   &i,
+                                                   sizeof(int),
+                                                   EINA_RBTREE_CMP_KEY_CB(
+                                                      eina_rbtree_int_key),
+                                                   NULL);
    fail_if(item);
 }
 END_TEST
@@ -161,24 +194,36 @@ START_TEST(eina_rbtree_remove)
 
    eina_init();
 
-   ea =  eina_array_new(11);
+   ea = eina_array_new(11);
    fail_if(!ea);
 
    srand(time(NULL));
 
    for (i = 0; i < 500; ++i)
      {
-       item = _eina_rbtree_int_new(rand());
-       eina_array_push(ea, item);
-       root = (Eina_Rbtree_Int*) eina_rbtree_inline_insert(&root->node, &item->node, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
+        item = _eina_rbtree_int_new(rand());
+        eina_array_push(ea, item);
+        root = (Eina_Rbtree_Int *)eina_rbtree_inline_insert(
+              &root->node,
+              &item->node,
+              EINA_RBTREE_CMP_NODE_CB(
+                 eina_rbtree_int_cmp),
+              NULL);
      }
 
-   _eina_rbtree_black_height(&root->node, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp));
+   _eina_rbtree_black_height(&root->node,
+                             EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp));
 
    EINA_ARRAY_ITER_NEXT(ea, i, item, it)
      {
-       root = (Eina_Rbtree_Int*) eina_rbtree_inline_remove(&root->node, &item->node, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
-       _eina_rbtree_black_height(&root->node, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp));
+        root = (Eina_Rbtree_Int *)eina_rbtree_inline_remove(
+              &root->node,
+              &item->node,
+              EINA_RBTREE_CMP_NODE_CB(
+                 eina_rbtree_int_cmp),
+              NULL);
+        _eina_rbtree_black_height(&root->node,
+                                  EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp));
      }
 
    fail_if(root != NULL);
@@ -193,20 +238,44 @@ START_TEST(eina_rbtree_simple_remove)
    Eina_Rbtree *lookup;
    int i;
 
-   root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(10), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
-   root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(42), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
-   root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(69), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
-   root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(1337), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
-   _eina_rbtree_black_height(root, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp));
+   root =
+      eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+                                   10),
+                                EINA_RBTREE_CMP_NODE_CB(
+                                   eina_rbtree_int_cmp), NULL);
+   root =
+      eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+                                   42),
+                                EINA_RBTREE_CMP_NODE_CB(
+                                   eina_rbtree_int_cmp), NULL);
+   root =
+      eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+                                   69),
+                                EINA_RBTREE_CMP_NODE_CB(
+                                   eina_rbtree_int_cmp), NULL);
+   root =
+      eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+                                   1337),
+                                EINA_RBTREE_CMP_NODE_CB(
+                                   eina_rbtree_int_cmp), NULL);
+   _eina_rbtree_black_height(root,
+                             EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp));
 
    fail_if(root == NULL);
 
    i = 69;
-   lookup = eina_rbtree_inline_lookup(root, &i, sizeof (int), EINA_RBTREE_CMP_KEY_CB(eina_rbtree_int_key), NULL);
+   lookup = eina_rbtree_inline_lookup(root,
+                                      &i,
+                                      sizeof (int),
+                                      EINA_RBTREE_CMP_KEY_CB(
+                                         eina_rbtree_int_key),
+                                      NULL);
    _eina_rbtree_black_height(root, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp));
    fail_if(lookup == NULL);
 
-   root = eina_rbtree_inline_remove(root, lookup, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
+   root =
+      eina_rbtree_inline_remove(root, lookup, EINA_RBTREE_CMP_NODE_CB(
+                                   eina_rbtree_int_cmp), NULL);
 
    _eina_rbtree_black_height(root, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp));
 }
@@ -218,23 +287,59 @@ START_TEST(eina_rbtree_simple_remove2)
    Eina_Rbtree *lookup;
    int i;
 
-   root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(10), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
-   root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(42), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
-   root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(69), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
-   root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(1337), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
-   root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(77), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
-   root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(75), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
-   root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(81), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
-   _eina_rbtree_black_height(root, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp));
+   root =
+      eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+                                   10),
+                                EINA_RBTREE_CMP_NODE_CB(
+                                   eina_rbtree_int_cmp), NULL);
+   root =
+      eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+                                   42),
+                                EINA_RBTREE_CMP_NODE_CB(
+                                   eina_rbtree_int_cmp), NULL);
+   root =
+      eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+                                   69),
+                                EINA_RBTREE_CMP_NODE_CB(
+                                   eina_rbtree_int_cmp), NULL);
+   root =
+      eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+                                   1337),
+                                EINA_RBTREE_CMP_NODE_CB(
+                                   eina_rbtree_int_cmp), NULL);
+   root =
+      eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+                                   77),
+                                EINA_RBTREE_CMP_NODE_CB(
+                                   eina_rbtree_int_cmp), NULL);
+   root =
+      eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+                                   75),
+                                EINA_RBTREE_CMP_NODE_CB(
+                                   eina_rbtree_int_cmp), NULL);
+   root =
+      eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+                                   81),
+                                EINA_RBTREE_CMP_NODE_CB(
+                                   eina_rbtree_int_cmp), NULL);
+   _eina_rbtree_black_height(root,
+                             EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp));
 
    fail_if(root == NULL);
 
    i = 69;
-   lookup = eina_rbtree_inline_lookup(root, &i, sizeof (int), EINA_RBTREE_CMP_KEY_CB(eina_rbtree_int_key), NULL);
+   lookup = eina_rbtree_inline_lookup(root,
+                                      &i,
+                                      sizeof (int),
+                                      EINA_RBTREE_CMP_KEY_CB(
+                                         eina_rbtree_int_key),
+                                      NULL);
    _eina_rbtree_black_height(root, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp));
    fail_if(lookup == NULL);
 
-   root = eina_rbtree_inline_remove(root, lookup, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
+   root =
+      eina_rbtree_inline_remove(root, lookup, EINA_RBTREE_CMP_NODE_CB(
+                                   eina_rbtree_int_cmp), NULL);
 
    _eina_rbtree_black_height(root, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp));
 }
@@ -246,29 +351,89 @@ START_TEST(eina_rbtree_simple_remove3)
    Eina_Rbtree *lookup;
    int i;
 
-   root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(1113497590), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
-   root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(499187507), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
-   root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(1693860487), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
-   root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(26211080), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
-   root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(797272577), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
-   root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(1252184882), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
-   root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(1448158229), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
-   root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(1821884856), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
-   root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(346086006), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
-   root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(936357333), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
-   root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(1462073936), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
-   root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(1717320055), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
-   root = eina_rbtree_inline_insert(root, (Eina_Rbtree*) _eina_rbtree_int_new(1845524606), EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
-   _eina_rbtree_black_height(root, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp));
+   root =
+      eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+                                   1113497590),
+                                EINA_RBTREE_CMP_NODE_CB(
+                                   eina_rbtree_int_cmp), NULL);
+   root =
+      eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+                                   499187507),
+                                EINA_RBTREE_CMP_NODE_CB(
+                                   eina_rbtree_int_cmp), NULL);
+   root =
+      eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+                                   1693860487),
+                                EINA_RBTREE_CMP_NODE_CB(
+                                   eina_rbtree_int_cmp), NULL);
+   root =
+      eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+                                   26211080),
+                                EINA_RBTREE_CMP_NODE_CB(
+                                   eina_rbtree_int_cmp), NULL);
+   root =
+      eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+                                   797272577),
+                                EINA_RBTREE_CMP_NODE_CB(
+                                   eina_rbtree_int_cmp), NULL);
+   root =
+      eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+                                   1252184882),
+                                EINA_RBTREE_CMP_NODE_CB(
+                                   eina_rbtree_int_cmp), NULL);
+   root =
+      eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+                                   1448158229),
+                                EINA_RBTREE_CMP_NODE_CB(
+                                   eina_rbtree_int_cmp), NULL);
+   root =
+      eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+                                   1821884856),
+                                EINA_RBTREE_CMP_NODE_CB(
+                                   eina_rbtree_int_cmp), NULL);
+   root =
+      eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+                                   346086006),
+                                EINA_RBTREE_CMP_NODE_CB(
+                                   eina_rbtree_int_cmp), NULL);
+   root =
+      eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+                                   936357333),
+                                EINA_RBTREE_CMP_NODE_CB(
+                                   eina_rbtree_int_cmp), NULL);
+   root =
+      eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+                                   1462073936),
+                                EINA_RBTREE_CMP_NODE_CB(
+                                   eina_rbtree_int_cmp), NULL);
+   root =
+      eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+                                   1717320055),
+                                EINA_RBTREE_CMP_NODE_CB(
+                                   eina_rbtree_int_cmp), NULL);
+   root =
+      eina_rbtree_inline_insert(root, (Eina_Rbtree *)_eina_rbtree_int_new(
+                                   1845524606),
+                                EINA_RBTREE_CMP_NODE_CB(
+                                   eina_rbtree_int_cmp), NULL);
+   _eina_rbtree_black_height(root,
+                             EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp));
 
    fail_if(root == NULL);
 
    i = 1113497590;
-   lookup = eina_rbtree_inline_lookup(root, &i, sizeof (int), EINA_RBTREE_CMP_KEY_CB(eina_rbtree_int_key), NULL);
+   lookup = eina_rbtree_inline_lookup(root,
+                                      &i,
+                                      sizeof (int),
+                                      EINA_RBTREE_CMP_KEY_CB(
+                                         eina_rbtree_int_key),
+                                      NULL);
    _eina_rbtree_black_height(root, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp));
    fail_if(lookup == NULL);
 
-   root = eina_rbtree_inline_remove(root, lookup, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp), NULL);
+   root =
+      eina_rbtree_inline_remove(root, lookup, EINA_RBTREE_CMP_NODE_CB(
+                                   eina_rbtree_int_cmp), NULL);
 
    _eina_rbtree_black_height(root, EINA_RBTREE_CMP_NODE_CB(eina_rbtree_int_cmp));
 }
index 0de1358..581ab76 100644 (file)
@@ -40,29 +40,29 @@ START_TEST(eina_rectangle_pool)
    fail_if(pool == NULL);
 
    eina_rectangle_pool_data_set(pool, rects);
-   fail_if(eina_rectangle_pool_data_get(pool) != rects);
+           fail_if(eina_rectangle_pool_data_get(pool) != rects);
 
-   fail_if(eina_rectangle_pool_request(pool, 1024, 1024) != NULL);
+           fail_if(eina_rectangle_pool_request(pool, 1024, 1024) != NULL);
 
    for (x = 0; x < 8; x++)
-     for (y = 0; y < 8; y++)
-       {
-         rects[x][y] = eina_rectangle_pool_request(pool, 32, 32);
-         fail_if(rects[x][y] == NULL);
-       }
+      for (y = 0; y < 8; y++)
+        {
+           rects[x][y] = eina_rectangle_pool_request(pool, 32, 32);
+           fail_if(rects[x][y] == NULL);
+        }
 
-   fail_if(eina_rectangle_pool_count(pool) != 64);
+           fail_if(eina_rectangle_pool_count(pool) != 64);
 
-   fail_if(eina_rectangle_pool_get(rects[0][0]) != pool);
+           fail_if(eina_rectangle_pool_get(rects[0][0]) != pool);
 
-   fail_if(eina_rectangle_pool_geometry_get(pool, &w, &h) != EINA_TRUE);
-   fail_if(w != 256 || h != 256);
+           fail_if(eina_rectangle_pool_geometry_get(pool, &w, &h) != EINA_TRUE);
+           fail_if(w != 256 || h != 256);
 
-   fail_if(eina_rectangle_pool_request(pool, 32, 32) != NULL);
-   fail_if(eina_rectangle_pool_request(pool, 1024, 1024) != NULL);
+           fail_if(eina_rectangle_pool_request(pool, 32, 32) != NULL);
+           fail_if(eina_rectangle_pool_request(pool, 1024, 1024) != NULL);
 
    for (x = 0; x < 8; x++)
-     eina_rectangle_pool_release(rects[0][x]);
+           eina_rectangle_pool_release(rects[0][x]);
 
    fail_if(eina_rectangle_pool_request(pool, 16, 16) == NULL);
 
@@ -80,7 +80,7 @@ START_TEST(eina_rectangle_intersect)
 
    EINA_RECTANGLE_SET(&r1, 10, 10, 50, 50);
    EINA_RECTANGLE_SET(&r2, 20, 20, 20, 20);
-   EINA_RECTANGLE_SET(&r3, 0, 0, 10, 10);
+   EINA_RECTANGLE_SET(&r3, 0,   0, 10, 10);
    EINA_RECTANGLE_SET(&r4, 30, 30, 50, 50);
 
    rd = r1;
@@ -89,18 +89,18 @@ START_TEST(eina_rectangle_intersect)
    fail_if(!eina_rectangle_intersection(&rd, &r2));
 
    fail_if(rd.x != r2.x
-          || rd.y != r2.y
-          || rd.w != r2.w
-          || rd.h != r2.h);
+           || rd.y != r2.y
+           || rd.w != r2.w
+           || rd.h != r2.h);
 
    rd = r1;
 
    fail_if(!eina_rectangle_intersection(&rd, &r4));
 
    fail_if(rd.x != 30
-          || rd.y != 30
-          || rd.w != 30
-          || rd.h != 30);
+           || rd.y != 30
+           || rd.w != 30
+           || rd.h != 30);
 
    eina_shutdown();
 }
index ad99326..f0ea291 100644 (file)
@@ -25,7 +25,7 @@
 #include "eina_suite.h"
 #include "Eina.h"
 
-START_TEST(str_simple)
+   START_TEST(str_simple)
 {
    eina_init();
 
@@ -91,85 +91,85 @@ START_TEST(str_split)
    eina_init();
 
    result = eina_str_split_full("nomatch", "", -1, &elements);
-   fail_if(result != NULL);
-   fail_if(elements != 0);
+        fail_if(result != NULL);
+        fail_if(elements != 0);
 
    result = eina_str_split_full("nomatch", "x", -1, &elements);
-   fail_if(result == NULL);
-   fail_if(elements != 1);
-   fail_if(strcmp(result[0], "nomatch") != 0);
-   free(result[0]);
-   free(result);
+        fail_if(result == NULL);
+        fail_if(elements != 1);
+        fail_if(strcmp(result[0], "nomatch") != 0);
+        free(result[0]);
+        free(result);
 
    result = eina_str_split_full("nomatch", "xyz", -1, &elements);
-   fail_if(result == NULL);
-   fail_if(elements != 1);
-   fail_if(strcmp(result[0], "nomatch") != 0);
-   free(result[0]);
-   free(result);
+        fail_if(result == NULL);
+        fail_if(elements != 1);
+        fail_if(strcmp(result[0], "nomatch") != 0);
+        free(result[0]);
+        free(result);
 
    result = eina_str_split_full("match:match:match", ":", -1, &elements);
-   fail_if(result == NULL);
-   fail_if(elements != 3);
+        fail_if(result == NULL);
+        fail_if(elements != 3);
    while (elements >= 1)
      {
-       elements--;
-       fail_if(strcmp(result[elements], "match") != 0);
+        elements--;
+        fail_if(strcmp(result[elements], "match") != 0);
      }
-   free(result[0]);
-   free(result);
+        free(result[0]);
+        free(result);
 
    result = eina_str_split_full("a:b:c", ":", -1, &elements);
-   fail_if(result == NULL);
-   fail_if(elements != 3);
-   fail_if(strcmp(result[0], "a") != 0);
-   fail_if(strcmp(result[1], "b") != 0);
-   fail_if(strcmp(result[2], "c") != 0);
-   free(result[0]);
-   free(result);
+        fail_if(result == NULL);
+        fail_if(elements != 3);
+        fail_if(strcmp(result[0], "a") != 0);
+        fail_if(strcmp(result[1], "b") != 0);
+        fail_if(strcmp(result[2], "c") != 0);
+        free(result[0]);
+        free(result);
 
    result = eina_str_split_full("a:b:", ":", -1, &elements);
-   fail_if(result == NULL);
-   fail_if(elements != 3);
-   fail_if(strcmp(result[0], "a") != 0);
-   fail_if(strcmp(result[1], "b") != 0);
-   fail_if(strcmp(result[2], "") != 0);
-   free(result[0]);
-   free(result);
+        fail_if(result == NULL);
+        fail_if(elements != 3);
+        fail_if(strcmp(result[0], "a") != 0);
+        fail_if(strcmp(result[1], "b") != 0);
+        fail_if(strcmp(result[2], "") != 0);
+        free(result[0]);
+        free(result);
 
    result = eina_str_split_full(":b:c", ":", -1, &elements);
-   fail_if(result == NULL);
-   fail_if(elements != 3);
-   fail_if(strcmp(result[0], "") != 0);
-   fail_if(strcmp(result[1], "b") != 0);
-   fail_if(strcmp(result[2], "c") != 0);
-   free(result[0]);
-   free(result);
+        fail_if(result == NULL);
+        fail_if(elements != 3);
+        fail_if(strcmp(result[0], "") != 0);
+        fail_if(strcmp(result[1], "b") != 0);
+        fail_if(strcmp(result[2], "c") != 0);
+        free(result[0]);
+        free(result);
 
    result = eina_str_split_full(":", ":", -1, &elements);
-   fail_if(result == NULL);
-   fail_if(elements != 2);
-   fail_if(strcmp(result[0], "") != 0);
-   fail_if(strcmp(result[1], "") != 0);
-   free(result[0]);
-   free(result);
+        fail_if(result == NULL);
+        fail_if(elements != 2);
+        fail_if(strcmp(result[0], "") != 0);
+        fail_if(strcmp(result[1], "") != 0);
+        free(result[0]);
+        free(result);
 
    result = eina_str_split_full("a", "!!!!!!!!!", -1, &elements);
-   fail_if(result == NULL);
-   fail_if(elements != 1);
-   fail_if(strcmp(result[0], "a") != 0);
-   free(result[0]);
-   free(result);
+        fail_if(result == NULL);
+        fail_if(elements != 1);
+        fail_if(strcmp(result[0], "a") != 0);
+        free(result[0]);
+        free(result);
 
    result = eina_str_split_full("aaba", "ab", -1, &elements);
-   fail_if(result == NULL);
-   fail_if(elements != 2);
-   fail_if(strcmp(result[0], "a") != 0);
-   fail_if(strcmp(result[1], "a") != 0);
-   free(result[0]);
-   free(result);
-
-   eina_shutdown();
+        fail_if(result == NULL);
+        fail_if(elements != 2);
+        fail_if(strcmp(result[0], "a") != 0);
+        fail_if(strcmp(result[1], "a") != 0);
+        free(result[0]);
+        free(result);
+
+        eina_shutdown();
 }
 END_TEST
 
index a2ad749..87dfc56 100644 (file)
@@ -29,7 +29,8 @@ START_TEST(strbuf_simple)
 {
    Eina_Strbuf *buf;
    char *txt;
-#define TEXT "This test should be so long that it is longer than the initial size of strbuf"
+#define TEXT \
+   "This test should be so long that it is longer than the initial size of strbuf"
 
    eina_init();
 
@@ -92,7 +93,8 @@ START_TEST(strbuf_remove)
    fail_if(strlen(eina_strbuf_string_get(buf)) != eina_strbuf_length_get(buf));
    fail_if(strcmp(eina_strbuf_string_get(buf), ""));
 
-#define TEXT "This test should be so long that it is longer than the initial size of strbuf"
+#define TEXT \
+   "This test should be so long that it is longer than the initial size of strbuf"
    eina_strbuf_append(buf, TEXT TEXT);
    fail_if(strlen(eina_strbuf_string_get(buf)) != eina_strbuf_length_get(buf));
    eina_strbuf_remove(buf, 0, eina_strbuf_length_get(buf) - 1);
@@ -193,9 +195,11 @@ START_TEST(strbuf_insert)
    fail_if(strncmp(eina_strbuf_string_get(buf) + 3, "678", 3));
 
    eina_strbuf_insert_escaped(buf, "089 '\\", 9);
-   fail_if(strlen(eina_strbuf_string_get(buf)) != eina_strbuf_length_get(buf));
-   fail_if(strncmp(eina_strbuf_string_get(buf) + 9, "089\\ \\'\\\\",
-                  strlen("089\\ \\'\\\\")));
+                   fail_if(strlen(eina_strbuf_string_get(
+                     buf)) != eina_strbuf_length_get(buf));
+                   fail_if(strncmp(eina_strbuf_string_get(buf) + 9,
+                   "089\\ \\'\\\\",
+                   strlen("089\\ \\'\\\\")));
    eina_strbuf_reset(buf);
 
    eina_strbuf_free(buf);
@@ -260,7 +264,7 @@ START_TEST(strbuf_realloc)
    size_t sz;
 
    for (i = 0; i < sizeof(pattern) - 1; i++)
-     pattern[i] = 'a' + (i % 26);
+      pattern[i] = 'a' + (i % 26);
    pattern[i] = '\0';
 
    eina_init();
@@ -297,7 +301,8 @@ START_TEST(strbuf_realloc)
 
    eina_strbuf_append_length(buf, pattern, sizeof(pattern) - 1);
    fail_if(eina_strbuf_length_get(buf) != sz + sizeof(pattern) - 1);
-   fail_if(memcmp(eina_strbuf_string_get(buf) + sz, pattern, sizeof(pattern) - 1));
+   fail_if(memcmp(eina_strbuf_string_get(buf) + sz, pattern, sizeof(pattern) -
+                  1));
    sz += sizeof(pattern) - 1;
 
 
@@ -331,25 +336,25 @@ START_TEST(strbuf_append_realloc)
    eina_init();
 
    buf = eina_strbuf_new();
-   fail_if(!buf);
+        fail_if(!buf);
 
    for (i = 0; i < runs; i++)
      {
-       fail_if(!eina_strbuf_append(buf, "string"));
-       fail_if(!eina_strbuf_append_n(buf, "string", 3));
-       fail_if(!eina_strbuf_append_char(buf, 's'));
-       fail_if(!eina_strbuf_append_length(buf, "string", 3));
+        fail_if(!eina_strbuf_append(buf, "string"));
+        fail_if(!eina_strbuf_append_n(buf, "string", 3));
+        fail_if(!eina_strbuf_append_char(buf, 's'));
+        fail_if(!eina_strbuf_append_length(buf, "string", 3));
      }
 
    target_pattern_size = strlen(target_pattern);
-   fail_if(eina_strbuf_length_get(buf) != (runs * target_pattern_size));
+        fail_if(eina_strbuf_length_get(buf) != (runs * target_pattern_size));
 
    str = eina_strbuf_string_get(buf);
-   fail_if(str == NULL);
+        fail_if(str == NULL);
    for (i = 0; i < runs; i++, str += target_pattern_size)
-     fail_if(memcmp(str, target_pattern, target_pattern_size));
+        fail_if(memcmp(str, target_pattern, target_pattern_size));
 
-   eina_strbuf_free(buf);
+        eina_strbuf_free(buf);
 
    eina_shutdown();
 }
@@ -366,25 +371,25 @@ START_TEST(strbuf_prepend_realloc)
    eina_init();
 
    buf = eina_strbuf_new();
-   fail_if(!buf);
+        fail_if(!buf);
 
    for (i = 0; i < runs; i++)
      {
-       fail_if(!eina_strbuf_prepend(buf, "string"));
-       fail_if(!eina_strbuf_prepend_n(buf, "string", 3));
-       fail_if(!eina_strbuf_prepend_char(buf, 's'));
-       fail_if(!eina_strbuf_prepend_length(buf, "string", 3));
+        fail_if(!eina_strbuf_prepend(buf, "string"));
+        fail_if(!eina_strbuf_prepend_n(buf, "string", 3));
+        fail_if(!eina_strbuf_prepend_char(buf, 's'));
+        fail_if(!eina_strbuf_prepend_length(buf, "string", 3));
      }
 
    target_pattern_size = strlen(target_pattern);
-   fail_if(eina_strbuf_length_get(buf) != (runs * target_pattern_size));
+        fail_if(eina_strbuf_length_get(buf) != (runs * target_pattern_size));
 
    str = eina_strbuf_string_get(buf);
-   fail_if(str == NULL);
+        fail_if(str == NULL);
    for (i = 0; i < runs; i++, str += target_pattern_size)
-     fail_if(memcmp(str, target_pattern, target_pattern_size));
+        fail_if(memcmp(str, target_pattern, target_pattern_size));
 
-   eina_strbuf_free(buf);
+        eina_strbuf_free(buf);
 
    eina_shutdown();
 }
index 2db4d5d..0d34aec 100644 (file)
@@ -45,7 +45,14 @@ START_TEST(eina_stringshare_simple)
    fail_if(t1 == NULL);
    fail_if(strcmp(t0, TEST0) != 0);
    fail_if(strcmp(t1, TEST1) != 0);
+   fail_if((int)strlen(TEST0) != eina_stringshare_strlen(t0));
+   fail_if((int)strlen(TEST1) != eina_stringshare_strlen(t1));
 
+   t0 = eina_stringshare_ref(t0);
+   fail_if(t0 == NULL);
+   fail_if((int)strlen(TEST0) != eina_stringshare_strlen(t0));
+
+   eina_stringshare_del(t0);
    eina_stringshare_del(t0);
    eina_stringshare_del(t1);
 
@@ -62,29 +69,31 @@ START_TEST(eina_stringshare_small)
 
    for (i = 0; i < 3; i++)
      {
-       const char *t0, *t1;
-       int j;
-
-       for (j = 0; j < i; j++)
-         {
-            char c;
-            for (c = 'a'; c <= 'z'; c++)
-              buf[j] = c;
-         }
-       buf[i] = '\0';
-       t0 = eina_stringshare_add(buf);
-       t1 = eina_stringshare_add(buf);
-
-       fail_if(t0 == NULL);
-       fail_if(t1 == NULL);
-       fail_if(t0 != t1);
-       fail_if(strcmp(t0, buf) != 0);
-
-       eina_stringshare_del(t0);
-       eina_stringshare_del(t1);
+        const char *t0, *t1;
+        int j;
+
+        for (j = 0; j < i; j++)
+          {
+             char c;
+             for (c = 'a'; c <= 'z'; c++)
+                buf[j] = c;
+          }
+        buf[i] = '\0';
+        t0 = eina_stringshare_add(buf);
+        t1 = eina_stringshare_add(buf);
+
+        fail_if(t0 == NULL);
+        fail_if(t1 == NULL);
+        fail_if(t0 != t1);
+        fail_if(strcmp(t0, buf) != 0);
+        fail_if((int)strlen(buf) != eina_stringshare_strlen(t0));
+        fail_if((int)strlen(buf) != eina_stringshare_strlen(t1));
+
+        eina_stringshare_del(t0);
+        eina_stringshare_del(t1);
      }
 
-   eina_shutdown();
+        eina_shutdown();
 }
 END_TEST
 
@@ -104,6 +113,7 @@ START_TEST(eina_stringshare_test_share)
    fail_if(strcmp(t0, TEST0) != 0);
    fail_if(strcmp(t1, TEST0) != 0);
    fail_if(t0 != t1);
+   fail_if((int)strlen(t0) != eina_stringshare_strlen(t0));
 
    eina_stringshare_del(t0);
    eina_stringshare_del(t1);
@@ -121,11 +131,11 @@ START_TEST(eina_stringshare_putstuff)
 
    for (i = 10000; i > 0; --i)
      {
-       char build[64] = "string_";
+        char build[64] = "string_";
 
-       eina_convert_xtoa(i, build + 7);
-       tmp = eina_stringshare_add(build);
-       fail_if(tmp != eina_stringshare_add(build));
+        eina_convert_xtoa(i, build + 7);
+        tmp = eina_stringshare_add(build);
+        fail_if(tmp != eina_stringshare_add(build));
      }
 
    eina_shutdown();
@@ -147,34 +157,34 @@ START_TEST(eina_stringshare_collision)
 
    for (i = 0; i < 10000; ++i)
      {
-       eina_convert_itoa(rand(), buffer);
-       eina_array_push(ea, (void*) eina_stringshare_add(buffer));
-       if (rand() > RAND_MAX / 2)
-         {
-            const char *r = eina_stringshare_add(buffer);
-            fail_if(r == NULL);
-         }
+        eina_convert_itoa(rand(), buffer);
+        eina_array_push(ea, (void *)eina_stringshare_add(buffer));
+        if (rand() > RAND_MAX / 2)
+          {
+             const char *r = eina_stringshare_add(buffer);
+             fail_if(r == NULL);
+          }
      }
 
    for (i = 0; i < 10000; ++i)
      {
-       const char *r;
-
-       eina_convert_itoa(60000 - i, buffer);
-       eina_array_push(ea, (void*) eina_stringshare_add(buffer));
-       r = eina_stringshare_add(buffer);
-       fail_if(r == NULL);
-       r = eina_stringshare_add(buffer);
-       fail_if(r == NULL);
+        const char *r;
+
+        eina_convert_itoa(60000 - i, buffer);
+        eina_array_push(ea, (void *)eina_stringshare_add(buffer));
+        r = eina_stringshare_add(buffer);
+        fail_if(r == NULL);
+        r = eina_stringshare_add(buffer);
+        fail_if(r == NULL);
      }
 
    for (i = 0; i < 200; ++i)
-     eina_stringshare_del(eina_array_data_get(ea, i));
+      eina_stringshare_del(eina_array_data_get(ea, i));
 
    for (i = 0; i < 1000; ++i)
-     eina_stringshare_del(eina_array_pop(ea));
+      eina_stringshare_del(eina_array_pop(ea));
 
-   eina_shutdown();
+      eina_shutdown();
 
    eina_array_free(ea);
 }
index b877839..4b8aa20 100644 (file)
 #include "eina_suite.h"
 #include "Eina.h"
 
-struct test_rect {
-     unsigned long col, row;
-     int x, y, w, h;
-     Eina_Bool full;
+struct test_rect
+{
+   unsigned long col, row;
+   int x, y, w, h;
+   Eina_Bool full;
 };
 
 static void
@@ -37,53 +38,53 @@ check_iterator(Eina_Iterator *it, struct test_rect *cur_test)
    unsigned int i = 0;
    struct Eina_Tile_Grid_Info *tile;
 
-   EINA_ITERATOR_FOREACH(it, tile) {
+      EINA_ITERATOR_FOREACH(it, tile) {
       fail_if(cur_test[i].col != tile->col ||
-             cur_test[i].row != tile->row ||
-             cur_test[i].x != tile->rect.x ||
-             cur_test[i].y != tile->rect.y ||
-             cur_test[i].w != tile->rect.w ||
-             cur_test[i].h != tile->rect.h ||
-             cur_test[i].full != tile->full);
+              cur_test[i].row != tile->row ||
+              cur_test[i].x != tile->rect.x ||
+              cur_test[i].y != tile->rect.y ||
+              cur_test[i].w != tile->rect.w ||
+              cur_test[i].h != tile->rect.h ||
+              cur_test[i].full != tile->full);
       i++;
    }
 
-   fail_if(i == 0);
+      fail_if(i == 0);
 }
 
-START_TEST(eina_test_tile_grid_slicer_iterator)
+      START_TEST(eina_test_tile_grid_slicer_iterator)
 {
    Eina_Iterator *it;
    struct test_rect *cur_test;
    struct test_rect test1[] = {{1, 1, 72, 82, 10, 15, 0}};
    struct test_rect test2[] =
-     {{1, 1,  72,  82,  56,  15,  0},
-      {2, 1,   0,  82, 128,  15,  0},
-      {3, 1,   0,  82, 116,  15,  0}};
+   {{1, 1,  72,  82,  56,  15,  0},
+    {2, 1,   0,  82, 128,  15,  0},
+    {3, 1,   0,  82, 116,  15,  0}};
    struct test_rect test3[] =
-     {{1, 1,  72,  82,  10,  46,  0},
-      {1, 2,  72,   0,  10, 128,  0},
-      {1, 3,  72,   0,  10, 126,  0}};
+   {{1, 1,  72,  82,  10,  46,  0},
+    {1, 2,  72,   0,  10, 128,  0},
+    {1, 3,  72,   0,  10, 126,  0}};
    struct test_rect test4[] =
-     {{1, 1,  72,  82,  56,  46,  0},
-      {2, 1,   0,  82, 128,  46,  0},
-      {3, 1,   0,  82, 128,  46,  0},
-      {4, 1,   0,  82,  88,  46,  0},
-      {1, 2,  72,   0,  56, 128,  0},
-      {2, 2,   0,   0, 128, 128,  1},
-      {3, 2,   0,   0, 128, 128,  1},
-      {4, 2,   0,   0,  88, 128,  0},
-      {1, 3,  72,   0,  56, 126,  0},
-      {2, 3,   0,   0, 128, 126,  0},
-      {3, 3,   0,   0, 128, 126,  0},
-      {4, 3,   0,   0,  88, 126,  0}};
+   {{1, 1,  72,  82,  56,  46,  0},
+    {2, 1,   0,  82, 128,  46,  0},
+    {3, 1,   0,  82, 128,  46,  0},
+    {4, 1,   0,  82,  88,  46,  0},
+    {1, 2,  72,   0,  56, 128,  0},
+    {2, 2,   0,   0, 128, 128,  1},
+    {3, 2,   0,   0, 128, 128,  1},
+    {4, 2,   0,   0,  88, 128,  0},
+    {1, 3,  72,   0,  56, 126,  0},
+    {2, 3,   0,   0, 128, 126,  0},
+    {3, 3,   0,   0, 128, 126,  0},
+    {4, 3,   0,   0,  88, 126,  0}};
    struct test_rect test5[] = {{1, 1, 0, 0, 128, 128, 1}};
    struct test_rect test6[] = {{1, 1, 0, 0, 1, 1, 0}};
    struct test_rect test7[] =
-     {{1, 1,   0,   0, 128, 128,  1},
-      {2, 1,   0,   0,   1, 128,  0},
-      {1, 2,   0,   0, 128,   1,  0},
-      {2, 2,   0,   0,   1,   1,  0}};
+   {{1, 1,   0,   0, 128, 128,  1},
+    {2, 1,   0,   0,   1, 128,  0},
+    {1, 2,   0,   0, 128,   1,  0},
+    {2, 2,   0,   0,   1,   1,  0}};
 
    eina_init();
 
@@ -147,22 +148,22 @@ START_TEST(eina_test_tiler_all)
 
    EINA_RECTANGLE_SET(&r, 40, 40, 20, 20);
    eina_tiler_rect_del(tl, &r);
-   
+
    it = eina_tiler_iterator_new(tl);
    fail_if(!it);
 
    EINA_ITERATOR_FOREACH(it, r)
-     {
-       fail_if(r.w <= 0);
-       fail_if(r.h <= 0);
-       fail_if(r.x < 0 || r.x + r.w > 640);
-       fail_if(r.y < 0 || r.y + r.h > 480);
-       ++i;
-     }
+   {
+      fail_if(r.w <= 0);
+      fail_if(r.h <= 0);
+      fail_if(r.x < 0 || r.x + r.w > 640);
+      fail_if(r.y < 0 || r.y + r.h > 480);
+      ++i;
+   }
 
-   fail_if(eina_iterator_container_get(it) != tl);
+      fail_if(eina_iterator_container_get(it) != tl);
 
-   eina_iterator_free(it);
+      eina_iterator_free(it);
 
    fail_if(i == 0);
 
diff --git a/src/tests/eina_test_ustr.c b/src/tests/eina_test_ustr.c
new file mode 100644 (file)
index 0000000..c4ccd95
--- /dev/null
@@ -0,0 +1,242 @@
+/* EINA - EFL data type library
+ * Copyright (C) 2010 Brett Nash
+ *
+ * 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
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+
+#include "eina_suite.h"
+#include "Eina.h"
+
+static const Eina_Unicode STR1[] = {'P', 'a', 'n', 't', 's',' ', 'O', 'n', 0};
+static const Eina_Unicode STR2[] = {'P', 'a', 'n', 't', 's',' ', 'O', 'f', 'f', 0};
+static const Eina_Unicode STR3[] = {'P', 'a', 'n', 't', 's',' ', 'O', 'n', 0};
+static const Eina_Unicode STR4[] = {'A', 0};
+static const Eina_Unicode EMPTYSTR[] = {0};
+
+START_TEST(eina_unicode_strcmp_test)
+{
+   eina_init();
+
+   /* 1 & 2 */
+   fail_if(eina_unicode_strcmp(STR1,STR2) == 0);
+   fail_if(eina_unicode_strcmp(STR1,STR2) < 1);
+
+   /* 1 & 3 */
+   fail_if(eina_unicode_strcmp(STR1, STR3) != 0);
+
+   /* 1 & 4 */
+   fail_if(eina_unicode_strcmp(STR1, STR4) == 0);
+   fail_if(eina_unicode_strcmp(STR1, STR4) > 1);
+
+   /* 1 & empty */
+   fail_if(eina_unicode_strcmp(STR1, EMPTYSTR) < 1);
+
+   /* Self tests */
+   fail_if(eina_unicode_strcmp(STR1, STR1) != 0);
+   fail_if(eina_unicode_strcmp(STR2, STR2) != 0);
+   fail_if(eina_unicode_strcmp(STR3, STR3) != 0);
+   fail_if(eina_unicode_strcmp(STR4, STR4) != 0);
+   fail_if(eina_unicode_strcmp(EMPTYSTR, EMPTYSTR) != 0);
+
+   eina_shutdown();
+}
+END_TEST
+
+START_TEST(eina_unicode_strcpy_test)
+{
+   Eina_Unicode buf[10] = { 0 };
+   Eina_Unicode *rv;
+
+   eina_init();
+
+   rv = eina_unicode_strcpy(buf,STR1);
+   fail_if(rv != buf);
+   fail_if(eina_unicode_strcmp(buf,STR1) != 0);
+
+   rv = eina_unicode_strcpy(buf,STR2);
+   fail_if(rv != buf);
+   fail_if(eina_unicode_strcmp(buf,STR2) != 0);
+
+   /* Now a shorter string */
+   rv = eina_unicode_strcpy(buf,STR2);
+   fail_if(rv != buf);
+   fail_if(eina_unicode_strcmp(buf,STR2) != 0);
+
+   /* Really short string */
+   rv = eina_unicode_strcpy(buf,STR4);
+   fail_if(rv != buf);
+   fail_if(eina_unicode_strcmp(buf,STR4) != 0);
+   fail_if(buf[2] != 'n'); /* check old buf is there */
+
+   buf[1] = '7';
+   rv = eina_unicode_strcpy(buf,EMPTYSTR);
+   fail_if(rv != buf);
+   fail_if(buf[0] != 0);
+   fail_if(buf[1] != '7');
+
+   eina_shutdown();
+}
+END_TEST
+
+START_TEST(eina_unicode_strncpy_test)
+{
+   Eina_Unicode buf[10] = { 0 };
+   Eina_Unicode *rv;
+
+   eina_init();
+
+   rv = eina_unicode_strncpy(buf,STR1,9);
+   fail_if(rv != buf);
+   fail_if(eina_unicode_strcmp(buf,STR1) != 0);
+
+   buf[1] = '7';
+   rv = eina_unicode_strncpy(buf,STR1,1);
+   fail_if(rv != buf);
+   fail_if(buf[1] != '7');
+   fail_if(buf[0] != STR1[0]);
+
+   buf[9] = '7';
+   rv = eina_unicode_strncpy(buf, STR4, 10);
+   fail_if(rv != buf);
+   fail_if(eina_unicode_strcmp(buf,STR4) != 0);
+   fail_if(buf[9] != 0);
+
+   buf[0] = '7';
+   rv = eina_unicode_strncpy(buf, STR1, 0);
+   fail_if(buf[0] != '7');
+
+   /* may segfault */
+   buf[0] = '7';
+   rv = eina_unicode_strncpy(buf, NULL, 0);
+   fail_if(buf[0] != '7');
+
+   /* Hopefully won't segfault */
+   rv = eina_unicode_strncpy(NULL, STR1, 0);
+   fail_if(rv != NULL);
+
+   eina_shutdown();
+}
+END_TEST
+
+
+
+START_TEST(eina_ustr_strlen_test)
+{
+
+   eina_init();
+
+   fail_if(eina_unicode_strlen(STR1) != 8);
+   fail_if(eina_unicode_strlen(STR2) != 9);
+   fail_if(eina_unicode_strlen(STR3) != 8);
+   fail_if(eina_unicode_strlen(STR4) != 1);
+   fail_if(eina_unicode_strlen(EMPTYSTR) != 0);
+   /* Eina unicode doesn't take NULL */
+   // fail_if(eina_unicode_strlen(NULL));
+
+   eina_shutdown();
+}
+END_TEST
+
+START_TEST(eina_unicode_strnlen_test)
+{
+   eina_init();
+
+   /* Strlen style tests*/
+   fail_if(eina_unicode_strnlen(STR1,10) != 8);
+   fail_if(eina_unicode_strnlen(STR2,10) != 9);
+   fail_if(eina_unicode_strnlen(STR3,10) != 8);
+   fail_if(eina_unicode_strnlen(STR4,10) != 1);
+   fail_if(eina_unicode_strnlen(EMPTYSTR,10) != 0);
+
+   /* Too short tests */
+   fail_if(eina_unicode_strnlen(STR1,3) != 3);
+   fail_if(eina_unicode_strnlen(STR2,3) != 3);
+   fail_if(eina_unicode_strnlen(STR3,3) != 3);
+   fail_if(eina_unicode_strnlen(EMPTYSTR,1) != 0);
+   fail_if(eina_unicode_strnlen(NULL,0) != 0);
+
+   eina_shutdown();
+}
+END_TEST
+
+START_TEST(eina_unicode_strdup_test)
+{
+   Eina_Unicode *buf;
+
+   eina_init();
+
+   buf = eina_unicode_strdup(STR1);
+   fail_if(!buf);
+   fail_if(eina_unicode_strlen(buf) != eina_unicode_strlen(STR1));
+   fail_if(eina_unicode_strcmp(buf, STR1));
+   free(buf);
+
+   buf = eina_unicode_strdup(EMPTYSTR);
+   fail_if(!buf);
+   fail_if(buf[0] != 0);
+
+   eina_shutdown();
+}
+END_TEST
+
+START_TEST(eina_unicode_strstr_test)
+{
+   Eina_Unicode *buf;
+   Eina_Unicode on[] = { 'O', 'n', 0 };
+
+   eina_init();
+
+   buf = eina_unicode_strstr(STR1,on);
+   fail_if(!buf);
+   fail_if(buf != STR1 + 6);
+   fail_if(eina_unicode_strcmp(buf,on) != 0);
+
+   buf = eina_unicode_strstr(STR2,on);
+   fail_if(buf);
+
+   buf = eina_unicode_strstr(EMPTYSTR, on);
+   fail_if(buf);
+
+   buf = eina_unicode_strstr(STR1, EMPTYSTR);
+   fail_if(!buf);
+   fail_if(buf != STR1);
+
+   eina_shutdown();
+}
+END_TEST
+
+void
+eina_test_ustr(TCase *tc)
+{
+   printf("ustr test\n");
+   tcase_add_test(tc,eina_unicode_strcmp_test);
+   tcase_add_test(tc,eina_unicode_strcpy_test);
+   tcase_add_test(tc,eina_unicode_strncpy_test);
+   tcase_add_test(tc,eina_ustr_strlen_test);
+   tcase_add_test(tc,eina_unicode_strnlen_test);
+   tcase_add_test(tc,eina_unicode_strdup_test);
+   tcase_add_test(tc,eina_unicode_strstr_test);
+
+}
+
diff --git a/src/tests/eina_test_ustringshare.c b/src/tests/eina_test_ustringshare.c
new file mode 100644 (file)
index 0000000..1d1f7b8
--- /dev/null
@@ -0,0 +1,119 @@
+/* EINA - EFL data type library
+ * Copyright (C) 2008 Cedric Bail
+ *
+ * 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
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+
+#include "eina_suite.h"
+#include "Eina.h"
+
+static const Eina_Unicode TEST0[] = {'t', 'e', 's', 't', '/', '0', 0};
+static const Eina_Unicode TEST1[] = {'t', 'e', 's', 't', '/', '1', 0};
+
+START_TEST(eina_ustringshare_simple)
+{
+   const Eina_Unicode *t0;
+   const Eina_Unicode *t1;
+
+   eina_init();
+
+   t0 = eina_ustringshare_add(TEST0);
+   t1 = eina_ustringshare_add(TEST1);
+
+   fail_if(t0 == NULL);
+   fail_if(t1 == NULL);
+   fail_if(eina_unicode_strcmp(t0, TEST0) != 0);
+   fail_if(eina_unicode_strcmp(t1, TEST1) != 0);
+   fail_if((int)eina_unicode_strlen(TEST0) != eina_ustringshare_strlen(t0));
+   fail_if((int)eina_unicode_strlen(TEST1) != eina_ustringshare_strlen(t1));
+
+   t0 = eina_ustringshare_ref(t0);
+   fail_if(t0 == NULL);
+   fail_if((int)strlen(TEST0) != eina_stringshare_strlen(t0));
+
+   eina_ustringshare_del(t0);
+   eina_ustringshare_del(t0);
+   eina_ustringshare_del(t1);
+
+   eina_shutdown();
+}
+END_TEST
+
+
+START_TEST(eina_ustringshare_test_share)
+{
+   const Eina_Unicode *t0;
+   const Eina_Unicode *t1;
+
+   eina_init();
+
+   t0 = eina_ustringshare_add(TEST0);
+   t1 = eina_ustringshare_add(TEST0);
+
+   fail_if(t0 == NULL);
+   fail_if(t1 == NULL);
+   fail_if(eina_unicode_strcmp(t0, TEST0) != 0);
+   fail_if(eina_unicode_strcmp(t1, TEST0) != 0);
+   fail_if(t0 != t1);
+   fail_if((int)eina_unicode_strlen(TEST0) != eina_ustringshare_strlen(t0));
+   fail_if((int)eina_unicode_strlen(TEST0) != eina_ustringshare_strlen(t1));
+
+   eina_ustringshare_del(t0);
+   eina_ustringshare_del(t1);
+
+   eina_shutdown();
+}
+END_TEST
+
+START_TEST(eina_ustringshare_putstuff)
+{
+   const Eina_Unicode *tmp;
+   int i;
+
+   eina_init();
+
+   for (i = 10000; i > 0; --i)
+     {
+        Eina_Unicode string_[] = {'s', 't', 'r', 'i', 'n', 'g', '_', 0};
+        Eina_Unicode build[64];
+        eina_unicode_strcpy(build, string_);
+
+        build[7] = i;
+        build[8] = 0;
+        tmp = eina_ustringshare_add(build);
+        fail_if(tmp != eina_ustringshare_add(build));
+        fail_if((int)eina_unicode_strlen(build) != eina_ustringshare_strlen(tmp));
+     }
+
+        eina_shutdown();
+}
+END_TEST
+
+void
+eina_test_ustringshare(TCase *tc)
+{
+   tcase_add_test(tc, eina_ustringshare_simple);
+   tcase_add_test(tc, eina_ustringshare_test_share);
+   tcase_add_test(tc, eina_ustringshare_putstuff);
+}
index 42892c0..27d36a6 100644 (file)
@@ -1,7 +1,3 @@
-/*
- * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
- */
-
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
@@ -15,9 +11,9 @@ typedef struct _Evas_Hash_El Evas_Hash_El;
 
 struct _Evas_Hash_El
 {
-   Evas_Object_List  _list_data;
-   const char       *key;
-   void             *data;
+   Evas_Object_List _list_data;
+   const char *key;
+   void *data;
 };
 
 static inline int _evas_hash_gen(const char *key);
@@ -29,11 +25,13 @@ _evas_hash_gen(const char *key)
 {
    unsigned int hash_num = 5381;
    const unsigned char *ptr;
-   
-   if (!key) return 0;
+
+   if (!key)
+      return 0;
+
    for (ptr = (unsigned char *)key; *ptr; ptr++)
-     hash_num = (hash_num * 33) ^ *ptr;
-   
+      hash_num = (hash_num * 33) ^ *ptr;
+
    hash_num &= 0xff;
    return (int)hash_num;
 }
@@ -106,32 +104,38 @@ evas_hash_add(Evas_Hash *hash, const char *key, const void *data)
    int hash_num;
    Evas_Hash_El *el;
 
-   if ((!key) || (!data)) return hash;
+   if ((!key) || (!data))
+      return hash;
+
    _evas_hash_alloc_error = 0;
    if (!hash)
      {
-       hash = calloc(1, sizeof(struct _Evas_Hash));
-       if (!hash)
-         {
-            _evas_hash_alloc_error = 1;
-            return NULL;
-         }
+        hash = calloc(1, sizeof(struct _Evas_Hash));
+        if (!hash)
+          {
+             _evas_hash_alloc_error = 1;
+             return NULL;
+          }
      }
+
    if (!(el = malloc(sizeof(struct _Evas_Hash_El) + strlen(key) + 1)))
      {
         if (hash->population <= 0)
-         {
-            free(hash);
-            hash = NULL;
-         }
-       _evas_hash_alloc_error = 1;
-       return hash;
-     };
+          {
+             free(hash);
+             hash = NULL;
+          }
+
+        _evas_hash_alloc_error = 1;
+        return hash;
+     }
+
    el->key = ((char *)el) + sizeof(struct _Evas_Hash_El);
-   strcpy((char *) el->key, key);
+   strcpy((char *)el->key, key);
    el->data = (void *)data;
    hash_num = _evas_hash_gen(key);
-   hash->buckets[hash_num] = evas_object_list_prepend(hash->buckets[hash_num], el);
+   hash->buckets[hash_num] = evas_object_list_prepend(hash->buckets[hash_num],
+                                                      el);
    hash->population++;
    return hash;
 }
@@ -165,31 +169,37 @@ evas_hash_direct_add(Evas_Hash *hash, const char *key, const void *data)
    int hash_num;
    Evas_Hash_El *el;
 
-   if ((!key) || (!data)) return hash;
+   if ((!key) || (!data))
+      return hash;
+
    _evas_hash_alloc_error = 0;
    if (!hash)
      {
-       hash = calloc(1, sizeof(struct _Evas_Hash));
-       if (!hash)
-         {
-            _evas_hash_alloc_error = 1;
-            return NULL;
-         }
+        hash = calloc(1, sizeof(struct _Evas_Hash));
+        if (!hash)
+          {
+             _evas_hash_alloc_error = 1;
+             return NULL;
+          }
      }
+
    if (!(el = malloc(sizeof(struct _Evas_Hash_El))))
      {
         if (hash->population <= 0)
-         {
-            free(hash);
-            hash = NULL;
-         }
-       _evas_hash_alloc_error = 1;
-       return hash;
-     };
+          {
+                          free(hash);
+             hash = NULL;
+          }
+
+        _evas_hash_alloc_error = 1;
+        return hash;
+     }
+
    el->key = key;
    el->data = (void *)data;
    hash_num = _evas_hash_gen(key);
-   hash->buckets[hash_num] = evas_object_list_prepend(hash->buckets[hash_num], el);
+   hash->buckets[hash_num] = evas_object_list_prepend(hash->buckets[hash_num],
+                                                      el);
    hash->population++;
    return hash;
 }
@@ -216,52 +226,58 @@ evas_hash_del(Evas_Hash *hash, const char *key, const void *data)
    Evas_Hash_El *el;
    Evas_Object_List *l;
 
-   if (!hash) return NULL;
+   if (!hash)
+      return NULL;
+
    if (!key)
-     {
-       for (hash_num = 0; hash_num < 256; hash_num++)
-         {
-            for (l = hash->buckets[hash_num]; l; l = l->next)
-              {
-                 el = (Evas_Hash_El *)l;
-                 if (el->data == data)
-                   {
-                      hash->buckets[hash_num] = evas_object_list_remove(hash->buckets[hash_num], el);
-                      free(el);
-                      hash->population--;
-                      if (hash->population <= 0)
-                        {
-                           free(hash);
-                           hash = NULL;
-                        }
-                      return hash;
-                   }
-              }
-         }
-     }
+      for (hash_num = 0; hash_num < 256; hash_num++)
+        {
+           for (l = hash->buckets[hash_num]; l; l = l->next)
+             {
+                el = (Evas_Hash_El *)l;
+                if (el->data == data)
+                  {
+                     hash->buckets[hash_num] = evas_object_list_remove(
+                           hash->buckets[hash_num],
+                           el);
+                          free(el);
+                     hash->population--;
+                     if (hash->population <= 0)
+                       {
+                          free(hash);
+                          hash = NULL;
+                       }
+
+                     return hash;
+                  }
+             }
+        }
    else
      {
-       hash_num = _evas_hash_gen(key);
-       for (l = hash->buckets[hash_num]; l; l = l->next)
-         {
-            el = (Evas_Hash_El *)l;
-            if (!strcmp(el->key, key))
-              {
-                  if ((!data) || (el->data == data))
-                   {
-                      hash->buckets[hash_num] = evas_object_list_remove(hash->buckets[hash_num], el);
-                      free(el);
-                      hash->population--;
-                      if (hash->population <= 0)
-                        {
-                           free(hash);
-                           hash = NULL;
-                        }
-                      return hash;
-                   }
-              }
-         }
+        hash_num = _evas_hash_gen(key);
+        for (l = hash->buckets[hash_num]; l; l = l->next)
+          {
+             el = (Evas_Hash_El *)l;
+             if (!strcmp(el->key, key))
+                if ((!data) || (el->data == data))
+                  {
+                     hash->buckets[hash_num] = evas_object_list_remove(
+                           hash->buckets[hash_num],
+                           el);
+                          free(el);
+                     hash->population--;
+                     if (hash->population <= 0)
+                       {
+                          free(hash);
+                          hash = NULL;
+                       }
+
+                     return hash;
+                  }
+
+          }
      }
+
    return hash;
 }
 
@@ -281,24 +297,27 @@ evas_hash_find(const Evas_Hash *hash, const char *key)
    Evas_Object_List *l;
 
    _evas_hash_alloc_error = 0;
-   if ((!hash) || (!key)) return NULL;
+   if ((!hash) || (!key))
+      return NULL;
+
    hash_num = _evas_hash_gen(key);
    for (l = hash->buckets[hash_num]; l; l = l->next)
      {
-       el = (Evas_Hash_El *)l;
-       if (!strcmp(el->key, key))
-         {
-            if (l != hash->buckets[hash_num])
-              {
-                 Evas_Object_List *bucket;
-
-                 bucket = hash->buckets[hash_num];
-                 bucket = evas_object_list_remove(bucket, el);
-                 bucket = evas_object_list_prepend(bucket, el);
-                 ((Evas_Hash *)hash)->buckets[hash_num] = bucket;
-              }
-            return el->data;
-         }
+        el = (Evas_Hash_El *)l;
+        if (!strcmp(el->key, key))
+          {
+             if (l != hash->buckets[hash_num])
+               {
+                  Evas_Object_List *bucket;
+
+                  bucket = hash->buckets[hash_num];
+                  bucket = evas_object_list_remove(bucket, el);
+                  bucket = evas_object_list_prepend(bucket, el);
+                  ((Evas_Hash *)hash)->buckets[hash_num] = bucket;
+               }
+
+             return el->data;
+          }
      }
    return NULL;
 }
@@ -321,24 +340,31 @@ evas_hash_modify(Evas_Hash *hash, const char *key, const void *data)
    Evas_Object_List *l;
 
    _evas_hash_alloc_error = 0;
-   if (!hash) return NULL;
+   if (!hash)
+      return NULL;
+
    hash_num = _evas_hash_gen(key);
    for (l = hash->buckets[hash_num]; l; l = l->next)
      {
-       el = (Evas_Hash_El *)l;
-       if ((key) && (!strcmp(el->key, key)))
-         {
-            void *old_data;
-            
-            if (l != hash->buckets[hash_num])
-              {
-                 hash->buckets[hash_num] = evas_object_list_remove(hash->buckets[hash_num], el);
-                 hash->buckets[hash_num] = evas_object_list_prepend(hash->buckets[hash_num], el);
-              }
-            old_data = el->data;
-            el->data = (void *) data;
-            return old_data;
-         }
+        el = (Evas_Hash_El *)l;
+        if ((key) && (!strcmp(el->key, key)))
+          {
+             void *old_data;
+
+             if (l != hash->buckets[hash_num])
+               {
+                  hash->buckets[hash_num] = evas_object_list_remove(
+                        hash->buckets[hash_num],
+                        el);
+                  hash->buckets[hash_num] = evas_object_list_prepend(
+                        hash->buckets[hash_num],
+                        el);
+               }
+
+             old_data = el->data;
+             el->data = (void *)data;
+             return old_data;
+          }
      }
    return NULL;
 }
@@ -358,7 +384,9 @@ evas_hash_modify(Evas_Hash *hash, const char *key, const void *data)
 EAPI int
 evas_hash_size(const Evas_Hash *hash)
 {
-   if (!hash) return 0;
+   if (!hash)
+      return 0;
+
    return 256;
 }
 
@@ -391,20 +419,22 @@ evas_hash_free(Evas_Hash *hash)
 {
    int i, size;
 
-   if (!hash) return;
+   if (!hash)
+      return;
+
    size = evas_hash_size(hash);
    for (i = 0; i < size; i++)
      {
-       while (hash->buckets[i])
-         {
-            Evas_Hash_El *el;
-
-            el = (Evas_Hash_El *)hash->buckets[i];
-            hash->buckets[i] = evas_object_list_remove(hash->buckets[i], el);
-            free(el);
-         }
+        while (hash->buckets[i])
+          {
+             Evas_Hash_El *el;
+
+             el = (Evas_Hash_El *)hash->buckets[i];
+             hash->buckets[i] = evas_object_list_remove(hash->buckets[i], el);
+                          free(el);
+          }
      }
-   free(hash);
+                          free(hash);
 }
 
 /**
@@ -441,25 +471,33 @@ evas_hash_free(Evas_Hash *hash)
  * @ingroup Evas_Hash_General_Group
  */
 EAPI void
-evas_hash_foreach(const Evas_Hash *hash, Evas_Bool (*func) (const Evas_Hash *hash, const char *key, void *data, void *fdata), const void *fdata)
+evas_hash_foreach(const Evas_Hash *hash, Evas_Bool (*func)(
+                     const Evas_Hash *hash,
+                     const char *key,
+                     void *data,
+                     void *fdata), const void *fdata)
 {
    int i, size;
 
-   if (!hash) return;
+   if (!hash)
+      return;
+
    size = evas_hash_size(hash);
    for (i = 0; i < size; i++)
      {
-       Evas_Object_List *l, *next_l;
+        Evas_Object_List *l, *next_l;
+
+        for (l = hash->buckets[i]; l; )
+          {
+             Evas_Hash_El *el;
 
-       for (l = hash->buckets[i]; l;)
-         {
-            Evas_Hash_El *el;
+             next_l = l->next;
+             el = (Evas_Hash_El *)l;
+             if (!func(hash, el->key, el->data, (void *)fdata))
+                return;
 
-            next_l = l->next;
-            el = (Evas_Hash_El *)l;
-            if (!func(hash, el->key, el->data, (void *)fdata)) return;
-            l = next_l;
-         }
+             l = next_l;
+          }
      }
 }
 
index 926a495..d1ab651 100644 (file)
@@ -1,7 +1,3 @@
-/*
- * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
- */
-
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
@@ -16,7 +12,7 @@ typedef struct _Evas_List_Accounting Evas_List_Accounting;
 struct _Evas_List_Accounting
 {
    Evas_List *last;
-   int        count;
+   int count;
 };
 
 static int _evas_list_alloc_error = 0;
@@ -75,25 +71,29 @@ evas_list_append(Evas_List *list, const void *data)
    new_l = evas_mempool_malloc(&_evas_list_mempool, sizeof(Evas_List));
    if (!new_l)
      {
-       _evas_list_alloc_error = 1;
-       return list;
+        _evas_list_alloc_error = 1;
+        return list;
      }
+
    new_l->next = NULL;
    new_l->data = (void *)data;
    if (!list)
      {
-       new_l->prev = NULL;
-       new_l->accounting = evas_mempool_malloc(&_evas_list_accounting_mempool, sizeof(Evas_List_Accounting));
-       if (!new_l->accounting)
-         {
-            _evas_list_alloc_error = 1;
-            evas_mempool_free(&_evas_list_mempool, new_l);
-            return list;
-         }
-       new_l->accounting->last = new_l;
-       new_l->accounting->count = 1;
-       return new_l;
+        new_l->prev = NULL;
+        new_l->accounting = evas_mempool_malloc(&_evas_list_accounting_mempool,
+                                                sizeof(Evas_List_Accounting));
+        if (!new_l->accounting)
+          {
+             _evas_list_alloc_error = 1;
+             evas_mempool_free(&_evas_list_mempool, new_l);
+             return list;
+          }
+
+        new_l->accounting->last = new_l;
+        new_l->accounting->count = 1;
+        return new_l;
      }
+
    l = list->accounting->last;
    l->next = new_l;
    new_l->prev = l;
@@ -138,25 +138,29 @@ evas_list_prepend(Evas_List *list, const void *data)
    new_l = evas_mempool_malloc(&_evas_list_mempool, sizeof(Evas_List));
    if (!new_l)
      {
-       _evas_list_alloc_error = 1;
-       return list;
+        _evas_list_alloc_error = 1;
+        return list;
      }
+
    new_l->prev = NULL;
    new_l->data = (void *)data;
    if (!list)
      {
-       new_l->next = NULL;
-       new_l->accounting = evas_mempool_malloc(&_evas_list_accounting_mempool, sizeof(Evas_List_Accounting));
-       if (!new_l->accounting)
-         {
-            _evas_list_alloc_error = 1;
-            evas_mempool_free(&_evas_list_mempool, new_l);
-            return list;
-         }
-       new_l->accounting->last = new_l;
-       new_l->accounting->count = 1;
-       return new_l;
+        new_l->next = NULL;
+        new_l->accounting = evas_mempool_malloc(&_evas_list_accounting_mempool,
+                                                sizeof(Evas_List_Accounting));
+        if (!new_l->accounting)
+          {
+             _evas_list_alloc_error = 1;
+             evas_mempool_free(&_evas_list_mempool, new_l);
+             return list;
+          }
+
+        new_l->accounting->last = new_l;
+        new_l->accounting->count = 1;
+        return new_l;
      }
+
    new_l->next = list;
    list->prev = new_l;
    new_l->accounting = list->accounting;
@@ -202,46 +206,54 @@ evas_list_prepend(Evas_List *list, const void *data)
  * @ingroup Evas_List_Data_Group
  */
 EAPI Evas_List *
-evas_list_append_relative(Evas_List *list, const void *data, const void *relative)
+evas_list_append_relative(Evas_List *list,
+                          const void *data,
+                          const void *relative)
 {
    Evas_List *l;
 
    for (l = list; l; l = l->next)
      {
-       if (l->data == relative)
-         return evas_list_append_relative_list(list, data, l);
+        if (l->data == relative)
+           return evas_list_append_relative_list(list, data, l);
      }
    return evas_list_append(list, data);
 }
 
 EAPI Evas_List *
-evas_list_append_relative_list(Evas_List *list, const void *data, Evas_List *relative)
+evas_list_append_relative_list(Evas_List *list,
+                               const void *data,
+                               Evas_List *relative)
 {
    Evas_List *new_l;
 
-   if ((!list) || (!relative)) return evas_list_append(list, data);
+   if ((!list) || (!relative))
+      return evas_list_append(list, data);
+
    _evas_list_alloc_error = 0;
    new_l = evas_mempool_malloc(&_evas_list_mempool, sizeof(Evas_List));
    if (!new_l)
      {
-       _evas_list_alloc_error = 1;
-       return list;
+        _evas_list_alloc_error = 1;
+        return list;
      }
+
    new_l->data = (void *)data;
    if (relative->next)
      {
-       new_l->next = relative->next;
-       relative->next->prev = new_l;
+        new_l->next = relative->next;
+        relative->next->prev = new_l;
      }
    else
-     new_l->next = NULL;
+      new_l->next = NULL;
 
    relative->next = new_l;
    new_l->prev = relative;
    new_l->accounting = list->accounting;
    list->accounting->count++;
    if (!new_l->next)
-     new_l->accounting->last = new_l;
+      new_l->accounting->last = new_l;
+
    return list;
 }
 
@@ -290,41 +302,51 @@ evas_list_append_relative_list(Evas_List *list, const void *data, Evas_List *rel
  * @ingroup Evas_List_Data_Group
  */
 EAPI Evas_List *
-evas_list_prepend_relative(Evas_List *list, const void *data, const void *relative)
+evas_list_prepend_relative(Evas_List *list,
+                           const void *data,
+                           const void *relative)
 {
    Evas_List *l;
 
    _evas_list_alloc_error = 0;
    for (l = list; l; l = l->next)
      {
-       if (l->data == relative)
-         return evas_list_prepend_relative_list(list, data, l);
+        if (l->data == relative)
+           return evas_list_prepend_relative_list(list, data, l);
      }
    return evas_list_prepend(list, data);
 }
 
 EAPI Evas_List *
-evas_list_prepend_relative_list(Evas_List *list, const void *data, Evas_List *relative)
+evas_list_prepend_relative_list(Evas_List *list,
+                                const void *data,
+                                Evas_List *relative)
 {
    Evas_List *new_l;
 
-   if ((!list) || (!relative)) return evas_list_prepend(list, data);
+   if ((!list) || (!relative))
+      return evas_list_prepend(list, data);
+
    _evas_list_alloc_error = 0;
    new_l = evas_mempool_malloc(&_evas_list_mempool, sizeof(Evas_List));
    if (!new_l)
      {
-       _evas_list_alloc_error = 1;
-       return list;
+        _evas_list_alloc_error = 1;
+        return list;
      }
+
    new_l->data = (void *)data;
    new_l->prev = relative->prev;
    new_l->next = relative;
-   if (relative->prev) relative->prev->next = new_l;
+   if (relative->prev)
+      relative->prev->next = new_l;
+
    relative->prev = new_l;
    new_l->accounting = list->accounting;
    list->accounting->count++;
    if (new_l->prev)
-     return list;
+      return list;
+
    return new_l;
 }
 
@@ -352,8 +374,8 @@ evas_list_remove(Evas_List *list, const void *data)
 
    for (l = list; l; l = l->next)
      {
-       if (l->data == data)
-         return evas_list_remove_list(list, l);
+        if (l->data == data)
+           return evas_list_remove_list(list, l);
      }
    return list;
 }
@@ -391,22 +413,31 @@ evas_list_remove_list(Evas_List *list, Evas_List *remove_list)
 {
    Evas_List *return_l;
 
-   if (!list) return NULL;
-   if (!remove_list) return list;
-   if (remove_list->next) remove_list->next->prev = remove_list->prev;
+   if (!list)
+      return NULL;
+
+   if (!remove_list)
+      return list;
+
+   if (remove_list->next)
+      remove_list->next->prev = remove_list->prev;
+
    if (remove_list->prev)
      {
-       remove_list->prev->next = remove_list->next;
-       return_l = list;
+        remove_list->prev->next = remove_list->next;
+        return_l = list;
      }
    else
-     return_l = remove_list->next;
+      return_l = remove_list->next;
+
    if (remove_list == list->accounting->last)
-     list->accounting->last = remove_list->prev;
+      list->accounting->last = remove_list->prev;
+
    list->accounting->count--;
    if (list->accounting->count == 0)
-     evas_mempool_free(&_evas_list_accounting_mempool, list->accounting);
-   evas_mempool_free(&_evas_list_mempool, remove_list);
+             evas_mempool_free(&_evas_list_accounting_mempool, list->accounting);
+
+             evas_mempool_free(&_evas_list_mempool,            remove_list);
    return return_l;
 }
 
@@ -443,22 +474,33 @@ evas_list_promote_list(Evas_List *list, Evas_List *move_list)
 {
    Evas_List *return_l;
 
-   if (!list) return NULL;
-   if (!move_list) return list;
-   if (move_list == list) return list;
-   if (move_list->next) move_list->next->prev = move_list->prev;
+   if (!list)
+      return NULL;
+
+   if (!move_list)
+      return list;
+
+   if (move_list == list)
+      return list;
+
+   if (move_list->next)
+      move_list->next->prev = move_list->prev;
+
    if (move_list->prev)
      {
-       move_list->prev->next = move_list->next;
-       return_l = list;
+        move_list->prev->next = move_list->next;
+        return_l = list;
      }
    else
-     return_l = move_list->next;
+      return_l = move_list->next;
+
    if (move_list == list->accounting->last)
-     list->accounting->last = move_list->prev;
+      list->accounting->last = move_list->prev;
+
    move_list->prev = return_l->prev;
    if (return_l->prev)
-     return_l->prev->next = move_list;
+      return_l->prev->next = move_list;
+
    return_l->prev = move_list;
    move_list->next = return_l;
    return move_list;
@@ -501,7 +543,8 @@ evas_list_find(const Evas_List *list, const void *data)
 
    for (l = list; l; l = l->next)
      {
-       if (l->data == data) return (void *)data;
+        if (l->data == data)
+           return (void *)data;
      }
    return NULL;
 }
@@ -538,7 +581,8 @@ evas_list_find_list(const Evas_List *list, const void *data)
 
    for (l = list; l; l = l->next)
      {
-       if (l->data == data) return (Evas_List *)l;
+        if (l->data == data)
+           return (Evas_List *)l;
      }
    return NULL;
 }
@@ -563,13 +607,15 @@ evas_list_free(Evas_List *list)
 {
    Evas_List *l, *free_l;
 
-   if (!list) return NULL;
-   evas_mempool_free(&_evas_list_accounting_mempool, list->accounting);
-   for (l = list; l;)
+   if (!list)
+      return NULL;
+
+             evas_mempool_free(&_evas_list_accounting_mempool, list->accounting);
+   for (l = list; l; )
      {
-       free_l = l;
-       l = l->next;
-       evas_mempool_free(&_evas_list_mempool, free_l);
+        free_l = l;
+        l = l->next;
+             evas_mempool_free(&_evas_list_mempool, free_l);
      }
    return NULL;
 }
@@ -608,7 +654,9 @@ evas_list_free(Evas_List *list)
 EAPI Evas_List *
 evas_list_last(const Evas_List *list)
 {
-   if (!list) return NULL;
+   if (!list)
+      return NULL;
+
    return list->accounting->last;
 }
 
@@ -636,7 +684,9 @@ evas_list_last(const Evas_List *list)
 EAPI Evas_List *
 evas_list_next(const Evas_List *list)
 {
-   if (!list) return NULL;
+   if (!list)
+      return NULL;
+
    return list->next;
 }
 
@@ -665,7 +715,9 @@ evas_list_next(const Evas_List *list)
 EAPI Evas_List *
 evas_list_prev(const Evas_List *list)
 {
-   if (!list) return NULL;
+   if (!list)
+      return NULL;
+
    return list->prev;
 }
 
@@ -699,7 +751,9 @@ evas_list_prev(const Evas_List *list)
 EAPI void *
 evas_list_data(const Evas_List *list)
 {
-   if (!list) return NULL;
+   if (!list)
+      return NULL;
+
    return list->data;
 }
 
@@ -725,7 +779,9 @@ evas_list_data(const Evas_List *list)
 EAPI int
 evas_list_count(const Evas_List *list)
 {
-   if (!list) return 0;
+   if (!list)
+      return 0;
+
    return list->accounting->count;
 }
 
@@ -791,28 +847,27 @@ evas_list_nth_list(const Evas_List *list, int n)
    /* check for non-existing nodes */
    if ((!list) || (n < 0) ||
        (n > (list->accounting->count - 1)))
-     return NULL;
+      return NULL;
 
    /* if the node is in the 2nd half of the list, search from the end
     * else, search from the beginning.
     */
    if (n > (list->accounting->count / 2))
-     {
-       for (i = list->accounting->count - 1,
-            l = list->accounting->last;
-            l;
-            l = l->prev, i--)
-         {
-            if (i == n) return (Evas_List *)l;
-         }
-     }
+      for (i = list->accounting->count - 1,
+           l = list->accounting->last;
+           l;
+           l = l->prev, i--)
+        {
+           if (i == n)
+              return (Evas_List *)l;
+        }
    else
-     {
-       for (i = 0, l = list; l; l = l->next, i++)
-         {
-            if (i == n) return (Evas_List *)l;
-         }
-     }
+      for (i = 0, l = list; l; l = l->next, i++)
+        {
+           if (i == n)
+              return (Evas_List *)l;
+        }
+
    return NULL;
 }
 
@@ -843,19 +898,23 @@ evas_list_reverse(Evas_List *list)
 {
    Evas_List *l1, *l2;
 
-   if (!list) return NULL;
+   if (!list)
+      return NULL;
+
    l1 = list;
    l2 = list->accounting->last;
    while (l1 != l2)
      {
-       void *data;
-
-       data = l1->data;
-       l1->data = l2->data;
-       l2->data = data;
-       l1 = l1->next;
-       if (l1 == l2) break;
-       l2 = l2->prev;
+        void *data;
+
+        data = l1->data;
+        l1->data = l2->data;
+        l2->data = data;
+        l1 = l1->next;
+        if (l1 == l2)
+           break;
+
+        l2 = l2->prev;
      }
 
    return list;
@@ -900,100 +959,103 @@ evas_list_reverse(Evas_List *list)
 EAPI Evas_List *
 evas_list_sort(Evas_List *list, int size, int (*func)(void *, void *))
 {
-   Evas_List*   last;
-   unsigned int        list_number;
-   unsigned int        middle;
-   int         list_size;
+   Evas_List *last;
+   unsigned int list_number;
+   unsigned int middle;
+   int list_size;
 
    if (!list || !func)
-     return NULL;
+      return NULL;
 
    /* if the caller specified an invalid size, sort the whole list */
    if ((size <= 0) ||
        (size > list->accounting->count))
-     size = list->accounting->count;
+      size = list->accounting->count;
 
    last = list->accounting->last;
    middle = size - size / 2;
 
    for (list_number = middle, list_size = 1;
-       list_size < middle * 2;
-       list_number >>= 1, list_size <<= 1)
+        list_size < middle * 2;
+        list_number >>= 1, list_size <<= 1)
      {
-       Evas_List       *head1 = list;
-       unsigned int    limit = size;
-       unsigned int    process_list;
-       unsigned int    pass_number;
-       unsigned int    split_size = list_size;
-
-       for (process_list = 0; process_list < list_number + 1; ++process_list)
-         {
-            Evas_List          *head2;
-            unsigned int       size_sum;
-            int                size1, size2;
-            int                i;
-
-            size1 = limit < split_size ? limit : split_size;
-            limit -= size1;
-
-            size2 = limit < split_size ? limit : split_size;
-            limit -= size2;
-
-            size_sum = size1 + size2;
-
-            for (head2 = head1, i = 0; i < size1; ++i)
-              head2 = evas_list_next (head2);
-
-            for (pass_number = 0; pass_number < size_sum; ++pass_number)
-              {
-                 Evas_List     *next;
-                 Evas_List     *prev1;
-                 Evas_List     *prev2;
-
-                 if (size1 == 0 || head1 == NULL) /* List1 is empty, head1 is already at the end of the list. So only need to update head2 */
-                   {
-                      for (; pass_number < size_sum; ++pass_number)
-                        head2 = evas_list_next (head2);
-                      break;
-                   }
-                 else
-                   if (size2 == 0 || head2 == NULL) /* List2 is empty, just leave */
-                     break;
-                   else
-                     if (func (head1->data, head2->data) < 0)
-                       {
-                          head1 = evas_list_next (head1);
-                          --size1;
-                       }
-                     else
-                       {
-                          next = evas_list_next (head2);
-                          prev1 = evas_list_prev (head1);
-                          prev2 = evas_list_prev (head2);
-
-                          if (next)
-                            next->prev = prev2;
-                          if (prev1)
-                            prev1->next = head2;
-                          if (prev2)
-                            prev2->next = next;
-
-                          head2->prev = prev1;
-                          head2->next = head1;
-                          head1->prev = head2;
-
-                          --size2;
-
-                           if (head1 == list)
-                             list = head2;
-                           if (head2 == last)
-                             last = prev2;
-
-                          head2 = next;
-                       }
-              }
-            head1 = head2;
-         }
+        Evas_List *head1 = list;
+        unsigned int limit = size;
+        unsigned int process_list;
+        unsigned int pass_number;
+        unsigned int split_size = list_size;
+
+        for (process_list = 0; process_list < list_number + 1; ++process_list)
+          {
+             Evas_List *head2;
+             unsigned int size_sum;
+             int size1, size2;
+             int i;
+
+             size1 = limit < split_size ? limit : split_size;
+             limit -= size1;
+
+             size2 = limit < split_size ? limit : split_size;
+             limit -= size2;
+
+             size_sum = size1 + size2;
+
+             for (head2 = head1, i = 0; i < size1; ++i)
+                head2 = evas_list_next (head2);
+
+             for (pass_number = 0; pass_number < size_sum; ++pass_number)
+               {
+                  Evas_List *next;
+                  Evas_List *prev1;
+                  Evas_List *prev2;
+
+                  if (size1 == 0 || head1 == NULL) /* List1 is empty, head1 is already at the end of the list. So only need to update head2 */
+                    {
+                       for (; pass_number < size_sum; ++pass_number)
+                          head2 = evas_list_next (head2);
+                       break;
+                    }
+                  else
+                  if (size2 == 0 || head2 == NULL) /* List2 is empty, just leave */
+                     break;
+                  else
+                  if (func (head1->data, head2->data) < 0)
+                    {
+                       head1 = evas_list_next (head1);
+                       --size1;
+                    }
+                  else
+                    {
+                       next = evas_list_next (head2);
+                       prev1 = evas_list_prev (head1);
+                       prev2 = evas_list_prev (head2);
+
+                       if (next)
+                          next->prev = prev2;
+
+                       if (prev1)
+                          prev1->next = head2;
+
+                       if (prev2)
+                          prev2->next = next;
+
+                       head2->prev = prev1;
+                       head2->next = head1;
+                       head1->prev = head2;
+
+                       --size2;
+
+                       if (head1 == list)
+                          list = head2;
+
+                       if (head2 == last)
+                          last = prev2;
+
+                       head2 = next;
+                    }
+               }
+             head1 = head2;
+          }
      }
 
    list->accounting->last = last;
index 6bbf390..fbc48fa 100644 (file)
@@ -1,7 +1,3 @@
-/*
- * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
- */
-
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
@@ -18,7 +14,7 @@ typedef struct _Pool Pool;
 
 struct _Pool
 {
-   int   usage;
+   int usage;
    void *base;
    Pool *prev, *next;
 };
@@ -26,163 +22,179 @@ struct _Pool
 
 Pool *
 _evas_mp_pool_new(Evas_Mempool *pool)
-#ifdef NOPOOL
 {
+#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 *);
+   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 = (void **)(((unsigned char *)ptr) + item_alloc);
+        ptr = *ptr;
      }
    *ptr = NULL;
    return p;
-}
 #endif
+}
 
 void
 _evas_mp_pool_free(Pool *p)
-#ifdef NOPOOL
-{
-}
-#else
 {
+#if !defined(NOPOOL)
    free(p);
-}
 #endif
+}
 
 void *
 evas_mempool_malloc(Evas_Mempool *pool, int size)
-#ifdef NOPOOL
 {
+#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->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;
+        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;
-         }
-     }
+      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
 {
+#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 *);
+   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;
-         }
+        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
 {
+#ifdef NOPOOL
    return calloc(1, size);
-}
 #else
-{
    void *mem;
 
    mem = evas_mempool_malloc(pool, size);
    memset(mem, 0, size);
    return mem;
-}
 #endif
+}
+
index b1d5283..983c434 100644 (file)
@@ -1,7 +1,3 @@
-/*
- * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
- */
-
 #ifndef _EVAS_MEMPOOL_H
 #define _EVAS_MEMPOOL_H
 
@@ -10,10 +6,10 @@ typedef struct _Evas_Mempool Evas_Mempool;
 
 struct _Evas_Mempool
 {
-   int           item_size;
-   int           pool_size;
-   int           usage;
-   void         *first, *last;
+   int item_size;
+   int pool_size;
+   int usage;
+   void *first, *last;
 };
 
 
index d77687c..8ba4267 100644 (file)
@@ -1,7 +1,3 @@
-/*
- * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
- */
-
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
@@ -22,12 +18,16 @@ evas_object_list_append(void *in_list, void *in_item)
    new_l->next = NULL;
    if (!list)
      {
-       new_l->prev = NULL;
-       new_l->last = new_l;
-       return new_l;
+        new_l->prev = NULL;
+        new_l->last = new_l;
+        return new_l;
      }
-   if (list->last) l = list->last;
-   else for (l = list; (l) && (l->next); l = l->next);
+
+   if (list->last)
+      l = list->last;
+   else
+      for (l = list; (l) && (l->next); l = l->next) ;
+
    l->next = new_l;
    new_l->prev = l;
    list->last = new_l;
@@ -45,10 +45,11 @@ evas_object_list_prepend(void *in_list, void *in_item)
    new_l->prev = NULL;
    if (!list)
      {
-       new_l->next = NULL;
-       new_l->last = new_l;
-       return new_l;
+        new_l->next = NULL;
+        new_l->last = new_l;
+        return new_l;
      }
+
    new_l->next = list;
    list->prev = new_l;
    new_l->last = list->last;
@@ -57,7 +58,9 @@ evas_object_list_prepend(void *in_list, void *in_item)
 }
 
 void *
-evas_object_list_append_relative(void *in_list, void *in_item, void *in_relative)
+evas_object_list_append_relative(void *in_list,
+                                 void *in_item,
+                                 void *in_relative)
 {
    Evas_Object_List *list, *relative, *new_l;
 
@@ -66,22 +69,29 @@ evas_object_list_append_relative(void *in_list, void *in_item, void *in_relative
    relative = in_relative;
    if (relative)
      {
-       if (relative->next)
-         {
-            new_l->next = relative->next;
-            relative->next->prev = new_l;
-         }
-       else new_l->next = NULL;
-       relative->next = new_l;
-       new_l->prev = relative;
-       if (!new_l->next) list->last = new_l;
-       return list;
+        if (relative->next)
+          {
+             new_l->next = relative->next;
+             relative->next->prev = new_l;
+          }
+        else
+           new_l->next = NULL;
+
+        relative->next = new_l;
+        new_l->prev = relative;
+        if (!new_l->next)
+           list->last = new_l;
+
+        return list;
      }
+
    return evas_object_list_append(list, new_l);
 }
 
 void *
-evas_object_list_prepend_relative(void *in_list, void *in_item, void *in_relative)
+evas_object_list_prepend_relative(void *in_list,
+                                  void *in_item,
+                                  void *in_relative)
 {
    Evas_Object_List *list, *relative, *new_l;
 
@@ -90,28 +100,31 @@ evas_object_list_prepend_relative(void *in_list, void *in_item, void *in_relativ
    relative = in_relative;
    if (relative)
      {
-       new_l->prev = relative->prev;
-       new_l->next = relative;
-       relative->prev = new_l;
-       if (new_l->prev)
-         {
-            new_l->prev->next = new_l;
-            if (!new_l->next)
-              list->last = new_l;
-            return list;
-         }
-       else
-         {
-            if (!new_l->next)
-              new_l->last = new_l;
-            else
-              {
-                 new_l->last = list->last;
-                 list->last = NULL;
-              }
-            return new_l;
-         }
+        new_l->prev = relative->prev;
+        new_l->next = relative;
+        relative->prev = new_l;
+        if (new_l->prev)
+          {
+             new_l->prev->next = new_l;
+             if (!new_l->next)
+                list->last = new_l;
+
+             return list;
+          }
+        else
+          {
+             if (!new_l->next)
+                new_l->last = new_l;
+             else
+               {
+                  new_l->last = list->last;
+                  list->last = NULL;
+               }
+
+             return new_l;
+          }
      }
+
    return evas_object_list_prepend(list, new_l);
 }
 
@@ -123,26 +136,31 @@ evas_object_list_remove(void *in_list, void *in_item)
 
    /* checkme */
    if(!in_list)
-     return in_list;
+      return in_list;
 
    list = in_list;
    item = in_item;
-   if (!item) return list;
+   if (!item)
+      return list;
+
    if (item->next)
-     item->next->prev = item->prev;
+      item->next->prev = item->prev;
+
    if (item->prev)
      {
-       item->prev->next = item->next;
-       return_l = list;
+        item->prev->next = item->next;
+        return_l = list;
      }
    else
      {
-       return_l = item->next;
-       if (return_l)
-         return_l->last = list->last;
+        return_l = item->next;
+        if (return_l)
+           return_l->last = list->last;
      }
+
    if (item == list->last)
-     list->last = item->prev;
+      list->last = item->prev;
+
    item->next = NULL;
    item->prev = NULL;
    return return_l;
@@ -158,7 +176,8 @@ evas_object_list_find(void *in_list, void *in_item)
    item = in_item;
    for (l = list; l; l = l->next)
      {
-       if (l == item) return item;
+        if (l == item)
+           return item;
      }
    return NULL;
 }
index b05dcdf..6e8797c 100644 (file)
@@ -1,7 +1,3 @@
-/*
- * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
- */
-
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
@@ -13,8 +9,8 @@
 
 #include "Evas_Data.h"
 
-typedef struct _Evas_Stringshare             Evas_Stringshare;
-typedef struct _Evas_Stringshare_El          Evas_Stringshare_El;
+typedef struct _Evas_Stringshare Evas_Stringshare;
+typedef struct _Evas_Stringshare_El Evas_Stringshare_El;
 
 struct _Evas_Stringshare
 {
@@ -25,80 +21,144 @@ struct _Evas_Stringshare_El
 {
    Evas_Stringshare_El *next;
 //   int op;
-   int                  references;
+   int references;
 };
 
 static Evas_Stringshare share =
 {
-     {
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-         
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-         
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
-     }
+   {
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+      NULL, NULL, NULL, NULL
+   }
 };
 
 //static int op = 0;
@@ -112,7 +172,7 @@ _evas_stringshare_hash_gen(const char *str, int *len)
 
    for (ptr = (const unsigned char *)str; *ptr; ptr++)
      {
-       hash_num = (hash_num * 33) ^ *ptr;
+        hash_num = (hash_num * 33) ^ *ptr;
      }
 
    hash_num &= 0x3ff;
@@ -127,8 +187,12 @@ evas_stringshare_add(const char *str)
    char *el_str;
    Evas_Stringshare_El *el, *pel = NULL;
 
-   if (!str) return NULL;
-//   if (!f)
+   if (!str)
+     {
+        return NULL; //   if (!f)
+
+     }
+
 //     {
 //     char bf[256];
 //     snprintf(bf, sizeof(bf), "strlog-%i", getpid());
@@ -137,22 +201,25 @@ evas_stringshare_add(const char *str)
    hash_num = _evas_stringshare_hash_gen(str, &slen);
    for (el = share.buckets[hash_num]; el; pel = el, el = el->next)
      {
-       el_str = ((char *)el) + sizeof(Evas_Stringshare_El);
-       if (!strcmp(el_str, str))
-         {
-            if (pel)
-              {
-                 pel->next = el->next;
-                 el->next = share.buckets[hash_num];
-                 share.buckets[hash_num] = el;
-              }
-            el->references++;
+        el_str = ((char *)el) + sizeof(Evas_Stringshare_El);
+        if (!strcmp(el_str, str))
+          {
+             if (pel)
+               {
+                  pel->next = el->next;
+                  el->next = share.buckets[hash_num];
+                  share.buckets[hash_num] = el;
+               }
+
+             el->references++;
 //          fprintf(f, "strings[%i] = str->add(strings[%i]);\n", el->op, el->op);
 //          fflush(f);
-            return el_str;
-         }
+             return el_str;
+          }
      }
-   if (!(el = malloc(sizeof(Evas_Stringshare_El) + slen + 1))) return NULL;
+   if (!(el = malloc(sizeof(Evas_Stringshare_El) + slen + 1)))
+      return NULL;
+
    el_str = ((char *)el) + sizeof(Evas_Stringshare_El);
    strcpy(el_str, str);
    el->references = 1;
@@ -172,33 +239,36 @@ evas_stringshare_del(const char *str)
    char *el_str;
    Evas_Stringshare_El *el, *pel = NULL;
 
-   if (!str) return;
+   if (!str)
+      return;
+
    hash_num = _evas_stringshare_hash_gen(str, &slen);
    for (el = share.buckets[hash_num]; el; pel = el, el = el->next)
      {
-       el_str = ((char *)el) + sizeof(Evas_Stringshare_El);
-       if (el_str == str)
-         {
-            el->references--;
+        el_str = ((char *)el) + sizeof(Evas_Stringshare_El);
+        if (el_str == str)
+          {
+             el->references--;
 //          fprintf(f, "str->del(strings[%i]);\n", el->op);
 //          fflush(f);
-            if (el->references == 0)
-              {
-                 if (pel) pel->next = el->next;
-                 else share.buckets[hash_num] = el->next;
-                 free(el);
-              }
-            else
-              {
-                 if (pel)
-                   {
-                      pel->next = el->next;
-                      el->next = share.buckets[hash_num];
-                      share.buckets[hash_num] = el;
-                   }
-              }
-            return;
-         }
+             if (el->references == 0)
+               {
+                  if (pel)
+                     pel->next = el->next;
+                  else
+                     share.buckets[hash_num] = el->next;
+
+                  free(el);
+               }
+             else if (pel)
+               {
+                  pel->next = el->next;
+                  el->next = share.buckets[hash_num];
+                  share.buckets[hash_num] = el;
+               }
+
+             return;
+          }
      }
    printf("EEEK trying to del non-shared stringshare \"%s\"\n", str);
    abort();