I want to copy page contents to another Page object. However it has the error, I think it is related to memory allocation. I haven't found specific reason. Anyone explain about reason? I attached my source code part of coping object. Thank
DB.Pages = new Page[numPages];
Page* tmp_Pages = new Page[numPages];
uint count = 0;
for(uint p = 0;p < numPages; p++){
uint *data = new uint[MAX_NUM_NODES_PER_DATA];
uint *tmp_data = DB.getPageByID(p)->data;
memcpy(data, tmp_data, sizeof(uint) * MAX_NUM_DATAS_PER_PAGE);
tmp_Pages[count].data = data;
count++;
}
memcpy(DB.Pages, tmp_Pages, sizeof(Page) * numPages);
mlock.c file error point void __cdecl _unlock (int locknum) { /* * leave the critical section. */ LeaveCriticalSection( _locktable[locknum].lock ); } Microsoft C++ exception: std::bad_alloc(memory location 0x002afa90)