Enlightenment CVS committal

Author  : ningerso
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src/lib


Modified Files:
        ewl_debug.h ewl_misc.c ewl_misc.h 


Log Message:
Change the indentation output to avoid an allocation.

===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_debug.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -3 -r1.25 -r1.26
--- ewl_debug.h 4 Jan 2007 05:09:46 -0000       1.25
+++ ewl_debug.h 6 Jan 2007 13:09:05 -0000       1.26
@@ -48,10 +48,9 @@
 { \
        if (DEBUGGING(lvl)) \
          { \
-               char *indent = ewl_debug_indent_get(1); \
-               fprintf(stderr, "%s--> %s:%i\tEntering %s();\n", \
-                       indent, __FILE__, __LINE__, __func__); \
-               FREE(indent); \
+               ewl_debug_indent_print(1); \
+               fprintf(stderr, "--> %s:%i\tEntering %s();\n", \
+                       __FILE__, __LINE__, __func__); \
          } \
 }
 
@@ -59,11 +58,9 @@
 { \
        if (DEBUGGING(lvl)) \
          { \
-               char *indent; \
-               indent = ewl_debug_indent_get(-1); \
-               fprintf(stderr, "%s<--  %s:%i\tLeaving  %s();\n", \
-                       indent, __FILE__, __LINE__, __func__); \
-               FREE(indent); \
+               ewl_debug_indent_print(-1); \
+               fprintf(stderr, "<--  %s:%i\tLeaving  %s();\n", \
+                       __FILE__, __LINE__, __func__); \
          } \
 }
 
@@ -72,11 +69,9 @@
        DLEAVE_FUNCTION(lvl); \
        if (DEBUGGING(lvl)) \
          { \
-               char *indent; \
-               indent = ewl_debug_indent_get(0); \
-               fprintf(stderr, "%s<--  %s:%i\tReturn in %s();\n", \
-                       indent, __FILE__, __LINE__, __func__); \
-               FREE(indent); \
+               ewl_debug_indent_print(0); \
+               fprintf(stderr, "<--  %s:%i\tReturn in %s();\n", \
+                       __FILE__, __LINE__, __func__); \
          } \
        return; \
 }
@@ -86,11 +81,9 @@
        DLEAVE_FUNCTION(lvl); \
        if (DEBUGGING(lvl)) \
          { \
-               char *indent; \
-               indent = ewl_debug_indent_get(0); \
-               fprintf(stderr, "%s<--  %s:%i\tReturning %p in %s();\n", \
-                       indent, __FILE__, __LINE__, (void *) (ptr), __func__); \
-               FREE(indent); \
+               ewl_debug_indent_print(0); \
+               fprintf(stderr, "<--  %s:%i\tReturning %p in %s();\n", \
+                       __FILE__, __LINE__, (void *) (ptr), __func__); \
          } \
        return (void *)(ptr); \
 }
@@ -100,11 +93,9 @@
        DLEAVE_FUNCTION(lvl); \
        if (DEBUGGING(lvl)) \
          { \
-               char *indent; \
-               indent = ewl_debug_indent_get(0); \
-               fprintf(stderr, "%s<--  %s:%i\tReturning %f in %s();\n", \
-                       indent, __FILE__, __LINE__, (float) (num), __func__); \
-               FREE(indent); \
+               ewl_debug_indent_print(0); \
+               fprintf(stderr, "<--  %s:%i\tReturning %f in %s();\n", \
+                       __FILE__, __LINE__, (float) (num), __func__); \
          } \
        return num; \
 }
@@ -114,11 +105,9 @@
        DLEAVE_FUNCTION(lvl); \
        if (DEBUGGING(lvl)) \
          { \
-               char *indent; \
-               indent = ewl_debug_indent_get(0); \
-               fprintf(stderr, "%s<--  %s:%i\tReturning %i in %s();\n", \
-                       indent, __FILE__, __LINE__, (int) (num), __func__); \
-               FREE(indent); \
+               ewl_debug_indent_print(0); \
+               fprintf(stderr, "<--  %s:%i\tReturning %i in %s();\n", \
+                       __FILE__, __LINE__, (int) (num), __func__); \
          } \
        return num; \
 }
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_misc.c,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -3 -r1.77 -r1.78
--- ewl_misc.c  4 Jan 2007 05:09:47 -0000       1.77
+++ ewl_misc.c  6 Jan 2007 13:09:05 -0000       1.78
@@ -1087,22 +1087,22 @@
  * @brief Creates a string used to indent debug messages
  */
 char *
-ewl_debug_indent_get(int mod_dir)
+ewl_debug_indent_print(int mod_dir)
 {
+       int indent;
        static int ewl_debug_indent_lvl = 0;
-       char *indent = NULL;
 
        if (mod_dir < 0) ewl_debug_indent_lvl --;
 
        if (ewl_debug_indent_lvl < 0)
                ewl_debug_indent_lvl = 0;
 
-       indent = NEW(char *, (ewl_debug_indent_lvl << 1) + 2); 
-       memset(indent, ' ', (ewl_debug_indent_lvl << 1) + 1);
+       for (indent = 0; indent < (ewl_debug_indent_lvl << 1) + 2; indent++)
+               fputc(' ', stderr);
 
        if (mod_dir > 0) ewl_debug_indent_lvl ++;
 
-       return indent;
+       return NULL;
 }
 
 void
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_misc.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -3 -r1.21 -r1.22
--- ewl_misc.h  4 Jan 2007 05:09:47 -0000       1.21
+++ ewl_misc.h  6 Jan 2007 13:09:05 -0000       1.22
@@ -21,7 +21,7 @@
 void    ewl_destroy_request(Ewl_Widget *w);
 void    ewl_evas_destroy(Evas *evas);
 void    ewl_evas_object_destroy(Evas_Object *obj);
-char   *ewl_debug_indent_get(int mod_dir);
+char   *ewl_debug_indent_print(int mod_dir);
 
 /*
  * Internal stuff



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to