More FIXME cleanup.
This commit is contained in:
parent
b2e6882f52
commit
24aef83ead
|
@ -37,7 +37,6 @@ From old TODO.txt...
|
||||||
important, since streaming archives aren't of much value to games (which
|
important, since streaming archives aren't of much value to games (which
|
||||||
is why zipfiles are king: random access), but it could have uses for, say,
|
is why zipfiles are king: random access), but it could have uses for, say,
|
||||||
an installer/updater.
|
an installer/updater.
|
||||||
- Reduce malloc() pressure all over the place. We fragment memory like mad.
|
|
||||||
- profile string list interpolation.
|
- profile string list interpolation.
|
||||||
- We have two different ways to find dir entries in zip.c.
|
- We have two different ways to find dir entries in zip.c.
|
||||||
- Do symlinks in zip archiver work when they point to dirs?
|
- Do symlinks in zip archiver work when they point to dirs?
|
||||||
|
|
|
@ -333,28 +333,27 @@ static PHYSFS_Io *ZIP_duplicate(PHYSFS_Io *io)
|
||||||
ZIPfileinfo *origfinfo = (ZIPfileinfo *) io->opaque;
|
ZIPfileinfo *origfinfo = (ZIPfileinfo *) io->opaque;
|
||||||
PHYSFS_Io *retval = (PHYSFS_Io *) allocator.Malloc(sizeof (PHYSFS_Io));
|
PHYSFS_Io *retval = (PHYSFS_Io *) allocator.Malloc(sizeof (PHYSFS_Io));
|
||||||
ZIPfileinfo *finfo = (ZIPfileinfo *) allocator.Malloc(sizeof (ZIPfileinfo));
|
ZIPfileinfo *finfo = (ZIPfileinfo *) allocator.Malloc(sizeof (ZIPfileinfo));
|
||||||
GOTO_IF_MACRO(!retval, PHYSFS_ERR_OUT_OF_MEMORY, ZIP_duplicate_failed);
|
GOTO_IF_MACRO(!retval, PHYSFS_ERR_OUT_OF_MEMORY, failed);
|
||||||
GOTO_IF_MACRO(!finfo, PHYSFS_ERR_OUT_OF_MEMORY, ZIP_duplicate_failed);
|
GOTO_IF_MACRO(!finfo, PHYSFS_ERR_OUT_OF_MEMORY, failed);
|
||||||
memset(finfo, '\0', sizeof (*finfo));
|
memset(finfo, '\0', sizeof (*finfo));
|
||||||
|
|
||||||
finfo->entry = origfinfo->entry;
|
finfo->entry = origfinfo->entry;
|
||||||
finfo->io = zip_get_io(origfinfo->io, NULL, finfo->entry);
|
finfo->io = zip_get_io(origfinfo->io, NULL, finfo->entry);
|
||||||
GOTO_IF_MACRO(!finfo->io, ERRPASS, ZIP_duplicate_failed);
|
GOTO_IF_MACRO(!finfo->io, ERRPASS, failed);
|
||||||
|
|
||||||
if (finfo->entry->compression_method != COMPMETH_NONE)
|
if (finfo->entry->compression_method != COMPMETH_NONE)
|
||||||
{
|
{
|
||||||
finfo->buffer = (PHYSFS_uint8 *) allocator.Malloc(ZIP_READBUFSIZE);
|
finfo->buffer = (PHYSFS_uint8 *) allocator.Malloc(ZIP_READBUFSIZE);
|
||||||
if (!finfo->buffer)
|
GOTO_IF_MACRO(!finfo->buffer, PHYSFS_ERR_OUT_OF_MEMORY, failed);
|
||||||
GOTO_MACRO(PHYSFS_ERR_OUT_OF_MEMORY, ZIP_duplicate_failed);
|
if (zlib_err(inflateInit2(&finfo->stream, -MAX_WBITS)) != Z_OK)
|
||||||
else if (zlib_err(inflateInit2(&finfo->stream, -MAX_WBITS)) != Z_OK)
|
goto failed;
|
||||||
goto ZIP_duplicate_failed;
|
|
||||||
} /* if */
|
} /* if */
|
||||||
|
|
||||||
memcpy(retval, io, sizeof (PHYSFS_Io));
|
memcpy(retval, io, sizeof (PHYSFS_Io));
|
||||||
retval->opaque = finfo;
|
retval->opaque = finfo;
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
ZIP_duplicate_failed:
|
failed:
|
||||||
if (finfo != NULL)
|
if (finfo != NULL)
|
||||||
{
|
{
|
||||||
if (finfo->io != NULL)
|
if (finfo->io != NULL)
|
||||||
|
@ -671,8 +670,7 @@ static int zip_resolve(PHYSFS_Io *io, ZIPinfo *info, ZIPentry *entry);
|
||||||
* Look for the entry named by (path). If it exists, resolve it, and return
|
* Look for the entry named by (path). If it exists, resolve it, and return
|
||||||
* a pointer to that entry. If it's another symlink, keep resolving until you
|
* a pointer to that entry. If it's another symlink, keep resolving until you
|
||||||
* hit a real file and then return a pointer to the final non-symlink entry.
|
* hit a real file and then return a pointer to the final non-symlink entry.
|
||||||
* If there's a problem, return NULL. (path) is always free()'d by this
|
* If there's a problem, return NULL.
|
||||||
* function.
|
|
||||||
*/
|
*/
|
||||||
static ZIPentry *zip_follow_symlink(PHYSFS_Io *io, ZIPinfo *info, char *path)
|
static ZIPentry *zip_follow_symlink(PHYSFS_Io *io, ZIPinfo *info, char *path)
|
||||||
{
|
{
|
||||||
|
@ -691,15 +689,14 @@ static ZIPentry *zip_follow_symlink(PHYSFS_Io *io, ZIPinfo *info, char *path)
|
||||||
} /* else */
|
} /* else */
|
||||||
} /* if */
|
} /* if */
|
||||||
|
|
||||||
allocator.Free(path);
|
|
||||||
return entry;
|
return entry;
|
||||||
} /* zip_follow_symlink */
|
} /* zip_follow_symlink */
|
||||||
|
|
||||||
|
|
||||||
static int zip_resolve_symlink(PHYSFS_Io *io, ZIPinfo *info, ZIPentry *entry)
|
static int zip_resolve_symlink(PHYSFS_Io *io, ZIPinfo *info, ZIPentry *entry)
|
||||||
{
|
{
|
||||||
char *path;
|
|
||||||
const PHYSFS_uint32 size = entry->uncompressed_size;
|
const PHYSFS_uint32 size = entry->uncompressed_size;
|
||||||
|
char *path = NULL;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -710,8 +707,8 @@ static int zip_resolve_symlink(PHYSFS_Io *io, ZIPinfo *info, ZIPentry *entry)
|
||||||
|
|
||||||
BAIL_IF_MACRO(!io->seek(io, entry->offset), ERRPASS, 0);
|
BAIL_IF_MACRO(!io->seek(io, entry->offset), ERRPASS, 0);
|
||||||
|
|
||||||
path = (char *) allocator.Malloc(size + 1);
|
path = (char *) __PHYSFS_smallAlloc(size + 1);
|
||||||
BAIL_IF_MACRO(path == NULL, PHYSFS_ERR_OUT_OF_MEMORY, 0);
|
BAIL_IF_MACRO(!path, PHYSFS_ERR_OUT_OF_MEMORY, 0);
|
||||||
|
|
||||||
if (entry->compression_method == COMPMETH_NONE)
|
if (entry->compression_method == COMPMETH_NONE)
|
||||||
rc = __PHYSFS_readAll(io, path, size);
|
rc = __PHYSFS_readAll(io, path, size);
|
||||||
|
@ -743,15 +740,15 @@ static int zip_resolve_symlink(PHYSFS_Io *io, ZIPinfo *info, ZIPentry *entry)
|
||||||
} /* if */
|
} /* if */
|
||||||
} /* else */
|
} /* else */
|
||||||
|
|
||||||
if (!rc)
|
if (rc)
|
||||||
allocator.Free(path);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
path[entry->uncompressed_size] = '\0'; /* null-terminate it. */
|
path[entry->uncompressed_size] = '\0'; /* null-terminate it. */
|
||||||
zip_convert_dos_path(entry, path);
|
zip_convert_dos_path(entry, path);
|
||||||
entry->symlink = zip_follow_symlink(io, info, path);
|
entry->symlink = zip_follow_symlink(io, info, path);
|
||||||
} /* else */
|
} /* else */
|
||||||
|
|
||||||
|
__PHYSFS_smallFree(path);
|
||||||
|
|
||||||
return (entry->symlink != NULL);
|
return (entry->symlink != NULL);
|
||||||
} /* zip_resolve_symlink */
|
} /* zip_resolve_symlink */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue