作者anniecia (Annie)
看板EE_DSnP
标题[问题] _recycleList[n] 和 _recycleList[rn]
时间Wed Nov 18 17:00:28 2009
In memMgr.h, function MemMgr::getMem()
// TODO ---
// 3. Check the _recycleList first...
// #ifdef MEM_DEBUG
// cout << "Recycled from _recycleList[" << n << "]..." << ret << endl;
// #endif // MEM_DEBUG
// => 'n' is the index for _recycleList[]
// => "ret" is the return address
// TODO ---
// 2. If not enough, recycle the remained memory and print out ---
// #ifdef MEM_DEBUG
// cout << "Recycling " << ret << " to _recycleList[" << rn << "]\n";
// #endif // MEM_DEBUG
请问这里的n和rn 要印原始值(实际阵列大小) 还是 0 到 R_SIZE-1 之间的值?
照comment写的好像是後者 但印前者不会比较合理吗~~
谢谢!
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 218.166.147.40
1F:推 goodword:不太清楚你的问题, _recycleList[n]应该就是指 回收长 11/18 19:21
2F:→ goodword:度是n的array的 大小啦. 11/18 19:22
3F:→ goodword:像 _recycleList[2]内存的就是 ToSize(2*sizeof(Obj))的 11/18 19:24
4F:→ goodword:大小吧 。 11/18 19:24
5F:→ goodword:此外, _recycleList[2] 内存的不只长度为2的array 11/18 19:25
6F:→ goodword:还包括 2+R_SIZE , 2+R_SIZE*2 ...的长度 通通存在这 11/18 19:26
7F:→ goodword:而至於怎麽正确判断回收的大小究竟是 2 还是 2+R_SIZE 11/18 19:27
8F:→ goodword:就得要好好的观察老师高明的作法了 11/18 19:28
9F:→ anniecia:我的意思是 要印2还是2+R_SIZE 11/18 20:23
10F:→ anniecia:5F应为_recycleList[2]只存长度为2的 但指到2+n*R_SIZE的 11/18 20:25
11F:推 goodword:印象中好像还是印 2 此处可以参考老师的ref就好了 11/18 21:04
12F:→ goodword:只是2+n*R_SIZE是存在 _recycleList[2] 的 _nextList内 11/18 21:05
13F:推 a3785lexx:是印出"n"和"rn"无误 跑跑memTest-32.debug就知道了 11/19 11:09
14F:→ a3785lexx:也就是您的array是几个element的它就印多少 11/19 11:15
15F:→ a3785lexx:顺带一提不是array是0...我当初脑包还把它改成1过orz 11/19 11:16
16F:→ goodword:抱歉 ref好像真的是印 2+n*R_SIZE 11/19 18:29
17F:推 ric2k1:啊, 典型的 comment 跟不上 code 的 update... 11/20 22:38
18F:→ ric2k1:其实是印 array size, that is, 2+R_SIZE*i 11/20 22:39