_________________________________________________________________ #define REGION_SIZE (4096 * 1024) struct region { unsigned char buf[REGION_SIZE]; atomicuword volatile offset; /* == 0 */ }; static void* galloc( struct region* const this, size_t const size ) { atomicuword offset; if (this->offset + size >= REGION_SIZE) { return NULL; } offset = XADD(&this->offset, size); if (offset + size >= REGION_SIZE) { return NULL; } return this->buf + offset; } static void gflush( struct region* const this ) { XCHG(&this->offset, 0); } _________________________________________________________________ Simple.