diff --git a/Source/DOH/Doh/Makefile b/Source/DOH/Doh/Makefile index 751ce0257..554a2c09d 100644 --- a/Source/DOH/Doh/Makefile +++ b/Source/DOH/Doh/Makefile @@ -9,8 +9,8 @@ # Set your C++ compiler here. g++ works on most machines, # but you might have to change it depending on your installation. # -CC = gcc -prefix = /home/beazley/Projects +CC = cc +prefix = /usr/local # Comment out the following line if you're on an SGI or don't have ranlib! RANLIB = ranlib diff --git a/Source/DOH/Doh/file.c b/Source/DOH/Doh/file.c index 4094063e6..c9efd6167 100644 --- a/Source/DOH/Doh/file.c +++ b/Source/DOH/Doh/file.c @@ -172,9 +172,9 @@ int File_read(DOH *so, void *buffer, int len) { File *s = (File *) so; if (s->filep) - return (size_t) fread(buffer,1,len,s->filep); + return fread(buffer,1,len,s->filep); else - return (size_t) read(s->fd,buffer,len); + return read(s->fd,buffer,len); } /* ----------------------------------------------------------------------------- @@ -186,9 +186,9 @@ int File_write(DOH *so, void *buffer, int len) { File *s = (File *) so; if (s->filep) - return (size_t) fwrite(buffer,1,len,s->filep); + return fwrite(buffer,1,len,s->filep); else - return (size_t) write(s->fd,buffer,len); + return write(s->fd, buffer, len); } /* ----------------------------------------------------------------------------- diff --git a/Source/DOH/Doh/fio.c b/Source/DOH/Doh/fio.c index 0d4133799..d58244ac0 100644 --- a/Source/DOH/Doh/fio.c +++ b/Source/DOH/Doh/fio.c @@ -324,7 +324,7 @@ int DohCopyto(DOH *in, DOH *out) { cw = buffer; while (nwrite) { wret = Write(out,cw,nwrite); - if (wret < 0) return nbytes; + if (wret < 0) return -1; nwrite = nwrite - wret; cw += wret; } diff --git a/Source/DOH/Doh/list.c b/Source/DOH/Doh/list.c index 0a9256646..bfd6d2591 100644 --- a/Source/DOH/Doh/list.c +++ b/Source/DOH/Doh/list.c @@ -343,7 +343,7 @@ List_dump(DOH *lo, DOH *out) { List *l = (List *) lo; for (i = 0; i < l->nitems; i++) { ret = Dump(l->items[i],out); - if (ret < 0) return -1; + if (ret < 0) ret; nsent += ret; } return nsent; diff --git a/Source/DOH/Doh/memory.c b/Source/DOH/Doh/memory.c index b6354d1af..58a210e76 100644 --- a/Source/DOH/Doh/memory.c +++ b/Source/DOH/Doh/memory.c @@ -23,8 +23,9 @@ #define DOH_MAX_FRAG 1024 #endif -int _DohMemoryCurrent = 0; -int _DohMemoryHigh = 0; +static int _DohMemoryCurrent = 0; +static int _DohMemoryHigh = 0; +static int _PoolSize = DOH_POOL_SIZE; /* ----------------------------------------------------------------------------- * memory.c @@ -84,7 +85,7 @@ static void InitPools() { for (i = 0; i < DOH_MAX_FRAG; i++) { FreeFragments[i] = 0; } - Pools = CreatePool(DOH_POOL_SIZE); /* Create initial pool */ + Pools = CreatePool(_PoolSize); /* Create initial pool */ pools_initialized = 1; } @@ -163,7 +164,7 @@ void *DohObjMalloc(size_t size) { f->next = FreeFragments[f->len]; FreeFragments[f->len] = f; } - p = CreatePool(DOH_POOL_SIZE); + p = CreatePool(_PoolSize); p->next = Pools; Pools = p; return DohObjMalloc(size); @@ -260,3 +261,12 @@ int DohMemoryUse() { int DohMemoryHigh() { return _DohMemoryHigh; } + +int DohPoolSize(int poolsize) { + int ps; + ps = _PoolSize; + if (poolsize > 0) { + _PoolSize = poolsize; + } + return ps; +} diff --git a/Source/DOH/Include/doh.h b/Source/DOH/Include/doh.h index 1901ca58f..d02bb5853 100644 --- a/Source/DOH/Include/doh.h +++ b/Source/DOH/Include/doh.h @@ -29,9 +29,6 @@ #define DOH_MAJOR_VERSION 0 #define DOH_MINOR_VERSION 1 -extern int _DohMemoryCurrent; -extern int _DohMemoryHigh; - typedef void DOH; #define DOH_BEGIN -1 @@ -124,6 +121,7 @@ extern int DohCheck(DOH *ptr); extern int DohFreeCheck(DOH *ptr); extern int DohMemoryUse(); extern int DohMemoryHigh(); +extern int DohPoolSize(int); /* Low-level doh methods. Do not call directly (well, unless you want to). */ extern void DohError(int level, char *fmt,...);