}
}
- read_buffer = (void *)calloc(1, IMG_HEADER_LENGTH + 1);
- if (read_buffer == NULL) {
- image_util_error("Allocation fail");
- fclose(fp);
- fp = NULL;
- return IMAGE_UTIL_ERROR_OUT_OF_MEMORY;
- }
+ read_buffer = g_malloc0(IMG_HEADER_LENGTH + 1);
if (fread(read_buffer, 1, IMG_HEADER_LENGTH, fp) != IMG_HEADER_LENGTH) {
- image_util_error("File read failed");
+ image_util_error("Fail to File read");
fclose(fp);
- fp = NULL;
- IMAGE_UTIL_SAFE_FREE(read_buffer);
+ g_free(read_buffer);
return IMAGE_UTIL_ERROR_INVALID_OPERATION;
}
- *buffer = read_buffer;
-
fclose(fp);
- fp = NULL;
+ *buffer = read_buffer;
return IMAGE_UTIL_ERROR_NONE;
}