Enlightenment CVS committal

Author  : handyande
Project : misc
Module  : enotes

Dir     : misc/enotes/src


Modified Files:
        note.c 


Log Message:
optimise the title calculation and fix it at the same time :)
===================================================================
RCS file: /cvsroot/enlightenment/misc/enotes/src/note.c,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -3 -r1.55 -r1.56
--- note.c      3 Feb 2006 22:19:15 -0000       1.55
+++ note.c      3 Feb 2006 22:41:15 -0000       1.56
@@ -779,29 +779,24 @@
 get_title_by_content(char *content)
 {
        char           *cont;
-       int             a;
        int             newlength;
 
        if (!content)
                return NULL;
-       cont = content;
-       a = 0;
        newlength = 0;
 
-       while (a < TITLE_LENGTH && cont != NULL) {
-               if (!strncmp(cont, "\n", 1)) {
-                       newlength = a;
+       while (newlength < TITLE_LENGTH && cont != NULL) {
+               if (content[newlength] == '\n') {
                        break;
                }
-               a++;
-               cont++;
+               newlength++;
        }
 
        if (newlength == 0)
                newlength = TITLE_LENGTH;
 
-       cont = malloc((newlength * sizeof(char)) + 1);
-       snprintf(cont, newlength, "%s", content);
+       cont = malloc((newlength + 1) * sizeof(char));
+       snprintf(cont, newlength + 1, "%s", content);
        return cont;
 }
 




-------------------------------------------------------
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