Index: src/OFDataArray.m ================================================================== --- src/OFDataArray.m +++ src/OFDataArray.m @@ -18,12 +18,15 @@ #import "OFDataArray.h" #import "OFExceptions.h" #import "OFMacros.h" -static size_t lastpagebyte = 0; -extern int getpagesize(void); +#ifdef _WIN32 +#include +#endif + +static int lastpagebyte = 0; @implementation OFDataArray + dataArrayWithItemSize: (size_t)is { return [[[self alloc] initWithItemSize: is] autorelease]; @@ -185,12 +188,21 @@ @implementation OFBigDataArray - initWithItemSize: (size_t)is { self = [super initWithItemSize: is]; - if (lastpagebyte == 0) - lastpagebyte = getpagesize() - 1; + if (lastpagebyte == 0) { +#ifndef _WIN32 + if ((lastpagebyte = sysconf(_SC_PAGESIZE)) == -1) + lastpagebyte = 4096; + lastpagebyte--; +#else + SYSTEM_INFO si; + GetSystemInfo(&si); + lastpagebyte = si.dwPageSize - 1; +#endif + } return self; } - addItem: (void*)item Index: src/OFStream.m ================================================================== --- src/OFStream.m +++ src/OFStream.m @@ -16,18 +16,34 @@ #import "OFStream.h" #import "OFExceptions.h" #import "OFMacros.h" -extern int getpagesize(void); +#ifdef _WIN32 +#include +#endif + +static int pagesize = 0; @implementation OFStream - init { self = [super init]; cache = NULL; + +#ifndef _WIN32 + if (pagesize == 0) + if ((pagesize = sysconf(_SC_PAGESIZE)) == -1) + pagesize = 4096; +#else + if (pagesize == 0) { + SYSTEM_INFO si; + GetSystemInfo(&si); + pagesize = si.dwPageSize - 1; + } +#endif return self; } - (size_t)readNBytes: (size_t)size @@ -75,15 +91,15 @@ } } } /* Read until we get a newline or \0 */ - tmp = [self allocWithSize: getpagesize()]; + tmp = [self allocWithSize: pagesize]; for (;;) { @try { - len = [self readNBytes: getpagesize() - 1 + len = [self readNBytes: pagesize - 1 intoBuffer: tmp]; } @catch (OFException *e) { [self freeMem: tmp]; @throw e; }