Пример #1
0
static int capacity(int size)
// Compute the buffer capacity corresponding to the given size.
// Basically round up to the next block size.
// Always return non-zero.
{
	// BLOCKSIZE must be a power of two.
	compiler_assert((BLOCKSIZE & (BLOCKSIZE - 1)) == 0);

	if (size == 0) {
		// Special case, always allocate.
		return BLOCKSIZE;
	}

	return (size + BLOCKSIZE - 1) & ~(BLOCKSIZE - 1);
}
Пример #2
0
void AssemblerBuffer::setByte(uint32_t location, uint8_t value)
{
	compiler_assert(location < usedSize, "assembler buffer out of range");
	reinterpret_cast<uint8_t*>(allocatedMemory)[location] = value;
}