notaz.gp2x.de
/
picodrive.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
bugfix, fd leak
[picodrive.git]
/
Pico
/
Cart.c
diff --git
a/Pico/Cart.c
b/Pico/Cart.c
index
0762473
..
07ced8c
100644
(file)
--- a/
Pico/Cart.c
+++ b/
Pico/Cart.c
@@
-12,6
+12,7
@@
#include "../unzip/unzip.h"
\r
#include "../unzip/unzip_stream.h"
\r
\r
#include "../unzip/unzip.h"
\r
#include "../unzip/unzip_stream.h"
\r
\r
+
\r
static char *rom_exts[] = { "bin", "gen", "smd", "iso" };
\r
\r
\r
static char *rom_exts[] = { "bin", "gen", "smd", "iso" };
\r
\r
\r
@@
-78,6
+79,9
@@
zip_failed:
f = fopen(path, "rb");
\r
if (f == NULL) return NULL;
\r
\r
f = fopen(path, "rb");
\r
if (f == NULL) return NULL;
\r
\r
+ /* we use our own buffering */
\r
+ setvbuf(f, NULL, _IONBF, 0);
\r
+
\r
file = malloc(sizeof(*file));
\r
if (file == NULL) {
\r
fclose(f);
\r
file = malloc(sizeof(*file));
\r
if (file == NULL) {
\r
fclose(f);
\r
@@
-120,10
+124,16
@@
int pm_seek(pm_file *stream, long offset, int whence)
{
\r
if (stream->type == PMT_UNCOMPRESSED)
\r
{
\r
{
\r
if (stream->type == PMT_UNCOMPRESSED)
\r
{
\r
- return fseek(stream->file, offset, whence);
\r
+ fseek(stream->file, offset, whence);
\r
+ return ftell(stream->file);
\r
}
\r
else if (stream->type == PMT_ZIP)
\r
{
\r
}
\r
else if (stream->type == PMT_ZIP)
\r
{
\r
+ if (PicoMessage != NULL && offset > 6*1024*1024) {
\r
+ long pos = gztell((gzFile) stream->param);
\r
+ if (offset < pos || offset - pos > 6*1024*1024)
\r
+ PicoMessage("Decompressing data...");
\r
+ }
\r
return gzseek((gzFile) stream->param, offset, whence);
\r
}
\r
else
\r
return gzseek((gzFile) stream->param, offset, whence);
\r
}
\r
else
\r
@@
-243,7
+253,10
@@
int PicoCartLoad(pm_file *f,unsigned char **prom,unsigned int *psize)
\r
// Allocate space for the rom plus padding
\r
rom=PicoCartAlloc(size);
\r
\r
// Allocate space for the rom plus padding
\r
rom=PicoCartAlloc(size);
\r
- if (rom==NULL) return 1; // { fclose(f); return 1; }
\r
+ if (rom==NULL) {
\r
+ printf("out of memory (wanted %i)\n", size);
\r
+ return 1;
\r
+ }
\r
\r
pm_read(rom,size,f); // Load up the rom
\r
\r
\r
pm_read(rom,size,f); // Load up the rom
\r
\r