ref: a79a9725a9ed45f80d0c9ecf6fc1697219937dd9
parent: d8784727e4b117e77c9cf4ff609dace2c4d1da24
author: Chris Moeller <kode54@gmail.com>
date: Mon Jan 14 14:26:42 EST 2013
Fixes for C89 limitations and some const types
--- a/dumb/include/dumb.h
+++ b/dumb/include/dumb.h
@@ -170,7 +170,7 @@
void register_dumbfile_system(const DUMBFILE_SYSTEM *dfs);
DUMBFILE *dumbfile_open(const char *filename);
-DUMBFILE *dumbfile_open_ex(void *file, DUMBFILE_SYSTEM *dfs);
+DUMBFILE *dumbfile_open_ex(void *file, const DUMBFILE_SYSTEM *dfs);
long dumbfile_pos(DUMBFILE *f);
int dumbfile_skip(DUMBFILE *f, long n);
--- a/dumb/src/core/dumbfile.c
+++ b/dumb/src/core/dumbfile.c
@@ -23,7 +23,7 @@
-static DUMBFILE_SYSTEM *the_dfs = NULL;
+static const DUMBFILE_SYSTEM *the_dfs = NULL;
@@ -42,7 +42,7 @@
struct DUMBFILE
{
- DUMBFILE_SYSTEM *dfs;
+ const DUMBFILE_SYSTEM *dfs;
void *file;
long pos;
};
@@ -55,7 +55,7 @@
ASSERT(the_dfs);
- f = malloc(sizeof(*f));
+ f = (DUMBFILE *) malloc(sizeof(*f));
if (!f)
return NULL;
@@ -76,7 +76,7 @@
-DUMBFILE *dumbfile_open_ex(void *file, DUMBFILE_SYSTEM *dfs)
+DUMBFILE *dumbfile_open_ex(void *file, const DUMBFILE_SYSTEM *dfs)
{
DUMBFILE *f;
@@ -84,7 +84,7 @@
ASSERT(dfs->getc);
ASSERT(file);
- f = malloc(sizeof(*f));
+ f = (DUMBFILE *) malloc(sizeof(*f));
if (!f) {
if (dfs->close)
--- a/dumb/src/helpers/stdfile.c
+++ b/dumb/src/helpers/stdfile.c
@@ -134,12 +134,13 @@
DUMBFILE *dumbfile_open_stdfile(FILE *p)
{
dumb_stdfile * file = ( dumb_stdfile * ) malloc( sizeof(dumb_stdfile) );
+ DUMBFILE *d;
if ( !file ) return 0;
file->file = p;
fseek(p, 0, SEEK_END);
file->size = ftell(p);
fseek(p, 0, SEEK_SET);
- DUMBFILE *d = dumbfile_open_ex(file, &stdfile_dfs_leave_open);
+ d = dumbfile_open_ex(file, &stdfile_dfs_leave_open);
return d;
}