Avoid calloc where possible

This commit is contained in:
twinaphex 2020-06-27 15:06:45 +02:00
parent 5783494e13
commit 4bd8c2a7ff
2 changed files with 21 additions and 23 deletions

View File

@ -298,7 +298,7 @@ void gfx_thumbnail_request(
if (path_is_valid(thumbnail_path))
{
gfx_thumbnail_tag_t *thumbnail_tag =
(gfx_thumbnail_tag_t*)calloc(1, sizeof(gfx_thumbnail_tag_t));
(gfx_thumbnail_tag_t*)malloc(sizeof(gfx_thumbnail_tag_t));
if (!thumbnail_tag)
goto end;
@ -398,7 +398,7 @@ void gfx_thumbnail_request_file(
return;
/* Load thumbnail */
thumbnail_tag = (gfx_thumbnail_tag_t*)calloc(1, sizeof(gfx_thumbnail_tag_t));
thumbnail_tag = (gfx_thumbnail_tag_t*)malloc(sizeof(gfx_thumbnail_tag_t));
if (!thumbnail_tag)
return;

View File

@ -52,27 +52,6 @@ struct gfx_thumbnail_path_data
enum playlist_thumbnail_mode playlist_left_mode;
};
/* Initialisation */
/* Creates new thumbnail path data container.
* Returns handle to new gfx_thumbnail_path_data_t object.
* on success, otherwise NULL.
* Note: Returned object must be free()d */
gfx_thumbnail_path_data_t *gfx_thumbnail_path_init(void)
{
gfx_thumbnail_path_data_t *path_data = (gfx_thumbnail_path_data_t*)
calloc(1, sizeof(*path_data));
if (!path_data)
return NULL;
/* Set these manually, since the default enum
* may not necessarily have a value of zero */
path_data->playlist_right_mode = PLAYLIST_THUMBNAIL_MODE_DEFAULT;
path_data->playlist_left_mode = PLAYLIST_THUMBNAIL_MODE_DEFAULT;
return path_data;
}
/* Resets thumbnail path data
* (blanks all internal string containers) */
void gfx_thumbnail_path_reset(gfx_thumbnail_path_data_t *path_data)
@ -93,6 +72,25 @@ void gfx_thumbnail_path_reset(gfx_thumbnail_path_data_t *path_data)
path_data->playlist_left_mode = PLAYLIST_THUMBNAIL_MODE_DEFAULT;
}
/* Initialisation */
/* Creates new thumbnail path data container.
* Returns handle to new gfx_thumbnail_path_data_t object.
* on success, otherwise NULL.
* Note: Returned object must be free()d */
gfx_thumbnail_path_data_t *gfx_thumbnail_path_init(void)
{
gfx_thumbnail_path_data_t *path_data = (gfx_thumbnail_path_data_t*)
malloc(sizeof(*path_data));
if (!path_data)
return NULL;
gfx_thumbnail_path_reset(path_data);
return path_data;
}
/* Utility Functions */
/* Fetches the thumbnail subdirectory (Named_Snaps,