I'm trying to initialize some values in couple of structs I created. (the goal of the program is to simulate virtual memory) For some reason when i try to initalize pgTable[i].validFlag = 1 I get this error,
malloc(): corrupted top size,
but not if I initialize it to 0. I thought this had something to go with me going off the end of my array but I don't see how that's possible.
Can anyone tell me what I'm doing wrong?
int* memmory = malloc( sizeof( int ) * sizeVM * pageSize );
struct TLBentry* tlb = malloc( sizeof(struct TLBentry) * sizeTLB );
struct pageTableEntry* pgTable = malloc( sizeof(struct pageTableEntry) * sizeVM );
for( int i = 0; i < sizeTLB; i++){
tlb[i].virtualAddress = i;
tlb[i].physicalAddress = i;
}
for( int i = 0; i < sizePM; i++){
pgTable[i].dirty = 0;
pgTable[i].validFlag = 1;
pgTable[i].physicalAddress = i;
}
memSys->virtMem = memmory;
memSys->tlb = tlb;
memSys->pgTable = pgTable;
在分配sizeVM
条目时,循环上升到sizePM
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.