Enlightenment CVS committal

Author  : raster
Project : e17
Module  : libs/eet

Dir     : e17/libs/eet/src/lib


Modified Files:
        eet_data.c 


Log Message:


now make eet REALLY not leak if a parse error occurs in decoding serialized
data struct.

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/eet/src/lib/eet_data.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- eet_data.c  7 Jul 2003 07:52:20 -0000       1.10
+++ eet_data.c  7 Jul 2003 22:36:37 -0000       1.11
@@ -1518,6 +1518,7 @@
    return val;
 }
 
+static int    freelist_ref = 0;
 static int    freelist_len = 0;
 static int    freelist_num = 0;
 static void **freelist = NULL;
@@ -1537,6 +1538,7 @@
 static void
 _eet_freelist_reset(void)
 {
+   if (freelist_ref > 0) return;
    freelist_len = 0;
    freelist_num = 0;
    if (freelist) free(freelist);
@@ -1547,12 +1549,26 @@
 _eet_freelist_free(void)
 {
    int i;
-   
+
+   if (freelist_ref > 0) return;
    for (i = 0; i < freelist_num; i++)
      free(freelist[i]);
    _eet_freelist_reset();
 }
 
+static void
+_eet_freelist_ref(void)
+{
+   freelist_ref++;
+}
+
+static void
+_eet_freelist_unref(void)
+{
+   freelist_ref--;
+}
+
+static int     freelist_list_ref = 0;
 static int     freelist_list_len = 0;
 static int     freelist_list_num = 0;
 static void ***freelist_list = NULL;
@@ -1578,6 +1594,7 @@
 static void
 _eet_freelist_list_reset(void)
 {
+   if (freelist_list_ref > 0) return;
    freelist_list_len = 0;
    freelist_list_num = 0;
    if (freelist_list) free(freelist_list);
@@ -1589,11 +1606,25 @@
 {
    int i;
    
+   if (freelist_list_ref > 0) return;
    for (i = 0; i < freelist_list_num; i++)
      edd->func.list_free(*(freelist_list[i]));
    _eet_freelist_list_reset();
 }
 
+static void
+_eet_freelist_list_ref(void)
+{
+   freelist_list_ref++;
+}
+
+static void
+_eet_freelist_list_unref(void)
+{
+   freelist_list_ref--;
+}
+
+
 void *
 eet_data_descriptor_decode(Eet_Data_Descriptor *edd,
                           void *data_in,
@@ -1615,10 +1646,14 @@
    
    data = calloc(1, edd->size);
    if (!data) return NULL;
+   _eet_freelist_ref();
+   _eet_freelist_list_ref();
    _eet_freelist_add(data);
    chnk = eet_data_chunk_get(data_in, size_in);
    if (!chnk)
      {
+       _eet_freelist_unref();
+       _eet_freelist_list_unref();
        _eet_freelist_free();
        _eet_freelist_list_free(edd);
        return NULL;
@@ -1626,6 +1661,8 @@
    if (strcmp(chnk->name, edd->name))
      {
        eet_data_chunk_free(chnk);
+       _eet_freelist_unref();
+       _eet_freelist_list_unref();
        _eet_freelist_free();
        _eet_freelist_list_free(edd);
        return NULL;
@@ -1641,6 +1678,8 @@
        echnk = eet_data_chunk_get(p, size);
        if (!echnk)
          {
+            _eet_freelist_unref();
+            _eet_freelist_list_unref();
             _eet_freelist_free();
             _eet_freelist_list_free(edd);
             eet_data_chunk_free(chnk);
@@ -1675,6 +1714,8 @@
                                                                  echnk->size);
                            if (!data_ret)
                              {
+                                _eet_freelist_unref();
+                                _eet_freelist_list_unref();
                                 _eet_freelist_free();
                                 _eet_freelist_list_free(edd);
                                 eet_data_chunk_free(chnk);
@@ -1717,6 +1758,8 @@
                                                                   data_ret);
                                           if (ret <= 0)
                                             {
+                                               _eet_freelist_unref();
+                                               _eet_freelist_list_unref();
                                                _eet_freelist_free();
                                                _eet_freelist_list_free(edd);
                                                eet_data_chunk_free(chnk);
@@ -1725,6 +1768,8 @@
                                        }
                                      else
                                        {
+                                          _eet_freelist_unref();
+                                          _eet_freelist_list_unref();
                                           _eet_freelist_free();
                                           _eet_freelist_list_free(edd);
                                           eet_data_chunk_free(chnk);
@@ -1745,6 +1790,8 @@
                                   }
                                 else
                                   {
+                                     _eet_freelist_unref();
+                                     _eet_freelist_list_unref();
                                      _eet_freelist_free();
                                      _eet_freelist_list_free(edd);
                                      eet_data_chunk_free(chnk);
@@ -1768,6 +1815,8 @@
        eet_data_chunk_free(echnk);
      }
    eet_data_chunk_free(chnk);
+   _eet_freelist_unref();
+   _eet_freelist_list_unref();
    _eet_freelist_reset();
    _eet_freelist_list_reset();
    return data;




-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to