[英]What is the meaning of this malloc error? Corrupted top size?
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, (该程序的目标是模拟虚拟内存)由于某种原因,当我尝试初始化pgTable [i] .validFlag = 1时,出现此错误,
malloc(): corrupted top size, malloc():损坏的最大大小,
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. 但是如果我将其初始化为0则没有。我认为这与我离开数组末尾的过程有些关系,但我看不出这是怎么回事。
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
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.