Files
tippecanoe/memfile.hpp
T
Claude 6e78110000 Make memfile offset atomic so checkdisk() can read it from other threads
checkdisk() is called from the parsing threads and sums the write
positions of every reader. The geometry/index/vertex/node positions were
already std::atomic, but memfile::off (the string pool and tree sizes)
was a plain size_t that the owning thread updates in memfile_write(),
which ThreadSanitizer reports as a data race.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EfWkLhwEvKQoNGVPsLGehj
2026-09-26 17:00:11 +00:00

23 lines
516 B
C++

#ifndef MEMFILE_HPP
#define MEMFILE_HPP
#include <atomic>
#include <string>
#include "errors.hpp"
struct memfile {
int fd = 0;
std::string map;
unsigned long tree = 0;
FILE *fp = NULL;
// Read by checkdisk() from other threads while the owning reader thread appends
std::atomic<size_t> off{0};
};
struct memfile *memfile_open(int fd);
int memfile_close(struct memfile *file);
int memfile_write(struct memfile *file, void *s, long long len, bool &in_memory);
void memfile_full(struct memfile *file);
#endif