kwo pushed a commit to branch master. http://git.enlightenment.org/legacy/imlib2_loaders.git/commit/?id=3f32c8785a86cffce8a000f781eeab347d520e16
commit 3f32c8785a86cffce8a000f781eeab347d520e16 Author: Kim Woelders <[email protected]> Date: Sat Dec 16 14:42:17 2017 +0100 Clean up formats() --- src/modules/loaders/loader_ani.c | 36 +++++++++++------------------------- src/modules/loaders/loader_eet.c | 24 ++++++++++-------------- src/modules/loaders/loader_ico.c | 36 +++++++++++------------------------- src/modules/loaders/loader_xcf.c | 36 +++++++++++------------------------- 4 files changed, 43 insertions(+), 89 deletions(-) diff --git a/src/modules/loaders/loader_ani.c b/src/modules/loaders/loader_ani.c index a465826..796fea7 100644 --- a/src/modules/loaders/loader_ani.c +++ b/src/modules/loaders/loader_ani.c @@ -341,29 +341,15 @@ load(ImlibImage *im, ImlibProgressFunction progress, char progress_granularity, progress_granularity = 0; } -/* fills the ImlibLoader struct with a strign array of format file */ -/* extensions this loader can load. eg: */ -/* loader->formats = { "jpeg", "jpg"}; */ -/* giving permutations is a good idea. case sensitivity is irrelevant */ -/* your laoder CAN load more than one format if it likes - like: */ -/* loader->formats = { "gif", "png", "jpeg", "jpg"} */ -/* if it can load those formats. */ -void -formats (ImlibLoader *l) -{ - /* this is the only bit you have to change... */ - char *list_formats[] = - { "ani" }; - - /* don't bother changing any of this - it just reads this in and sets */ - /* the struct values and makes copies */ - { - int i; - - l->num_formats = (sizeof(list_formats) / sizeof (char *)); - l->formats = malloc(sizeof(char *) * l->num_formats); - for (i = 0; i < l->num_formats; i++) - l->formats[i] = strdup(list_formats[i]); - } -} +void +formats(ImlibLoader * l) +{ + static const char *const list_formats[] = { "ani" }; + int i; + l->num_formats = sizeof(list_formats) / sizeof(char *); + l->formats = malloc(sizeof(char *) * l->num_formats); + + for (i = 0; i < l->num_formats; i++) + l->formats[i] = strdup(list_formats[i]); +} diff --git a/src/modules/loaders/loader_eet.c b/src/modules/loaders/loader_eet.c index 7b83fd5..8f079e8 100644 --- a/src/modules/loaders/loader_eet.c +++ b/src/modules/loaders/loader_eet.c @@ -390,19 +390,15 @@ save (ImlibImage *im, ImlibProgressFunction progress, progress_granularity = 0; } -void -formats (ImlibLoader *l) -{ - char *list_formats[] = - { "eet" }; +void +formats(ImlibLoader * l) +{ + static const char *const list_formats[] = { "eet" }; + int i; - { - int i; - - l->num_formats = (sizeof(list_formats) / sizeof (char *)); - l->formats = malloc(sizeof(char *) * l->num_formats); - for (i = 0; i < l->num_formats; i++) - l->formats[i] = strdup(list_formats[i]); - } -} + l->num_formats = sizeof(list_formats) / sizeof(char *); + l->formats = malloc(sizeof(char *) * l->num_formats); + for (i = 0; i < l->num_formats; i++) + l->formats[i] = strdup(list_formats[i]); +} diff --git a/src/modules/loaders/loader_ico.c b/src/modules/loaders/loader_ico.c index 67096f5..04f6479 100644 --- a/src/modules/loaders/loader_ico.c +++ b/src/modules/loaders/loader_ico.c @@ -593,29 +593,15 @@ load(ImlibImage *im, ImlibProgressFunction progress, char progress_granularity, return 0; } -/* fills the ImlibLoader struct with a strign array of format file */ -/* extensions this loader can load. eg: */ -/* loader->formats = { "jpeg", "jpg"}; */ -/* giving permutations is a good idea. case sensitivity is irrelevant */ -/* your laoder CAN load more than one format if it likes - like: */ -/* loader->formats = { "gif", "png", "jpeg", "jpg"} */ -/* if it can load those formats. */ -void -formats (ImlibLoader *l) -{ - /* this is the only bit you have to change... */ - char *list_formats[] = - { "ico" }; - - /* don't bother changing any of this - it just reads this in and sets */ - /* the struct values and makes copies */ - { - int i; - - l->num_formats = (sizeof(list_formats) / sizeof (char *)); - l->formats = malloc(sizeof(char *) * l->num_formats); - for (i = 0; i < l->num_formats; i++) - l->formats[i] = strdup(list_formats[i]); - } -} +void +formats(ImlibLoader * l) +{ + static const char *const list_formats[] = { "ico" }; + int i; + l->num_formats = sizeof(list_formats) / sizeof(char *); + l->formats = malloc(sizeof(char *) * l->num_formats); + + for (i = 0; i < l->num_formats; i++) + l->formats[i] = strdup(list_formats[i]); +} diff --git a/src/modules/loaders/loader_xcf.c b/src/modules/loaders/loader_xcf.c index 12bd72b..e69a24b 100644 --- a/src/modules/loaders/loader_xcf.c +++ b/src/modules/loaders/loader_xcf.c @@ -1720,29 +1720,15 @@ load(ImlibImage *im, ImlibProgressFunction progress, char progress_granularity, return 1; } -/* fills the ImlibLoader struct with a strign array of format file */ -/* extensions this loader can load. eg: */ -/* loader->formats = { "jpeg", "jpg"}; */ -/* giving permutations is a good idea. case sensitivity is irrelevant */ -/* your laoder CAN load more than one format if it likes - like: */ -/* loader->formats = { "gif", "png", "jpeg", "jpg"} */ -/* if it can load those formats. */ -void -formats (ImlibLoader *l) -{ - /* this is the only bit you have to change... */ - char *list_formats[] = - { "xcf" }; - - /* don't bother changing any of this - it just reads this in and sets */ - /* the struct values and makes copies */ - { - int i; - - l->num_formats = (sizeof(list_formats) / sizeof (char *)); - l->formats = malloc(sizeof(char *) * l->num_formats); - for (i = 0; i < l->num_formats; i++) - l->formats[i] = strdup(list_formats[i]); - } -} +void +formats(ImlibLoader * l) +{ + static const char *const list_formats[] = { "xcf" }; + int i; + l->num_formats = sizeof(list_formats) / sizeof(char *); + l->formats = malloc(sizeof(char *) * l->num_formats); + + for (i = 0; i < l->num_formats; i++) + l->formats[i] = strdup(list_formats[i]); +} --
