From 357852ebb9b5a76d027c00726b850931f359a214 Mon Sep 17 00:00:00 2001 From: Kim Woelders Date: Tue, 2 Jul 2013 22:47:17 +0200 Subject: Silence compiler warnings (loaders). --- src/modules/loaders/loader_argb.c | 14 ++++---- src/modules/loaders/loader_bmp.c | 67 +++++++++++++++++++-------------------- src/modules/loaders/loader_bz2.c | 6 +--- src/modules/loaders/loader_gif.c | 24 ++++---------- src/modules/loaders/loader_id3.c | 42 ++++++++++++------------ src/modules/loaders/loader_jpeg.c | 23 ++++++-------- src/modules/loaders/loader_lbm.c | 10 +++--- src/modules/loaders/loader_png.c | 20 ++++-------- src/modules/loaders/loader_pnm.c | 18 +++++------ src/modules/loaders/loader_tga.c | 18 +++++------ src/modules/loaders/loader_tiff.c | 34 +++++++------------- src/modules/loaders/loader_xpm.c | 28 +++++----------- src/modules/loaders/loader_zlib.c | 6 +--- 13 files changed, 125 insertions(+), 185 deletions(-) diff --git a/src/modules/loaders/loader_argb.c b/src/modules/loaders/loader_argb.c index 176322f..6437494 100644 --- a/src/modules/loaders/loader_argb.c +++ b/src/modules/loaders/loader_argb.c @@ -176,14 +176,12 @@ save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity) void formats(ImlibLoader * l) { - char *list_formats[] = { "argb", "arg" }; + static const char *const list_formats[] = { "argb", "arg" }; + int i; - { - int i; + l->num_formats = sizeof(list_formats) / sizeof(char *); + l->formats = malloc(sizeof(char *) * l->num_formats); - 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]); - } + for (i = 0; i < l->num_formats; i++) + l->formats[i] = strdup(list_formats[i]); } diff --git a/src/modules/loaders/loader_bmp.c b/src/modules/loaders/loader_bmp.c index bdd2a2a..34ab42b 100644 --- a/src/modules/loaders/loader_bmp.c +++ b/src/modules/loaders/loader_bmp.c @@ -115,7 +115,7 @@ load(ImlibImage * im, ImlibProgressFunction progress, unsigned char byte = 0, g, b, r; unsigned long i, w, h; unsigned short x, y; - DATA32 *ptr, *data_end; + DATA32 *ptr; unsigned char *buffer_ptr, *buffer, *buffer_end; RGBQUAD rgbQuads[256]; unsigned long rmask = 0xff, gmask = 0xff, bmask = 0xff; @@ -303,7 +303,6 @@ load(ImlibImage * im, ImlibProgressFunction progress, buffer_ptr = buffer; buffer_end = buffer + imgsize; - data_end = im->data + w * h; ptr = im->data + ((h - 1) * w); if (bitcount == 1) @@ -329,16 +328,16 @@ load(ImlibImage * im, ImlibProgressFunction progress, if (progress) { char per; - int l; + int ll; per = (char)((100 * y) / im->h); if (((per - pper) >= progress_granularity) || (y == (im->h - 1))) { - l = y - pl; + ll = y - pl; if (!progress (im, per, 0, im->h - y - 1, im->w, - im->h - y + l)) + im->h - y + ll)) { free(buffer); return 2; @@ -490,16 +489,16 @@ load(ImlibImage * im, ImlibProgressFunction progress, if (progress) { char per; - int l; + int ll; per = (char)((100 * y) / im->h); if (((per - pper) >= progress_granularity) || (y == (im->h - 1))) { - l = y - pl; + ll = y - pl; if (!progress (im, per, 0, im->h - y - 1, im->w, - im->h - y + l)) + im->h - y + ll)) { free(buffer); return 2; @@ -532,16 +531,16 @@ load(ImlibImage * im, ImlibProgressFunction progress, if (progress) { char per; - int l; + int ll; per = (char)((100 * y) / im->h); if (((per - pper) >= progress_granularity) || (y == (im->h - 1))) { - l = y - pl; + ll = y - pl; if (!progress (im, per, 0, im->h - y - 1, im->w, - im->h - y + l)) + im->h - y + ll)) { free(buffer); return 2; @@ -634,16 +633,16 @@ load(ImlibImage * im, ImlibProgressFunction progress, if (progress) { char per; - int l; + int ll; per = (char)((100 * y) / im->h); if (((per - pper) >= progress_granularity) || (y == (im->h - 1))) { - l = y - pl; + ll = y - pl; if (!progress (im, per, 0, im->h - y - 1, im->w, - im->h - y + l)) + im->h - y + ll)) { free(buffer); return 2; @@ -671,16 +670,16 @@ load(ImlibImage * im, ImlibProgressFunction progress, if (progress) { char per; - int l; + int ll; per = (char)((100 * y) / im->h); if (((per - pper) >= progress_granularity) || (y == (im->h - 1))) { - l = y - pl; + ll = y - pl; if (!progress (im, per, 0, im->h - y - 1, im->w, - im->h - y + l)) + im->h - y + ll)) { free(buffer); return 2; @@ -726,16 +725,16 @@ load(ImlibImage * im, ImlibProgressFunction progress, if (progress) { char per; - int l; + int ll; per = (char)((100 * y) / im->h); if (((per - pper) >= progress_granularity) || (y == (im->h - 1))) { - l = y - pl; + ll = y - pl; if (!progress (im, per, 0, im->h - y - 1, im->w, - im->h - y + l)) + im->h - y + ll)) { free(buffer); return 2; @@ -766,16 +765,16 @@ load(ImlibImage * im, ImlibProgressFunction progress, if (progress) { char per; - int l; + int ll; per = (char)((100 * y) / im->h); if (((per - pper) >= progress_granularity) || (y == (im->h - 1))) { - l = y - pl; + ll = y - pl; if (!progress (im, per, 0, im->h - y - 1, im->w, - im->h - y + l)) + im->h - y + ll)) { free(buffer); return 2; @@ -820,16 +819,16 @@ load(ImlibImage * im, ImlibProgressFunction progress, if (progress) { char per; - int l; + int ll; per = (char)((100 * y) / im->h); if (((per - pper) >= progress_granularity) || (y == (im->h - 1))) { - l = y - pl; + ll = y - pl; if (!progress (im, per, 0, im->h - y - 1, im->w, - im->h - y + l)) + im->h - y + ll)) { free(buffer); return 2; @@ -851,7 +850,7 @@ save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity) { FILE *f; Imlib_Color pixel_color; - unsigned long i, j, pad; + int i, j, pad; if (!im->data) return 0; @@ -902,14 +901,12 @@ save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity) void formats(ImlibLoader * l) { - char *list_formats[] = { "bmp" }; + static const char *const list_formats[] = { "bmp" }; + int i; - { - int i; + l->num_formats = sizeof(list_formats) / sizeof(char *); + l->formats = malloc(sizeof(char *) * l->num_formats); - 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]); - } + for (i = 0; i < l->num_formats; i++) + l->formats[i] = strdup(list_formats[i]); } diff --git a/src/modules/loaders/loader_bz2.c b/src/modules/loaders/loader_bz2.c index adda48a..3cacd9e 100644 --- a/src/modules/loaders/loader_bz2.c +++ b/src/modules/loaders/loader_bz2.c @@ -119,13 +119,9 @@ load(ImlibImage * im, ImlibProgressFunction progress, void formats(ImlibLoader * l) { - /* this is the only bit you have to change... */ - char *list_formats[] = { "bz2" }; + static const char *const list_formats[] = { "bz2" }; int i; - /* don't bother changing any of this - it just reads this in - * and sets the struct values and makes copies - */ l->num_formats = sizeof(list_formats) / sizeof(char *); l->formats = malloc(sizeof(char *) * l->num_formats); diff --git a/src/modules/loaders/loader_gif.c b/src/modules/loaders/loader_gif.c index 45ff0b9..23b8fd0 100644 --- a/src/modules/loaders/loader_gif.c +++ b/src/modules/loaders/loader_gif.c @@ -207,27 +207,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[] = { "gif" }; + static const char *const list_formats[] = { "gif" }; + int i; - /* 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); - 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]); - } + for (i = 0; i < l->num_formats; i++) + l->formats[i] = strdup(list_formats[i]); } diff --git a/src/modules/loaders/loader_id3.c b/src/modules/loaders/loader_id3.c index 2b3ccb1..2c241d0 100644 --- a/src/modules/loaders/loader_id3.c +++ b/src/modules/loaders/loader_id3.c @@ -257,7 +257,7 @@ get_options(lopt * opt, ImlibImage * im) if (!value) { value = tok; - tok = "index"; + tok = (char *)"index"; } else { @@ -297,7 +297,7 @@ get_options(lopt * opt, ImlibImage * im) if (htag && htag->val) index = htag->val; } - if (index < 0 || index > id3_tag_get_numframes(ctx->tag) || + if (index > id3_tag_get_numframes(ctx->tag) || (index == 0 && id3_tag_get_numframes(ctx->tag) < 1)) { if (index) @@ -386,7 +386,7 @@ get_loader(lopt * opt, ImlibLoader ** loader) return 1; } -static char *id3_pic_types[] = { +static const char *const id3_pic_types[] = { /* $00 */ "Other", /* $01 */ "32x32 pixels file icon", /* $02 */ "Other file icon", @@ -413,7 +413,7 @@ static char *id3_pic_types[] = { #define NUM_OF_ID3_PIC_TYPES \ (sizeof(id3_pic_types) / sizeof(id3_pic_types[0])) -static char *id3_text_encodings[] = { +static const char *const id3_text_encodings[] = { /* $00 */ "ISO-8859-1", /* $01 */ "UTF-16 encoded Unicode with BOM", /* $02 */ "UTF-16BE encoded Unicode without BOM", @@ -428,7 +428,7 @@ write_tags(ImlibImage * im, lopt * opt) { struct id3_frame *frame = id3_tag_get_frame(opt->ctx->tag, opt->index - 1); union id3_field *field; - int num_data; + unsigned int num_data; char *data; if ((field = id3_frame_field(frame, 1)) && @@ -448,16 +448,20 @@ write_tags(ImlibImage * im, lopt * opt) memcpy(dup, data, length); __imlib_AttachTag(im, "id3-description", 0, dup, destructor_data); } - if (field = id3_frame_field(frame, 0)) - __imlib_AttachTag(im, "id3-description-text-encoding", - (num_data = (int)id3_field_gettextencoding(field)), - num_data < NUM_OF_ID3_TEXT_ENCODINGS ? - id3_text_encodings[num_data] : NULL, NULL); - if (field = id3_frame_field(frame, 2)) - __imlib_AttachTag(im, "id3-picture-type", - (num_data = id3_field_getint(field)), - num_data < NUM_OF_ID3_PIC_TYPES ? - id3_pic_types[num_data] : NULL, NULL); + if ((field = id3_frame_field(frame, 0))) + { + num_data = id3_field_gettextencoding(field); + __imlib_AttachTag(im, "id3-description-text-encoding", num_data, + num_data < NUM_OF_ID3_TEXT_ENCODINGS ? + (char *)id3_text_encodings[num_data] : NULL, NULL); + } + if ((field = id3_frame_field(frame, 2))) + { + num_data = id3_field_getint(field); + __imlib_AttachTag(im, "id3-picture-type", num_data, + num_data < NUM_OF_ID3_PIC_TYPES ? + (char *)id3_pic_types[num_data] : NULL, NULL); + } __imlib_AttachTag(im, "count", id3_tag_get_numframes(opt->ctx->tag), NULL, NULL); if (opt->cache_level) @@ -596,15 +600,11 @@ load(ImlibImage * im, ImlibProgressFunction progress, void formats(ImlibLoader * l) { - /* this is the only bit you have to change... */ - char *list_formats[] = { "mp3" }; + static const char *const list_formats[] = { "mp3" }; int i; - /* don't bother changing any of this - it just reads this in - * and sets the struct values and makes copies - */ l->num_formats = sizeof(list_formats) / sizeof(char *); - l->formats = (char **)malloc(sizeof(char *) * l->num_formats); + 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_jpeg.c b/src/modules/loaders/loader_jpeg.c index 94e956a..5fb550b 100644 --- a/src/modules/loaders/loader_jpeg.c +++ b/src/modules/loaders/loader_jpeg.c @@ -16,30 +16,30 @@ _JPEGFatalErrorHandler(j_common_ptr cinfo) errmgr = (emptr) cinfo->err; /* cinfo->err->output_message(cinfo);*/ siglongjmp(errmgr->setjmp_buffer, 1); - return; } static void _JPEGErrorHandler(j_common_ptr cinfo) { +#if 0 emptr errmgr; errmgr = (emptr) cinfo->err; /* cinfo->err->output_message(cinfo);*/ /* siglongjmp(errmgr->setjmp_buffer, 1);*/ - return; +#endif } static void _JPEGErrorHandler2(j_common_ptr cinfo, int msg_level) { +#if 0 emptr errmgr; errmgr = (emptr) cinfo->err; /* cinfo->err->output_message(cinfo);*/ /* siglongjmp(errmgr->setjmp_buffer, 1);*/ - return; - msg_level = 0; +#endif } char @@ -347,15 +347,12 @@ save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity) void formats(ImlibLoader * l) { - char *list_formats[] = { "jpg", "jpeg", "jfif", "jfi" }; + static const char *const list_formats[] = { "jpg", "jpeg", "jfif", "jfi" }; + int i; - { - int i; + l->num_formats = sizeof(list_formats) / sizeof(char *); + l->formats = malloc(sizeof(char *) * l->num_formats); - 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]); - } + for (i = 0; i < l->num_formats; i++) + l->formats[i] = strdup(list_formats[i]); } diff --git a/src/modules/loaders/loader_lbm.c b/src/modules/loaders/loader_lbm.c index 8027eae..617c602 100644 --- a/src/modules/loaders/loader_lbm.c +++ b/src/modules/loaders/loader_lbm.c @@ -129,7 +129,7 @@ loadchunks(char *name, ILBM * ilbm, int full) break; /* Out of memory. */ s = fread(c->data, 1, c->size, f); - if (s != c->size) + if (s != (size_t) c->size) break; /* Error or short file. */ seek = 0; @@ -549,6 +549,7 @@ load(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity, ok = 0; cancel = 0; plane[0] = NULL; + gran = nexty = 0; im->data = malloc(im->w * im->h * sizeof(DATA32)); n = ilbm.depth; @@ -637,11 +638,12 @@ save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity) void formats(ImlibLoader * l) { - char *list_formats[] = { "iff", "ilbm", "lbm" }; + static const char *const list_formats[] = { "iff", "ilbm", "lbm" }; int i; - l->num_formats = sizeof(list_formats) / sizeof(list_formats[0]); - l->formats = malloc(l->num_formats * sizeof(list_formats[0])); + 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_png.c b/src/modules/loaders/loader_png.c index fbfb991..f7fe94f 100644 --- a/src/modules/loaders/loader_png.c +++ b/src/modules/loaders/loader_png.c @@ -333,7 +333,7 @@ save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity) #ifdef PNG_TEXT_SUPPORTED png_text text; - text.key = "Imlib2-Comment"; + text.key = (char *)"Imlib2-Comment"; text.text = tag->data; text.compression = PNG_TEXT_COMPRESSION_zTXt; png_set_text(png_ptr, info_ptr, &(text), 1); @@ -415,18 +415,12 @@ save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity) void formats(ImlibLoader * l) { - /* this is the only bit you have to change... */ - char *list_formats[] = { "png" }; + static const char *const list_formats[] = { "png" }; + int i; - /* 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); - 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]); - } + for (i = 0; i < l->num_formats; i++) + l->formats[i] = strdup(list_formats[i]); } diff --git a/src/modules/loaders/loader_pnm.c b/src/modules/loaders/loader_pnm.c index f974ed5..173e127 100644 --- a/src/modules/loaders/loader_pnm.c +++ b/src/modules/loaders/loader_pnm.c @@ -1,7 +1,7 @@ #include "loader_common.h" #include -int +static int do_progress(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity, char *pper, int *py, int y) { @@ -632,15 +632,13 @@ save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity) void formats(ImlibLoader * l) { - char *list_formats[] = { "pnm", "ppm", "pgm", "pbm", "pam" }; + static const char *const list_formats[] = + { "pnm", "ppm", "pgm", "pbm", "pam" }; + int i; - { - int i; + l->num_formats = sizeof(list_formats) / sizeof(char *); + l->formats = malloc(sizeof(char *) * l->num_formats); - 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]); - } + for (i = 0; i < l->num_formats; i++) + l->formats[i] = strdup(list_formats[i]); } diff --git a/src/modules/loaders/loader_tga.c b/src/modules/loaders/loader_tga.c index 84029ef..38d6898 100644 --- a/src/modules/loaders/loader_tga.c +++ b/src/modules/loaders/loader_tga.c @@ -213,7 +213,7 @@ load(ImlibImage * im, ImlibProgressFunction progress, return 0; } - if (ss.st_size < sizeof(tga_header) + sizeof(tga_footer)) + if (ss.st_size < (long)(sizeof(tga_header) + sizeof(tga_footer))) { close(fd); return 0; @@ -329,7 +329,7 @@ load(ImlibImage * im, ImlibProgressFunction progress, /* bufptr is the next byte to be read from the buffer */ bufptr = filedata; - bufend = filedata + datasize; + bufend = bufptr + datasize; /* dataptr is the next 32-bit pixel to be filled in */ dataptr = im->data; @@ -516,16 +516,14 @@ load(ImlibImage * im, ImlibProgressFunction progress, void formats(ImlibLoader * l) { - char *list_formats[] = { "tga" }; + static const char *const list_formats[] = { "tga" }; + int i; - { - int i; + l->num_formats = sizeof(list_formats) / sizeof(char *); + l->formats = malloc(sizeof(char *) * l->num_formats); - 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]); - } + for (i = 0; i < l->num_formats; i++) + l->formats[i] = strdup(list_formats[i]); } /**********************/ diff --git a/src/modules/loaders/loader_tiff.c b/src/modules/loaders/loader_tiff.c index b6779a9..7f16383 100644 --- a/src/modules/loaders/loader_tiff.c +++ b/src/modules/loaders/loader_tiff.c @@ -54,9 +54,9 @@ static void raster(TIFFRGBAImage_Extra * img, uint32 * rast, uint32 x, uint32 y, uint32 w, uint32 h) { - int image_width, image_height; + uint32 image_width, image_height; uint32 *pixel, pixel_value; - int i, j, k; + uint32 i, j, k; DATA32 *buffer_pixel, *buffer = img->image->data; int alpha_premult; int a, r, g, b; @@ -408,7 +408,7 @@ save(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity) uint8 *buf = NULL; DATA32 pixel, *data = im->data; double alpha_factor; - uint32 x, y; + int x, y; uint8 r, g, b, a = 0; int has_alpha = IMAGE_HAS_ALPHA(im); int i = 0, pl = 0; @@ -579,27 +579,15 @@ save(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[] = { "tiff", "tif" }; - - /* 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]); - } + static const char *const list_formats[] = { "tiff", "tif" }; + 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_xpm.c b/src/modules/loaders/loader_xpm.c index 4a594d0..518ba36 100644 --- a/src/modules/loaders/loader_xpm.c +++ b/src/modules/loaders/loader_xpm.c @@ -102,7 +102,7 @@ load(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity, char *line, s[256], tok[256], col[256]; int lsz = 256; struct _cmap { - unsigned char str[6]; + char str[6]; unsigned char transp; short r, g, b; } *cmap; @@ -649,7 +649,7 @@ load(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity, lsz += 256; line = realloc(line, lsz); } - if (((ptr) && ((ptr - im->data) >= (w * h * sizeof(DATA32)))) || + if (((ptr) && ((ptr - im->data) >= (w * h * (int)sizeof(DATA32)))) || ((context > 1) && (count >= pixels))) done = 1; } @@ -668,27 +668,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[] = { "xpm" }; + static const char *const list_formats[] = { "xpm" }; + int i; - /* 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); - 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]); - } + for (i = 0; i < l->num_formats; i++) + l->formats[i] = strdup(list_formats[i]); } diff --git a/src/modules/loaders/loader_zlib.c b/src/modules/loaders/loader_zlib.c index 401ea0a..f15cf11 100644 --- a/src/modules/loaders/loader_zlib.c +++ b/src/modules/loaders/loader_zlib.c @@ -116,13 +116,9 @@ load(ImlibImage * im, ImlibProgressFunction progress, void formats(ImlibLoader * l) { - /* this is the only bit you have to change... */ - char *list_formats[] = { "gz" }; + static const char *const list_formats[] = { "gz" }; int i; - /* don't bother changing any of this - it just reads this in - * and sets the struct values and makes copies - */ l->num_formats = sizeof(list_formats) / sizeof(char *); l->formats = malloc(sizeof(char *) * l->num_formats); -- cgit v1.2.1