Enlightenment CVS committal
Author : sebastid
Project : e17
Module : libs/ecore
Dir : e17/libs/ecore/src/lib/ecore_file
Modified Files:
ecore_file.c
Log Message:
Only allocate the necessary amount of memory
===================================================================
RCS file:
/cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_file/ecore_file.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -3 -r1.27 -r1.28
--- ecore_file.c 6 Oct 2005 18:48:03 -0000 1.27
+++ ecore_file.c 7 Oct 2005 17:32:31 -0000 1.28
@@ -381,14 +381,22 @@
char *
ecore_file_strip_ext(const char *path)
{
- char *p, *file;
+ char *p, *file = NULL;
- file = strdup(path);
- if (!file) return NULL;
-
- p = strrchr(file, '.');
- if (p)
- *p = 0;
+ p = strrchr(path, '.');
+ if (!p)
+ {
+ file = strdup(path);
+ }
+ else if (p != path)
+ {
+ file = malloc(((p - path) + 1) * sizeof(char));
+ if (file)
+ {
+ memcpy(file, path, (p - path));
+ file[p - path] = 0;
+ }
+ }
return file;
}
-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs