* If the buffer in `snapshot` is active, then either munmap the * memory and close the file, or free the memory. Then set the buffer * pointers to NULL. */
| 178 | * pointers to NULL. |
| 179 | */ |
| 180 | static void clear_snapshot_buffer(struct snapshot *snapshot) |
| 181 | { |
| 182 | if (snapshot->mmapped) { |
| 183 | if (munmap(snapshot->buf, snapshot->eof - snapshot->buf)) |
| 184 | die_errno("error ummapping packed-refs file %s", |
| 185 | snapshot->refs->path); |
| 186 | snapshot->mmapped = 0; |
| 187 | } else { |
| 188 | free(snapshot->buf); |
| 189 | } |
| 190 | snapshot->buf = snapshot->start = snapshot->eof = NULL; |
| 191 | } |
| 192 | |
| 193 | /* |
| 194 | * Decrease the reference count of `*snapshot`. If it goes to zero, |
no test coverage detected