*/
#include "default_backend.h"
+#include <limits.h>
pui_backend_ani_func *ani_func = NULL;
Eina_Hash *_animations_hash = NULL;
{
FILE *fp = fopen(path, "rb");
int size;
- char *buffer;
+ char *buffer = NULL;
ERROR_CHECK(fp, return NULL, "Failed to open file: %s\n", path);
fseek(fp, 0, SEEK_END);
- size = ftell(fp);
+ size = (long int)ftell(fp);
fseek(fp, 0, SEEK_SET);
+ ERROR_CHECK(0 < size && size < INT_MAX, goto error, "Invalid file: %d size\n", size);
buffer = (char *)calloc(sizeof(char), size + 1);
+ ERROR_CHECK(buffer, goto error, "Failed to allocate memory for buffer\n");
if (fread(buffer, size, 1, fp) < 1) {
- *data_size = 0;
- free(buffer);
- fclose(fp);
- return NULL;
+ goto error;
}
*data_size = size;
fclose(fp);
return buffer;
+
+error:
+ *data_size = 0;
+ if (buffer) free(buffer);
+ fclose(fp);
+ return NULL;
}
static default_ani_info *
int data_size = 0, i, j;
buffer = _read_json_file(path, &data_size);
- ERROR_CHECK(buffer && data_size > 0, return EINA_FALSE, "File %s has no data\n", path);
+ ERROR_CHECK(buffer && data_size > 0, goto error, "File %s has no data\n", path);
root_obj = json_tokener_parse(buffer);
ERROR_CHECK(root_obj, goto error, "Failed to tokenize json object\n");
return ani_info;
error:
- free(buffer);
+ if (buffer) free(buffer);
if (ani_info) {
if (ani_info->frames) {
for (i = 0; i < ani_info->num_key_frames; i++) {
return e;
}
+pui_bool
+_geometry_get(int *width, int *height)
+{
+ if (!width || !height)
+ return 0;
+
+ if (width)
+ *width = DEFAULT_BACKEND_GEOM_WIDTH;
+ if (height)
+ *height = DEFAULT_BACKEND_GEOM_HEIGHT;
+
+ return 1;
+}
+
pui_int_error
_is_ani_supported(pui_id id)
{
}
backend_data->create_ani_collection = _create_ani_collection;
+ backend_data->geometry_get = _geometry_get;
backend_data->ani_create = _ani_create;
backend_data->ani_destroy = _ani_destroy;
}
backend_data->create_ani_collection = NULL;
+ backend_data->geometry_get = NULL;
backend_data->ani_create = NULL;
backend_data->ani_destroy = NULL;