64,654
社区成员
发帖
与我相关
我的任务
分享
inline PageLayoutPtr allocZeroPageLayout()
{
fprintf(stderr,"before malloc!\n");
void* ptr = std::malloc(PAGE_SIZE);
fprintf(stderr, ptr == NULL ? "malloc error!\n" : "malloc success!\n");
std::memset(ptr, 0, PAGE_SIZE); // XXX 考虑按字长的memset
fprintf(stderr, "memset sucess!\n");
return static_cast<PageLayoutPtr>(ptr);
}
int main() {
printf("size of index_hdr = %d\n", sizeof(cfg::index_hdr));
cfg::Cfg* pCfg = cfg::Cfg::createCfg(cfg::Cfg::TAG_SIMPLE);
const unsigned int scope = 4096;
const unsigned int testnum = 10000;
srand(0);
std::string* szstrs[testnum];
szstrs[0] = new std::string(10, 'a');
for (int i = 1; i < testnum; i++)
{
fprintf(stderr, "(((((((((((((((( Test %d ))))))))))))))\n", i);
fprintf(stderr, "before rand()\n");
unsigned int size = (unsigned int)rand() % scope;
//unsigned int size = 5;
fprintf(stderr, "after rand()\n");
fprintf(stderr, "size = %u\n", size);
std::string str(size, 'b');
// VC2005尽然在上行崩掉了,换成堆就没出错,我修改栈大小为10M reserve, 1M commit还出错
fprintf(stderr, "after string\n");
fprintf(stderr, "before putData()\n");
pCfg->putData(i, str.c_str(), size);
fprintf(stderr, "after putData()\n");
}
return 0;
}
void* ptr = std::malloc(PAGE_SIZE);