Enlightenment CVS committal

Author  : cedric
Project : e17
Module  : proto/eina

Dir     : e17/proto/eina/src/lib


Modified Files:
        eina_lalloc.c 


Log Message:
Cover lazy allocator at 100%. Add error checking capability.


===================================================================
RCS file: /cvs/e/e17/proto/eina/src/lib/eina_lalloc.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- eina_lalloc.c       30 Jul 2008 16:34:54 -0000      1.3
+++ eina_lalloc.c       4 Aug 2008 16:50:03 -0000       1.4
@@ -35,43 +35,64 @@
  * To be documented
  * FIXME: To be fixed
  */
-EAPI void eina_lalloc_element_add(Eina_Lalloc *a)
+EAPI Eina_Bool eina_lalloc_element_add(Eina_Lalloc *a)
 {
        if (a->num_elements == a->num_allocated)
        {
-               a->num_allocated = (1 << a->acc);
-               a->acc++;
-               a->alloc_cb(a->data, 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;
 }
 
 /**
  * To be documented
  * FIXME: To be fixed
  */
-EAPI void eina_lalloc_elements_add(Eina_Lalloc *a, int num)
+EAPI Eina_Bool eina_lalloc_elements_add(Eina_Lalloc *a, int num)
 {
        int tmp;
-       
+
        tmp = a->num_elements + num;
        if (tmp > a->num_allocated)
        {
-               while (tmp > a->num_allocated)
+               int allocated;
+               int acc;
+
+               allocated = a->num_allocated;
+               acc = a->acc;
+
+               while (tmp > allocated)
                {
-                       a->num_allocated = (1 << a->acc);
-                       a->acc++;
+                       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->alloc_cb(a->data, a->num_allocated);
        }
        a->num_elements += num;
+
+       return EINA_TRUE;
 }
 
 /**
  * To be documented
  * FIXME: To be fixed
  */
-EAPI void eina_lalloc_free(Eina_Lalloc *a)
+EAPI void eina_lalloc_delete(Eina_Lalloc *a)
 {
        a->free_cb(a->data);
        free(a);



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to