* NAME: compact() * DESCRIPTION: clean up a node, removing deleted records */
| 150 | * DESCRIPTION: clean up a node, removing deleted records |
| 151 | */ |
| 152 | static |
| 153 | void compact(node *np) |
| 154 | { |
| 155 | byte *ptr; |
| 156 | int offset, nrecs, i; |
| 157 | |
| 158 | offset = 0x00e; |
| 159 | ptr = np->data + offset; |
| 160 | nrecs = 0; |
| 161 | |
| 162 | for (i = 0; i < np->nd.ndNRecs; ++i) |
| 163 | { |
| 164 | const byte *rec; |
| 165 | int reclen; |
| 166 | |
| 167 | rec = HFS_NODEREC(*np, i); |
| 168 | reclen = HFS_RECLEN(*np, i); |
| 169 | |
| 170 | if (HFS_RECKEYLEN(rec) > 0) |
| 171 | { |
| 172 | np->roff[nrecs++] = offset; |
| 173 | offset += reclen; |
| 174 | |
| 175 | if (ptr == rec) |
| 176 | ptr += reclen; |
| 177 | else |
| 178 | { |
| 179 | while (reclen--) |
| 180 | *ptr++ = *rec++; |
| 181 | } |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | np->roff[nrecs] = offset; |
| 186 | np->nd.ndNRecs = nrecs; |
| 187 | } |
| 188 | |
| 189 | /* |
| 190 | * NAME: node->search() |