string.cpp
来自「3D游戏开发需要用到BSP树来经行场景渲染的管理。本代码包含完整的BSP及文件生」· C++ 代码 · 共 26 行
CPP
26 行
#include "string.h"
#include "log.h"
int CString::Hash() {
int hash = 0;
for(int i = 0; i < len; i++)
hash += (int)data[i] * (473 + i);
return hash;
}
void CString::EnsureAllocated(int new_size) {
if(own_data) {
if(size >= new_size)
return;
size += new_size;
int mod = size % STRING_GRANULARITY;
if(mod)
size += STRING_GRANULARITY - mod;
data = (char *)realloc(data, size);
} else
g_CLog.Log(LOG_SYSTEM, "EnsureAllocated: Tried to resize CString without local storage\n");
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?