Some more ALLOC_MEMSET debug code

上级 a184838e
......@@ -41,6 +41,9 @@ morecore(int c, int b)
if(p == 0)
return -1;
if (ALLOC_MEMSET)
memset(p, 3, PGSIZE);
int sz = 1 << b;
assert(sz >= sizeof(header));
for(char *q = p; q + sz <= p + PGSIZE; q += sz){
......@@ -105,8 +108,13 @@ kmalloc(u64 nbytes, const char *name)
mtlabel(mtrace_label_heap, (void*) h, nbytes, name, strlen(name));
if (ALLOC_MEMSET)
if (ALLOC_MEMSET) {
char* chk = (char*)(h + 1);
for (int i = 0; i < (1<<b)-sizeof(*h); i++)
if (chk[i] != 3)
panic("kmalloc: oops %p+%x", chk, i);
memset(h, 4, (1<<b));
}
return h;
}
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论