📄 memsrc.cpp
字号:
// memsrc.cc// code for memsrc.h// copyright SafeTP Development Group, Inc., 2000 Terms of use are as specified in license.txt#include "memsrc.h" // this module#include <string.h> // memcpy#include "xassert.h" // xassert#include "typ.h" // SELFCHECK, min//#define min(a,b) ((a)<(b)?(a):(b))MemoryInputSource::MemoryInputSource(char const *D, int L) : data(D), dataLen(L), next(D){ selfCheck(); // check ctor arguments}// check invariantsvoid MemoryInputSource::selfCheck() const{ xassert(data != NULL && dataLen >= 0 && 0 <= (next-data) && (next-data) <= dataLen);}int MemoryInputSource::read(char *buffer, int bufLen){ SELFCHECK(); // compute # of bytes to copy int rem = remaining(); int supply = mymin(rem, bufLen); // copy bytes if (supply > 0) { memcpy(buffer, next, supply); // consume bytes next += supply; } SELFCHECK(); return supply;}int MemoryInputSource::remaining() const{ return dataLen - (next-data);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -