added debugging codes.

This commit is contained in:
PyYoshi 2012-09-19 19:14:49 +09:00
parent dbf96f6f55
commit ea5a35d137
2 changed files with 57 additions and 0 deletions

View file

@ -0,0 +1,49 @@
#include "memory_leak.h"
#include "charsetdetect.h"
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
#define BUFFER_SIZE 100*1024
void main(){
::_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
csd_t csd = csd_open();
if(csd == (csd_t)-1){
std::cout << "csd_open faild\n";
exit(1);
}
//ifstream ifs("E:\\MySourcecode\\git\\cchardet\\test\\testdata\\bg\\ISO-8859-5\\wikitop_bg_ISO-8859-5.txt");
//ifstream ifs("E:\\MySourcecode\\git\\cchardet\\test\\testdata\\bg\\UTF-8\\wikitop_bg_UTF-8.txt");
ifstream ifs("E:\\MySourcecode\\git\\cchardet\\test\\testdata\\cz\\ISO-8859-2\\wikitop_cz_ISO-8859-2.txt");
if(!ifs){
std::cerr<<"Cant open the file\n";
exit(1);
}
int len;
ifs.seekg(0,std::ios::end);
len = ifs.tellg();
ifs.seekg(0,std::ios::beg);
char* buf = new char[len];
ifs.read(buf,len);
int result;
const char *result_;
std::cout<<"CLIENT SENDING More Data\n";
result = csd_consider(csd, buf,len);
if(result < 0){
std::cout<<"csd_consider failed\n";
exit(1);
}
result_ = csd_close(csd);
if(result_ == NULL){
std::cout<<"Unknown character set\n";
}else{
printf("%s\n", result_);
}
delete buf;
}

View file

@ -0,0 +1,8 @@
#ifndef MEMORY_LEAK_H
#define MEMORY_LEAK_H
#define _CRTDBG_MAP_ALLOC
#include <crtdbg.h>
#ifdef _DEBUG
#define new new(_NORMAL_BLOCK,__FILE__,__LINE__)
#endif
#endif