?? mcio.cpp
字號(hào):
// Created:10-04-98
// By Jeff Connelly
// Memory I/O for ComprLib
#include "stdafx.h"
#include <string.h>
#include <stdlib.h>
//#include "mcio.h"
#define EXPORTING
#include "comprlib.h"
// Static members initalization
char* ComprLibMemIO::source_ptr = NULL;
char* ComprLibMemIO::dest_ptr = NULL;
long ComprLibMemIO::source_len = 0;
long ComprLibMemIO::dest_len = 0;
long ComprLibMemIO::source_pos = 0;
long ComprLibMemIO::dest_pos = 0;
long ComprLibMemIO::grow_by = 1024; // Increment in 1K
// End of input data?
bool ComprLibMemIO::end_of_data()
{
if (source_pos >= source_len)
return true;
return false;
}
// Size of input stream
long ComprLibMemIO::stream_size()
{
return source_len;
}
// Read a byte from input memory
unsigned char ComprLibMemIO::read_byte()
{
unsigned char c;
if (end_of_data())
return 0;
c = *(source_ptr + source_pos);
++source_pos;
return c;
}
// Write a byte to memory
void ComprLibMemIO::write_byte(unsigned char byte)
{
// Reallocate the memory until we have enough
while (dest_pos >= dest_len)
dest_ptr = (char*)
realloc(dest_ptr, dest_len += grow_by);
*(dest_ptr + dest_pos) = byte;
++dest_pos;
}
// Reset the input position to the beginning
void ComprLibMemIO::beginning_of_data()
{
source_pos = 0;
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -