From cb772047ffdcb47113d0bf29af8f85cc869ed84a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 21 Oct 2016 19:32:44 +0200 Subject: [PATCH] Prevent some more memsets --- libretro-common/formats/image_texture.c | 4 +++- menu/menu_display.c | 9 +-------- playlist.c | 13 ++++++------- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/libretro-common/formats/image_texture.c b/libretro-common/formats/image_texture.c index b1369c06dc..72de97ed12 100644 --- a/libretro-common/formats/image_texture.c +++ b/libretro-common/formats/image_texture.c @@ -220,7 +220,9 @@ void image_texture_free(struct texture_image *img) if (img->pixels) free(img->pixels); - memset(img, 0, sizeof(*img)); + img->width = 0; + img->height = 0; + img->pixels = NULL; } static enum video_image_format image_texture_get_type(const char *path) diff --git a/menu/menu_display.c b/menu/menu_display.c index f991d0d0cd..045225b830 100644 --- a/menu/menu_display.c +++ b/menu/menu_display.c @@ -723,17 +723,10 @@ void menu_display_snow(int width, int height) float alpha; bool alive; }; - static struct display_particle particles[PARTICLES_COUNT]; - static bool initialized = false; + static struct display_particle particles[PARTICLES_COUNT] = {0}; static int timeout = 0; unsigned i, max_gen = 2; - if (!initialized) - { - memset(particles, 0, sizeof(particles)); - initialized = true; - } - for (i = 0; i < PARTICLES_COUNT; ++i) { struct display_particle *p = (struct display_particle*)&particles[i]; diff --git a/playlist.c b/playlist.c index dd9ec187e9..a3f2c80efe 100644 --- a/playlist.c +++ b/playlist.c @@ -152,29 +152,28 @@ static void playlist_free_entry(struct playlist_entry *entry) if (entry->path) free(entry->path); - entry->path = NULL; if (entry->label) free(entry->label); - entry->label = NULL; if (entry->core_path) free(entry->core_path); - entry->core_path = NULL; if (entry->core_name) free(entry->core_name); - entry->core_name = NULL; if (entry->db_name) free(entry->db_name); - entry->core_name = NULL; if (entry->crc32) free(entry->crc32); - entry->crc32 = NULL; - memset(entry, 0, sizeof(*entry)); + entry->path = NULL; + entry->label = NULL; + entry->core_path = NULL; + entry->core_name = NULL; + entry->db_name = NULL; + entry->crc32 = NULL; } void playlist_update(playlist_t *playlist, size_t idx,