Enlightenment CVS committal
Author : doursse
Project : e17
Module : libs/efreet
Dir : e17/libs/efreet/src/lib
Modified Files:
efreet_ini.c
Log Message:
in efreet_ini_parse:
* move the opening of the file after the creation of the hash table and
return it on failure
* return NULL when the hash table can not be created
* add the binary flag when opening a file for compatibility with Windows
in efreet_new, return NULL when efreet_ini_parse returns NULL (mem alloc
failure)
===================================================================
RCS file: /cvs/e/e17/libs/efreet/src/lib/efreet_ini.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- efreet_ini.c 25 Jul 2007 17:00:56 -0000 1.4
+++ efreet_ini.c 6 Sep 2007 16:05:35 -0000 1.5
@@ -43,7 +43,7 @@
* @internal
* @param file: The file to parse
* @return Returns a new Efreet_Ini structure initialized with the contents
- * of @a file, or NULL on failure
+ * of @a file, or NULL on memory allocation failure
* @brief Creates and initializes a new Ini structure with the contents of
* @a file, or NULL on failure
*/
@@ -56,6 +56,11 @@
if (!ini) return NULL;
ini->data = efreet_ini_parse(file);
+ if (!ini->data)
+ {
+ FREE(ini);
+ return NULL;
+ }
return ini;
}
@@ -93,13 +98,15 @@
buf = read_buf = static_buf;
read_len = static_buf_len;
- f = fopen(file, "r");
- if (!f) return NULL;
-
data = ecore_hash_new(ecore_str_hash, ecore_str_compare);
+ if (!data) return NULL;
+
ecore_hash_free_key_cb_set(data, ECORE_FREE_CB(ecore_string_release));
ecore_hash_free_value_cb_set(data, ECORE_FREE_CB(ecore_hash_destroy));
+ f = fopen(file, "rb");
+ if (!f) return data;
+
/* if a line is longer than the buffer size, this \n will get overwritten.
*/
read_buf[read_len - 2] = '\n';
while (fgets(read_buf, read_len, f) != NULL)
@@ -268,7 +275,7 @@
FILE *f;
if (!ini) return 0;
- f = fopen(file, "w");
+ f = fopen(file, "wb");
if (!f) return 0;
ecore_hash_for_each_node(ini->data,
ECORE_FOR_EACH(efreet_ini_section_save), f);
fclose(f);
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs