| 178 | } |
| 179 | |
| 180 | int |
| 181 | testclear() |
| 182 | { |
| 183 | int ret = 0; |
| 184 | |
| 185 | RefCountCache<ExampleStruct> *cache = new RefCountCache<ExampleStruct>(4); |
| 186 | |
| 187 | // Create and then immediately delete an item |
| 188 | ExampleStruct *item = ExampleStruct::alloc(); |
| 189 | ret |= item->refcount() != 0; |
| 190 | cache->put(1, item); |
| 191 | ret |= item->refcount() != 1; |
| 192 | cache->clear(); |
| 193 | ret |= item->refcount() != 0; |
| 194 | ret |= item->idx != -1; |
| 195 | |
| 196 | delete cache; |
| 197 | |
| 198 | return ret; |
| 199 | } |
| 200 | |
| 201 | int |
| 202 | test() |