// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: mmap.cc,v 1.15 1999/04/18 06:36:36 jgg Exp $
+// $Id: mmap.cc,v 1.20 1999/10/02 04:14:54 jgg Exp $
/* ######################################################################
MMap Class - Provides 'real' mmap or a faked mmap using read().
#ifdef _POSIX_SYNCHRONIZED_IO
if ((Flags & ReadOnly) != ReadOnly)
if (msync((char *)Base,iSize,MS_SYNC) != 0)
- return _error->Error("msync","Unable to write mmap");
+ return _error->Errno("msync","Unable to write mmap");
#endif
return true;
}
unsigned long PSize = sysconf(_SC_PAGESIZE);
if ((Flags & ReadOnly) != ReadOnly)
if (msync((char *)Base+(int)(Start/PSize)*PSize,Stop - Start,MS_SYNC) != 0)
- return _error->Error("msync","Unable to write mmap");
+ return _error->Errno("msync","Unable to write mmap");
#endif
return true;
}
_error->Error("Dynamic MMap ran out of room");
return 0;
}
+
return Result;
}
/*}}}*/
I->Count--;
unsigned long Result = I->Start;
- I->Start += ItemSize;
+ I->Start += ItemSize;
return Result/ItemSize;
}
/*}}}*/
{
unsigned long Result = iSize;
// Just in case error check
- if (Result > WorkSpace)
+ if (Result + Len > WorkSpace)
{
_error->Error("Dynamic MMap ran out of room");
return 0;
}
- if (Len == 0)
+ if (Len == (unsigned long)-1)
Len = strlen(String);
iSize += Len + 1;
memcpy((char *)Base + Result,String,Len);