On Wed, Mar 5, 2008 at 4:31 AM, The Rasterman Carsten Haitzler
<[EMAIL PROTECTED]> wrote:
> On Tue, 26 Feb 2008 13:28:14 +0100 Dave <[EMAIL PROTECTED]> babbled:
>  as this is so cool a thing, i'm putting your patch into edje code - so any 
> more
>  work for edje_edit - put it there :) we'll work in mainline. good work mate!
>  good work!

And here is a patch that will give you a chance to know if a string
has been provided by eet dictionary (in case you must never free it)
or not (in case you must). With an already nice place to use it in
edje.

-- 
Cedric BAIL
From 5dad549fba9ae36669574d9795760ac0f1205f94 Mon Sep 17 00:00:00 2001
From: Cedric BAIL <[EMAIL PROTECTED]>
Date: Thu, 6 Mar 2008 14:30:21 +0100
Subject: [PATCH] Add a way to know if a string is managed by eet or not.

---
 src/lib/Eet.h            |    1 +
 src/lib/Eet_private.h    |    3 +++
 src/lib/eet_dictionary.c |   20 ++++++++++++++++++++
 src/lib/eet_lib.c        |    5 +++++
 4 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/src/lib/Eet.h b/src/lib/Eet.h
index 42597e4..0801b26 100644
--- a/src/lib/Eet.h
+++ b/src/lib/Eet.h
@@ -224,6 +224,7 @@ extern "C" {
 
    /* FIXME: Add some documentation */
    EAPI Eet_Dictionary* eet_dictionary_get(Eet_File *ef);
+   EAPI int eet_dictionary_string_check(Eet_Dictionary *ed, const char *string);
 
    /**
     * Read a specified entry from an eet file and return data
diff --git a/src/lib/Eet_private.h b/src/lib/Eet_private.h
index b5372ed..018626c 100644
--- a/src/lib/Eet_private.h
+++ b/src/lib/Eet_private.h
@@ -88,6 +88,9 @@ struct _Eet_Dictionary
 
   int           count;
   int           total;
+
+  const char   *start;
+  const char   *end;
 };
 
 Eet_Dictionary  *eet_dictionary_add(void);
diff --git a/src/lib/eet_dictionary.c b/src/lib/eet_dictionary.c
index 2491f5b..f83f843 100644
--- a/src/lib/eet_dictionary.c
+++ b/src/lib/eet_dictionary.c
@@ -297,3 +297,23 @@ eet_dictionary_string_get_double(const Eet_Dictionary *ed, int index, double *re
      }
    return 0;
 }
+
+EAPI int
+eet_dictionary_string_check(Eet_Dictionary *ed, const char *string)
+{
+   int	i;
+
+   if (ed == NULL
+       || string == NULL)
+     return 0;
+
+   if (ed->start <= string
+       && string < ed->end)
+     return 1;
+
+   for (i = 0; i < ed->count; ++i)
+     if (ed->all[i].str == string)
+       return 1;
+
+   return 0;
+}
diff --git a/src/lib/eet_lib.c b/src/lib/eet_lib.c
index 536a70b..406f7ca 100644
--- a/src/lib/eet_lib.c
+++ b/src/lib/eet_lib.c
@@ -816,6 +816,8 @@ eet_internal_read2(Eet_File *ef)
 
         ef->ed->count = num_dictionary_entries;
 	ef->ed->total = num_dictionary_entries;
+	ef->ed->start = start + bytes_dictionary_entries + bytes_directory_entries;
+	ef->ed->end = ef->ed->start;
 
         for (j = 0; j < ef->ed->count; ++j)
           {
@@ -841,6 +843,9 @@ eet_internal_read2(Eet_File *ef)
              ef->ed->all[j].mmap = start + offset;
              ef->ed->all[j].str = NULL;
 
+	     if (ef->ed->all[j].mmap + ef->ed->all[j].len > ef->ed->end)
+	       ef->ed->end = ef->ed->all[j].mmap + ef->ed->all[j].len;
+
              /* Check '\0' at the end of the string */
              if (eet_test_close(ef->ed->all[j].mmap[ef->ed->all[j].len - 1] != '\0', ef)) return NULL;
 
-- 
1.5.4.GIT

From baa2824bc11af2f1b12c33b0ff0bb3dcac1e8811 Mon Sep 17 00:00:00 2001
From: Cedric BAIL <[EMAIL PROTECTED]>
Date: Thu, 6 Mar 2008 14:30:55 +0100
Subject: [PATCH] Use eet to know if I a string is managed by it or evas.

---
 src/lib/edje_textblock_styles.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/lib/edje_textblock_styles.c b/src/lib/edje_textblock_styles.c
index 2d2e09f..4236bd6 100644
--- a/src/lib/edje_textblock_styles.c
+++ b/src/lib/edje_textblock_styles.c
@@ -426,8 +426,8 @@ _edje_textblock_style_parse_and_fix(Edje_File *edf)
 	     /* Add and Handle tag parsed data */
 	     if (ts)
 	       {
-                  /* FIXME: How to know if the previous value was a stringshare */
-/* 		  evas_stringshare_del(tag->value); */
+		  if (eet_dictionary_string_check(eet_dictionary_get(edf->ef), tag->value) == 0)
+		    evas_stringshare_del(tag->value);
 		  tag->value = evas_stringshare_add(ts);
 		  buf = _edje_strbuf_append(buf, tag->value, &buflen, &bufalloc);
 		  free(ts);
-- 
1.5.4.GIT

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to