⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mcio.cpp

📁 非常好用的五子棋游戏源码
💻 CPP
字号:
// 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;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -