Revision: 5993 http://geany.svn.sourceforge.net/geany/?rev=5993&view=rev Author: colombanw Date: 2011-10-03 17:05:57 +0000 (Mon, 03 Oct 2011) Log Message: ----------- Cleanup utils_remove_ext_from_filename()
Modified Paths: -------------- trunk/src/utils.c
Modified: trunk/src/utils.c =================================================================== --- trunk/src/utils.c 2011-10-03 17:05:41 UTC (rev 5992) +++ trunk/src/utils.c 2011-10-03 17:05:57 UTC (rev 5993) @@ -596,7 +596,7 @@ { gchar *last_dot; gchar *result; - gint i; + gsize len;
g_return_val_if_fail(filename != NULL, NULL);
@@ -604,15 +604,11 @@ if (! last_dot) return g_strdup(filename);
- /* assumes extension is small, so extra bytes don't matter */ - result = g_malloc(strlen(filename)); - i = 0; - while ((filename + i) != last_dot) - { - result[i] = filename[i]; - i++; - } - result[i] = 0; + len = (gsize) (last_dot - filename); + result = g_malloc(len + 1); + memcpy(result, filename, len); + result[len] = 0; + return result; }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.