/* A custom allocator. Returns memory from a statically allocated array.  */
ModbusError staticAllocator(ModbusBuffer *buffer, uint16_t size, void *context)
/* A custom allocator. Returns memory from a statically allocated array.  */
ModbusError staticAllocator(ModbusBuffer *buffer, uint16_t size, void *context)
{
	static uint8_t response[MAX_RESPONSE];
	if (size != 0)
	{
		if (size <= MAX_RESPONSE)
		{
			buffer->data = response;
			return MODBUS_OK;
		}
		else
		{
			buffer->data = NULL;
			return MODBUS_ERROR_ALLOC;
		}
	}
	else
	{
		buffer->data = NULL;
		return MODBUS_OK;
	}
}