diff --git a/src/libImaging/Mode.h b/src/libImaging/Mode.h index cedad1e03..09810b584 100644 --- a/src/libImaging/Mode.h +++ b/src/libImaging/Mode.h @@ -2,10 +2,6 @@ #define __MODE_H__ -// Maximum length (including null terminator) for both mode and rawmode names. -#define IMAGING_MODE_LENGTH 6+1 - - typedef struct { const char * const name; } Mode; diff --git a/src/libImaging/Palette.c b/src/libImaging/Palette.c index 78916bca5..6b4fea6a5 100644 --- a/src/libImaging/Palette.c +++ b/src/libImaging/Palette.c @@ -21,13 +21,13 @@ #include ImagingPalette -ImagingPaletteNew(const char *mode) { +ImagingPaletteNew(const Mode *mode) { /* Create a palette object */ int i; ImagingPalette palette; - if (strcmp(mode, "RGB") && strcmp(mode, "RGBA")) { + if (mode != IMAGING_MODE_RGB && mode != IMAGING_MODE_RGBA) { return (ImagingPalette)ImagingError_ModeError(); } @@ -36,8 +36,7 @@ ImagingPaletteNew(const char *mode) { return (ImagingPalette)ImagingError_MemoryError(); } - strncpy(palette->mode, mode, IMAGING_MODE_LENGTH - 1); - palette->mode[IMAGING_MODE_LENGTH - 1] = 0; + palette->mode = mode; palette->size = 0; for (i = 0; i < 256; i++) { @@ -54,7 +53,7 @@ ImagingPaletteNewBrowser(void) { int i, r, g, b; ImagingPalette palette; - palette = ImagingPaletteNew("RGB"); + palette = ImagingPaletteNew(IMAGING_MODE_RGB); if (!palette) { return NULL; }