Kaydet (Commit) 7ff6f6b7 authored tarafından Colomban Wendling's avatar Colomban Wendling

Cleanup utils_remove_ext_from_filename()

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5993 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 386b3212
...@@ -596,7 +596,7 @@ gchar *utils_remove_ext_from_filename(const gchar *filename) ...@@ -596,7 +596,7 @@ gchar *utils_remove_ext_from_filename(const gchar *filename)
{ {
gchar *last_dot; gchar *last_dot;
gchar *result; gchar *result;
gint i; gsize len;
g_return_val_if_fail(filename != NULL, NULL); g_return_val_if_fail(filename != NULL, NULL);
...@@ -604,15 +604,11 @@ gchar *utils_remove_ext_from_filename(const gchar *filename) ...@@ -604,15 +604,11 @@ gchar *utils_remove_ext_from_filename(const gchar *filename)
if (! last_dot) if (! last_dot)
return g_strdup(filename); return g_strdup(filename);
/* assumes extension is small, so extra bytes don't matter */ len = (gsize) (last_dot - filename);
result = g_malloc(strlen(filename)); result = g_malloc(len + 1);
i = 0; memcpy(result, filename, len);
while ((filename + i) != last_dot) result[len] = 0;
{
result[i] = filename[i];
i++;
}
result[i] = 0;
return result; return result;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment