📄 mtest.cpp
字号:
// Created:11-13-98
// By Jeff Connelly
// Memory test
#include "comprlib.h"
#include <stdio.h>
#include <stdio.h>
// Note: 'xmalloc', and 'xfree' are like 'malloc' and 'free' respectivily,
// except 'xmalloc' terminates the program with an error if it cannot
// allocate memory, and 'xfree' handles null-pointers safely.
// 'xmalloc' and 'xfree' are NOT declared in STDLIB.H (read the
// comments) so if you get an "implict declaration of" error, ignore
// it.
int main(int argc, char* argv[])
{
int i;
char* buf;
ComprLibMemIO::Set();
printf ("Encoding...\n");
ComprLibMemIO::source_ptr = (char*)xmalloc(5);
ComprLibMemIO::source_len = 5;
ComprLibMemIO::dest_ptr = (char*)xmalloc(1);
ComprLibMemIO::dest_len = 1;
strcpy (ComprLibMemIO::source_ptr, "test!");
lzss_encode();
printf ("Decoding...\n");
ComprLibMemIO::Swap();
lzss_decode();
*(ComprLibMemIO::dest_ptr + ComprLibMemIO::dest_len) = 0;
printf ("Decoded as: %s\n", ComprLibMemIO::dest_ptr);
printf ("Ratio: %d / %d = %g%%\n", ComprLibMemIO::dest_len,
ComprLibMemIO::source_len,
((double)ComprLibMemIO::dest_len /
(double)ComprLibMemIO::source_len)
* 100);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -