Cleaned up some minor bloat with my new evil GOTO_*_MACRO macros.
This commit is contained in:
parent
9f9800928d
commit
389a4d826a
|
@ -270,11 +270,7 @@ static void *GRP_openArchive(const char *name, int forWriting)
|
||||||
|
|
||||||
memset(info, '\0', sizeof (GRPinfo));
|
memset(info, '\0', sizeof (GRPinfo));
|
||||||
info->filename = (char *) malloc(strlen(name) + 1);
|
info->filename = (char *) malloc(strlen(name) + 1);
|
||||||
if (info->filename == NULL)
|
GOTO_IF_MACRO(!info->filename, ERR_OUT_OF_MEMORY, GRP_openArchive_failed);
|
||||||
{
|
|
||||||
__PHYSFS_setError(ERR_OUT_OF_MEMORY);
|
|
||||||
goto GRP_openArchive_failed;
|
|
||||||
} /* if */
|
|
||||||
|
|
||||||
if (!grp_load_entries(name, forWriting, info))
|
if (!grp_load_entries(name, forWriting, info))
|
||||||
goto GRP_openArchive_failed;
|
goto GRP_openArchive_failed;
|
||||||
|
|
|
@ -309,11 +309,7 @@ static void *HOG_openArchive(const char *name, int forWriting)
|
||||||
BAIL_IF_MACRO(info == NULL, ERR_OUT_OF_MEMORY, 0);
|
BAIL_IF_MACRO(info == NULL, ERR_OUT_OF_MEMORY, 0);
|
||||||
memset(info, '\0', sizeof (HOGinfo));
|
memset(info, '\0', sizeof (HOGinfo));
|
||||||
info->filename = (char *) malloc(strlen(name) + 1);
|
info->filename = (char *) malloc(strlen(name) + 1);
|
||||||
if (info->filename == NULL)
|
GOTO_IF_MACRO(!info->filename, ERR_OUT_OF_MEMORY, HOG_openArchive_failed);
|
||||||
{
|
|
||||||
__PHYSFS_setError(ERR_OUT_OF_MEMORY);
|
|
||||||
goto HOG_openArchive_failed;
|
|
||||||
} /* if */
|
|
||||||
|
|
||||||
if (!hog_load_entries(name, forWriting, info))
|
if (!hog_load_entries(name, forWriting, info))
|
||||||
goto HOG_openArchive_failed;
|
goto HOG_openArchive_failed;
|
||||||
|
|
|
@ -236,12 +236,8 @@ static void *MIX_openArchive(const char *name, int forWriting)
|
||||||
memset(info, '\0', sizeof (MIXinfo));
|
memset(info, '\0', sizeof (MIXinfo));
|
||||||
|
|
||||||
info->filename = (char *) malloc(strlen(name) + 1);
|
info->filename = (char *) malloc(strlen(name) + 1);
|
||||||
if (info->filename == NULL)
|
GOTO_IF_MACRO(!info->filename, ERR_OUT_OF_MEMORY, MIX_openArchive_failed);
|
||||||
{
|
|
||||||
__PHYSFS_setError(ERR_OUT_OF_MEMORY);
|
|
||||||
goto MIX_openArchive_failed;
|
|
||||||
} /* if */
|
|
||||||
|
|
||||||
/* store filename */
|
/* store filename */
|
||||||
strcpy(info->filename, name);
|
strcpy(info->filename, name);
|
||||||
|
|
||||||
|
@ -259,12 +255,8 @@ static void *MIX_openArchive(const char *name, int forWriting)
|
||||||
|
|
||||||
/* allocate space for the entries and read the entries */
|
/* allocate space for the entries and read the entries */
|
||||||
info->entry = malloc(sizeof (MIXentry) * info->header.num_files);
|
info->entry = malloc(sizeof (MIXentry) * info->header.num_files);
|
||||||
if (info->entry == NULL)
|
GOTO_IF_MACRO(!info->entry, ERR_OUT_OF_MEMORY, MIX_openArchive_failed);
|
||||||
{
|
|
||||||
__PHYSFS_setError(ERR_OUT_OF_MEMORY);
|
|
||||||
goto MIX_openArchive_failed;
|
|
||||||
} /* if */
|
|
||||||
|
|
||||||
/* read the directory list */
|
/* read the directory list */
|
||||||
for (i = 0; i < header.num_files; i++)
|
for (i = 0; i < header.num_files; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -268,12 +268,7 @@ static void *MVL_openArchive(const char *name, int forWriting)
|
||||||
memset(info, '\0', sizeof (MVLinfo));
|
memset(info, '\0', sizeof (MVLinfo));
|
||||||
|
|
||||||
info->filename = (char *) malloc(strlen(name) + 1);
|
info->filename = (char *) malloc(strlen(name) + 1);
|
||||||
if (info->filename == NULL)
|
GOTO_IF_MACRO(!info->filename, ERR_OUT_OF_MEMORY, MVL_openArchive_failed);
|
||||||
{
|
|
||||||
__PHYSFS_setError(ERR_OUT_OF_MEMORY);
|
|
||||||
goto MVL_openArchive_failed;
|
|
||||||
} /* if */
|
|
||||||
|
|
||||||
if (!mvl_load_entries(name, forWriting, info))
|
if (!mvl_load_entries(name, forWriting, info))
|
||||||
goto MVL_openArchive_failed;
|
goto MVL_openArchive_failed;
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ typedef struct
|
||||||
} QPAKfileinfo;
|
} QPAKfileinfo;
|
||||||
|
|
||||||
/* Magic numbers... */
|
/* Magic numbers... */
|
||||||
#define QPAK_SIGNATURE 0x4b434150 /* "PACK" in ASCII. */
|
#define QPAK_SIG 0x4b434150 /* "PACK" in ASCII. */
|
||||||
|
|
||||||
|
|
||||||
static void QPAK_dirClose(dvoid *opaque)
|
static void QPAK_dirClose(dvoid *opaque)
|
||||||
|
@ -175,11 +175,7 @@ static int qpak_open(const char *filename, int forWriting,
|
||||||
goto openQpak_failed;
|
goto openQpak_failed;
|
||||||
|
|
||||||
buf = PHYSFS_swapULE32(buf);
|
buf = PHYSFS_swapULE32(buf);
|
||||||
if (buf != QPAK_SIGNATURE)
|
GOTO_IF_MACRO(buf != QPAK_SIG, ERR_UNSUPPORTED_ARCHIVE, openQpak_failed);
|
||||||
{
|
|
||||||
__PHYSFS_setError(ERR_UNSUPPORTED_ARCHIVE);
|
|
||||||
goto openQpak_failed;
|
|
||||||
} /* if */
|
|
||||||
|
|
||||||
if (__PHYSFS_platformRead(*fh, &buf, sizeof (PHYSFS_uint32), 1) != 1)
|
if (__PHYSFS_platformRead(*fh, &buf, sizeof (PHYSFS_uint32), 1) != 1)
|
||||||
goto openQpak_failed;
|
goto openQpak_failed;
|
||||||
|
@ -191,11 +187,8 @@ static int qpak_open(const char *filename, int forWriting,
|
||||||
|
|
||||||
*count = PHYSFS_swapULE32(*count);
|
*count = PHYSFS_swapULE32(*count);
|
||||||
|
|
||||||
if ((*count % 64) != 0) /* corrupted archive? */
|
/* corrupted archive? */
|
||||||
{
|
GOTO_IF_MACRO((*count % 64) != 0, ERR_CORRUPTED, openQpak_failed);
|
||||||
__PHYSFS_setError(ERR_CORRUPTED);
|
|
||||||
goto openQpak_failed;
|
|
||||||
} /* if */
|
|
||||||
|
|
||||||
if (!__PHYSFS_platformSeek(*fh, buf))
|
if (!__PHYSFS_platformSeek(*fh, buf))
|
||||||
goto openQpak_failed;
|
goto openQpak_failed;
|
||||||
|
|
|
@ -298,11 +298,7 @@ static void *WAD_openArchive(const char *name, int forWriting)
|
||||||
memset(info, '\0', sizeof (WADinfo));
|
memset(info, '\0', sizeof (WADinfo));
|
||||||
|
|
||||||
info->filename = (char *) malloc(strlen(name) + 1);
|
info->filename = (char *) malloc(strlen(name) + 1);
|
||||||
if (info->filename == NULL)
|
GOTO_IF_MACRO(!info->filename, ERR_OUT_OF_MEMORY, WAD_openArchive_failed);
|
||||||
{
|
|
||||||
__PHYSFS_setError(ERR_OUT_OF_MEMORY);
|
|
||||||
goto WAD_openArchive_failed;
|
|
||||||
} /* if */
|
|
||||||
|
|
||||||
if (!wad_load_entries(name, forWriting, info))
|
if (!wad_load_entries(name, forWriting, info))
|
||||||
goto WAD_openArchive_failed;
|
goto WAD_openArchive_failed;
|
||||||
|
|
|
@ -219,11 +219,7 @@ void __PHYSFS_platformDetectAvailableCDs(PHYSFS_StringCallback cb, void *data)
|
||||||
struct mntent *ent = NULL;
|
struct mntent *ent = NULL;
|
||||||
|
|
||||||
mounts = setmntent("/etc/mtab", "r");
|
mounts = setmntent("/etc/mtab", "r");
|
||||||
if (mounts == NULL)
|
BAIL_IF_MACRO(mounts == NULL, ERR_IO_ERROR, /*return void*/);
|
||||||
{
|
|
||||||
__PHYSFS_setError(ERR_IO_ERROR);
|
|
||||||
return;
|
|
||||||
} /* if */
|
|
||||||
|
|
||||||
while ( (ent = getmntent(mounts)) != NULL )
|
while ( (ent = getmntent(mounts)) != NULL )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue