| 106 | } |
| 107 | |
| 108 | int |
| 109 | verifyCache(RefCountCache<ExampleStruct> *cache, int start, int end) |
| 110 | { |
| 111 | // Re-query all the structs to make sure they are there and accurate |
| 112 | for (int i = start; i < end; i++) { |
| 113 | Ptr<ExampleStruct> ccitem = cache->get(i); |
| 114 | ExampleStruct *tmp = ccitem.get(); |
| 115 | if (tmp == nullptr) { |
| 116 | // printf("ExampleStruct %d missing, skipping\n", i); |
| 117 | continue; |
| 118 | } |
| 119 | // printf("Get (%p) ExampleStruct%d idx=%d name=%s\n", tmp, i, tmp->idx, tmp->name()); |
| 120 | |
| 121 | // Check that idx is correct |
| 122 | if (tmp->idx != i) { |
| 123 | printf("IDX of ExampleStruct%d incorrect! (%d)\n", i, tmp->idx); |
| 124 | return 1; // TODO: spin over all? |
| 125 | } |
| 126 | } |
| 127 | return 0; |
| 128 | } |
| 129 | |
| 130 | // TODO: check that the memory was actually free-d better |
| 131 | int |