* Fix possible divide by zero in els_scroller animator.
* Fix uninitialized data path in elm_flip, elm_gesture_layer, elm_interface_scrollable,
els_scroller.
+ * Fix the way we read file in elm_entry.
Removals:
}
static char *
-_buf_append(char *buf,
- const char *str,
- int *len,
- int *alloc)
+_file_load(const char *file)
{
- int len2 = strlen(str);
+ Eina_File *f;
+ char *text = NULL;
+ void *tmp = NULL;
- if ((*len + len2) >= *alloc)
- {
- char *buf2 = realloc(buf, *alloc + len2 + 512);
- if (!buf2) return NULL;
- buf = buf2;
- *alloc += (512 + len2);
- }
+ f = eina_file_open(file, EINA_FALSE);
+ if (!f) return NULL;
- strcpy(buf + *len, str);
- *len += len2;
+ tmp = eina_file_map_all(file, EINA_FILE_SEQUENTIAL);
+ if (!tmp) goto on_error;
- return buf;
-}
+ text = malloc(eina_file_size_get(f) + 1);
+ if (!text) goto on_error;
-static char *
-_file_load(const char *file)
-{
- FILE *f;
- size_t size;
- int alloc = 0, len = 0;
- char *text = NULL, buf[16384 + 1];
+ memcpy(text, tmp, eina_file_size_get(f));
+ text[eina_file_size_get(f)] = 0;
- f = fopen(file, "rb");
- if (!f) return NULL;
- while ((size = fread(buf, 1, sizeof(buf) - 1, f)))
+ if (eina_file_map_faulted(f))
{
- char *tmp_text;
-
- buf[size] = 0;
- tmp_text = _buf_append(text, buf, &len, &alloc);
- if (!tmp_text) break;
- text = tmp_text;
+ free(text);
+ text = NULL;
}
- fclose(f);
+
+ on_error:
+ if (tmp) eina_file_map_free(tmp);
+ eina_file_close(f);
return text;
}