Enlightenment CVS committal

Author  : handyande
Project : e17
Module  : libs/ecore

Dir     : e17/libs/ecore/src/lib/ecore_config


Modified Files:
        ecore_config_util.c 


Log Message:
Mortens latest ecore_config update - fixes last breakage ;)
===================================================================
RCS file: 
/cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_config/ecore_config_util.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- ecore_config_util.c 18 Jan 2006 12:35:06 -0000      1.4
+++ ecore_config_util.c 12 Feb 2006 21:08:36 -0000      1.5
@@ -49,9 +49,9 @@
 int
 estring_appendf(estring * e, const char *fmt, ...)
 {
-   int                 need;
-   va_list             ap;
-   char               *p;
+   int      need;
+   va_list  ap;
+   char    *p;
 
    if (!e)
       return ECORE_CONFIG_ERR_FAIL;
@@ -59,35 +59,31 @@
    if (!e->str)
      {
        e->used = e->alloc = 0;
-       if (!(e->str = (char *)malloc(e->alloc = 512)))
+       if (!(e->str = (char *)malloc(e->alloc = CHUNKLEN)))
           return ECORE_CONFIG_ERR_OOM;
      }
 
- retry:
    va_start(ap, fmt);
-   need = vsnprintf(e->str + e->used, e->alloc - e->used, fmt, ap);
+   need = vsnprintf(NULL, 0, fmt, ap);
    va_end(ap);
 
-   if ((need >= (e->alloc - e->used)) || (need < 0))
+   if (need >= (e->alloc - e->used))
      {
-       if (need < 0)
-          need = 2 * e->alloc;
-       else
-          need++;
-       need += e->used;
-       need += (CHUNKLEN - (need % CHUNKLEN));
+       e->alloc = e->used + need + (CHUNKLEN - (need % CHUNKLEN));
 
-       if (!(p = (char *)realloc(e->str, need)))
-         {
+       if (!(p = (char *)realloc(e->str, e->alloc)))
+          {
             free(e->str);
             e->alloc = e->used = 0;
             return ECORE_CONFIG_ERR_OOM;
-         }
-       e->alloc = need;
+          }
        e->str = p;
-       goto retry;
      }
 
+   va_start(ap, fmt);
+   need = vsnprintf(e->str + e->used, e->alloc - e->used, fmt, ap);
+   va_end(ap);
+
    return e->used += need;
 }
 




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to