IMG.c
changeset 7 e1b6443ffb6b
parent 4 b1bb33e907f8
child 11 b3d1b573a542
     1.1 --- a/IMG.c	Fri Nov 17 21:42:53 2000 +0000
     1.2 +++ b/IMG.c	Wed Nov 29 11:55:32 2000 +0000
     1.3 @@ -30,6 +30,8 @@
     1.4  
     1.5  #include "SDL_image.h"
     1.6  
     1.7 +#define ARRAYSIZE(a) (sizeof(a) / sizeof((a)[0]))
     1.8 +
     1.9  /* Table of image detection and loading functions */
    1.10  static struct {
    1.11  	char *type;
    1.12 @@ -40,11 +42,12 @@
    1.13  	{ "TGA", NULL,      IMG_LoadTGA_RW },
    1.14  	{ "BMP", IMG_isBMP, IMG_LoadBMP_RW },
    1.15  	{ "PPM", IMG_isPPM, IMG_LoadPPM_RW },
    1.16 +	{ "XPM", IMG_isXPM, IMG_LoadXPM_RW },
    1.17  	{ "PCX", IMG_isPCX, IMG_LoadPCX_RW },
    1.18  	{ "GIF", IMG_isGIF, IMG_LoadGIF_RW },
    1.19  	{ "JPG", IMG_isJPG, IMG_LoadJPG_RW },
    1.20  	{ "TIF", IMG_isTIF, IMG_LoadTIF_RW },
    1.21 -	{ "PNG", IMG_isPNG, IMG_LoadPNG_RW },
    1.22 +	{ "PNG", IMG_isPNG, IMG_LoadPNG_RW }
    1.23  };
    1.24  
    1.25  /* Load an image from a file */
    1.26 @@ -96,7 +99,7 @@
    1.27  	/* Detect the type of image being loaded */
    1.28  	start = SDL_RWtell(src);
    1.29  	image = NULL;
    1.30 -	for ( i=0; supported[i].type && !image; ++i ) {
    1.31 +	for ( i=0; i < ARRAYSIZE(supported) && !image; ++i ) {
    1.32  	        if( (supported[i].is
    1.33  		     && (SDL_RWseek(src, start, SEEK_SET),
    1.34  			 supported[i].is(src)))