4.0读取csv的卡机问题

个人水平有限,引擎升级以后,原来的游戏频繁出现卡机问题,
错误显示

引发了异常: 读取访问权限冲突。
this->_vertexbuffer->**** 是 0xdddddddd。

查找原因最后锁定在csv->getData(xx, xx);
因为每次对白都要去在csv里寻找对白内容,现在问题是固定说几十句以后就会在固定的位置死机,请问如何解决,卡了很久,十分感谢

每一次开始的对话位置不同,死机的位置也不同,但同一个对话位置肯定到同一个地方死机,不知道如何改正

最好提供下demo

		sText = gk->csv_plot->getData(csv_h_num, gk->plot_text_contents);//只有这个有问题,下面的全都没有错误

gk->csv_plot的函数为

CSVReader::CSVReader()
:m_seperator(",")
, m_colLength(0)
{

}

CSVReader::~CSVReader()
{

}

#pragma region reselove the content begin…

bool CSVReader::openAndResolveFile(const char fileName)
{
std::string pathKey = FileUtils::getInstance()->fullPathForFilename(fileName);
unsigned char
pBuffer = NULL;
ssize_t bufferSize = 0;

Data data_gk = FileUtils::getInstance()->getDataFromFile(pathKey.c_str());
pBuffer = data_gk.takeBuffer(&bufferSize);


std::string tmpStr = (char*)pBuffer;
std::string fileContent = tmpStr.substr(0, bufferSize);

std::vector<std::string> line;
rowSplit(line, fileContent, '\n');
for (unsigned int i = 0; i < line.size(); ++i) {
	std::vector<std::string> fieldVector;
	fieldSplit(fieldVector, line[i]);
	data.push_back(fieldVector);
	m_colLength = std::max(m_colLength, (int)fieldVector.size());
}

return true;

}

void CSVReader::rowSplit(std::vectorstd::string &rows, const std::string &content, const char &rowSeperator)
{
std::string::size_type lastIndex = content.find_first_not_of(rowSeperator, 0);
std::string::size_type currentIndex = content.find_first_of(rowSeperator, lastIndex);

while (std::string::npos != currentIndex || std::string::npos != lastIndex) {
	rows.push_back(content.substr(lastIndex, currentIndex - lastIndex));
	lastIndex = content.find_first_not_of(rowSeperator, currentIndex);
	currentIndex = content.find_first_of(rowSeperator, lastIndex);
}

}

//内容划分成带引号和不带引号两种
void CSVReader::fieldSplit(std::vectorstd::string &fields, std::string line)
{
if (line[line.length() - 1] == ‘\r’) {
line = line.substr(0, line.length() - 1);
}

std::string field;
unsigned int i = 0, j = 0;
while (j < line.length()) {
	if (line[i] == '"') {
		//有引号
		j = getFieldWithQuoted(line, field, i);
	}
	else {
		j = getFieldNoQuoted(line, field, i);
	}

	fields.push_back(field);
	i = j + 1; //解析下一个field, +1为了跳过当前的分隔符
}

}

int CSVReader::getFieldWithQuoted(const std::string &line, std::string &field, int i)
{
unsigned int j = 0;
field = std::string();
if (line[i] != ‘"’) {
//不是引号起始,有问题
CCLOGERROR(“start char is not quote when call %s”, FUNCTION);
return -1;
}

for (j = i + 1; j < line.length() - 1; ++j) {
	if (line[j] != '"') {
		//当前char不为引号,则是field内容(包括逗号)
		field += line[j];
	}
	else {
		//遇到field结束时的引号,可以返回
		return j;
		break;
	}
}

if (j == line.length()) {
	//没有找到成对的结束引号
	CCLOGERROR("resoleve the line error: no pair quote, line:%s, field:%s, start index:%d", line.c_str(), field.c_str(), i);
}

return j;

}

int CSVReader::getFieldNoQuoted(const std::string &line, std::string &field, int index)
{
unsigned int j = 0;
//找到下一个分隔符位置
j = line.find_first_of(m_seperator, index);
if (j > line.length()) {
j = line.length();
}

field = std::string(line, index, j - index);

return j;

}

#pragma region end.

///////search data
const char *CSVReader::getData(unsigned int rowIndex, unsigned int colIndex)
{
if (rowIndex >= getRowLength() || colIndex >= getColLength()) {
return “”;
}

if (colIndex >= data[rowIndex].size()) {
	return "";
}

return data[rowIndex][colIndex].c_str();//utf8

}

demo的意思是能让我调试的小工程:joy:这看代码脑仁看疼

我发现以前CsvReader我一直用的是下面的语句
   unsigned char* pBuffer = NULL;
ssize_t bufferSize = 0;
pBuffer = FileUtils::getInstance()->getFileData(pathKey.c_str(), "rb", &bufferSize);

    4.0以后上面的不能用了,我改成了这样,然后不停的读对白的时候就会报错,下面这里是我哪里改错了吗?
unsigned char* pBuffer = NULL;
ssize_t bufferSize = 0;
Data data_gk = FileUtils::getInstance()->getDataFromFile(pathKey.c_str());
pBuffer = data_gk.takeBuffer(&bufferSize);